MLIR
20.0.0git
|
SPIR-V struct type. More...
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
Classes | |
struct | MemberDecorationInfo |
Public Types | |
using | OffsetInfo = uint32_t |
using | Base = StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits... > |
Utility declarations for the concrete attribute class. 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 | |
StringRef | getIdentifier () const |
For literal structs, return an empty string. More... | |
bool | isIdentified () const |
Returns true if the StructType is identified. More... | |
unsigned | getNumElements () const |
Type | getElementType (unsigned) const |
TypeRange | getElementTypes () const |
bool | hasOffset () const |
uint64_t | getMemberOffset (unsigned) const |
void | getMemberDecorations (SmallVectorImpl< StructType::MemberDecorationInfo > &memberDecorations) const |
void | getMemberDecorations (unsigned i, SmallVectorImpl< StructType::MemberDecorationInfo > &decorationsInfo) const |
LogicalResult | trySetBody (ArrayRef< Type > memberTypes, ArrayRef< OffsetInfo > offsetInfo={}, ArrayRef< MemberDecorationInfo > memberDecorations={}) |
Sets the contents of an incomplete identified StructType. More... | |
void | getExtensions (SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt) |
void | getCapabilities (SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt) |
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 StructType | get (ArrayRef< Type > memberTypes, ArrayRef< OffsetInfo > offsetInfo={}, ArrayRef< MemberDecorationInfo > memberDecorations={}) |
Construct a literal StructType with at least one member. More... | |
static StructType | getIdentified (MLIRContext *context, StringRef identifier) |
Construct an identified StructType. More... | |
static StructType | getEmpty (MLIRContext *context, StringRef identifier="") |
Construct a (possibly identified) StructType with no members. 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 = "spirv.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... | |
SPIR-V struct type.
Two kinds of struct types are supported:
struct A { A* next; };
would be represented in MLIR as:
!spirv.struct<A, (!spirv.ptr<!spirv.struct, Generic>)>
In the above, expressing recursive struct types is accomplished by giving a recursive struct a unique identified and using that identifier in the struct definition for recursive references.
Definition at line 291 of file SPIRVTypes.h.
using mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::Base = StorageUserBase<ConcreteT, BaseT, StorageT, UniquerT, Traits...> |
Utility declarations for the concrete attribute class.
Definition at line 100 of file StorageUniquerSupport.h.
using mlir::spirv::StructType::OffsetInfo = uint32_t |
Definition at line 298 of file SPIRVTypes.h.
|
static |
Construct a literal StructType with at least one member.
Definition at line 961 of file SPIRVTypes.cpp.
References mlir::get().
Referenced by createGlobalVarForEntryPointArgument(), and parseStructType().
void StructType::getCapabilities | ( | SPIRVType::CapabilityArrayRefVector & | capabilities, |
std::optional< StorageClass > | storage = std::nullopt |
||
) |
Definition at line 1060 of file SPIRVTypes.cpp.
References getElementTypes().
Type StructType::getElementType | ( | unsigned | index | ) | const |
Definition at line 1004 of file SPIRVTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl(), and getNumElements().
Referenced by mlir::spirv::CompositeType::getElementType(), and print().
TypeRange StructType::getElementTypes | ( | ) | const |
Definition at line 1009 of file SPIRVTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl(), and getNumElements().
Referenced by convertStructTypePacked(), convertStructTypeWithOffset(), getCapabilities(), and getExtensions().
|
static |
Construct a (possibly identified) StructType with no members.
Note: this method might fail in a multi-threaded setup if another thread created an identified struct with the same identifier but with different contents before returning. In which case, an empty (default-constructed) StructType is returned.
Definition at line 984 of file SPIRVTypes.cpp.
References mlir::get(), isIdentified(), and trySetBody().
Referenced by parseStructType().
void StructType::getExtensions | ( | SPIRVType::ExtensionArrayRefVector & | extensions, |
std::optional< StorageClass > | storage = std::nullopt |
||
) |
Definition at line 1054 of file SPIRVTypes.cpp.
References getElementTypes().
|
static |
Construct an identified StructType.
This creates a StructType whose body (member types, offset info, and decorations) is not set yet. A call to StructType::trySetBody(...) must follow when the StructType contents are available (e.g. parsed or deserialized).
Note: If another thread creates (or had already created) a struct with the same identifier, that struct will be returned as a result.
Definition at line 974 of file SPIRVTypes.cpp.
References mlir::get().
Referenced by parseStructType().
StringRef StructType::getIdentifier | ( | ) | const |
For literal structs, return an empty string.
For identified structs, return the struct's identifier.
Definition at line 998 of file SPIRVTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by print().
void StructType::getMemberDecorations | ( | SmallVectorImpl< StructType::MemberDecorationInfo > & | memberDecorations | ) | const |
Definition at line 1021 of file SPIRVTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by convertStructType(), and print().
void StructType::getMemberDecorations | ( | unsigned | i, |
SmallVectorImpl< StructType::MemberDecorationInfo > & | decorationsInfo | ||
) | const |
Definition at line 1030 of file SPIRVTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl(), and getNumElements().
uint64_t StructType::getMemberOffset | ( | unsigned | index | ) | const |
Definition at line 1016 of file SPIRVTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl(), and getNumElements().
Referenced by print().
unsigned StructType::getNumElements | ( | ) | const |
Definition at line 1002 of file SPIRVTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by getElementType(), getElementTypes(), getMemberDecorations(), getMemberOffset(), mlir::VulkanLayoutUtils::isLegalType(), and print().
bool StructType::hasOffset | ( | ) | const |
Definition at line 1014 of file SPIRVTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by convertStructType(), mlir::VulkanLayoutUtils::isLegalType(), and print().
bool StructType::isIdentified | ( | ) | const |
Returns true if the StructType is identified.
Definition at line 1000 of file SPIRVTypes.cpp.
References mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >::getImpl().
Referenced by getEmpty(), and print().
LogicalResult StructType::trySetBody | ( | ArrayRef< Type > | memberTypes, |
ArrayRef< OffsetInfo > | offsetInfo = {} , |
||
ArrayRef< MemberDecorationInfo > | memberDecorations = {} |
||
) |
Sets the contents of an incomplete identified StructType.
This method must be called only for identified StructTypes and it must be called only once per instance. Otherwise, failure() is returned.
Definition at line 1048 of file SPIRVTypes.cpp.
Referenced by getEmpty(), and parseStructType().
|
staticconstexpr |
Definition at line 300 of file SPIRVTypes.h.