MLIR  19.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 undef (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 void computeSizes (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, ArrayRef< UnrankedMemRefDescriptor > values, ArrayRef< unsigned > addressSpaces, SmallVectorImpl< Value > &sizes)
 Builds IR computing the sizes in bytes (suitable for opaque allocation) and appends the corresponding values into sizes. 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 undef (OpBuilder &builder, Location loc, Type descriptorType)
 Builds IR creating an undef 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 299 of file MemRefBuilder.cpp.

Referenced by undef().

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 419 of file MemRefBuilder.cpp.

References castToElemPtrPtr(), mlir::OpBuilder::create(), 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 400 of file MemRefBuilder.cpp.

References mlir::OpBuilder::create(), and memRefDescPtr().

Referenced by setAllocatedPtr().

◆ computeSizes()

void UnrankedMemRefDescriptor::computeSizes ( OpBuilder builder,
Location  loc,
const LLVMTypeConverter typeConverter,
ArrayRef< UnrankedMemRefDescriptor values,
ArrayRef< unsigned >  addressSpaces,
SmallVectorImpl< Value > &  sizes 
)
static

Builds IR computing the sizes in bytes (suitable for opaque allocation) and appends the corresponding values into sizes.

addressSpaces which must have the same length as values, is needed to handle layouts where sizeof(ptr addrspace(N)) != sizeof(ptr addrspace(0)).

Definition at line 352 of file MemRefBuilder.cpp.

References mlir::ceilDiv(), mlir::OpBuilder::create(), createIndexAttrConstant(), mlir::LLVMTypeConverter::getIndexType(), mlir::LLVMTypeConverter::getIndexTypeBitwidth(), mlir::LLVMTypeConverter::getPointerBitwidth(), and rank().

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

◆ 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 453 of file MemRefBuilder.cpp.

References mlir::OpBuilder::create(), 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 443 of file MemRefBuilder.cpp.

References castToElemPtrPtr(), mlir::OpBuilder::create(), 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 329 of file MemRefBuilder.cpp.

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

Referenced by mlir::LLVMTypeConverter::LLVMTypeConverter(), and wrapExternalFunction().

◆ rank()

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

Builds IR extracting the rank from the descriptor.

Definition at line 309 of file MemRefBuilder.cpp.

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

Referenced by computeSizes(), mlir::ConvertToLLVMPattern::copyUnrankedDescriptors(), 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 431 of file MemRefBuilder.cpp.

References alignedPtr(), castToElemPtrPtr(), mlir::OpBuilder::create(), 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 406 of file MemRefBuilder.cpp.

References allocatedPtr(), mlir::OpBuilder::create(), and memRefDescPtr().

◆ setMemRefDescPtr()

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

Builds IR setting ranked memref descriptor ptr.

Definition at line 320 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 463 of file MemRefBuilder.cpp.

References mlir::OpBuilder::create(), 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 312 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 496 of file MemRefBuilder.cpp.

References mlir::OpBuilder::create(), 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 529 of file MemRefBuilder.cpp.

References mlir::OpBuilder::create(), 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 484 of file MemRefBuilder.cpp.

References mlir::OpBuilder::create(), 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 473 of file MemRefBuilder.cpp.

References mlir::OpBuilder::create(), mlir::get(), mlir::Builder::getContext(), mlir::Type::getContext(), mlir::LLVMTypeConverter::getIndexType(), mlir::LLVM::LLVMStructType::getLiteral(), 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 517 of file MemRefBuilder.cpp.

References mlir::OpBuilder::create(), 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 508 of file MemRefBuilder.cpp.

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

Referenced by setStride(), and stride().

◆ undef()

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

Builds IR creating an undef value of the descriptor type.

Definition at line 303 of file MemRefBuilder.cpp.

References mlir::OpBuilder::create(), and UnrankedMemRefDescriptor().

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

◆ 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 343 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: