MLIR  20.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
mlir::spirv::StructType Class Reference

SPIR-V struct type. More...

#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"

+ Inheritance diagram for mlir::spirv::StructType:

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 >
ImplTypegetImpl () 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...
 

Detailed Description

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.

Member Typedef Documentation

◆ Base

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.

◆ OffsetInfo

Definition at line 298 of file SPIRVTypes.h.

Member Function Documentation

◆ get()

StructType StructType::get ( ArrayRef< Type memberTypes,
ArrayRef< OffsetInfo offsetInfo = {},
ArrayRef< MemberDecorationInfo memberDecorations = {} 
)
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().

◆ getCapabilities()

void StructType::getCapabilities ( SPIRVType::CapabilityArrayRefVector capabilities,
std::optional< StorageClass >  storage = std::nullopt 
)

Definition at line 1060 of file SPIRVTypes.cpp.

References getElementTypes().

◆ getElementType()

Type StructType::getElementType ( unsigned  index) const

◆ getElementTypes()

TypeRange StructType::getElementTypes ( ) const

◆ getEmpty()

StructType StructType::getEmpty ( MLIRContext context,
StringRef  identifier = "" 
)
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().

◆ getExtensions()

void StructType::getExtensions ( SPIRVType::ExtensionArrayRefVector extensions,
std::optional< StorageClass >  storage = std::nullopt 
)

Definition at line 1054 of file SPIRVTypes.cpp.

References getElementTypes().

◆ getIdentified()

StructType StructType::getIdentified ( MLIRContext context,
StringRef  identifier 
)
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().

◆ getIdentifier()

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().

◆ getMemberDecorations() [1/2]

void StructType::getMemberDecorations ( SmallVectorImpl< StructType::MemberDecorationInfo > &  memberDecorations) const

◆ getMemberDecorations() [2/2]

void StructType::getMemberDecorations ( unsigned  i,
SmallVectorImpl< StructType::MemberDecorationInfo > &  decorationsInfo 
) const

◆ getMemberOffset()

uint64_t StructType::getMemberOffset ( unsigned  index) const

◆ getNumElements()

unsigned StructType::getNumElements ( ) const

◆ hasOffset()

bool StructType::hasOffset ( ) const

◆ isIdentified()

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().

◆ trySetBody()

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().

Member Data Documentation

◆ name

constexpr StringLiteral mlir::spirv::StructType::name = "spirv.struct"
staticconstexpr

Definition at line 300 of file SPIRVTypes.h.


The documentation for this class was generated from the following files: