@@ -42,6 +42,7 @@ struct DXILOperationDesc {
42
42
SmallVector<const Record *> OverloadRecs;
43
43
SmallVector<const Record *> StageRecs;
44
44
SmallVector<const Record *> AttrRecs;
45
+ SmallVector<const Record *> PropRecs;
45
46
StringRef Intrinsic; // The llvm intrinsic map to OpName. Default is "" which
46
47
// means no map exists
47
48
SmallVector<StringRef, 4 >
@@ -149,6 +150,13 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
149
150
AttrRecs.push_back (CR);
150
151
}
151
152
153
+ Recs = R->getValueAsListOfDefs (" properties" );
154
+
155
+ // Get property records
156
+ for (const Record *CR : Recs) {
157
+ PropRecs.push_back (CR);
158
+ }
159
+
152
160
// Get the operation class
153
161
OpClass = R->getValueAsDef (" OpClass" )->getName ();
154
162
@@ -318,6 +326,28 @@ static std::string getAttributeListString(ArrayRef<const Record *> Recs) {
318
326
return ListString;
319
327
}
320
328
329
+ // / Return a string representation of valid property information denoted
330
+ // by input records
331
+ //
332
+ // / \param Recs A vector of records of TableGen Property records
333
+ // / \return std::string string representation of properties list string
334
+ // {Attr1, Attr2, ...}
335
+ static std::string getPropertyListString (ArrayRef<const Record *> Recs) {
336
+ std::string ListString = " " ;
337
+ std::string Prefix = " " ;
338
+ ListString.append (" {" );
339
+
340
+ std::string CommaPrefix = " " ;
341
+ for (const auto *Rec : Recs) {
342
+ ListString.append (CommaPrefix)
343
+ .append (" dxil::Property::" )
344
+ .append (Rec->getName ());
345
+ CommaPrefix = " , " ;
346
+ }
347
+ ListString.append (" }" );
348
+ return ListString;
349
+ }
350
+
321
351
// / Emit a mapping of DXIL opcode to opname
322
352
static void emitDXILOpCodes (ArrayRef<DXILOperationDesc> Ops, raw_ostream &OS) {
323
353
OS << " #ifdef DXIL_OPCODE\n " ;
@@ -356,6 +386,30 @@ static void emitDXILAttributes(const RecordKeeper &Records, raw_ostream &OS) {
356
386
OS << " #endif\n\n " ;
357
387
}
358
388
389
+ // / Emit a list of DXIL op properties and their query functions
390
+ static void emitDXILProperties (const RecordKeeper &Records, raw_ostream &OS) {
391
+ // Generate their definitions
392
+ OS << " #ifdef DXIL_PROPERTY\n " ;
393
+ for (const Record *Prop: Records.getAllDerivedDefinitions (" DXILProperty" ))
394
+ OS << " DXIL_PROPERTY(" << Prop->getName () << " )\n " ;
395
+ OS << " #undef DXIL_PROPERTY\n " ;
396
+ OS << " #endif\n\n " ;
397
+ }
398
+
399
+ static void emitDXILPropertyHelpers (const RecordKeeper &Records, raw_ostream &OS) {
400
+ // Generate their helper functions
401
+ for (const Record *Prop: Records.getAllDerivedDefinitions (" DXILProperty" )) {
402
+ OS << " [[maybe_unused]]\n " ;
403
+ OS << " static bool has" << Prop->getName () << " (dxil::OpCode Op) {\n " ;
404
+ OS << " auto *OpCodeProp = getOpCodeProperty(Op);\n " ;
405
+ OS << " for (auto Prop : OpCodeProp->Properties)\n " ;
406
+ OS << " if (Prop == dxil::Property::" << Prop->getName () << " )\n " ;
407
+ OS << " return true;\n " ;
408
+ OS << " return false;\n " ;
409
+ OS << " }\n\n " ;
410
+ }
411
+ }
412
+
359
413
// / Emit a list of DXIL op function types
360
414
static void emitDXILOpFunctionTypes (ArrayRef<DXILOperationDesc> Ops,
361
415
raw_ostream &OS) {
@@ -426,7 +480,8 @@ static void emitDXILOperationTable(ArrayRef<DXILOperationDesc> Ops,
426
480
<< OpClassStrings.get (Op.OpClass .data ()) << " , "
427
481
<< getOverloadMaskString (Op.OverloadRecs ) << " , "
428
482
<< getStageMaskString (Op.StageRecs ) << " , "
429
- << getAttributeListString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
483
+ << getAttributeListString (Op.AttrRecs ) << " , "
484
+ << getPropertyListString (Op.PropRecs ) << " , " << Op.OverloadParamIndex
430
485
<< " }" ;
431
486
Prefix = " ,\n " ;
432
487
}
@@ -532,11 +587,13 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
532
587
emitDXILOpClasses (Records, OS);
533
588
emitDXILOpParamTypes (Records, OS);
534
589
emitDXILAttributes (Records, OS);
590
+ emitDXILProperties (Records, OS);
535
591
emitDXILOpFunctionTypes (DXILOps, OS);
536
592
emitDXILIntrinsicMap (DXILOps, OS);
537
593
OS << " #ifdef DXIL_OP_OPERATION_TABLE\n\n " ;
538
594
emitDXILOperationTableDataStructs (Records, OS);
539
595
emitDXILOperationTable (DXILOps, OS);
596
+ emitDXILPropertyHelpers (Records, OS);
540
597
OS << " #undef DXIL_OP_OPERATION_TABLE\n " ;
541
598
OS << " #endif\n\n " ;
542
599
}
0 commit comments