@@ -181,9 +181,8 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
181
181
Recs = R->getValueAsListOfDefs (" properties" );
182
182
183
183
// Get property records
184
- for (const Record *CR : Recs) {
184
+ for (const Record *CR : Recs)
185
185
PropRecs.push_back (CR);
186
- }
187
186
188
187
// Get the operation class
189
188
OpClass = R->getValueAsDef (" OpClass" )->getName ();
@@ -371,7 +370,8 @@ static void emitDXILAttributes(const RecordKeeper &Records, raw_ostream &OS) {
371
370
OS << " #endif\n\n " ;
372
371
}
373
372
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
375
375
static bool attrIsDefined (std::vector<const Record *> Attrs,
376
376
const Record *Attr) {
377
377
for (auto CurAttr : Attrs)
@@ -384,6 +384,13 @@ static bool attrIsDefined(std::vector<const Record *> Attrs,
384
384
static void emitDXILOpAttributes (const RecordKeeper &Records,
385
385
ArrayRef<DXILOperationDesc> Ops,
386
386
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, ...
387
394
OS << " #ifdef DXIL_OP_ATTRIBUTES\n " ;
388
395
for (const auto &Op : Ops) {
389
396
for (const auto *Rec : Op.AttrRecs ) {
@@ -393,7 +400,11 @@ static void emitDXILOpAttributes(const RecordKeeper &Records,
393
400
Rec->getValueAsDef (" dxil_version" )->getValueAsInt (" Minor" );
394
401
OS << " DXIL_OP_ATTRIBUTES(dxil::OpCode::" << Op.OpName << " , " ;
395
402
OS << std::to_string (Major) << " , " << std::to_string (Minor);
403
+ // These Attrs are the ones set for above DXIL version
396
404
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
397
408
for (const Record *Attr :
398
409
Records.getAllDerivedDefinitions (" DXILAttribute" )) {
399
410
std::string HasAttr = " , false" ;
@@ -408,7 +419,7 @@ static void emitDXILOpAttributes(const RecordKeeper &Records,
408
419
OS << " #endif\n\n " ;
409
420
}
410
421
411
- // / Emit a list of DXIL op properties and their query functions
422
+ // / Emit a list of DXIL op properties
412
423
static void emitDXILProperties (const RecordKeeper &Records, raw_ostream &OS) {
413
424
OS << " #ifdef DXIL_PROPERTY\n " ;
414
425
for (const Record *Prop : Records.getAllDerivedDefinitions (" DXILProperty" ))
0 commit comments