MLIR  15.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | 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:
+ Collaboration diagram for mlir::spirv::StructType:

Classes

class  ElementTypeRange
 Range class for element types. More...
 
struct  MemberDecorationInfo
 

Public Types

using OffsetInfo = uint32_t
 
- 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
 
ElementTypeRange 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, Optional< StorageClass > storage=llvm::None)
 
void getCapabilities (SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
 

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

- 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...
 
ImplTypegetImpl () const
 Utility for easy access to the storage instance. More...
 
- Static Protected Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >
template<typename... Args>
static LogicalResult verify (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:

!spv.struct<A, (!spv.ptr<!spv.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 278 of file SPIRVTypes.h.

Member Typedef Documentation

◆ OffsetInfo

Definition at line 284 of file SPIRVTypes.h.

Member Function Documentation

◆ get()

StructType StructType::get ( ArrayRef< Type memberTypes,
ArrayRef< OffsetInfo offsetInfo = {},
ArrayRef< MemberDecorationInfo memberDecorations = {} 
)
static

◆ getCapabilities()

void StructType::getCapabilities ( SPIRVType::CapabilityArrayRefVector capabilities,
Optional< StorageClass >  storage = llvm::None 
)

Definition at line 1047 of file SPIRVTypes.cpp.

◆ getElementType()

Type StructType::getElementType ( unsigned  index) const

◆ getElementTypes()

StructType::ElementTypeRange StructType::getElementTypes ( ) const

Definition at line 996 of file SPIRVTypes.cpp.

References getNumElements().

Referenced by convertStructTypePacked(), and convertStructTypeWithOffset().

◆ 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 971 of file SPIRVTypes.cpp.

References mlir::failed(), isIdentified(), and trySetBody().

Referenced by mlir::spirv::Deserializer::collect(), and parseStructType().

◆ getExtensions()

void StructType::getExtensions ( SPIRVType::ExtensionArrayRefVector extensions,
Optional< StorageClass >  storage = llvm::None 
)

Definition at line 1041 of file SPIRVTypes.cpp.

◆ 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 961 of file SPIRVTypes.cpp.

Referenced by mlir::spirv::Deserializer::collect(), parseStructType(), and mlir::spirv::Serializer::processTypeDecoration< spirv::RuntimeArrayType >().

◆ getIdentifier()

StringRef StructType::getIdentifier ( ) const

For literal structs, return an empty string.

For identified structs, return the struct's identifier.

Definition at line 985 of file SPIRVTypes.cpp.

Referenced by print(), and mlir::spirv::Serializer::processTypeDecoration< spirv::RuntimeArrayType >().

◆ getMemberDecorations() [1/2]

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

◆ getMemberDecorations() [2/2]

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

Definition at line 1017 of file SPIRVTypes.cpp.

References getNumElements().

◆ getMemberOffset()

uint64_t StructType::getMemberOffset ( unsigned  index) const

Definition at line 1003 of file SPIRVTypes.cpp.

References getNumElements().

Referenced by print().

◆ getNumElements()

unsigned StructType::getNumElements ( ) const

◆ hasOffset()

bool StructType::hasOffset ( ) const

Definition at line 1001 of file SPIRVTypes.cpp.

Referenced by convertStructType(), mlir::VulkanLayoutUtils::isLegalType(), and print().

◆ isIdentified()

bool StructType::isIdentified ( ) const

◆ 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 1035 of file SPIRVTypes.cpp.

Referenced by getEmpty().


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