[Mlir-commits] [mlir] [mlir] [irdl] Add support for regions in irdl-to-cpp (PR #158540)

Théo Degioanni llvmlistbot at llvm.org
Thu Oct 2 01:42:03 PDT 2025


================
@@ -131,6 +140,15 @@ static void fillDict(irdl::detail::dictionary &dict, const OpStrings &strings) {
       operandCount ? joinNameList(strings.opOperandNames) : "{\"\"}";
   dict["OP_RESULT_INITIALIZER_LIST"] =
       resultCount ? joinNameList(strings.opResultNames) : "{\"\"}";
+  dict["OP_REGION_COUNT"] = std::to_string(regionCount);
+  dict["OP_ADD_REGIONS"] = regionCount
+                               ? std::string(llvm::formatv(
+                                     R"(for (unsigned i = 0; i != {0}; ++i) {{
+    (void)odsState.addRegion();
+  }
+)",
+                                     regionCount))
+                               : "";
----------------
Moxinilian wrote:

Ah, I see what you mean. An other approach could have been to run the loop in the template generator, basically unrolling the output. But do as you prefer it's not a big deal!

https://github.com/llvm/llvm-project/pull/158540


More information about the Mlir-commits mailing list