Skip to content

Commit 4a1561d

Browse files
committed
remove dependcy on OpCodeProperty for helper function
- before this change, we would be required to define OpCodeProperty and all used structs to use hasProperty, which for all uses outside of DXILOpBuilder is not usable.
1 parent eb10290 commit 4a1561d

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

llvm/utils/TableGen/DXILEmitter.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,22 @@ static void emitDXILProperties(const RecordKeeper &Records, raw_ostream &OS) {
426426
OS << "#endif\n\n";
427427
}
428428

429-
static void emitDXILPropertyHelper(raw_ostream &OS) {
429+
static void emitDXILPropertyHelper(ArrayRef<DXILOperationDesc> Ops,
430+
raw_ostream &OS) {
430431
// Generate helper function to query all the functions
431-
OS << "[[maybe_unused]]\n";
432+
OS << "static llvm::SmallVector<dxil::Property> getProperties(dxil::OpCode "
433+
"Op) {\n";
434+
OS << " switch (Op) {\n";
435+
for (const auto &Op : Ops) {
436+
OS << " case dxil::OpCode::" << Op.OpName << ": return "
437+
<< getPropertyListString(Op.PropRecs) << ";\n";
438+
}
439+
OS << " }\n";
440+
OS << " return {};\n";
441+
OS << "}\n\n";
432442
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";
443+
OS << " auto Properties = getProperties(Op);\n";
444+
OS << " for (auto CurProp : Properties)\n";
435445
OS << " if (CurProp == Prop)\n";
436446
OS << " return true;\n";
437447
OS << " return false;\n";
@@ -648,9 +658,12 @@ static void emitDxilOperation(const RecordKeeper &Records, raw_ostream &OS) {
648658
OS << "#ifdef DXIL_OP_OPERATION_TABLE\n\n";
649659
emitDXILOperationTableDataStructs(Records, OS);
650660
emitDXILOperationTable(DXILOps, OS);
651-
emitDXILPropertyHelper(OS);
652661
OS << "#undef DXIL_OP_OPERATION_TABLE\n";
653662
OS << "#endif\n\n";
663+
OS << "#ifdef DXIL_OP_PROPERTY_HELPER\n";
664+
emitDXILPropertyHelper(DXILOps, OS);
665+
OS << "#undef DXIL_OP_PROPERTY_HELPER\n";
666+
OS << "#endif\n\n";
654667
}
655668

656669
static TableGen::Emitter::Opt X("gen-dxil-operation", emitDxilOperation,

0 commit comments

Comments
 (0)