MLIR  17.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 <tuple>
24 
25 namespace mlir {
26 namespace spirv {
27 
28 namespace detail {
29 struct ArrayTypeStorage;
30 struct CooperativeMatrixTypeStorage;
31 struct ImageTypeStorage;
32 struct JointMatrixTypeStorage;
33 struct MatrixTypeStorage;
34 struct PointerTypeStorage;
35 struct RuntimeArrayTypeStorage;
36 struct SampledImageTypeStorage;
37 struct StructTypeStorage;
38 
39 } // namespace detail
40 
41 // Base SPIR-V type for providing availability queries.
42 class SPIRVType : public Type {
43 public:
44  using Type::Type;
45 
46  static bool classof(Type type);
47 
48  bool isScalarOrVector();
49 
50  /// The extension requirements for each type are following the
51  /// ((Extension::A OR Extension::B) AND (Extension::C OR Extension::D))
52  /// convention.
54 
55  /// Appends to `extensions` the extensions needed for this type to appear in
56  /// the given `storage` class. This method does not guarantee the uniqueness
57  /// of extensions; the same extension may be appended multiple times.
58  void getExtensions(ExtensionArrayRefVector &extensions,
59  std::optional<StorageClass> storage = std::nullopt);
60 
61  /// The capability requirements for each type are following the
62  /// ((Capability::A OR Extension::B) AND (Capability::C OR Capability::D))
63  /// convention.
65 
66  /// Appends to `capabilities` the capabilities needed for this type to appear
67  /// in the given `storage` class. This method does not guarantee the
68  /// uniqueness of capabilities; the same capability may be appended multiple
69  /// times.
70  void getCapabilities(CapabilityArrayRefVector &capabilities,
71  std::optional<StorageClass> storage = std::nullopt);
72 
73  /// Returns the size in bytes for each type. If no size can be calculated,
74  /// returns `std::nullopt`. Note that if the type has explicit layout, it is
75  /// also taken into account in calculation.
76  std::optional<int64_t> getSizeInBytes();
77 };
78 
79 // SPIR-V scalar type: bool type, integer type, floating point type.
80 class ScalarType : public SPIRVType {
81 public:
82  using SPIRVType::SPIRVType;
83 
84  static bool classof(Type type);
85 
86  /// Returns true if the given integer type is valid for the SPIR-V dialect.
87  static bool isValid(FloatType);
88  /// Returns true if the given float type is valid for the SPIR-V dialect.
89  static bool isValid(IntegerType);
90 
92  std::optional<StorageClass> storage = std::nullopt);
94  std::optional<StorageClass> storage = std::nullopt);
95 
96  std::optional<int64_t> getSizeInBytes();
97 };
98 
99 // SPIR-V composite type: VectorType, SPIR-V ArrayType, or SPIR-V StructType.
100 class CompositeType : public SPIRVType {
101 public:
102  using SPIRVType::SPIRVType;
103 
104  static bool classof(Type type);
105 
106  /// Returns true if the given vector type is valid for the SPIR-V dialect.
107  static bool isValid(VectorType);
108 
109  /// Return the number of elements of the type. This should only be called if
110  /// hasCompileTimeKnownNumElements is true.
111  unsigned getNumElements() const;
112 
113  Type getElementType(unsigned) const;
114 
115  /// Return true if the number of elements is known at compile time and is not
116  /// implementation dependent.
117  bool hasCompileTimeKnownNumElements() const;
118 
120  std::optional<StorageClass> storage = std::nullopt);
122  std::optional<StorageClass> storage = std::nullopt);
123 
124  std::optional<int64_t> getSizeInBytes();
125 };
126 
127 // SPIR-V array type
128 class ArrayType : public Type::TypeBase<ArrayType, CompositeType,
129  detail::ArrayTypeStorage> {
130 public:
131  using Base::Base;
132 
133  static ArrayType get(Type elementType, unsigned elementCount);
134 
135  /// Returns an array type with the given stride in bytes.
136  static ArrayType get(Type elementType, unsigned elementCount,
137  unsigned stride);
138 
139  unsigned getNumElements() const;
140 
141  Type getElementType() const;
142 
143  /// Returns the array stride in bytes. 0 means no stride decorated on this
144  /// type.
145  unsigned getArrayStride() const;
146 
148  std::optional<StorageClass> storage = std::nullopt);
150  std::optional<StorageClass> storage = std::nullopt);
151 
152  /// Returns the array size in bytes. Since array type may have an explicit
153  /// stride declaration (in bytes), we also include it in the calculation.
154  std::optional<int64_t> getSizeInBytes();
155 };
156 
157 // SPIR-V image type
159  : public Type::TypeBase<ImageType, SPIRVType, detail::ImageTypeStorage> {
160 public:
161  using Base::Base;
162 
163  static ImageType
164  get(Type elementType, Dim dim,
165  ImageDepthInfo depth = ImageDepthInfo::DepthUnknown,
166  ImageArrayedInfo arrayed = ImageArrayedInfo::NonArrayed,
167  ImageSamplingInfo samplingInfo = ImageSamplingInfo::SingleSampled,
168  ImageSamplerUseInfo samplerUse = ImageSamplerUseInfo::SamplerUnknown,
169  ImageFormat format = ImageFormat::Unknown) {
170  return ImageType::get(
171  std::tuple<Type, Dim, ImageDepthInfo, ImageArrayedInfo,
172  ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat>(
173  elementType, dim, depth, arrayed, samplingInfo, samplerUse,
174  format));
175  }
176 
177  static ImageType
178  get(std::tuple<Type, Dim, ImageDepthInfo, ImageArrayedInfo,
179  ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat>);
180 
181  Type getElementType() const;
182  Dim getDim() const;
183  ImageDepthInfo getDepthInfo() const;
184  ImageArrayedInfo getArrayedInfo() const;
185  ImageSamplingInfo getSamplingInfo() const;
186  ImageSamplerUseInfo getSamplerUseInfo() const;
187  ImageFormat getImageFormat() const;
188  // TODO: Add support for Access qualifier
189 
191  std::optional<StorageClass> storage = std::nullopt);
193  std::optional<StorageClass> storage = std::nullopt);
194 };
195 
196 // SPIR-V pointer type
197 class PointerType : public Type::TypeBase<PointerType, SPIRVType,
198  detail::PointerTypeStorage> {
199 public:
200  using Base::Base;
201 
202  static PointerType get(Type pointeeType, StorageClass storageClass);
203 
204  Type getPointeeType() const;
205 
206  StorageClass getStorageClass() const;
207 
209  std::optional<StorageClass> storage = std::nullopt);
211  std::optional<StorageClass> storage = std::nullopt);
212 };
213 
214 // SPIR-V run-time array type
216  : public Type::TypeBase<RuntimeArrayType, SPIRVType,
217  detail::RuntimeArrayTypeStorage> {
218 public:
219  using Base::Base;
220 
221  static RuntimeArrayType get(Type elementType);
222 
223  /// Returns a runtime array type with the given stride in bytes.
224  static RuntimeArrayType get(Type elementType, unsigned stride);
225 
226  Type getElementType() const;
227 
228  /// Returns the array stride in bytes. 0 means no stride decorated on this
229  /// type.
230  unsigned getArrayStride() const;
231 
233  std::optional<StorageClass> storage = std::nullopt);
235  std::optional<StorageClass> storage = std::nullopt);
236 };
237 
238 // SPIR-V sampled image type
240  : public Type::TypeBase<SampledImageType, SPIRVType,
241  detail::SampledImageTypeStorage> {
242 public:
243  using Base::Base;
244 
245  static SampledImageType get(Type imageType);
246 
247  static SampledImageType
249 
251  Type imageType);
252 
253  Type getImageType() const;
254 
256  std::optional<spirv::StorageClass> storage = std::nullopt);
257  void
259  std::optional<spirv::StorageClass> storage = std::nullopt);
260 };
261 
262 /// SPIR-V struct type. Two kinds of struct types are supported:
263 /// - Literal: a literal struct type is uniqued by its fields (types + offset
264 /// info + decoration info).
265 /// - Identified: an indentified struct type is uniqued by its string identifier
266 /// (name). This is useful in representing recursive structs. For example, the
267 /// following C struct:
268 ///
269 /// struct A {
270 /// A* next;
271 /// };
272 ///
273 /// would be represented in MLIR as:
274 ///
275 /// !spirv.struct<A, (!spirv.ptr<!spirv.struct<A>, Generic>)>
276 ///
277 /// In the above, expressing recursive struct types is accomplished by giving a
278 /// recursive struct a unique identified and using that identifier in the struct
279 /// definition for recursive references.
281  : public Type::TypeBase<StructType, CompositeType,
282  detail::StructTypeStorage, TypeTrait::IsMutable> {
283 public:
284  using Base::Base;
285 
286  // Type for specifying the offset of the struct members
287  using OffsetInfo = uint32_t;
288 
289  // Type for specifying the decoration(s) on struct members
291  uint32_t memberIndex : 31;
292  uint32_t hasValue : 1;
293  Decoration decoration;
294  uint32_t decorationValue;
295 
296  MemberDecorationInfo(uint32_t index, uint32_t hasValue,
297  Decoration decoration, uint32_t decorationValue)
300 
301  bool operator==(const MemberDecorationInfo &other) const {
302  return (this->memberIndex == other.memberIndex) &&
303  (this->decoration == other.decoration) &&
304  (this->decorationValue == other.decorationValue);
305  }
306 
307  bool operator<(const MemberDecorationInfo &other) const {
308  return this->memberIndex < other.memberIndex ||
309  (this->memberIndex == other.memberIndex &&
310  static_cast<uint32_t>(this->decoration) <
311  static_cast<uint32_t>(other.decoration));
312  }
313  };
314 
315  /// Construct a literal StructType with at least one member.
316  static StructType get(ArrayRef<Type> memberTypes,
317  ArrayRef<OffsetInfo> offsetInfo = {},
318  ArrayRef<MemberDecorationInfo> memberDecorations = {});
319 
320  /// Construct an identified StructType. This creates a StructType whose body
321  /// (member types, offset info, and decorations) is not set yet. A call to
322  /// StructType::trySetBody(...) must follow when the StructType contents are
323  /// available (e.g. parsed or deserialized).
324  ///
325  /// Note: If another thread creates (or had already created) a struct with the
326  /// same identifier, that struct will be returned as a result.
327  static StructType getIdentified(MLIRContext *context, StringRef identifier);
328 
329  /// Construct a (possibly identified) StructType with no members.
330  ///
331  /// Note: this method might fail in a multi-threaded setup if another thread
332  /// created an identified struct with the same identifier but with different
333  /// contents before returning. In which case, an empty (default-constructed)
334  /// StructType is returned.
335  static StructType getEmpty(MLIRContext *context, StringRef identifier = "");
336 
337  /// For literal structs, return an empty string.
338  /// For identified structs, return the struct's identifier.
339  StringRef getIdentifier() const;
340 
341  /// Returns true if the StructType is identified.
342  bool isIdentified() const;
343 
344  unsigned getNumElements() const;
345 
346  Type getElementType(unsigned) const;
347 
348  /// Range class for element types.
351  ElementTypeRange, const Type *, Type, Type, Type> {
352  private:
353  using RangeBaseT::RangeBaseT;
354 
355  /// See `llvm::detail::indexed_accessor_range_base` for details.
356  static const Type *offset_base(const Type *object, ptrdiff_t index) {
357  return object + index;
358  }
359  /// See `llvm::detail::indexed_accessor_range_base` for details.
360  static Type dereference_iterator(const Type *object, ptrdiff_t index) {
361  return object[index];
362  }
363 
364  /// Allow base class access to `offset_base` and `dereference_iterator`.
365  friend RangeBaseT;
366  };
367 
369 
370  bool hasOffset() const;
371 
372  uint64_t getMemberOffset(unsigned) const;
373 
374  // Returns in `memberDecorations` the Decorations (apart from Offset)
375  // associated with all members of the StructType.
377  &memberDecorations) const;
378 
379  // Returns in `decorationsInfo` all the Decorations (apart from Offset)
380  // associated with the `i`-th member of the StructType.
382  unsigned i,
384 
385  /// Sets the contents of an incomplete identified StructType. This method must
386  /// be called only for identified StructTypes and it must be called only once
387  /// per instance. Otherwise, failure() is returned.
389  trySetBody(ArrayRef<Type> memberTypes, ArrayRef<OffsetInfo> offsetInfo = {},
390  ArrayRef<MemberDecorationInfo> memberDecorations = {});
391 
393  std::optional<StorageClass> storage = std::nullopt);
395  std::optional<StorageClass> storage = std::nullopt);
396 };
397 
398 llvm::hash_code
399 hash_value(const StructType::MemberDecorationInfo &memberDecorationInfo);
400 
401 // SPIR-V cooperative matrix type
403  : public Type::TypeBase<CooperativeMatrixNVType, CompositeType,
404  detail::CooperativeMatrixTypeStorage> {
405 public:
406  using Base::Base;
407 
408  static CooperativeMatrixNVType get(Type elementType, Scope scope,
409  unsigned rows, unsigned columns);
410  Type getElementType() const;
411 
412  /// Return the scope of the cooperative matrix.
413  Scope getScope() const;
414  /// return the number of rows of the matrix.
415  unsigned getRows() const;
416  /// return the number of columns of the matrix.
417  unsigned getColumns() const;
418 
420  std::optional<StorageClass> storage = std::nullopt);
422  std::optional<StorageClass> storage = std::nullopt);
423 };
424 
425 // SPIR-V joint matrix type
427  : public Type::TypeBase<JointMatrixINTELType, CompositeType,
428  detail::JointMatrixTypeStorage> {
429 public:
430  using Base::Base;
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 MatrixType get(Type columnType, uint32_t columnCount);
459 
461  Type columnType, uint32_t columnCount);
462 
464  Type columnType, uint32_t columnCount);
465 
466  /// Returns true if the matrix elements are vectors of float elements.
467  static bool isValidColumnType(Type columnType);
468 
469  Type getColumnType() const;
470 
471  /// Returns the number of rows.
472  unsigned getNumRows() const;
473 
474  /// Returns the number of columns.
475  unsigned getNumColumns() const;
476 
477  /// Returns total number of elements (rows*columns).
478  unsigned getNumElements() const;
479 
480  /// Returns the elements' type (i.e, single element type).
481  Type getElementType() const;
482 
484  std::optional<StorageClass> storage = std::nullopt);
486  std::optional<StorageClass> storage = std::nullopt);
487 };
488 
489 } // namespace spirv
490 } // namespace mlir
491 
492 #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:64
unsigned getArrayStride() const
Returns the array stride in bytes.
Definition: SPIRVTypes.cpp:66
unsigned getNumElements() const
Definition: SPIRVTypes.cpp:62
static ArrayType get(Type elementType, unsigned elementCount)
Definition: SPIRVTypes.cpp:50
std::optional< int64_t > getSizeInBytes()
Returns the array size in bytes.
Definition: SPIRVTypes.cpp:79
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:68
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:73
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:168
std::optional< int64_t > getSizeInBytes()
Definition: SPIRVTypes.cpp:188
bool hasCompileTimeKnownNumElements() const
Return true if the number of elements is known at compile time and is not implementation dependent.
Definition: SPIRVTypes.cpp:149
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:154
unsigned getNumElements() const
Return the number of elements of the type.
Definition: SPIRVTypes.cpp:125
static bool isValid(VectorType)
Returns true if the given vector type is valid for the SPIR-V dialect.
Definition: SPIRVTypes.cpp:99
Type getElementType(unsigned) const
Definition: SPIRVTypes.cpp:113
static bool classof(Type type)
Definition: SPIRVTypes.cpp:91
unsigned getRows() const
return the number of rows of the matrix.
Definition: SPIRVTypes.cpp:242
unsigned getColumns() const
return the number of columns of the matrix.
Definition: SPIRVTypes.cpp:244
static CooperativeMatrixNVType get(Type elementType, Scope scope, unsigned rows, unsigned columns)
Definition: SPIRVTypes.cpp:230
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:257
Scope getScope() const
Return the scope of the cooperative matrix.
Definition: SPIRVTypes.cpp:240
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:248
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:164
ImageDepthInfo getDepthInfo() const
Definition: SPIRVTypes.cpp:420
ImageArrayedInfo getArrayedInfo() const
Definition: SPIRVTypes.cpp:422
ImageFormat getImageFormat() const
Definition: SPIRVTypes.cpp:434
ImageSamplerUseInfo getSamplerUseInfo() const
Definition: SPIRVTypes.cpp:430
Type getElementType() const
Definition: SPIRVTypes.cpp:416
ImageSamplingInfo getSamplingInfo() const
Definition: SPIRVTypes.cpp:426
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:441
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:436
Scope getScope() const
Return the scope of the joint matrix.
Definition: SPIRVTypes.cpp:306
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:325
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:316
unsigned getColumns() const
return the number of columns of the matrix.
Definition: SPIRVTypes.cpp:310
static JointMatrixINTELType get(Type elementType, Scope scope, unsigned rows, unsigned columns, MatrixLayout matrixLayout)
Definition: SPIRVTypes.cpp:295
unsigned getRows() const
return the number of rows of the matrix.
Definition: SPIRVTypes.cpp:308
MatrixLayout getMatrixLayout() const
return the layout of the matrix
Definition: SPIRVTypes.cpp:312
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)
Definition: SPIRVTypes.cpp:487
Type getPointeeType() const
Definition: SPIRVTypes.cpp:481
StorageClass getStorageClass() const
Definition: SPIRVTypes.cpp:483
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:498
static PointerType get(Type pointeeType, StorageClass storageClass)
Definition: SPIRVTypes.cpp:477
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:552
unsigned getArrayStride() const
Returns the array stride in bytes.
Definition: SPIRVTypes.cpp:544
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:546
static RuntimeArrayType get(Type elementType)
Definition: SPIRVTypes.cpp:534
SmallVectorImpl< ArrayRef< Capability > > CapabilityArrayRefVector
The capability requirements for each type are following the ((Capability::A OR Extension::B) AND (Cap...
Definition: SPIRVTypes.h:64
std::optional< int64_t > getSizeInBytes()
Returns the size in bytes for each type.
Definition: SPIRVTypes.cpp:782
static bool classof(Type type)
Definition: SPIRVTypes.cpp:728
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:762
SmallVectorImpl< ArrayRef< Extension > > ExtensionArrayRefVector
The extension requirements for each type are following the ((Extension::A OR Extension::B) AND (Exten...
Definition: SPIRVTypes.h:53
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:743
static LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Type imageType)
Definition: SPIRVTypes.cpp:822
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< spirv::StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:836
static SampledImageType getChecked(function_ref< InFlightDiagnostic()> emitError, Type imageType)
Definition: SPIRVTypes.cpp:814
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< spirv::StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:830
static SampledImageType get(Type imageType)
Definition: SPIRVTypes.cpp:809
static bool classof(Type type)
Definition: SPIRVTypes.cpp:567
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:592
static bool isValid(FloatType)
Returns true if the given integer type is valid for the SPIR-V dialect.
Definition: SPIRVTypes.cpp:577
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, std::optional< StorageClass > storage=std::nullopt)
Definition: SPIRVTypes.cpp:623
std::optional< int64_t > getSizeInBytes()
Definition: SPIRVTypes.cpp:711
Range class for element types.
Definition: SPIRVTypes.h:351
SPIR-V struct type.
Definition: SPIRVTypes.h:282
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)
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:301
MemberDecorationInfo(uint32_t index, uint32_t hasValue, Decoration decoration, uint32_t decorationValue)
Definition: SPIRVTypes.h:296
bool operator<(const MemberDecorationInfo &other) const
Definition: SPIRVTypes.h:307