@@ -315,41 +315,37 @@ static std::string getStageMaskString(ArrayRef<const Record *> Recs) {
315
315
// by input records
316
316
//
317
317
// / \param Recs A vector of records of TableGen Attribute records
318
- // / \return std::string string representation of stages mask string
318
+ // / \return std::string string representation of attributes list string
319
319
// / predicated by DXIL Version. E.g.,
320
- // {{{1, 0}, Mask1} , {{1, 2}, Mask2 }, ...}
321
- static std::string getAttributeMaskString (ArrayRef<const Record *> Recs) {
322
- std::string MaskString = " " ;
320
+ // {{{1, 0}, {Attr1, ...}} , {{1, 2}, {Attr2, ...} }, ...}
321
+ static std::string getAttributeListString (ArrayRef<const Record *> Recs) {
322
+ std::string ListString = " " ;
323
323
std::string Prefix = " " ;
324
- MaskString .append (" {" );
324
+ ListString .append (" {" );
325
325
326
326
for (const auto *Rec : Recs) {
327
327
unsigned Major = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Major" );
328
328
unsigned Minor = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Minor" );
329
- MaskString .append (Prefix)
329
+ ListString .append (Prefix)
330
330
.append (" {{" )
331
331
.append (std::to_string (Major))
332
332
.append (" , " )
333
- .append (std::to_string (Minor).append (" }, " ));
334
-
335
- std::string PipePrefix = " " ;
336
- auto Attrs = Rec->getValueAsListOfDefs (" op_attrs" );
337
- if (Attrs.empty ()) {
338
- MaskString.append (" Attribute::None" );
339
- } else {
340
- for (const auto *Attr : Attrs) {
341
- MaskString.append (PipePrefix)
342
- .append (" Attribute::" )
343
- .append (Attr->getName ());
344
- PipePrefix = " | " ;
345
- }
333
+ .append (std::to_string (Minor).append (" }, {" ));
334
+
335
+ std::string CommaPrefix = " " ;
336
+ auto Attrs = Rec->getValueAsListOfDefs (" fn_attrs" );
337
+ for (const auto *Attr : Attrs) {
338
+ ListString.append (CommaPrefix)
339
+ .append (" dxil::Attribute::" )
340
+ .append (Attr->getName ());
341
+ CommaPrefix = " , " ;
346
342
}
347
-
348
- MaskString .append (" }" );
343
+ ListString. append ( " } " ); // End of Attrs
344
+ ListString .append (" }" ); // End of Rec
349
345
Prefix = " , " ;
350
346
}
351
- MaskString .append (" }" );
352
- return MaskString ;
347
+ ListString .append (" }" ); // End of List
348
+ return ListString ;
353
349
}
354
350
355
351
// / Emit a mapping of DXIL opcode to opname
@@ -381,6 +377,15 @@ static void emitDXILOpParamTypes(const RecordKeeper &Records, raw_ostream &OS) {
381
377
OS << " #endif\n\n " ;
382
378
}
383
379
380
+ // / Emit a list of DXIL op function attributes
381
+ static void emitDXILAttributes (const RecordKeeper &Records, raw_ostream &OS) {
382
+ OS << " #ifdef DXIL_ATTRIBUTE\n " ;
383
+ for (const Record *Attr : Records.getAllDerivedDefinitions (" DXILAttribute" ))
384
+ OS << " DXIL_ATTRIBUTE(" << Attr->getName () << " )\n " ;
385
+ OS << " #undef DXIL_ATTRIBUTE\n " ;
386
+ OS << " #endif\n\n " ;
387
+ }
388
+
384
389
// / Emit a list of DXIL op function types
385
390
static void emitDXILOpFunctionTypes (ArrayRef<DXILOperationDesc> Ops,
386
391
raw_ostream &OS) {
@@ -477,7 +482,7 @@ static void emitDXILOperationTable(ArrayRef<DXILOperationDesc> Ops,
477
482
<< OpClassStrings.get (Op.OpClass .data ()) << " , "
478
483
<< getOverloadMaskString (Op.OverloadRecs ) << " , "
479
484
<< getStageMaskString (Op.StageRecs ) << " , "
480
- << getAttributeMaskString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
485
+ << getAttributeListString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
481
486
<< " }" ;
482
487
Prefix = " ,\n " ;
483
488
}
@@ -582,6 +587,7 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
582
587
emitDXILOpCodes (DXILOps, OS);
583
588
emitDXILOpClasses (Records, OS);
584
589
emitDXILOpParamTypes (Records, OS);
590
+ emitDXILAttributes (Records, OS);
585
591
emitDXILOpFunctionTypes (DXILOps, OS);
586
592
emitDXILIntrinsicArgSelectTypes (Records, OS);
587
593
emitDXILIntrinsicMap (DXILOps, OS);
0 commit comments