MLIR
15.0.0git
|
LLVM dialect structure type representing a collection of different-typed elements manipulated together. More...
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
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... | |
unsigned | getTypeSizeInBits (const DataLayout &dataLayout, DataLayoutEntryListRef params) const |
Hooks for DataLayoutTypeInterface. More... | |
unsigned | getABIAlignment (const DataLayout &dataLayout, DataLayoutEntryListRef params) const |
unsigned | getPreferredAlignment (const DataLayout &dataLayout, DataLayoutEntryListRef params) const |
bool | areCompatible (DataLayoutEntryListRef oldLayout, DataLayoutEntryListRef newLayout) const |
LogicalResult | verifyEntries (DataLayoutEntryListRef entries, Location loc) const |
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) |
![]() | |
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... | |
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... | |
Additional Inherited Members | |
![]() | |
using | Base = StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits... > |
Utility declarations for the concrete attribute class. More... | |
using | ImplType = StorageT |
using | HasTraitFn = bool(*)(TypeID) |
![]() | |
template<typename... Args> | |
LogicalResult | mutate (Args &&...args) |
Mutate the current storage instance. More... | |
ImplType * | getImpl () const |
Utility for easy access to the 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 265 of file LLVMTypes.h.
bool LLVMStructType::areCompatible | ( | DataLayoutEntryListRef | oldLayout, |
DataLayoutEntryListRef | newLayout | ||
) | const |
Definition at line 539 of file LLVMTypes.cpp.
References extractStructSpecValue().
unsigned LLVMStructType::getABIAlignment | ( | const DataLayout & | dataLayout, |
DataLayoutEntryListRef | params | ||
) | const |
Definition at line 521 of file LLVMTypes.cpp.
References calculateStructAlignment().
Returns the list of element types contained in a non-opaque struct.
Definition at line 430 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by calculateStructAlignment(), mlir::LLVMTypeConverter::LLVMTypeConverter(), recordStructIndices(), and mlir::LLVM::detail::TypeToLLVMIRTranslatorImpl::translateType().
|
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 365 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::get().
Referenced by getNewIdentified(), mlir::LLVMTypeConverter::LLVMTypeConverter(), and mlir::LLVM::detail::TypeFromLLVMIRTranslatorImpl::translateType().
|
static |
Definition at line 370 of file LLVMTypes.cpp.
References mlir::emitError(), and mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getChecked().
|
static |
Gets or creates a literal struct with the given body in the provided context.
Definition at line 393 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::get().
Referenced by mlir::convertMMAToLLVMType(), convertStructType(), convertStructTypePacked(), convertStructTypeWithOffset(), mlir::LLVMTypeConverter::getMemRefDescriptorSize(), mlir::LLVMTypeConverter::getPointerBitwidth(), mlir::LLVMTypeConverter::getUnrankedMemRefDescriptorSize(), inferIntrinsicResultType(), mlir::LLVMTypeConverter::LLVMTypeConverter(), mlirLLVMStructTypeLiteralGet(), mlir::LLVMTypeConverter::packFunctionResults(), mlir::UnrankedMemRefDescriptor::sizeBasePtr(), mlir::LLVM::detail::TypeFromLLVMIRTranslatorImpl::translateType(), and unpackOperandVector().
|
static |
Definition at line 399 of file LLVMTypes.cpp.
References mlir::emitError(), and mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getChecked().
StringRef LLVMStructType::getName | ( | ) |
Returns the name of an identified struct.
Definition at line 429 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by mlir::LLVMTypeConverter::LLVMTypeConverter(), printStructType(), and mlir::LLVM::detail::TypeToLLVMIRTranslatorImpl::translateType().
|
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 376 of file LLVMTypes.cpp.
References mlir::failed(), and getIdentified().
Referenced by isDefinedByCallTo(), and mlir::DataDescriptor::undef().
|
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 405 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::get().
Referenced by mlir::LLVM::detail::TypeFromLLVMIRTranslatorImpl::translateType().
|
static |
Definition at line 410 of file LLVMTypes.cpp.
References mlir::emitError(), and mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getChecked().
unsigned LLVMStructType::getPreferredAlignment | ( | const DataLayout & | dataLayout, |
DataLayoutEntryListRef | params | ||
) | const |
Definition at line 528 of file LLVMTypes.cpp.
References calculateStructAlignment().
unsigned 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 451 of file LLVMTypes.cpp.
References mlir::DataLayout::getTypeABIAlignment(), mlir::DataLayout::getTypeSize(), kBitsInByte, and max().
bool LLVMStructType::isIdentified | ( | ) | const |
Checks if a struct is identified.
Definition at line 423 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by mlir::LLVMTypeConverter::LLVMTypeConverter(), printStructType(), and mlir::LLVM::detail::TypeToLLVMIRTranslatorImpl::translateType().
bool LLVMStructType::isInitialized | ( | ) |
Checks if a struct is initialized.
Definition at line 428 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 424 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by mlir::LLVM::detail::TypeToLLVMIRTranslatorImpl::translateType().
bool LLVMStructType::isPacked | ( | ) | const |
Checks if a struct is packed.
Definition at line 422 of file LLVMTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by calculateStructAlignment(), mlir::LLVMTypeConverter::LLVMTypeConverter(), and mlir::LLVM::detail::TypeToLLVMIRTranslatorImpl::translateType().
|
static |
Checks if the given type can be contained in a structure type.
Definition at line 360 of file LLVMTypes.cpp.
References mlir::Type::isa().
Referenced by setBody().
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 415 of file LLVMTypes.cpp.
References isValidElementType(), and mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::mutate().
Referenced by mlir::LLVM::detail::TypeFromLLVMIRTranslatorImpl::translateType().
|
static |
Verifies that the type about to be constructed is well-formed.
Definition at line 435 of file LLVMTypes.cpp.
References mlir::success().
|
static |
Definition at line 441 of file LLVMTypes.cpp.
References mlir::emitError(), mlir::LLVM::LLVMArrayType::isValidElementType(), and mlir::success().
LogicalResult LLVMStructType::verifyEntries | ( | DataLayoutEntryListRef | entries, |
Location | loc | ||
) | const |
Definition at line 562 of file LLVMTypes.cpp.
References mlir::emitError(), extractStructSpecValue(), and mlir::success().