MLIR  19.0.0git
SPIRVTypes.h
Go to the documentation of this file.
1 //===- SPIRVTypes.h - MLIR SPIR-V Types -------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the types in the SPIR-V dialect.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
14 #define MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
15 
17 #include "mlir/IR/BuiltinTypes.h"
18 #include "mlir/IR/Diagnostics.h"
19 #include "mlir/IR/Location.h"
20 #include "mlir/IR/TypeSupport.h"
21 #include "mlir/IR/Types.h"
22 
23 #include <cstdint>
24 #include <tuple>
25 
26 namespace mlir {
27 namespace spirv {
28 
29 namespace detail {
30 struct ArrayTypeStorage;
31 struct CooperativeMatrixTypeStorage;
32 struct ImageTypeStorage;
33 struct JointMatrixTypeStorage;
34 struct MatrixTypeStorage;
35 struct PointerTypeStorage;
36 struct RuntimeArrayTypeStorage;
37 struct SampledImageTypeStorage;
38 struct StructTypeStorage;
39 
40 } // namespace detail
41 
42 // Base SPIR-V type for providing availability queries.
43 class SPIRVType : public Type {
44 public:
45  using Type::Type;
46 
47  static bool classof(Type type);
48 
49  bool isScalarOrVector();
50 
51  /// The extension requirements for each type are following the
52  /// ((Extension::A OR Extension::B) AND (Extension::C OR Extension::D))
53  /// convention.
55 
56  /// Appends to `extensions` the extensions needed for this type to appear in
57  /// the given `storage` class. This method does not guarantee the uniqueness
58  /// of extensions; the same extension may be appended multiple times.
59  void getExtensions(ExtensionArrayRefVector &extensions,
60  std::optional<StorageClass> storage = std::nullopt);
61 
62  /// The capability requirements for each type are following the
63  /// ((Capability::A OR Extension::B) AND (Capability::C OR Capability::D))
64  /// convention.
66 
67  /// Appends to `capabilities` the capabilities needed for this type to appear
68  /// in the given `storage` class. This method does not guarantee the
69  /// uniqueness of capabilities; the same capability may be appended multiple
70  /// times.
71  void getCapabilities(CapabilityArrayRefVector &capabilities,
72  std::optional<StorageClass> storage = std::nullopt);
73 
74  /// Returns the size in bytes for each type. If no size can be calculated,
75  /// returns `std::nullopt`. Note that if the type has explicit layout, it is
76  /// also taken into account in calculation.
77  std::optional<int64_t> getSizeInBytes();
78 };
79 
80 // SPIR-V scalar type: bool type, integer type, floating point type.
81 class ScalarType : public SPIRVType {
82 public:
83  using SPIRVType::SPIRVType;
84 
85  static bool classof(Type type);
86 
87  /// Returns true if the given integer type is valid for the SPIR-V dialect.
88  static bool isValid(FloatType);
89  /// Returns true if the given float type is valid for the SPIR-V dialect.
90  static bool isValid(IntegerType);
91 
93  std::optional<StorageClass> storage = std::nullopt);
95  std::optional<StorageClass> storage = std::nullopt);
96 
97  std::optional<int64_t> getSizeInBytes();
98 };
99 
100 // SPIR-V composite type: VectorType, SPIR-V ArrayType, or SPIR-V StructType.
101 class CompositeType : public SPIRVType {
102 public:
103  using SPIRVType::SPIRVType;
104 
105  static bool classof(Type type);
106 
107  /// Returns true if the given vector type is valid for the SPIR-V dialect.
108  static bool isValid(VectorType);
109 
110  /// Return the number of elements of the type. This should only be called if
111  /// hasCompileTimeKnownNumElements is true.
112  unsigned getNumElements() const;
113 
114  Type getElementType(unsigned) const;
115 
116  /// Return true if the number of elements is known at compile time and is not
117  /// implementation dependent.
118  bool hasCompileTimeKnownNumElements() const;
119 
121  std::optional<StorageClass> storage = std::nullopt);
123  std::optional<StorageClass> storage = std::nullopt);
124 
125  std::optional<int64_t> getSizeInBytes();
126 };
127 
128 // SPIR-V array type
129 class ArrayType : public Type::TypeBase<ArrayType, CompositeType,
130  detail::ArrayTypeStorage> {
131 public:
132  using Base::Base;
133 
134  static constexpr StringLiteral name = "spirv.array";
135 
136  static ArrayType get(Type elementType, unsigned elementCount);
137 
138  /// Returns an array type with the given stride in bytes.
139  static ArrayType get(Type elementType, unsigned elementCount,
140  unsigned stride);
141 
142  unsigned getNumElements() const;
143 
144  Type getElementType() const;
145 
146  /// Returns the array stride in bytes. 0 means no stride decorated on this
147  /// type.
148  unsigned getArrayStride() const;
149 
151  std::optional<StorageClass> storage = std::nullopt);
153  std::optional<StorageClass> storage = std::nullopt);
154 
155  /// Returns the array size in bytes. Since array type may have an explicit
156  /// stride declaration (in bytes), we also include it in the calculation.
157  std::optional<int64_t> getSizeInBytes();
158 };
159 
160 // SPIR-V image type
162  : public Type::TypeBase<ImageType, SPIRVType, detail::ImageTypeStorage> {
163 public:
164  using Base::Base;
165 
166  static constexpr StringLiteral name = "spirv.image";
167 
168  static ImageType
169  get(Type elementType, Dim dim,
170  ImageDepthInfo depth = ImageDepthInfo::DepthUnknown,
171  ImageArrayedInfo arrayed = ImageArrayedInfo::NonArrayed,
172  ImageSamplingInfo samplingInfo = ImageSamplingInfo::SingleSampled,
173  ImageSamplerUseInfo samplerUse = ImageSamplerUseInfo::SamplerUnknown,
174  ImageFormat format = ImageFormat::Unknown) {
175  return ImageType::get(
176  std::tuple<Type, Dim, ImageDepthInfo, ImageArrayedInfo,
177  ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat>(
178  elementType, dim, depth, arrayed, samplingInfo, samplerUse,
179  format));
180  }
181 
182  static ImageType
183  get(std::tuple<Type, Dim, ImageDepthInfo, ImageArrayedInfo,
184  ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat>);
185 
186  Type getElementType() const;
187  Dim getDim() const;
188  ImageDepthInfo getDepthInfo() const;
189  ImageArrayedInfo getArrayedInfo() const;
190  ImageSamplingInfo getSamplingInfo() const;
191  ImageSamplerUseInfo getSamplerUseInfo() const;
192  ImageFormat getImageFormat() const;
193  // TODO: Add support for Access qualifier
194 
196  std::optional<StorageClass> storage = std::nullopt);
198  std::optional<StorageClass> storage = std::nullopt);
199 };
200 
201 // SPIR-V pointer type
202 class PointerType : public Type::TypeBase<PointerType, SPIRVType,
203  detail::PointerTypeStorage> {
204 public:
205  using Base::Base;
206 
207  static constexpr StringLiteral name = "spirv.pointer";
208 
209  static PointerType get(Type pointeeType, StorageClass storageClass);
210 
211  Type getPointeeType() const;
212 
213  StorageClass getStorageClass() const;
214 
216  std::optional<StorageClass> storage = std::nullopt);
218  std::optional<StorageClass> storage = std::nullopt);
219 };
220 
221 // SPIR-V run-time array type
223  : public Type::TypeBase<RuntimeArrayType, SPIRVType,
224  detail::RuntimeArrayTypeStorage> {
225 public:
226  using Base::Base;
227 
228  static constexpr StringLiteral name = "spirv.rtarray";
229 
230  static RuntimeArrayType get(Type elementType);
231 
232  /// Returns a runtime array type with the given stride in bytes.
233  static RuntimeArrayType get(Type elementType, unsigned stride);
234 
235  Type getElementType() const;
236 
237  /// Returns the array stride in bytes. 0 means no stride decorated on this
238  /// type.
239  unsigned getArrayStride() const;
240 
242  std::optional<StorageClass> storage = std::nullopt);
244  std::optional<StorageClass> storage = std::nullopt);
245 };
246 
247 // SPIR-V sampled image type
249  : public Type::TypeBase<SampledImageType, SPIRVType,
250  detail::SampledImageTypeStorage> {
251 public:
252  using Base::Base;
253 
254  static constexpr StringLiteral name = "spirv.sampled_image";
255 
256  static SampledImageType get(Type imageType);
257 
258  static SampledImageType
260 
262  Type imageType);
263 
264  Type getImageType() const;
265 
267  std::optional<spirv::StorageClass> storage = std::nullopt);
268  void
270  std::optional<spirv::StorageClass> storage = std::nullopt);
271 };
272 
273 /// SPIR-V struct type. Two kinds of struct types are supported:
274 /// - Literal: a literal struct type is uniqued by its fields (types + offset
275 /// info + decoration info).
276 /// - Identified: an indentified struct type is uniqued by its string identifier
277 /// (name). This is useful in representing recursive structs. For example, the
278 /// following C struct:
279 ///
280 /// struct A {
281 /// A* next;
282 /// };
283 ///
284 /// would be represented in MLIR as:
285 ///
286 /// !spirv.struct<A, (!spirv.ptr<!spirv.struct<A>, Generic>)>
287 ///
288 /// In the above, expressing recursive struct types is accomplished by giving a
289 /// recursive struct a unique identified and using that identifier in the struct
290 /// definition for recursive references.
292  : public Type::TypeBase<StructType, CompositeType,
293  detail::StructTypeStorage, TypeTrait::IsMutable> {
294 public:
295  using Base::Base;
296 
297  // Type for specifying the offset of the struct members
298  using OffsetInfo = uint32_t;
299 
300  static constexpr StringLiteral name = "spirv.struct";
301 
302  // Type for specifying the decoration(s) on struct members
304  uint32_t memberIndex : 31;
305  uint32_t hasValue : 1;
306  Decoration decoration;
307  uint32_t decorationValue;
308 
309  MemberDecorationInfo(uint32_t index, uint32_t hasValue,
310  Decoration decoration, uint32_t decorationValue)
313 
314  bool operator==(const MemberDecorationInfo &other) const {
315  return (this->memberIndex == other.memberIndex) &&
316  (this->decoration == other.decoration) &&
317  (this->decorationValue == other.decorationValue);
318  }
319 
320  bool operator<(const MemberDecorationInfo &other) const {
321  return this->memberIndex < other.memberIndex ||
322  (this->memberIndex == other.memberIndex &&
323  static_cast<uint32_t>(this->decoration) <
324  static_cast<uint32_t>(other.decoration));
325  }
326  };
327 
328  /// Construct a literal StructType with at least one member.
329  static StructType get(ArrayRef<Type> memberTypes,
330  ArrayRef<OffsetInfo> offsetInfo = {},
331  ArrayRef<MemberDecorationInfo> memberDecorations = {});
332 
333  /// Construct an identified StructType. This creates a StructType whose body
334  /// (member types, offset info, and decorations) is not set yet. A call to
335  /// StructType::trySetBody(...) must follow when the StructType contents are
336  /// available (e.g. parsed or deserialized).
337  ///
338  /// Note: If another thread creates (or had already created) a struct with the
339  /// same identifier, that struct will be returned as a result.
340  static StructType getIdentified(MLIRContext *context, StringRef identifier);
341 
342  /// Construct a (possibly identified) StructType with no members.
343  ///
344  /// Note: this method might fail in a multi-threaded setup if another thread
345  /// created an identified struct with the same identifier but with different
346  /// contents before returning. In which case, an empty (default-constructed)
347  /// StructType is returned.
348  static StructType getEmpty(MLIRContext *context, StringRef identifier = "");
349 
350  /// For literal structs, return an empty string.
351  /// For identified structs, return the struct's identifier.
352  StringRef getIdentifier() const;
353 
354  /// Returns true if the StructType is identified.
355  bool isIdentified() const;
356 
357  unsigned getNumElements() const;
358 
359  Type getElementType(unsigned) const;
360 
361  TypeRange getElementTypes() const;
362 
363  bool hasOffset() const;
364 
365  uint64_t getMemberOffset(unsigned) const;
366 
367  // Returns in `memberDecorations` the Decorations (apart from Offset)
368  // associated with all members of the StructType.
369  void getMemberDecorations(SmallVectorImpl<StructType::MemberDecorationInfo>
370  &memberDecorations) const;
371 
372  // Returns in `decorationsInfo` all the Decorations (apart from Offset)
373  // associated with the `i`-th member of the StructType.
375  unsigned i,
376  SmallVectorImpl<StructType::MemberDecorationInfo> &decorationsInfo) const;
377 
378  /// Sets the contents of an incomplete identified StructType. This method must
379  /// be called only for identified StructTypes and it must be called only once
380  /// per instance. Otherwise, failure() is returned.
381  LogicalResult
382  trySetBody(ArrayRef<Type> memberTypes, ArrayRef<OffsetInfo> offsetInfo = {},
383  ArrayRef<MemberDecorationInfo> memberDecorations = {});
384 
386  std::optional<StorageClass> storage = std::nullopt);
388  std::optional<StorageClass> storage = std::nullopt);
389 };
390 
391 llvm::hash_code
392 hash_value(const StructType::MemberDecorationInfo &memberDecorationInfo);
393 
394 // SPIR-V KHR cooperative matrix type
396  : public Type::TypeBase<CooperativeMatrixType, CompositeType,
397  detail::CooperativeMatrixTypeStorage> {
398 public:
399  using Base::Base;
400 
401  static constexpr StringLiteral name = "spirv.coopmatrix";
402 
403  static CooperativeMatrixType get(Type elementType, uint32_t rows,
404  uint32_t columns, Scope scope,
405  CooperativeMatrixUseKHR use);
406  Type getElementType() const;
407 
408  /// Returns the scope of the matrix.
409  Scope getScope() const;
410  /// Returns the number of rows of the matrix.
411  uint32_t getRows() const;
412  /// Returns the number of columns of the matrix.
413  uint32_t getColumns() const;
414  /// Returns the use parameter of the cooperative matrix.
415  CooperativeMatrixUseKHR getUse() const;
416 
418  std::optional<StorageClass> storage = std::nullopt);
420  std::optional<StorageClass> storage = std::nullopt);
421 };
422 
423 // SPIR-V joint matrix type
425  : public Type::TypeBase<JointMatrixINTELType, CompositeType,
426  detail::JointMatrixTypeStorage> {
427 public:
428  using Base::Base;
429 
430  static constexpr StringLiteral name = "spirv.jointmatrix";
431 
432  static JointMatrixINTELType get(Type elementType, Scope scope, unsigned rows,
433  unsigned columns, MatrixLayout matrixLayout);
434  Type getElementType() const;
435 
436  /// Return the scope of the joint matrix.
437  Scope getScope() const;
438  /// return the number of rows of the matrix.
439  unsigned getRows() const;
440  /// return the number of columns of the matrix.
441  unsigned getColumns() const;
442 
443  /// return the layout of the matrix
444  MatrixLayout getMatrixLayout() const;
445 
447  std::optional<StorageClass> storage = std::nullopt);
449  std::optional<StorageClass> storage = std::nullopt);
450 };
451 
452 // SPIR-V matrix type
453 class MatrixType : public Type::TypeBase<MatrixType, CompositeType,
454  detail::MatrixTypeStorage> {
455 public:
456  using Base::Base;
457 
458  static constexpr StringLiteral name = "spirv.matrix";
459 
460  static MatrixType get(Type columnType, uint32_t columnCount);
461 
463  Type columnType, uint32_t columnCount);
464 
466  Type columnType, uint32_t columnCount);
467 
468  /// Returns true if the matrix elements are vectors of float elements.
469  static bool isValidColumnType(Type columnType);
470 
471  Type getColumnType() const;
472 
473  /// Returns the number of rows.
474  unsigned getNumRows() const;
475 
476  /// Returns the number of columns.
477  unsigned getNumColumns() const;
478 
479  /// Returns total number of elements (rows*columns).
480  unsigned getNumElements() const;
481 
482  /// Returns the elements' type (i.e, single element type).
483  Type getElementType() const;
484 
486  std::optional<StorageClass> storage = std::nullopt);
488  std::optional<StorageClass> storage = std::nullopt);
489 };
490 
491 } // namespace spirv
492 } // namespace mlir
493 
494 #endif // MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
This class represents a diagnostic that is inflight and set to be reported.
Definition: Diagnostics.h:308
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition: Types.h:74
constexpr Type()=default
Utility class for implementing users of storage classes uniqued by a StorageUniquer.
Type getElementType() const
Definition: SPIRVTypes.cpp:66
unsigned getArrayStride() const
Returns the array stride in bytes.
Definition: SPIRVTypes.cpp:68
unsigned getNumElements() const
Definition: SPIRVTypes.cpp:64
static ArrayType get(Type elementType, unsigned elementCount)
Definition: SPIRVTypes.cpp:52
std::optional< int64_t > getSizeInBytes()
Returns the array size in bytes.
Definition: SPIRVTypes.cpp:82
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:70
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:75
static constexpr StringLiteral name
Definition: SPIRVTypes.h:134
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:163
std::optional< int64_t > getSizeInBytes()
Definition: SPIRVTypes.cpp:183
bool hasCompileTimeKnownNumElements() const
Return true if the number of elements is known at compile time and is not implementation dependent.
Definition: SPIRVTypes.cpp:144
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:149
unsigned getNumElements() const
Return the number of elements of the type.
Definition: SPIRVTypes.cpp:120
static bool isValid(VectorType)
Returns true if the given vector type is valid for the SPIR-V dialect.
Definition: SPIRVTypes.cpp:102
Type getElementType(unsigned) const
Definition: SPIRVTypes.cpp:108
static bool classof(Type type)
Definition: SPIRVTypes.cpp:94
static constexpr StringLiteral name
Definition: SPIRVTypes.h:401
Scope getScope() const
Returns the scope of the matrix.
Definition: SPIRVTypes.cpp:246
uint32_t getRows() const
Returns the number of rows of the matrix.
Definition: SPIRVTypes.cpp:240
uint32_t getColumns() const
Returns the number of columns of the matrix.
Definition: SPIRVTypes.cpp:242
static CooperativeMatrixType get(Type elementType, uint32_t rows, uint32_t columns, Scope scope, CooperativeMatrixUseKHR use)
Definition: SPIRVTypes.cpp:228
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:252
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:260
CooperativeMatrixUseKHR getUse() const
Returns the use parameter of the cooperative matrix.
Definition: SPIRVTypes.cpp:248
static constexpr StringLiteral name
Definition: SPIRVTypes.h:166
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)
Definition: SPIRVTypes.h:169
ImageDepthInfo getDepthInfo() const
Definition: SPIRVTypes.cpp:424
ImageArrayedInfo getArrayedInfo() const
Definition: SPIRVTypes.cpp:426
ImageFormat getImageFormat() const
Definition: SPIRVTypes.cpp:438
ImageSamplerUseInfo getSamplerUseInfo() const
Definition: SPIRVTypes.cpp:434
Type getElementType() const
Definition: SPIRVTypes.cpp:420
ImageSamplingInfo getSamplingInfo() const
Definition: SPIRVTypes.cpp:430
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:445
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:440
Scope getScope() const
Return the scope of the joint matrix.
Definition: SPIRVTypes.cpp:309
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:328
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:319
unsigned getColumns() const
return the number of columns of the matrix.
Definition: SPIRVTypes.cpp:313
static JointMatrixINTELType get(Type elementType, Scope scope, unsigned rows, unsigned columns, MatrixLayout matrixLayout)
Definition: SPIRVTypes.cpp:298
unsigned getRows() const
return the number of rows of the matrix.
Definition: SPIRVTypes.cpp:311
static constexpr StringLiteral name
Definition: SPIRVTypes.h:430
MatrixLayout getMatrixLayout() const
return the layout of the matrix
Definition: SPIRVTypes.cpp:315
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)
static constexpr StringLiteral name
Definition: SPIRVTypes.h:458
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)
Definition: SPIRVTypes.cpp:491
Type getPointeeType() const
Definition: SPIRVTypes.cpp:485
static constexpr StringLiteral name
Definition: SPIRVTypes.h:207
StorageClass getStorageClass() const
Definition: SPIRVTypes.cpp:487
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:502
static PointerType get(Type pointeeType, StorageClass storageClass)
Definition: SPIRVTypes.cpp:481
static constexpr StringLiteral name
Definition: SPIRVTypes.h:228
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:556
unsigned getArrayStride() const
Returns the array stride in bytes.
Definition: SPIRVTypes.cpp:548
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:550
static RuntimeArrayType get(Type elementType)
Definition: SPIRVTypes.cpp:538
SmallVectorImpl< ArrayRef< Capability > > CapabilityArrayRefVector
The capability requirements for each type are following the ((Capability::A OR Extension::B) AND (Cap...
Definition: SPIRVTypes.h:65
std::optional< int64_t > getSizeInBytes()
Returns the size in bytes for each type.
Definition: SPIRVTypes.cpp:780
static bool classof(Type type)
Definition: SPIRVTypes.cpp:726
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.
Definition: SPIRVTypes.cpp:760
SmallVectorImpl< ArrayRef< Extension > > ExtensionArrayRefVector
The extension requirements for each type are following the ((Extension::A OR Extension::B) AND (Exten...
Definition: SPIRVTypes.h:54
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.
Definition: SPIRVTypes.cpp:741
static LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Type imageType)
Definition: SPIRVTypes.cpp:820
static constexpr StringLiteral name
Definition: SPIRVTypes.h:254
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< spirv::StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:834
static SampledImageType getChecked(function_ref< InFlightDiagnostic()> emitError, Type imageType)
Definition: SPIRVTypes.cpp:812
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< spirv::StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:828
static SampledImageType get(Type imageType)
Definition: SPIRVTypes.cpp:807
static bool classof(Type type)
Definition: SPIRVTypes.cpp:572
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:590
static bool isValid(FloatType)
Returns true if the given integer type is valid for the SPIR-V dialect.
Definition: SPIRVTypes.cpp:582
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:621
std::optional< int64_t > getSizeInBytes()
Definition: SPIRVTypes.cpp:709
SPIR-V struct type.
Definition: SPIRVTypes.h:293
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.
static constexpr StringLiteral name
Definition: SPIRVTypes.h:300
TypeRange 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)
Include the generated interface declarations.
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.
Definition: LogicalResult.h:26
bool operator==(const MemberDecorationInfo &other) const
Definition: SPIRVTypes.h:314
MemberDecorationInfo(uint32_t index, uint32_t hasValue, Decoration decoration, uint32_t decorationValue)
Definition: SPIRVTypes.h:309
bool operator<(const MemberDecorationInfo &other) const
Definition: SPIRVTypes.h:320