@@ -285,41 +285,37 @@ static std::string getStageMaskString(ArrayRef<const Record *> Recs) {
285285// by input records
286286//
287287// / \param Recs A vector of records of TableGen Attribute records
288- // / \return std::string string representation of stages mask string
288+ // / \return std::string string representation of attributes list string
289289// / predicated by DXIL Version. E.g.,
290- // {{{1, 0}, Mask1} , {{1, 2}, Mask2 }, ...}
291- static std::string getAttributeMaskString (ArrayRef<const Record *> Recs) {
292- std::string MaskString = " " ;
290+ // {{{1, 0}, {Attr1, ...}} , {{1, 2}, {Attr2, ...} }, ...}
291+ static std::string getAttributeListString (ArrayRef<const Record *> Recs) {
292+ std::string ListString = " " ;
293293 std::string Prefix = " " ;
294- MaskString .append (" {" );
294+ ListString .append (" {" );
295295
296296 for (const auto *Rec : Recs) {
297297 unsigned Major = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Major" );
298298 unsigned Minor = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Minor" );
299- MaskString .append (Prefix)
299+ ListString .append (Prefix)
300300 .append (" {{" )
301301 .append (std::to_string (Major))
302302 .append (" , " )
303- .append (std::to_string (Minor).append (" }, " ));
304-
305- std::string PipePrefix = " " ;
306- auto Attrs = Rec->getValueAsListOfDefs (" op_attrs" );
307- if (Attrs.empty ()) {
308- MaskString.append (" Attribute::None" );
309- } else {
310- for (const auto *Attr : Attrs) {
311- MaskString.append (PipePrefix)
312- .append (" Attribute::" )
313- .append (Attr->getName ());
314- PipePrefix = " | " ;
315- }
303+ .append (std::to_string (Minor).append (" }, {" ));
304+
305+ std::string CommaPrefix = " " ;
306+ auto Attrs = Rec->getValueAsListOfDefs (" fn_attrs" );
307+ for (const auto *Attr : Attrs) {
308+ ListString.append (CommaPrefix)
309+ .append (" dxil::Attribute::" )
310+ .append (Attr->getName ());
311+ CommaPrefix = " , " ;
316312 }
317-
318- MaskString .append (" }" );
313+ ListString. append ( " } " ); // End of Attrs
314+ ListString .append (" }" ); // End of Rec
319315 Prefix = " , " ;
320316 }
321- MaskString .append (" }" );
322- return MaskString ;
317+ ListString .append (" }" ); // End of List
318+ return ListString ;
323319}
324320
325321// / Emit a mapping of DXIL opcode to opname
@@ -351,6 +347,15 @@ static void emitDXILOpParamTypes(const RecordKeeper &Records, raw_ostream &OS) {
351347 OS << " #endif\n\n " ;
352348}
353349
350+ // / Emit a list of DXIL op function attributes
351+ static void emitDXILAttributes (const RecordKeeper &Records, raw_ostream &OS) {
352+ OS << " #ifdef DXIL_ATTRIBUTE\n " ;
353+ for (const Record *Attr : Records.getAllDerivedDefinitions (" DXILAttribute" ))
354+ OS << " DXIL_ATTRIBUTE(" << Attr->getName () << " )\n " ;
355+ OS << " #undef DXIL_ATTRIBUTE\n " ;
356+ OS << " #endif\n\n " ;
357+ }
358+
354359// / Emit a list of DXIL op function types
355360static void emitDXILOpFunctionTypes (ArrayRef<DXILOperationDesc> Ops,
356361 raw_ostream &OS) {
@@ -421,7 +426,7 @@ static void emitDXILOperationTable(ArrayRef<DXILOperationDesc> Ops,
421426 << OpClassStrings.get (Op.OpClass .data ()) << " , "
422427 << getOverloadMaskString (Op.OverloadRecs ) << " , "
423428 << getStageMaskString (Op.StageRecs ) << " , "
424- << getAttributeMaskString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
429+ << getAttributeListString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
425430 << " }" ;
426431 Prefix = " ,\n " ;
427432 }
@@ -526,6 +531,7 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
526531 emitDXILOpCodes (DXILOps, OS);
527532 emitDXILOpClasses (Records, OS);
528533 emitDXILOpParamTypes (Records, OS);
534+ emitDXILAttributes (Records, OS);
529535 emitDXILOpFunctionTypes (DXILOps, OS);
530536 emitDXILIntrinsicMap (DXILOps, OS);
531537 OS << " #ifdef DXIL_OP_OPERATION_TABLE\n\n " ;
0 commit comments