[clang] [CIR] Add if statement support (PR #134333)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 4 16:19:57 PDT 2025


================
@@ -462,6 +462,58 @@ def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp", "DoWhileOp",
   let hasVerifier = 1;
 }
 
+//===----------------------------------------------------------------------===//
+// IfOp
+//===----------------------------------------------------------------------===//
+
+def IfOp : CIR_Op<"if",
+     [DeclareOpInterfaceMethods<RegionBranchOpInterface>,
+     RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments]>{
+
+  let summary = "the if-then-else operation";
+  let description = [{
+    The `cir.if` operation represents an if-then-else construct for
+    conditionally executing two regions of code. The operand is a `cir.bool`
+    type.
+
+    Examples:
+
+    ```mlir
+    cir.if %b  {
----------------
erichkeane wrote:

FWIW, I feel the above conversation/future directions is enough for me, so discuss/evolve as we go, but feel free to move on with the current representaiton here.

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


More information about the cfe-commits mailing list