@@ -315,41 +315,37 @@ static std::string getStageMaskString(ArrayRef<const Record *> Recs) {
315315// by input records
316316//
317317// / \param Recs A vector of records of TableGen Attribute records
318- // / \return std::string string representation of stages mask string
318+ // / \return std::string string representation of attributes list string
319319// / predicated by DXIL Version. E.g.,
320- // {{{1, 0}, Mask1} , {{1, 2}, Mask2 }, ...}
321- static std::string getAttributeMaskString (ArrayRef<const Record *> Recs) {
322- std::string MaskString = " " ;
320+ // {{{1, 0}, {Attr1, ...}} , {{1, 2}, {Attr2, ...} }, ...}
321+ static std::string getAttributeListString (ArrayRef<const Record *> Recs) {
322+ std::string ListString = " " ;
323323 std::string Prefix = " " ;
324- MaskString .append (" {" );
324+ ListString .append (" {" );
325325
326326 for (const auto *Rec : Recs) {
327327 unsigned Major = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Major" );
328328 unsigned Minor = Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Minor" );
329- MaskString .append (Prefix)
329+ ListString .append (Prefix)
330330 .append (" {{" )
331331 .append (std::to_string (Major))
332332 .append (" , " )
333- .append (std::to_string (Minor).append (" }, " ));
334-
335- std::string PipePrefix = " " ;
336- auto Attrs = Rec->getValueAsListOfDefs (" op_attrs" );
337- if (Attrs.empty ()) {
338- MaskString.append (" Attribute::None" );
339- } else {
340- for (const auto *Attr : Attrs) {
341- MaskString.append (PipePrefix)
342- .append (" Attribute::" )
343- .append (Attr->getName ());
344- PipePrefix = " | " ;
345- }
333+ .append (std::to_string (Minor).append (" }, {" ));
334+
335+ std::string CommaPrefix = " " ;
336+ auto Attrs = Rec->getValueAsListOfDefs (" fn_attrs" );
337+ for (const auto *Attr : Attrs) {
338+ ListString.append (CommaPrefix)
339+ .append (" dxil::Attribute::" )
340+ .append (Attr->getName ());
341+ CommaPrefix = " , " ;
346342 }
347-
348- MaskString .append (" }" );
343+ ListString. append ( " } " ); // End of Attrs
344+ ListString .append (" }" ); // End of Rec
349345 Prefix = " , " ;
350346 }
351- MaskString .append (" }" );
352- return MaskString ;
347+ ListString .append (" }" ); // End of List
348+ return ListString ;
353349}
354350
355351// / Emit a mapping of DXIL opcode to opname
@@ -381,6 +377,15 @@ static void emitDXILOpParamTypes(const RecordKeeper &Records, raw_ostream &OS) {
381377 OS << " #endif\n\n " ;
382378}
383379
380+ // / Emit a list of DXIL op function attributes
381+ static void emitDXILAttributes (const RecordKeeper &Records, raw_ostream &OS) {
382+ OS << " #ifdef DXIL_ATTRIBUTE\n " ;
383+ for (const Record *Attr : Records.getAllDerivedDefinitions (" DXILAttribute" ))
384+ OS << " DXIL_ATTRIBUTE(" << Attr->getName () << " )\n " ;
385+ OS << " #undef DXIL_ATTRIBUTE\n " ;
386+ OS << " #endif\n\n " ;
387+ }
388+
384389// / Emit a list of DXIL op function types
385390static void emitDXILOpFunctionTypes (ArrayRef<DXILOperationDesc> Ops,
386391 raw_ostream &OS) {
@@ -477,7 +482,7 @@ static void emitDXILOperationTable(ArrayRef<DXILOperationDesc> Ops,
477482 << OpClassStrings.get (Op.OpClass .data ()) << " , "
478483 << getOverloadMaskString (Op.OverloadRecs ) << " , "
479484 << getStageMaskString (Op.StageRecs ) << " , "
480- << getAttributeMaskString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
485+ << getAttributeListString (Op.AttrRecs ) << " , " << Op.OverloadParamIndex
481486 << " }" ;
482487 Prefix = " ,\n " ;
483488 }
@@ -582,6 +587,7 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
582587 emitDXILOpCodes (DXILOps, OS);
583588 emitDXILOpClasses (Records, OS);
584589 emitDXILOpParamTypes (Records, OS);
590+ emitDXILAttributes (Records, OS);
585591 emitDXILOpFunctionTypes (DXILOps, OS);
586592 emitDXILIntrinsicArgSelectTypes (Records, OS);
587593 emitDXILIntrinsicMap (DXILOps, OS);
0 commit comments