[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu May 8 16:16:20 PDT 2025


================
@@ -971,6 +971,52 @@ def SwitchOp : CIR_Op<"switch",
   }];
 }
 
+//===----------------------------------------------------------------------===//
+// SwitchFlatOp
+//===----------------------------------------------------------------------===//
+
+def SwitchFlatOp : CIR_Op<"switch.flat", [AttrSizedOperandSegments,
+                                          Terminator]> {
+
+  let description = [{
+    The `cir.switch.flat` operation is a region-less and simplified
+    version of the `cir.switch`.
+    It's representation is closer to LLVM IR dialect
+    than the C/C++ language feature.
+  }];
+
+  let arguments = (ins
+    CIR_IntType:$condition,
+    Variadic<AnyType>:$defaultOperands,
+    VariadicOfVariadic<AnyType, "case_operand_segments">:$caseOperands,
+    ArrayAttr:$case_values,
----------------
andykaylor wrote:

There's an inconsistency between `case_values` here and on line 1004, and `caseValues` on line 1014. I see that the LLVM dialect's `LLVM_SwitchOp` has the same inconsistency, but I don't see any other place that it's referenced directly.

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


More information about the cfe-commits mailing list