@@ -56,6 +56,7 @@ struct DXILOperationDesc {
5656 SmallVector<const Record *> OverloadRecs;
5757 SmallVector<const Record *> StageRecs;
5858 SmallVector<const Record *> AttrRecs;
59+ SmallVector<const Record *> PropRecs;
5960 SmallVector<DXILIntrinsicSelect> IntrinsicSelects;
6061 SmallVector<StringRef, 4 >
6162 ShaderStages; // shader stages to which this applies, empty for all.
@@ -177,6 +178,13 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
177178 AttrRecs.push_back (CR);
178179 }
179180
181+ Recs = R->getValueAsListOfDefs (" properties" );
182+
183+ // Get property records
184+ for (const Record *CR : Recs) {
185+ PropRecs.push_back (CR);
186+ }
187+
180188 // Get the operation class
181189 OpClass = R->getValueAsDef (" OpClass" )->getName ();
182190
@@ -348,6 +356,28 @@ static std::string getAttributeListString(ArrayRef<const Record *> Recs) {
348356 return ListString;
349357}
350358
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+
351381// / Emit a mapping of DXIL opcode to opname
352382static void emitDXILOpCodes (ArrayRef<DXILOperationDesc> Ops, raw_ostream &OS) {
353383 OS << " #ifdef DXIL_OPCODE\n " ;
@@ -386,6 +416,30 @@ static void emitDXILAttributes(const RecordKeeper &Records, raw_ostream &OS) {
386416 OS << " #endif\n\n " ;
387417}
388418
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+
389443// / Emit a list of DXIL op function types
390444static void emitDXILOpFunctionTypes (ArrayRef<DXILOperationDesc> Ops,
391445 raw_ostream &OS) {
@@ -482,7 +536,8 @@ static void emitDXILOperationTable(ArrayRef<DXILOperationDesc> Ops,
482536 << OpClassStrings.get (Op.OpClass .data ()) << " , "
483537 << getOverloadMaskString (Op.OverloadRecs ) << " , "
484538 << getStageMaskString (Op.StageRecs ) << " , "
485- << getAttributeListString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
539+ << getAttributeListString (Op.AttrRecs ) << " , "
540+ << getPropertyListString (Op.PropRecs ) << " , " << Op.OverloadParamIndex
486541 << " }" ;
487542 Prefix = " ,\n " ;
488543 }
@@ -588,12 +643,14 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
588643 emitDXILOpClasses (Records, OS);
589644 emitDXILOpParamTypes (Records, OS);
590645 emitDXILAttributes (Records, OS);
646+ emitDXILProperties (Records, OS);
591647 emitDXILOpFunctionTypes (DXILOps, OS);
592648 emitDXILIntrinsicArgSelectTypes (Records, OS);
593649 emitDXILIntrinsicMap (DXILOps, OS);
594650 OS << " #ifdef DXIL_OP_OPERATION_TABLE\n\n " ;
595651 emitDXILOperationTableDataStructs (Records, OS);
596652 emitDXILOperationTable (DXILOps, OS);
653+ emitDXILPropertyHelpers (Records, OS);
597654 OS << " #undef DXIL_OP_OPERATION_TABLE\n " ;
598655 OS << " #endif\n\n " ;
599656}
0 commit comments