Skip to content

Commit 3ae43a5

Browse files
committed
[ods] Enable getting forward decls allow
Summary: Currently forward decls are included with all the op classes. But there are cases (say when splitting up headers) where one wants the forward decls but not all the classes. Add an option to enable this. This does not change any current behavior (some further refactoring is probably due here). Differential Revision: https://reviews.llvm.org/D83727
1 parent 8978032 commit 3ae43a5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2129,15 +2129,19 @@ void OpOperandAdaptorEmitter::emitDef(const Operator &op, raw_ostream &os) {
21292129
// Emits the opcode enum and op classes.
21302130
static void emitOpClasses(const std::vector<Record *> &defs, raw_ostream &os,
21312131
bool emitDecl) {
2132-
IfDefScope scope("GET_OP_CLASSES", os);
21332132
// First emit forward declaration for each class, this allows them to refer
21342133
// to each others in traits for example.
21352134
if (emitDecl) {
2135+
os << "#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES)\n";
2136+
os << "#undef GET_OP_FWD_DEFINES\n";
21362137
for (auto *def : defs) {
21372138
Operator op(*def);
21382139
os << "class " << op.getCppClassName() << ";\n";
21392140
}
2141+
os << "#endif\n\n";
21402142
}
2143+
2144+
IfDefScope scope("GET_OP_CLASSES", os);
21412145
for (auto *def : defs) {
21422146
Operator op(*def);
21432147
if (emitDecl) {

0 commit comments

Comments
 (0)