@@ -285,41 +285,37 @@ static std::string getStageMaskString(ArrayRef<const Record *> Recs) {
285
285
// by input records
286
286
//
287
287
// / \param Recs A vector of records of TableGen Attribute records
288
- // / \return std::string string representation of stages mask string
288
+ // / \return std::string string representation of attributes list string
289
289
// / predicated by DXIL Version. E.g.,
290
- // {{{1, 0}, Mask1} , {{1, 2}, Mask2 }, ...}
291
- static std::string getAttributeMaskString (ArrayRef<const Record *> Recs) {
292
- std::string MaskString = " " ;
290
+ // {{{1, 0}, {Attr1, ...}} , {{1, 2}, {Attr2, ...} }, ...}
291
+ static std::string getAttributeListString (ArrayRef<const Record *> Recs) {
292
+ std::string ListString = " " ;
293
293
std::string Prefix = " " ;
294
- MaskString .append (" {" );
294
+ ListString .append (" {" );
295
295
296
296
for (const auto *Rec : Recs) {
297
297
unsigned Major = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Major" );
298
298
unsigned Minor = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Minor" );
299
- MaskString .append (Prefix)
299
+ ListString .append (Prefix)
300
300
.append (" {{" )
301
301
.append (std::to_string (Major))
302
302
.append (" , " )
303
- .append (std::to_string (Minor).append (" }, " ));
304
-
305
- std::string PipePrefix = " " ;
306
- auto Attrs = Rec->getValueAsListOfDefs (" op_attrs" );
307
- if (Attrs.empty ()) {
308
- MaskString.append (" Attribute::None" );
309
- } else {
310
- for (const auto *Attr : Attrs) {
311
- MaskString.append (PipePrefix)
312
- .append (" Attribute::" )
313
- .append (Attr->getName ());
314
- PipePrefix = " | " ;
315
- }
303
+ .append (std::to_string (Minor).append (" }, {" ));
304
+
305
+ std::string CommaPrefix = " " ;
306
+ auto Attrs = Rec->getValueAsListOfDefs (" fn_attrs" );
307
+ for (const auto *Attr : Attrs) {
308
+ ListString.append (CommaPrefix)
309
+ .append (" dxil::Attribute::" )
310
+ .append (Attr->getName ());
311
+ CommaPrefix = " , " ;
316
312
}
317
-
318
- MaskString .append (" }" );
313
+ ListString. append ( " } " ); // End of Attrs
314
+ ListString .append (" }" ); // End of Rec
319
315
Prefix = " , " ;
320
316
}
321
- MaskString .append (" }" );
322
- return MaskString ;
317
+ ListString .append (" }" ); // End of List
318
+ return ListString ;
323
319
}
324
320
325
321
// / Emit a mapping of DXIL opcode to opname
@@ -351,6 +347,15 @@ static void emitDXILOpParamTypes(const RecordKeeper &Records, raw_ostream &OS) {
351
347
OS << " #endif\n\n " ;
352
348
}
353
349
350
+ // / Emit a list of DXIL op function attributes
351
+ static void emitDXILAttributes (const RecordKeeper &Records, raw_ostream &OS) {
352
+ OS << " #ifdef DXIL_ATTRIBUTE\n " ;
353
+ for (const Record *Attr : Records.getAllDerivedDefinitions (" DXILAttribute" ))
354
+ OS << " DXIL_ATTRIBUTE(" << Attr->getName () << " )\n " ;
355
+ OS << " #undef DXIL_ATTRIBUTE\n " ;
356
+ OS << " #endif\n\n " ;
357
+ }
358
+
354
359
// / Emit a list of DXIL op function types
355
360
static void emitDXILOpFunctionTypes (ArrayRef<DXILOperationDesc> Ops,
356
361
raw_ostream &OS) {
@@ -421,7 +426,7 @@ static void emitDXILOperationTable(ArrayRef<DXILOperationDesc> Ops,
421
426
<< OpClassStrings.get (Op.OpClass .data ()) << " , "
422
427
<< getOverloadMaskString (Op.OverloadRecs ) << " , "
423
428
<< getStageMaskString (Op.StageRecs ) << " , "
424
- << getAttributeMaskString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
429
+ << getAttributeListString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
425
430
<< " }" ;
426
431
Prefix = " ,\n " ;
427
432
}
@@ -526,6 +531,7 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
526
531
emitDXILOpCodes (DXILOps, OS);
527
532
emitDXILOpClasses (Records, OS);
528
533
emitDXILOpParamTypes (Records, OS);
534
+ emitDXILAttributes (Records, OS);
529
535
emitDXILOpFunctionTypes (DXILOps, OS);
530
536
emitDXILIntrinsicMap (DXILOps, OS);
531
537
OS << " #ifdef DXIL_OP_OPERATION_TABLE\n\n " ;
0 commit comments