@@ -330,10 +330,34 @@ class StructType
330
330
bool hasValue () const { return !isa<UnitAttr>(decorationValue); }
331
331
};
332
332
333
+ // Type for specifying the decoration(s) on the struct itself.
334
+ struct StructDecorationInfo {
335
+ Decoration decoration;
336
+ Attribute decorationValue;
337
+
338
+ StructDecorationInfo (Decoration decoration, Attribute decorationValue)
339
+ : decoration(decoration), decorationValue(decorationValue) {}
340
+
341
+ friend bool operator ==(const StructDecorationInfo &lhs,
342
+ const StructDecorationInfo &rhs) {
343
+ return lhs.decoration == rhs.decoration &&
344
+ lhs.decorationValue == rhs.decorationValue ;
345
+ }
346
+
347
+ friend bool operator <(const StructDecorationInfo &lhs,
348
+ const StructDecorationInfo &rhs) {
349
+ return llvm::to_underlying (lhs.decoration ) <
350
+ llvm::to_underlying (rhs.decoration );
351
+ }
352
+
353
+ bool hasValue () const { return !isa<UnitAttr>(decorationValue); }
354
+ };
355
+
333
356
// / Construct a literal StructType with at least one member.
334
357
static StructType get (ArrayRef<Type> memberTypes,
335
358
ArrayRef<OffsetInfo> offsetInfo = {},
336
- ArrayRef<MemberDecorationInfo> memberDecorations = {});
359
+ ArrayRef<MemberDecorationInfo> memberDecorations = {},
360
+ ArrayRef<StructDecorationInfo> structDecorations = {});
337
361
338
362
// / Construct an identified StructType. This creates a StructType whose body
339
363
// / (member types, offset info, and decorations) is not set yet. A call to
@@ -367,6 +391,9 @@ class StructType
367
391
368
392
bool hasOffset () const ;
369
393
394
+ // / Returns true if the struct has a specified decoration.
395
+ bool hasDecoration (spirv::Decoration decoration) const ;
396
+
370
397
uint64_t getMemberOffset (unsigned ) const ;
371
398
372
399
// Returns in `memberDecorations` the Decorations (apart from Offset)
@@ -380,12 +407,18 @@ class StructType
380
407
unsigned i,
381
408
SmallVectorImpl<StructType::MemberDecorationInfo> &decorationsInfo) const ;
382
409
410
+ // Returns in `structDecorations` the Decorations associated with the
411
+ // StructType.
412
+ void getStructDecorations (SmallVectorImpl<StructType::StructDecorationInfo>
413
+ &structDecorations) const ;
414
+
383
415
// / Sets the contents of an incomplete identified StructType. This method must
384
416
// / be called only for identified StructTypes and it must be called only once
385
417
// / per instance. Otherwise, failure() is returned.
386
418
LogicalResult
387
419
trySetBody (ArrayRef<Type> memberTypes, ArrayRef<OffsetInfo> offsetInfo = {},
388
- ArrayRef<MemberDecorationInfo> memberDecorations = {});
420
+ ArrayRef<MemberDecorationInfo> memberDecorations = {},
421
+ ArrayRef<StructDecorationInfo> structDecorations = {});
389
422
390
423
void getExtensions (SPIRVType::ExtensionArrayRefVector &extensions,
391
424
std::optional<StorageClass> storage = std::nullopt);
@@ -396,6 +429,9 @@ class StructType
396
429
llvm::hash_code
397
430
hash_value (const StructType::MemberDecorationInfo &memberDecorationInfo);
398
431
432
+ llvm::hash_code
433
+ hash_value (const StructType::StructDecorationInfo &structDecorationInfo);
434
+
399
435
// SPIR-V KHR cooperative matrix type
400
436
class CooperativeMatrixType
401
437
: public Type::TypeBase<CooperativeMatrixType, CompositeType,
0 commit comments