MLIR
20.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... | |
Public Types inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits > | |
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... | |
Public Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits > | |
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 | verifyInvariants (function_ref< InFlightDiagnostic()> emitError, StringRef, bool) |
Verifies that the type about to be constructed is well-formed. More... | |
static LogicalResult | verifyInvariants (function_ref< InFlightDiagnostic()> emitError, ArrayRef< Type > types, bool) |
template<typename... Args> | |
static LogicalResult | verifyInvariants (Args... args) |
Default implementation that just returns success. More... | |
Static Public Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits > | |
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 | |
Protected Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits > | |
template<typename... Args> | |
LogicalResult | mutate (Args &&...args) |
Mutate the current storage instance. More... | |
Static Protected Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits > | |
template<typename... Args> | |
static LogicalResult | verifyInvariants (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 104 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 100 of file StorageUniquerSupport.h.
bool LLVMStructType::areCompatible | ( | DataLayoutEntryListRef | oldLayout, |
DataLayoutEntryListRef | newLayout | ||
) | const |
Definition at line 599 of file LLVMTypes.cpp.
References extractStructSpecValue().
uint64_t LLVMStructType::getABIAlignment | ( | const DataLayout & | dataLayout, |
DataLayoutEntryListRef | params | ||
) | const |
Definition at line 581 of file LLVMTypes.cpp.
References calculateStructAlignment().
Returns the list of element types contained in a non-opaque struct.
Definition at line 489 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl(), and isIdentified().
Referenced by calculateStructAlignment(), destructureIndices(), gepToByteOffset(), getSubelementIndexMap(), getSubslotAccessInfo(), 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 424 of file LLVMTypes.cpp.
References mlir::get(), and name.
Referenced by getNewIdentified(), mlir::LLVMTypeConverter::LLVMTypeConverter(), and mlirLLVMStructTypeIdentifiedGet().
|
static |
Definition at line 429 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 452 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 458 of file LLVMTypes.cpp.
References mlir::emitError(), and isPacked().
Referenced by mlirLLVMStructTypeLiteralGetChecked().
StringRef LLVMStructType::getName | ( | ) |
Returns the name of an identified struct.
Definition at line 488 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 435 of file LLVMTypes.cpp.
References getIdentified(), isPacked(), and name.
Referenced by mlirLLVMStructTypeIdentifiedNewGet().
|
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 464 of file LLVMTypes.cpp.
References mlir::get(), and name.
Referenced by mlirLLVMStructTypeOpaqueGet().
|
static |
Definition at line 469 of file LLVMTypes.cpp.
References mlir::emitError(), and name.
uint64_t LLVMStructType::getPreferredAlignment | ( | const DataLayout & | dataLayout, |
DataLayoutEntryListRef | params | ||
) | const |
Definition at line 588 of file LLVMTypes.cpp.
References calculateStructAlignment().
Destructs the struct into its indexed field types.
Definition at line 1404 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 1412 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 511 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 482 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 487 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 483 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 481 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by calculateStructAlignment(), gepToByteOffset(), getLiteral(), getLiteralChecked(), getNewIdentified(), getSubslotAccessInfo(), getTypeSizeInBits(), and setBody().
|
static |
Checks if the given type can be contained in a structure type.
Definition at line 419 of file LLVMTypes.cpp.
Referenced by setBody(), and verifyInvariants().
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 474 of file LLVMTypes.cpp.
References isIdentified(), isPacked(), and isValidElementType().
LogicalResult LLVMStructType::verifyEntries | ( | DataLayoutEntryListRef | entries, |
Location | loc | ||
) | const |
Definition at line 622 of file LLVMTypes.cpp.
References mlir::emitError(), extractStructSpecValue(), and mlir::Type::isInteger().
|
inlinestatic |
Default implementation that just returns success.
Definition at line 229 of file StorageUniquerSupport.h.
|
static |
Definition at line 501 of file LLVMTypes.cpp.
References mlir::emitError(), and isValidElementType().
|
static |
Verifies that the type about to be constructed is well-formed.
Definition at line 495 of file LLVMTypes.cpp.
|
staticconstexpr |
Definition at line 113 of file LLVMTypes.h.
Referenced by getIdentified(), getIdentifiedChecked(), getNewIdentified(), getOpaque(), and getOpaqueChecked().