[clang] [CIR] Add if statement support (PR #134333)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 4 09:47:49 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:
is `%b` here the condition? Can we make that more clear by renaming this variable?
This differs from the loops, where the condition has its own block. I find myself curious why that is. Also, what happens with variable declarations in the condition? Do we properly set scope for those?
https://github.com/llvm/llvm-project/pull/134333
More information about the cfe-commits
mailing list