MLIR  22.0.0git
Public Member Functions | Static Public Member Functions | List of all members
mlir::UnrankedMemRefDescriptor Class Reference

#include "mlir/Conversion/LLVMCommon/MemRefBuilder.h"

+ Inheritance diagram for mlir::UnrankedMemRefDescriptor:

Public Member Functions

 UnrankedMemRefDescriptor (Value descriptor)
 Construct a helper for the given descriptor value. More...
 
Value rank (OpBuilder &builder, Location loc) const
 Builds IR extracting the rank from the descriptor. More...
 
void setRank (OpBuilder &builder, Location loc, Value value)
 Builds IR setting the rank in the descriptor. More...
 
Value memRefDescPtr (OpBuilder &builder, Location loc) const
 Builds IR extracting ranked memref descriptor ptr. More...
 
void setMemRefDescPtr (OpBuilder &builder, Location loc, Value value)
 Builds IR setting ranked memref descriptor ptr. More...
 
- Public Member Functions inherited from mlir::StructBuilder
 StructBuilder (Value v)
 Construct a helper for the given value. More...
 
 operator Value ()
 

Static Public Member Functions

static UnrankedMemRefDescriptor poison (OpBuilder &builder, Location loc, Type descriptorType)
 Builds IR creating an undef value of the descriptor type. More...
 
static Value pack (OpBuilder &builder, Location loc, const LLVMTypeConverter &converter, UnrankedMemRefType type, ValueRange values)
 Builds IR populating an unranked MemRef descriptor structure from a list of individual constituent values in the following order: More...
 
static void unpack (OpBuilder &builder, Location loc, Value packed, SmallVectorImpl< Value > &results)
 Builds IR extracting individual elements that compose an unranked memref descriptor and returns them as results list. More...
 
static unsigned getNumUnpackedValues ()
 Returns the number of non-aggregate values that would be produced by unpack. More...
 
static Value computeSize (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, UnrankedMemRefDescriptor desc, unsigned addressSpace)
 Builds and returns IR computing the size in bytes (suitable for opaque allocation). More...
 
static Value allocatedPtr (OpBuilder &builder, Location loc, Value memRefDescPtr, LLVM::LLVMPointerType elemPtrType)
 TODO: The following accessors don't take alignment rules between elements of the descriptor struct into account. More...
 
static void setAllocatedPtr (OpBuilder &builder, Location loc, Value memRefDescPtr, LLVM::LLVMPointerType elemPtrType, Value allocatedPtr)
 Builds IR inserting the allocated pointer into the descriptor. More...
 
static Value alignedPtr (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value memRefDescPtr, LLVM::LLVMPointerType elemPtrType)
 Builds IR extracting the aligned pointer from the descriptor. More...
 
static void setAlignedPtr (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value memRefDescPtr, LLVM::LLVMPointerType elemPtrType, Value alignedPtr)
 Builds IR inserting the aligned pointer into the descriptor. More...
 
static Value offsetBasePtr (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value memRefDescPtr, LLVM::LLVMPointerType elemPtrType)
 Builds IR for getting the pointer to the offset's location. More...
 
static Value offset (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value memRefDescPtr, LLVM::LLVMPointerType elemPtrType)
 Builds IR extracting the offset from the descriptor. More...
 
static void setOffset (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value memRefDescPtr, LLVM::LLVMPointerType elemPtrType, Value offset)
 Builds IR inserting the offset into the descriptor. More...
 
static Value sizeBasePtr (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value memRefDescPtr, LLVM::LLVMPointerType elemPtrType)
 Builds IR extracting the pointer to the first element of the size array. More...
 
static Value size (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value sizeBasePtr, Value index)
 Builds IR extracting the size[index] from the descriptor. More...
 
static void setSize (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value sizeBasePtr, Value index, Value size)
 Builds IR inserting the size[index] into the descriptor. More...
 
static Value strideBasePtr (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value sizeBasePtr, Value rank)
 Builds IR extracting the pointer to the first element of the stride array. More...
 
static Value stride (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value strideBasePtr, Value index, Value stride)
 Builds IR extracting the stride[index] from the descriptor. More...
 
static void setStride (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, Value strideBasePtr, Value index, Value stride)
 Builds IR inserting the stride[index] into the descriptor. More...
 
- Static Public Member Functions inherited from mlir::StructBuilder
static StructBuilder poison (OpBuilder &builder, Location loc, Type descriptorType)
 Builds IR creating a poison value of the descriptor type. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mlir::StructBuilder
Value extractPtr (OpBuilder &builder, Location loc, unsigned pos) const
 Builds IR to extract a value from the struct at position pos. More...
 
void setPtr (OpBuilder &builder, Location loc, unsigned pos, Value ptr)
 Builds IR to set a value in the struct at position pos. More...
 
- Protected Attributes inherited from mlir::StructBuilder
Value value
 
Type structType
 

Detailed Description

Definition at line 158 of file MemRefBuilder.h.

Constructor & Destructor Documentation

◆ UnrankedMemRefDescriptor()

UnrankedMemRefDescriptor::UnrankedMemRefDescriptor ( Value  descriptor)
explicit

Construct a helper for the given descriptor value.

Definition at line 303 of file MemRefBuilder.cpp.

Referenced by poison().

Member Function Documentation

◆ alignedPtr()

Value UnrankedMemRefDescriptor::alignedPtr ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  memRefDescPtr,
LLVM::LLVMPointerType  elemPtrType 
)
static

Builds IR extracting the aligned pointer from the descriptor.

Definition at line 415 of file MemRefBuilder.cpp.

References castToElemPtrPtr(), and memRefDescPtr().

Referenced by setAlignedPtr().

◆ allocatedPtr()

Value UnrankedMemRefDescriptor::allocatedPtr ( OpBuilder builder,
Location  loc,
Value  memRefDescPtr,
LLVM::LLVMPointerType  elemPtrType 
)
static

TODO: The following accessors don't take alignment rules between elements of the descriptor struct into account.

For some architectures, it might be necessary to extend them and to use llvm::DataLayout contained in LLVMTypeConverter. Builds IR extracting the allocated pointer from the descriptor.

Definition at line 396 of file MemRefBuilder.cpp.

References memRefDescPtr().

Referenced by setAllocatedPtr().

◆ computeSize()

Value UnrankedMemRefDescriptor::computeSize ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
UnrankedMemRefDescriptor  desc,
unsigned  addressSpace 
)
static

Builds and returns IR computing the size in bytes (suitable for opaque allocation).

addressSpace is needed to handle layouts where sizeof(ptr addrspace(N)) != sizeof(ptr addrspace(0)).

Definition at line 356 of file MemRefBuilder.cpp.

References createIndexAttrConstant(), mlir::detail::divideCeil(), mlir::LLVMTypeConverter::getIndexType(), mlir::LLVMTypeConverter::getIndexTypeBitwidth(), mlir::LLVMTypeConverter::getPointerBitwidth(), and rank().

Referenced by mlir::ConvertToLLVMPattern::copyUnrankedDescriptor().

◆ getNumUnpackedValues()

static unsigned mlir::UnrankedMemRefDescriptor::getNumUnpackedValues ( )
inlinestatic

Returns the number of non-aggregate values that would be produced by unpack.

Definition at line 190 of file MemRefBuilder.h.

Referenced by wrapExternalFunction().

◆ memRefDescPtr()

Value UnrankedMemRefDescriptor::memRefDescPtr ( OpBuilder builder,
Location  loc 
) const

◆ offset()

Value UnrankedMemRefDescriptor::offset ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  memRefDescPtr,
LLVM::LLVMPointerType  elemPtrType 
)
static

Builds IR extracting the offset from the descriptor.

Definition at line 449 of file MemRefBuilder.cpp.

References mlir::LLVMTypeConverter::getIndexType(), memRefDescPtr(), and offsetBasePtr().

Referenced by setOffset().

◆ offsetBasePtr()

Value UnrankedMemRefDescriptor::offsetBasePtr ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  memRefDescPtr,
LLVM::LLVMPointerType  elemPtrType 
)
static

Builds IR for getting the pointer to the offset's location.

Returns a pointer to a convertType(index), which points to the beggining of a struct {index, index[rank], index[rank]}.

Definition at line 439 of file MemRefBuilder.cpp.

References castToElemPtrPtr(), and memRefDescPtr().

Referenced by offset(), and setOffset().

◆ pack()

Value UnrankedMemRefDescriptor::pack ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter converter,
UnrankedMemRefType  type,
ValueRange  values 
)
static

Builds IR populating an unranked MemRef descriptor structure from a list of individual constituent values in the following order:

  • rank of the memref;
  • pointer to the memref descriptor.

Definition at line 333 of file MemRefBuilder.cpp.

References mlir::LLVMTypeConverter::convertType(), kPtrInUnrankedMemRefDescriptor, kRankInUnrankedMemRefDescriptor, and poison().

Referenced by packUnrankedMemRefDesc(), and wrapExternalFunction().

◆ poison()

UnrankedMemRefDescriptor UnrankedMemRefDescriptor::poison ( OpBuilder builder,
Location  loc,
Type  descriptorType 
)
static

Builds IR creating an undef value of the descriptor type.

Definition at line 307 of file MemRefBuilder.cpp.

References UnrankedMemRefDescriptor().

Referenced by mlir::ConvertToLLVMPattern::copyUnrankedDescriptor(), and pack().

◆ rank()

Value UnrankedMemRefDescriptor::rank ( OpBuilder builder,
Location  loc 
) const

Builds IR extracting the rank from the descriptor.

Definition at line 313 of file MemRefBuilder.cpp.

References mlir::StructBuilder::extractPtr(), and kRankInUnrankedMemRefDescriptor.

Referenced by computeSize(), mlir::ConvertToLLVMPattern::copyUnrankedDescriptor(), strideBasePtr(), and unpack().

◆ setAlignedPtr()

void UnrankedMemRefDescriptor::setAlignedPtr ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  memRefDescPtr,
LLVM::LLVMPointerType  elemPtrType,
Value  alignedPtr 
)
static

Builds IR inserting the aligned pointer into the descriptor.

Definition at line 427 of file MemRefBuilder.cpp.

References alignedPtr(), castToElemPtrPtr(), and memRefDescPtr().

◆ setAllocatedPtr()

void UnrankedMemRefDescriptor::setAllocatedPtr ( OpBuilder builder,
Location  loc,
Value  memRefDescPtr,
LLVM::LLVMPointerType  elemPtrType,
Value  allocatedPtr 
)
static

Builds IR inserting the allocated pointer into the descriptor.

Definition at line 402 of file MemRefBuilder.cpp.

References allocatedPtr(), and memRefDescPtr().

◆ setMemRefDescPtr()

void UnrankedMemRefDescriptor::setMemRefDescPtr ( OpBuilder builder,
Location  loc,
Value  value 
)

Builds IR setting ranked memref descriptor ptr.

Definition at line 324 of file MemRefBuilder.cpp.

References kPtrInUnrankedMemRefDescriptor, and mlir::StructBuilder::setPtr().

◆ setOffset()

void UnrankedMemRefDescriptor::setOffset ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  memRefDescPtr,
LLVM::LLVMPointerType  elemPtrType,
Value  offset 
)
static

Builds IR inserting the offset into the descriptor.

Definition at line 459 of file MemRefBuilder.cpp.

References memRefDescPtr(), offset(), and offsetBasePtr().

◆ setRank()

void UnrankedMemRefDescriptor::setRank ( OpBuilder builder,
Location  loc,
Value  value 
)

Builds IR setting the rank in the descriptor.

Definition at line 316 of file MemRefBuilder.cpp.

References kRankInUnrankedMemRefDescriptor, and mlir::StructBuilder::setPtr().

◆ setSize()

void UnrankedMemRefDescriptor::setSize ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  sizeBasePtr,
Value  index,
Value  size 
)
static

Builds IR inserting the size[index] into the descriptor.

Definition at line 492 of file MemRefBuilder.cpp.

References mlir::get(), mlir::Builder::getContext(), mlir::LLVMTypeConverter::getIndexType(), size(), and sizeBasePtr().

◆ setStride()

void UnrankedMemRefDescriptor::setStride ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  strideBasePtr,
Value  index,
Value  stride 
)
static

Builds IR inserting the stride[index] into the descriptor.

Definition at line 525 of file MemRefBuilder.cpp.

References mlir::get(), mlir::Builder::getContext(), mlir::LLVMTypeConverter::getIndexType(), stride(), and strideBasePtr().

◆ size()

Value UnrankedMemRefDescriptor::size ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  sizeBasePtr,
Value  index 
)
static

Builds IR extracting the size[index] from the descriptor.

Definition at line 480 of file MemRefBuilder.cpp.

References mlir::get(), mlir::Builder::getContext(), mlir::LLVMTypeConverter::getIndexType(), and sizeBasePtr().

Referenced by setSize().

◆ sizeBasePtr()

Value UnrankedMemRefDescriptor::sizeBasePtr ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  memRefDescPtr,
LLVM::LLVMPointerType  elemPtrType 
)
static

Builds IR extracting the pointer to the first element of the size array.

Definition at line 469 of file MemRefBuilder.cpp.

References mlir::get(), mlir::Builder::getContext(), mlir::Type::getContext(), mlir::LLVMTypeConverter::getIndexType(), and memRefDescPtr().

Referenced by setSize(), size(), and strideBasePtr().

◆ stride()

Value UnrankedMemRefDescriptor::stride ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  strideBasePtr,
Value  index,
Value  stride 
)
static

Builds IR extracting the stride[index] from the descriptor.

Definition at line 513 of file MemRefBuilder.cpp.

References mlir::get(), mlir::Builder::getContext(), mlir::LLVMTypeConverter::getIndexType(), and strideBasePtr().

Referenced by setStride().

◆ strideBasePtr()

Value UnrankedMemRefDescriptor::strideBasePtr ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
Value  sizeBasePtr,
Value  rank 
)
static

Builds IR extracting the pointer to the first element of the stride array.

Definition at line 504 of file MemRefBuilder.cpp.

References mlir::get(), mlir::Builder::getContext(), mlir::LLVMTypeConverter::getIndexType(), rank(), and sizeBasePtr().

Referenced by setStride(), and stride().

◆ unpack()

void UnrankedMemRefDescriptor::unpack ( OpBuilder builder,
Location  loc,
Value  packed,
SmallVectorImpl< Value > &  results 
)
static

Builds IR extracting individual elements that compose an unranked memref descriptor and returns them as results list.

Definition at line 347 of file MemRefBuilder.cpp.

References memRefDescPtr(), and rank().

Referenced by mlir::LLVMTypeConverter::promoteOperands(), and wrapForExternalCallers().


The documentation for this class was generated from the following files: