MLIR
18.0.0git
|
LLVM dialect structure type representing a collection of different-typed elements manipulated together. More...
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
Public Types | |
using | Base = StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits... > |
Inherit base constructors. More... | |
![]() | |
using | Base = StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits... > |
Utility declarations for the concrete attribute class. More... | |
using | ImplType = StorageT |
using | HasTraitFn = bool(*)(TypeID) |
Public Member Functions | |
LogicalResult | setBody (ArrayRef< Type > types, bool isPacked) |
Set the body of an identified struct. More... | |
bool | isPacked () const |
Checks if a struct is packed. More... | |
bool | isIdentified () const |
Checks if a struct is identified. More... | |
bool | isOpaque () |
Checks if a struct is opaque. More... | |
bool | isInitialized () |
Checks if a struct is initialized. More... | |
StringRef | getName () |
Returns the name of an identified struct. More... | |
ArrayRef< Type > | getBody () const |
Returns the list of element types contained in a non-opaque struct. More... | |
llvm::TypeSize | getTypeSizeInBits (const DataLayout &dataLayout, DataLayoutEntryListRef params) const |
Hooks for DataLayoutTypeInterface. More... | |
uint64_t | getABIAlignment (const DataLayout &dataLayout, DataLayoutEntryListRef params) const |
uint64_t | getPreferredAlignment (const DataLayout &dataLayout, DataLayoutEntryListRef params) const |
bool | areCompatible (DataLayoutEntryListRef oldLayout, DataLayoutEntryListRef newLayout) const |
LogicalResult | verifyEntries (DataLayoutEntryListRef entries, Location loc) const |
std::optional< DenseMap< Attribute, Type > > | getSubelementIndexMap () |
Destructs the struct into its indexed field types. More... | |
Type | getTypeAtIndex (Attribute index) |
Returns which type is stored at a given integer index within the struct. More... | |
![]() | |
ImplType * | getImpl () const |
Utility for easy access to the storage instance. More... | |
Static Public Member Functions | |
static bool | isValidElementType (Type type) |
Checks if the given type can be contained in a structure type. More... | |
static LLVMStructType | getIdentified (MLIRContext *context, StringRef name) |
Gets or creates an identified struct with the given name in the provided context. More... | |
static LLVMStructType | getIdentifiedChecked (function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, StringRef name) |
static LLVMStructType | getNewIdentified (MLIRContext *context, StringRef name, ArrayRef< Type > elements, bool isPacked=false) |
Gets a new identified struct with the given body. More... | |
static LLVMStructType | getLiteral (MLIRContext *context, ArrayRef< Type > types, bool isPacked=false) |
Gets or creates a literal struct with the given body in the provided context. More... | |
static LLVMStructType | getLiteralChecked (function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, ArrayRef< Type > types, bool isPacked=false) |
static LLVMStructType | getOpaque (StringRef name, MLIRContext *context) |
Gets or creates an intentionally-opaque identified struct. More... | |
static LLVMStructType | getOpaqueChecked (function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, StringRef name) |
static LogicalResult | verify (function_ref< InFlightDiagnostic()> emitError, StringRef, bool) |
Verifies that the type about to be constructed is well-formed. More... | |
static LogicalResult | verify (function_ref< InFlightDiagnostic()> emitError, ArrayRef< Type > types, bool) |
template<typename... Args> | |
static LogicalResult | verify (Args... args) |
Default implementation that just returns success. More... | |
![]() | |
static TypeID | getTypeID () |
Return a unique identifier for the concrete type. More... | |
template<typename T > | |
static bool | classof (T val) |
Provide an implementation of 'classof' that compares the type id of the provided value with that of the concrete type. More... | |
static detail::InterfaceMap | getInterfaceMap () |
Returns an interface map for the interfaces registered to this storage user. More... | |
static HasTraitFn | getHasTraitFn () |
Returns the function that returns true if the given Trait ID matches the IDs of any of the traits defined by the storage user. More... | |
static auto | getWalkImmediateSubElementsFn () |
Returns a function that walks immediate sub elements of a given instance of the storage user. More... | |
static auto | getReplaceImmediateSubElementsFn () |
Returns a function that replaces immediate sub elements of a given instance of the storage user. More... | |
template<typename... IfaceModels> | |
static void | attachInterface (MLIRContext &context) |
Attach the given models as implementations of the corresponding interfaces for the concrete storage user class. More... | |
template<typename... Args> | |
static ConcreteT | get (MLIRContext *ctx, Args &&...args) |
Get or create a new ConcreteT instance within the ctx. More... | |
template<typename... Args> | |
static ConcreteT | getChecked (const Location &loc, Args &&...args) |
Get or create a new ConcreteT instance within the ctx, defined at the given, potentially unknown, location. More... | |
template<typename... Args> | |
static ConcreteT | getChecked (function_ref< InFlightDiagnostic()> emitErrorFn, MLIRContext *ctx, Args... args) |
Get or create a new ConcreteT instance within the ctx. More... | |
static ConcreteT | getFromOpaquePointer (const void *ptr) |
Get an instance of the concrete type from a void pointer. More... | |
Static Public Attributes | |
static constexpr StringLiteral | name = "llvm.struct" |
Additional Inherited Members | |
![]() | |
template<typename... Args> | |
LogicalResult | mutate (Args &&...args) |
Mutate the current storage instance. More... | |
![]() | |
template<typename... Args> | |
static LogicalResult | verify (Args... args) |
Default implementation that just returns success. More... | |
LLVM dialect structure type representing a collection of different-typed elements manipulated together.
Structured can optionally be packed, meaning that their elements immediately follow each other in memory without accounting for potential alignment.
Structure types can be identified (named) or literal. Literal structures are uniquely represented by the list of types they contain and packedness. Literal structure types are immutable after construction.
Identified structures are uniquely represented by their name, a string. They have a mutable component, consisting of the list of types they contain, the packedness and the opacity bits. Identified structs can be created without providing the lists of element types, making them suitable to represent recursive, i.e. self-referring, structures. Identified structs without body are considered opaque. For such structs, one can set the body. Identified structs can be created as intentionally-opaque, implying that the caller does not intend to ever set the body (e.g. forward-declarations of structs from another module) and wants to disallow further modification of the body. For intentionally-opaque structs or non-opaque structs with the body, one is not allowed to set another body (however, one can set exactly the same body).
Note that the packedness of the struct takes place in uniquing of literal structs, but does not in uniquing of identified structs.
Definition at line 105 of file LLVMTypes.h.
using mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::Base = StorageUserBase<ConcreteT, BaseT, StorageT, UniquerT, Traits...> |
Inherit base constructors.
Definition at line 101 of file StorageUniquerSupport.h.
bool LLVMStructType::areCompatible | ( | DataLayoutEntryListRef | oldLayout, |
DataLayoutEntryListRef | newLayout | ||
) | const |
Definition at line 582 of file LLVMTypes.cpp.
References extractStructSpecValue().
uint64_t LLVMStructType::getABIAlignment | ( | const DataLayout & | dataLayout, |
DataLayoutEntryListRef | params | ||
) | const |
Definition at line 564 of file LLVMTypes.cpp.
References calculateStructAlignment().
Returns the list of element types contained in a non-opaque struct.
Definition at line 473 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl(), and isIdentified().
Referenced by calculateStructAlignment(), destructureIndices(), findIndicesForOffset(), gepToByteOffset(), getSubelementIndexMap(), and getTypeSizeInBits().
|
static |
Gets or creates an identified struct with the given name in the provided context.
Note that unlike llvm::StructType::create, this function will NOT rename a struct in case a struct with the same name already exists in the context. Instead, it will just return the existing struct, similarly to the rest of MLIR type get methods.
Definition at line 408 of file LLVMTypes.cpp.
References mlir::get(), and name.
Referenced by getNewIdentified(), and mlir::LLVMTypeConverter::LLVMTypeConverter().
|
static |
Definition at line 413 of file LLVMTypes.cpp.
References mlir::emitError(), and name.
|
static |
Gets or creates a literal struct with the given body in the provided context.
Definition at line 436 of file LLVMTypes.cpp.
References mlir::get(), and isPacked().
Referenced by mlir::convertMMAToLLVMType(), convertStructTypePacked(), convertStructTypeWithOffset(), inferIntrinsicResultType(), mlir::LLVMTypeConverter::LLVMTypeConverter(), mlir::GPUPrintfOpToVPrintfLowering::matchAndRewrite(), mlirLLVMStructTypeLiteralGet(), mlir::LLVMTypeConverter::packFunctionResults(), mlir::LLVMTypeConverter::packOperationResults(), and mlir::UnrankedMemRefDescriptor::sizeBasePtr().
|
static |
Definition at line 442 of file LLVMTypes.cpp.
References mlir::emitError(), and isPacked().
StringRef LLVMStructType::getName | ( | ) |
Returns the name of an identified struct.
Definition at line 472 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by printStructType().
|
static |
Gets a new identified struct with the given body.
The body cannot be changed later. If a struct with the given name already exists, renames the struct by appending a .
followed by a number to the name. Renaming happens even if the existing struct has the same body.
Definition at line 419 of file LLVMTypes.cpp.
References mlir::failed(), getIdentified(), isPacked(), and name.
|
static |
Gets or creates an intentionally-opaque identified struct.
Such a struct cannot have its body set. To create an opaque struct with a mutable body, use getIdentified
. Note that unlike llvm::StructType::create, this function will NOT rename a struct in case a struct with the same name already exists in the context. Instead, it will just return the existing struct, similarly to the rest of MLIR type get methods.
Definition at line 448 of file LLVMTypes.cpp.
References mlir::get(), and name.
|
static |
Definition at line 453 of file LLVMTypes.cpp.
References mlir::emitError(), and name.
uint64_t LLVMStructType::getPreferredAlignment | ( | const DataLayout & | dataLayout, |
DataLayoutEntryListRef | params | ||
) | const |
Definition at line 571 of file LLVMTypes.cpp.
References calculateStructAlignment().
Destructs the struct into its indexed field types.
Definition at line 900 of file LLVMMemorySlot.cpp.
References mlir::detail::enumerate(), mlir::get(), getBody(), and getContext().
Returns which type is stored at a given integer index within the struct.
Definition at line 908 of file LLVMMemorySlot.cpp.
llvm::TypeSize LLVMStructType::getTypeSizeInBits | ( | const DataLayout & | dataLayout, |
DataLayoutEntryListRef | params | ||
) | const |
Hooks for DataLayoutTypeInterface.
Should not be called directly. Obtain a DataLayout instance and query it instead.
Definition at line 494 of file LLVMTypes.cpp.
References getBody(), mlir::DataLayout::getTypeABIAlignment(), mlir::DataLayout::getTypeSize(), isPacked(), kBitsInByte, and max().
bool LLVMStructType::isIdentified | ( | ) | const |
Checks if a struct is identified.
Definition at line 466 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by getBody(), printStructType(), and setBody().
bool LLVMStructType::isInitialized | ( | ) |
Checks if a struct is initialized.
Definition at line 471 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
bool LLVMStructType::isOpaque | ( | ) |
Checks if a struct is opaque.
Definition at line 467 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
bool LLVMStructType::isPacked | ( | ) | const |
Checks if a struct is packed.
Definition at line 465 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by calculateStructAlignment(), findIndicesForOffset(), gepToByteOffset(), getLiteral(), getLiteralChecked(), getNewIdentified(), getTypeSizeInBits(), and setBody().
|
static |
Checks if the given type can be contained in a structure type.
Definition at line 402 of file LLVMTypes.cpp.
LogicalResult LLVMStructType::setBody | ( | ArrayRef< Type > | types, |
bool | isPacked | ||
) |
Set the body of an identified struct.
Returns failure if the body could not be set, e.g. if the struct already has a body or if it was marked as intentionally opaque. This might happen in a multi-threaded context when a different thread modified the struct after it was created. Most callers are likely to assert this always succeeds, but it is possible to implement a local renaming scheme based on the result of this call.
Definition at line 458 of file LLVMTypes.cpp.
References isIdentified(), isPacked(), and isValidElementType().
|
inlinestatic |
Default implementation that just returns success.
Definition at line 230 of file StorageUniquerSupport.h.
|
static |
Definition at line 484 of file LLVMTypes.cpp.
References mlir::emitError(), isValidElementType(), and mlir::success().
|
static |
Verifies that the type about to be constructed is well-formed.
Definition at line 478 of file LLVMTypes.cpp.
References mlir::success().
LogicalResult LLVMStructType::verifyEntries | ( | DataLayoutEntryListRef | entries, |
Location | loc | ||
) | const |
Definition at line 605 of file LLVMTypes.cpp.
References mlir::emitError(), extractStructSpecValue(), mlir::Type::isInteger(), and mlir::success().
|
staticconstexpr |
Definition at line 114 of file LLVMTypes.h.
Referenced by getIdentified(), getIdentifiedChecked(), getNewIdentified(), getOpaque(), and getOpaqueChecked().