@@ -181,9 +181,8 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
181181 Recs = R->getValueAsListOfDefs (" properties" );
182182
183183 // Get property records
184- for (const Record *CR : Recs) {
184+ for (const Record *CR : Recs)
185185 PropRecs.push_back (CR);
186- }
187186
188187 // Get the operation class
189188 OpClass = R->getValueAsDef (" OpClass" )->getName ();
@@ -371,7 +370,8 @@ static void emitDXILAttributes(const RecordKeeper &Records, raw_ostream &OS) {
371370 OS << " #endif\n\n " ;
372371}
373372
374- // Determine which function attributes are set for a dxil version
373+ // Helper function to determine if the given Attr is defined in the vector
374+ // Attrs, by comparing the names
375375static bool attrIsDefined (std::vector<const Record *> Attrs,
376376 const Record *Attr) {
377377 for (auto CurAttr : Attrs)
@@ -384,6 +384,13 @@ static bool attrIsDefined(std::vector<const Record *> Attrs,
384384static void emitDXILOpAttributes (const RecordKeeper &Records,
385385 ArrayRef<DXILOperationDesc> Ops,
386386 raw_ostream &OS) {
387+ // A DXIL op can have multiple function attributes that are specific to a
388+ // specific DXIL version and higher. AttrRecs models this by grouping the
389+ // attributes by the versions. So we will output a macro for each version
390+ // number with a table of bools in the following format:
391+ //
392+ // OpName, VersionMajor, VersionMinor, FnAttr1, FnAttr2, ...
393+ // Eg) Abs, 1, 0, true, false, ...
387394 OS << " #ifdef DXIL_OP_ATTRIBUTES\n " ;
388395 for (const auto &Op : Ops) {
389396 for (const auto *Rec : Op.AttrRecs ) {
@@ -393,7 +400,11 @@ static void emitDXILOpAttributes(const RecordKeeper &Records,
393400 Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Minor" );
394401 OS << " DXIL_OP_ATTRIBUTES(dxil::OpCode::" << Op.OpName << " , " ;
395402 OS << std::to_string (Major) << " , " << std::to_string (Minor);
403+ // These Attrs are the ones set for above DXIL version
396404 auto Attrs = Rec->getValueAsListOfDefs (" fn_attrs" );
405+ // We will then iteratre through all possible attributes and mark the
406+ // present ones as 'true' and all the others as 'false' to create the
407+ // boolean table, eg) true, false, false, false
397408 for (const Record *Attr :
398409 Records.getAllDerivedDefinitions (" DXILAttribute" )) {
399410 std::string HasAttr = " , false" ;
@@ -408,7 +419,7 @@ static void emitDXILOpAttributes(const RecordKeeper &Records,
408419 OS << " #endif\n\n " ;
409420}
410421
411- // / Emit a list of DXIL op properties and their query functions
422+ // / Emit a list of DXIL op properties
412423static void emitDXILProperties (const RecordKeeper &Records, raw_ostream &OS) {
413424 OS << " #ifdef DXIL_PROPERTY\n " ;
414425 for (const Record *Prop : Records.getAllDerivedDefinitions (" DXILProperty" ))
0 commit comments