Skip to content

Commit 7cd364b

Browse files
committed
change to emitting a general query helper
- instead of generating a query helper for each property, just use a general one for all property enums
1 parent aaef22f commit 7cd364b

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

llvm/utils/TableGen/DXILEmitter.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,16 @@ static void emitDXILProperties(const RecordKeeper &Records, raw_ostream &OS) {
396396
OS << "#endif\n\n";
397397
}
398398

399-
static void emitDXILPropertyHelpers(const RecordKeeper &Records,
400-
raw_ostream &OS) {
401-
// Generate their helper functions
402-
for (const Record *Prop : Records.getAllDerivedDefinitions("DXILProperty")) {
403-
OS << "[[maybe_unused]]\n";
404-
OS << "static bool has" << Prop->getName() << "(dxil::OpCode Op) {\n";
405-
OS << " auto *OpCodeProp = getOpCodeProperty(Op);\n";
406-
OS << " for (auto Prop : OpCodeProp->Properties)\n";
407-
OS << " if (Prop == dxil::Property::" << Prop->getName() << ")\n";
408-
OS << " return true;\n";
409-
OS << " return false;\n";
410-
OS << "}\n\n";
411-
}
399+
static void emitDXILPropertyHelper(raw_ostream &OS) {
400+
// Generate helper function to query all the functions
401+
OS << "[[maybe_unused]]\n";
402+
OS << "static bool hasProperty(dxil::OpCode Op, dxil::Property Prop) {\n";
403+
OS << " auto *OpCodeProp = getOpCodeProperty(Op);\n";
404+
OS << " for (auto CurProp : OpCodeProp->Properties)\n";
405+
OS << " if (CurProp == Prop)\n";
406+
OS << " return true;\n";
407+
OS << " return false;\n";
408+
OS << "}\n\n";
412409
}
413410

414411
/// Emit a list of DXIL op function types
@@ -594,7 +591,7 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
594591
OS << "#ifdef DXIL_OP_OPERATION_TABLE\n\n";
595592
emitDXILOperationTableDataStructs(Records, OS);
596593
emitDXILOperationTable(DXILOps, OS);
597-
emitDXILPropertyHelpers(Records, OS);
594+
emitDXILPropertyHelper(OS);
598595
OS << "#undef DXIL_OP_OPERATION_TABLE\n";
599596
OS << "#endif\n\n";
600597
}

0 commit comments

Comments
 (0)