Skip to content

Commit 242873d

Browse files
committed
move region-adding loop to template
1 parent f935477 commit 242873d

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

mlir/lib/Target/IRDLToCpp/IRDLToCpp.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ static void fillDict(irdl::detail::dictionary &dict, const OpStrings &strings) {
141141
dict["OP_RESULT_INITIALIZER_LIST"] =
142142
resultCount ? joinNameList(strings.opResultNames) : "{\"\"}";
143143
dict["OP_REGION_COUNT"] = std::to_string(regionCount);
144-
dict["OP_ADD_REGIONS"] = regionCount
145-
? std::string(llvm::formatv(
146-
R"(for (unsigned i = 0; i != {0}; ++i) {{
147-
(void)odsState.addRegion();
148-
}
149-
)",
150-
regionCount))
151-
: "";
152144
}
153145

154146
/// Fills a dictionary with values from DialectStrings

mlir/lib/Target/IRDLToCpp/Templates/PerOperationDef.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ void __OP_CPP_NAME__::build(::mlir::OpBuilder &odsBuilder,
2121
odsState.addOperands(operands);
2222
odsState.addAttributes(attributes);
2323
odsState.addTypes(resultTypes);
24-
__OP_ADD_REGIONS__
24+
for (unsigned i = 0; i != __OP_REGION_COUNT__; ++i) {
25+
(void)odsState.addRegion();
26+
}
2527
}
2628

2729
__OP_CPP_NAME__

0 commit comments

Comments
 (0)