13 #ifndef MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
14 #define MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
30 struct ArrayTypeStorage;
31 struct CooperativeMatrixTypeStorage;
32 struct CooperativeMatrixNVTypeStorage;
33 struct ImageTypeStorage;
34 struct JointMatrixTypeStorage;
35 struct MatrixTypeStorage;
36 struct PointerTypeStorage;
37 struct RuntimeArrayTypeStorage;
38 struct SampledImageTypeStorage;
39 struct StructTypeStorage;
61 std::optional<StorageClass> storage = std::nullopt);
73 std::optional<StorageClass> storage = std::nullopt);
84 using SPIRVType::SPIRVType;
91 static bool isValid(IntegerType);
94 std::optional<StorageClass> storage = std::nullopt);
96 std::optional<StorageClass> storage = std::nullopt);
104 using SPIRVType::SPIRVType;
109 static bool isValid(VectorType);
122 std::optional<StorageClass> storage = std::nullopt);
124 std::optional<StorageClass> storage = std::nullopt);
131 detail::ArrayTypeStorage> {
150 std::optional<StorageClass> storage = std::nullopt);
152 std::optional<StorageClass> storage = std::nullopt);
161 :
public Type::TypeBase<ImageType, SPIRVType, detail::ImageTypeStorage> {
167 ImageDepthInfo depth = ImageDepthInfo::DepthUnknown,
168 ImageArrayedInfo arrayed = ImageArrayedInfo::NonArrayed,
169 ImageSamplingInfo samplingInfo = ImageSamplingInfo::SingleSampled,
170 ImageSamplerUseInfo samplerUse = ImageSamplerUseInfo::SamplerUnknown,
171 ImageFormat format = ImageFormat::Unknown) {
173 std::tuple<
Type, Dim, ImageDepthInfo, ImageArrayedInfo,
174 ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat>(
175 elementType, dim, depth, arrayed, samplingInfo, samplerUse,
180 get(std::tuple<
Type, Dim, ImageDepthInfo, ImageArrayedInfo,
181 ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat>);
193 std::optional<StorageClass> storage = std::nullopt);
195 std::optional<StorageClass> storage = std::nullopt);
200 detail::PointerTypeStorage> {
211 std::optional<StorageClass> storage = std::nullopt);
213 std::optional<StorageClass> storage = std::nullopt);
219 detail::RuntimeArrayTypeStorage> {
235 std::optional<StorageClass> storage = std::nullopt);
237 std::optional<StorageClass> storage = std::nullopt);
243 detail::SampledImageTypeStorage> {
258 std::optional<spirv::StorageClass> storage = std::nullopt);
261 std::optional<spirv::StorageClass> storage = std::nullopt);
284 detail::StructTypeStorage, TypeTrait::IsMutable> {
329 static StructType
getIdentified(MLIRContext *context, StringRef identifier);
337 static StructType
getEmpty(MLIRContext *context, StringRef identifier =
"");
353 ElementTypeRange, const Type *, Type, Type, Type> {
355 using RangeBaseT::RangeBaseT;
358 static const Type *offset_base(
const Type *
object, ptrdiff_t index) {
359 return object + index;
362 static Type dereference_iterator(
const Type *
object, ptrdiff_t index) {
363 return object[index];
379 &memberDecorations)
const;
395 std::optional<StorageClass> storage = std::nullopt);
397 std::optional<StorageClass> storage = std::nullopt);
401 hash_value(
const StructType::MemberDecorationInfo &memberDecorationInfo);
406 detail::CooperativeMatrixTypeStorage> {
411 uint32_t columns, Scope scope,
412 CooperativeMatrixUseKHR use);
422 CooperativeMatrixUseKHR
getUse()
const;
425 std::optional<StorageClass> storage = std::nullopt);
427 std::optional<StorageClass> storage = std::nullopt);
433 detail::CooperativeMatrixNVTypeStorage> {
438 unsigned rows,
unsigned columns);
449 std::optional<StorageClass> storage = std::nullopt);
451 std::optional<StorageClass> storage = std::nullopt);
457 detail::JointMatrixTypeStorage> {
462 unsigned columns, MatrixLayout matrixLayout);
476 std::optional<StorageClass> storage = std::nullopt);
478 std::optional<StorageClass> storage = std::nullopt);
483 detail::MatrixTypeStorage> {
490 Type columnType, uint32_t columnCount);
493 Type columnType, uint32_t columnCount);
513 std::optional<StorageClass> storage = std::nullopt);
515 std::optional<StorageClass> storage = std::nullopt);
This class represents a diagnostic that is inflight and set to be reported.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Utility class for implementing users of storage classes uniqued by a StorageUniquer.
Type getElementType() const
unsigned getArrayStride() const
Returns the array stride in bytes.
unsigned getNumElements() const
static ArrayType get(Type elementType, unsigned elementCount)
std::optional< int64_t > getSizeInBytes()
Returns the array size in bytes.
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
std::optional< int64_t > getSizeInBytes()
bool hasCompileTimeKnownNumElements() const
Return true if the number of elements is known at compile time and is not implementation dependent.
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
unsigned getNumElements() const
Return the number of elements of the type.
static bool isValid(VectorType)
Returns true if the given vector type is valid for the SPIR-V dialect.
Type getElementType(unsigned) const
static bool classof(Type type)
unsigned getRows() const
Returns the number of rows of the matrix.
unsigned getColumns() const
Returns the number of columns of the matrix.
static CooperativeMatrixNVType get(Type elementType, Scope scope, unsigned rows, unsigned columns)
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Scope getScope() const
Returns the scope of the matrix.
Type getElementType() const
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Scope getScope() const
Returns the scope of the matrix.
uint32_t getRows() const
Returns the number of rows of the matrix.
uint32_t getColumns() const
Returns the number of columns of the matrix.
static CooperativeMatrixType get(Type elementType, uint32_t rows, uint32_t columns, Scope scope, CooperativeMatrixUseKHR use)
Type getElementType() const
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
CooperativeMatrixUseKHR getUse() const
Returns the use parameter of the cooperative matrix.
static ImageType get(Type elementType, Dim dim, ImageDepthInfo depth=ImageDepthInfo::DepthUnknown, ImageArrayedInfo arrayed=ImageArrayedInfo::NonArrayed, ImageSamplingInfo samplingInfo=ImageSamplingInfo::SingleSampled, ImageSamplerUseInfo samplerUse=ImageSamplerUseInfo::SamplerUnknown, ImageFormat format=ImageFormat::Unknown)
ImageDepthInfo getDepthInfo() const
ImageArrayedInfo getArrayedInfo() const
ImageFormat getImageFormat() const
ImageSamplerUseInfo getSamplerUseInfo() const
Type getElementType() const
ImageSamplingInfo getSamplingInfo() const
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Scope getScope() const
Return the scope of the joint matrix.
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
unsigned getColumns() const
return the number of columns of the matrix.
static JointMatrixINTELType get(Type elementType, Scope scope, unsigned rows, unsigned columns, MatrixLayout matrixLayout)
unsigned getRows() const
return the number of rows of the matrix.
MatrixLayout getMatrixLayout() const
return the layout of the matrix
Type getElementType() const
static MatrixType getChecked(function_ref< InFlightDiagnostic()> emitError, Type columnType, uint32_t columnCount)
unsigned getNumElements() const
Returns total number of elements (rows*columns).
static MatrixType get(Type columnType, uint32_t columnCount)
Type getColumnType() const
unsigned getNumColumns() const
Returns the number of columns.
static bool isValidColumnType(Type columnType)
Returns true if the matrix elements are vectors of float elements.
Type getElementType() const
Returns the elements' type (i.e, single element type).
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
unsigned getNumRows() const
Returns the number of rows.
static LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Type columnType, uint32_t columnCount)
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Type getPointeeType() const
StorageClass getStorageClass() const
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
static PointerType get(Type pointeeType, StorageClass storageClass)
Type getElementType() const
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
unsigned getArrayStride() const
Returns the array stride in bytes.
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
static RuntimeArrayType get(Type elementType)
SmallVectorImpl< ArrayRef< Capability > > CapabilityArrayRefVector
The capability requirements for each type are following the ((Capability::A OR Extension::B) AND (Cap...
std::optional< int64_t > getSizeInBytes()
Returns the size in bytes for each type.
static bool classof(Type type)
void getCapabilities(CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Appends to capabilities the capabilities needed for this type to appear in the given storage class.
SmallVectorImpl< ArrayRef< Extension > > ExtensionArrayRefVector
The extension requirements for each type are following the ((Extension::A OR Extension::B) AND (Exten...
void getExtensions(ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Appends to extensions the extensions needed for this type to appear in the given storage class.
static LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Type imageType)
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< spirv::StorageClass > storage=std::nullopt)
static SampledImageType getChecked(function_ref< InFlightDiagnostic()> emitError, Type imageType)
Type getImageType() const
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< spirv::StorageClass > storage=std::nullopt)
static SampledImageType get(Type imageType)
static bool classof(Type type)
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
static bool isValid(FloatType)
Returns true if the given integer type is valid for the SPIR-V dialect.
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
std::optional< int64_t > getSizeInBytes()
Range class for element types.
void getMemberDecorations(SmallVectorImpl< StructType::MemberDecorationInfo > &memberDecorations) const
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
static StructType getIdentified(MLIRContext *context, StringRef identifier)
Construct an identified StructType.
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
bool isIdentified() const
Returns true if the StructType is identified.
StringRef getIdentifier() const
For literal structs, return an empty string.
static StructType getEmpty(MLIRContext *context, StringRef identifier="")
Construct a (possibly identified) StructType with no members.
unsigned getNumElements() const
Type getElementType(unsigned) const
LogicalResult trySetBody(ArrayRef< Type > memberTypes, ArrayRef< OffsetInfo > offsetInfo={}, ArrayRef< MemberDecorationInfo > memberDecorations={})
Sets the contents of an incomplete identified StructType.
ElementTypeRange getElementTypes() const
static StructType get(ArrayRef< Type > memberTypes, ArrayRef< OffsetInfo > offsetInfo={}, ArrayRef< MemberDecorationInfo > memberDecorations={})
Construct a literal StructType with at least one member.
uint64_t getMemberOffset(unsigned) const
llvm::hash_code hash_value(const StructType::MemberDecorationInfo &memberDecorationInfo)
This header declares functions that assist transformations in the MemRef dialect.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
This class represents an efficient way to signal success or failure.
bool operator==(const MemberDecorationInfo &other) const
MemberDecorationInfo(uint32_t index, uint32_t hasValue, Decoration decoration, uint32_t decorationValue)
bool operator<(const MemberDecorationInfo &other) const