@@ -56,6 +56,7 @@ struct DXILOperationDesc {
56
56
SmallVector<const Record *> OverloadRecs;
57
57
SmallVector<const Record *> StageRecs;
58
58
SmallVector<const Record *> AttrRecs;
59
+ SmallVector<const Record *> PropRecs;
59
60
SmallVector<DXILIntrinsicSelect> IntrinsicSelects;
60
61
SmallVector<StringRef, 4 >
61
62
ShaderStages; // shader stages to which this applies, empty for all.
@@ -177,6 +178,13 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
177
178
AttrRecs.push_back (CR);
178
179
}
179
180
181
+ Recs = R->getValueAsListOfDefs (" properties" );
182
+
183
+ // Get property records
184
+ for (const Record *CR : Recs) {
185
+ PropRecs.push_back (CR);
186
+ }
187
+
180
188
// Get the operation class
181
189
OpClass = R->getValueAsDef (" OpClass" )->getName ();
182
190
@@ -348,6 +356,28 @@ static std::string getAttributeListString(ArrayRef<const Record *> Recs) {
348
356
return ListString;
349
357
}
350
358
359
+ // / Return a string representation of valid property information denoted
360
+ // by input records
361
+ //
362
+ // / \param Recs A vector of records of TableGen Property records
363
+ // / \return std::string string representation of properties list string
364
+ // {Attr1, Attr2, ...}
365
+ static std::string getPropertyListString (ArrayRef<const Record *> Recs) {
366
+ std::string ListString = " " ;
367
+ std::string Prefix = " " ;
368
+ ListString.append (" {" );
369
+
370
+ std::string CommaPrefix = " " ;
371
+ for (const auto *Rec : Recs) {
372
+ ListString.append (CommaPrefix)
373
+ .append (" dxil::Property::" )
374
+ .append (Rec->getName ());
375
+ CommaPrefix = " , " ;
376
+ }
377
+ ListString.append (" }" );
378
+ return ListString;
379
+ }
380
+
351
381
// / Emit a mapping of DXIL opcode to opname
352
382
static void emitDXILOpCodes (ArrayRef<DXILOperationDesc> Ops, raw_ostream &OS) {
353
383
OS << " #ifdef DXIL_OPCODE\n " ;
@@ -386,6 +416,30 @@ static void emitDXILAttributes(const RecordKeeper &Records, raw_ostream &OS) {
386
416
OS << " #endif\n\n " ;
387
417
}
388
418
419
+ // / Emit a list of DXIL op properties and their query functions
420
+ static void emitDXILProperties (const RecordKeeper &Records, raw_ostream &OS) {
421
+ // Generate their definitions
422
+ OS << " #ifdef DXIL_PROPERTY\n " ;
423
+ for (const Record *Prop: Records.getAllDerivedDefinitions (" DXILProperty" ))
424
+ OS << " DXIL_PROPERTY(" << Prop->getName () << " )\n " ;
425
+ OS << " #undef DXIL_PROPERTY\n " ;
426
+ OS << " #endif\n\n " ;
427
+ }
428
+
429
+ static void emitDXILPropertyHelpers (const RecordKeeper &Records, raw_ostream &OS) {
430
+ // Generate their helper functions
431
+ for (const Record *Prop: Records.getAllDerivedDefinitions (" DXILProperty" )) {
432
+ OS << " [[maybe_unused]]\n " ;
433
+ OS << " static bool has" << Prop->getName () << " (dxil::OpCode Op) {\n " ;
434
+ OS << " auto *OpCodeProp = getOpCodeProperty(Op);\n " ;
435
+ OS << " for (auto Prop : OpCodeProp->Properties)\n " ;
436
+ OS << " if (Prop == dxil::Property::" << Prop->getName () << " )\n " ;
437
+ OS << " return true;\n " ;
438
+ OS << " return false;\n " ;
439
+ OS << " }\n\n " ;
440
+ }
441
+ }
442
+
389
443
// / Emit a list of DXIL op function types
390
444
static void emitDXILOpFunctionTypes (ArrayRef<DXILOperationDesc> Ops,
391
445
raw_ostream &OS) {
@@ -482,7 +536,8 @@ static void emitDXILOperationTable(ArrayRef<DXILOperationDesc> Ops,
482
536
<< OpClassStrings.get (Op.OpClass .data ()) << " , "
483
537
<< getOverloadMaskString (Op.OverloadRecs ) << " , "
484
538
<< getStageMaskString (Op.StageRecs ) << " , "
485
- << getAttributeListString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
539
+ << getAttributeListString (Op.AttrRecs ) << " , "
540
+ << getPropertyListString (Op.PropRecs ) << " , " << Op.OverloadParamIndex
486
541
<< " }" ;
487
542
Prefix = " ,\n " ;
488
543
}
@@ -588,12 +643,14 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
588
643
emitDXILOpClasses (Records, OS);
589
644
emitDXILOpParamTypes (Records, OS);
590
645
emitDXILAttributes (Records, OS);
646
+ emitDXILProperties (Records, OS);
591
647
emitDXILOpFunctionTypes (DXILOps, OS);
592
648
emitDXILIntrinsicArgSelectTypes (Records, OS);
593
649
emitDXILIntrinsicMap (DXILOps, OS);
594
650
OS << " #ifdef DXIL_OP_OPERATION_TABLE\n\n " ;
595
651
emitDXILOperationTableDataStructs (Records, OS);
596
652
emitDXILOperationTable (DXILOps, OS);
653
+ emitDXILPropertyHelpers (Records, OS);
597
654
OS << " #undef DXIL_OP_OPERATION_TABLE\n " ;
598
655
OS << " #endif\n\n " ;
599
656
}
0 commit comments