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