Skip to content

Commit 4205861

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 66c0750 commit 4205861

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
@@ -426,19 +426,16 @@ static void emitDXILProperties(const RecordKeeper &Records, raw_ostream &OS) {
426426
OS << "#endif\n\n";
427427
}
428428

429-
static void emitDXILPropertyHelpers(const RecordKeeper &Records,
430-
raw_ostream &OS) {
431-
// Generate their helper functions
432-
for (const Record *Prop : Records.getAllDerivedDefinitions("DXILProperty")) {
433-
OS << "[[maybe_unused]]\n";
434-
OS << "static bool has" << Prop->getName() << "(dxil::OpCode Op) {\n";
435-
OS << " auto *OpCodeProp = getOpCodeProperty(Op);\n";
436-
OS << " for (auto Prop : OpCodeProp->Properties)\n";
437-
OS << " if (Prop == dxil::Property::" << Prop->getName() << ")\n";
438-
OS << " return true;\n";
439-
OS << " return false;\n";
440-
OS << "}\n\n";
441-
}
429+
static void emitDXILPropertyHelper(raw_ostream &OS) {
430+
// Generate helper function to query all the functions
431+
OS << "[[maybe_unused]]\n";
432+
OS << "static bool hasProperty(dxil::OpCode Op, dxil::Property Prop) {\n";
433+
OS << " auto *OpCodeProp = getOpCodeProperty(Op);\n";
434+
OS << " for (auto CurProp : OpCodeProp->Properties)\n";
435+
OS << " if (CurProp == Prop)\n";
436+
OS << " return true;\n";
437+
OS << " return false;\n";
438+
OS << "}\n\n";
442439
}
443440

444441
/// Emit a list of DXIL op function types
@@ -651,7 +648,7 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
651648
OS << "#ifdef DXIL_OP_OPERATION_TABLE\n\n";
652649
emitDXILOperationTableDataStructs(Records, OS);
653650
emitDXILOperationTable(DXILOps, OS);
654-
emitDXILPropertyHelpers(Records, OS);
651+
emitDXILPropertyHelper(OS);
655652
OS << "#undef DXIL_OP_OPERATION_TABLE\n";
656653
OS << "#endif\n\n";
657654
}

0 commit comments

Comments
 (0)