@@ -319,43 +319,6 @@ static std::string getStageMaskString(ArrayRef<const Record *> Recs) {
319
319
return MaskString;
320
320
}
321
321
322
- // / Return a string representation of valid attribute information denoted
323
- // by input records
324
- //
325
- // / \param Recs A vector of records of TableGen Attribute records
326
- // / \return std::string string representation of attributes list string
327
- // / predicated by DXIL Version. E.g.,
328
- // {{{1, 0}, {Attr1, ...}}, {{1, 2}, {Attr2, ...}}, ...}
329
- static std::string getAttributeListString (ArrayRef<const Record *> Recs) {
330
- std::string ListString = " " ;
331
- std::string Prefix = " " ;
332
- ListString.append (" {" );
333
-
334
- for (const auto *Rec : Recs) {
335
- unsigned Major = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Major" );
336
- unsigned Minor = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Minor" );
337
- ListString.append (Prefix)
338
- .append (" {{" )
339
- .append (std::to_string (Major))
340
- .append (" , " )
341
- .append (std::to_string (Minor).append (" }, {" ));
342
-
343
- std::string CommaPrefix = " " ;
344
- auto Attrs = Rec->getValueAsListOfDefs (" fn_attrs" );
345
- for (const auto *Attr : Attrs) {
346
- ListString.append (CommaPrefix)
347
- .append (" dxil::Attribute::" )
348
- .append (Attr->getName ());
349
- CommaPrefix = " , " ;
350
- }
351
- ListString.append (" }" ); // End of Attrs
352
- ListString.append (" }" ); // End of Rec
353
- Prefix = " , " ;
354
- }
355
- ListString.append (" }" ); // End of List
356
- return ListString;
357
- }
358
-
359
322
// / Return a string representation of valid property information denoted
360
323
// by input records
361
324
//
@@ -378,6 +341,20 @@ static std::string getPropertyListString(ArrayRef<const Record *> Recs) {
378
341
return ListString;
379
342
}
380
343
344
+ // / Emit a list valid DXIL Version records
345
+ static void emitDXILVersions (const RecordKeeper &Records, raw_ostream &OS) {
346
+ OS << " #ifdef DXIL_VERSION\n " ;
347
+ for (const Record *Version : Records.getAllDerivedDefinitions (" Version" )) {
348
+ unsigned Major = Version->getValueAsInt (" Major" );
349
+ unsigned Minor = Version->getValueAsInt (" Minor" );
350
+ OS << " DXIL_VERSION(" ;
351
+ OS << std::to_string (Major) << " , " << std::to_string (Minor);
352
+ OS << " )\n " ;
353
+ }
354
+ OS << " #undef DXIL_VERSION\n " ;
355
+ OS << " #endif\n\n " ;
356
+ }
357
+
381
358
// / Emit a mapping of DXIL opcode to opname
382
359
static void emitDXILOpCodes (ArrayRef<DXILOperationDesc> Ops, raw_ostream &OS) {
383
360
OS << " #ifdef DXIL_OPCODE\n " ;
@@ -416,6 +393,40 @@ static void emitDXILAttributes(const RecordKeeper &Records, raw_ostream &OS) {
416
393
OS << " #endif\n\n " ;
417
394
}
418
395
396
+ // Determine which function attributes are set for a dxil version
397
+ static bool attrIsDefined (std::vector<const Record *> Attrs, const Record *Attr) {
398
+ for (auto CurAttr : Attrs)
399
+ if (CurAttr->getName () == Attr->getName ())
400
+ return true ;
401
+ return false ;
402
+ }
403
+
404
+ // / Emit a table of bools denoting a DXIL op's function attributes
405
+ static void emitDXILOpAttributes (const RecordKeeper &Records,
406
+ ArrayRef<DXILOperationDesc> Ops,
407
+ raw_ostream &OS) {
408
+ OS << " #ifdef DXIL_OP_ATTRIBUTES\n " ;
409
+ for (const auto &Op : Ops) {
410
+ for (const auto *Rec : Op.AttrRecs ) {
411
+ unsigned Major = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Major" );
412
+ unsigned Minor = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Minor" );
413
+ OS << " DXIL_OP_ATTRIBUTES(dxil::OpCode::" << Op.OpName << " , " ;
414
+ OS << std::to_string (Major) << " , " << std::to_string (Minor);
415
+ auto Attrs = Rec->getValueAsListOfDefs (" fn_attrs" );
416
+ for (const Record *Attr : Records.getAllDerivedDefinitions (" DXILAttribute" )) {
417
+ std::string HasAttr = " , false" ;
418
+ if (attrIsDefined (Attrs, Attr))
419
+ HasAttr = " , true" ;
420
+ OS << HasAttr;
421
+ }
422
+ OS << " )\n " ;
423
+ }
424
+
425
+ }
426
+ OS << " #undef DXIL_OP_ATTRIBUTES\n " ;
427
+ OS << " #endif\n\n " ;
428
+ }
429
+
419
430
// / Emit a list of DXIL op properties and their query functions
420
431
static void emitDXILProperties (const RecordKeeper &Records, raw_ostream &OS) {
421
432
// Generate their definitions
@@ -544,7 +555,6 @@ static void emitDXILOperationTable(ArrayRef<DXILOperationDesc> Ops,
544
555
<< OpClassStrings.get (Op.OpClass .data ()) << " , "
545
556
<< getOverloadMaskString (Op.OverloadRecs ) << " , "
546
557
<< getStageMaskString (Op.StageRecs ) << " , "
547
- << getAttributeListString (Op.AttrRecs ) << " , "
548
558
<< getPropertyListString (Op.PropRecs ) << " , " << Op.OverloadParamIndex
549
559
<< " }" ;
550
560
Prefix = " ,\n " ;
@@ -647,10 +657,12 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
647
657
PrevOp = Desc.OpCode ;
648
658
}
649
659
660
+ emitDXILVersions (Records, OS);
650
661
emitDXILOpCodes (DXILOps, OS);
651
662
emitDXILOpClasses (Records, OS);
652
663
emitDXILOpParamTypes (Records, OS);
653
664
emitDXILAttributes (Records, OS);
665
+ emitDXILOpAttributes (Records, DXILOps, OS);
654
666
emitDXILProperties (Records, OS);
655
667
emitDXILOpFunctionTypes (DXILOps, OS);
656
668
emitDXILIntrinsicArgSelectTypes (Records, OS);
0 commit comments