================
@@ -1246,6 +1246,59 @@ def SelectOp : CIR_Op<"select", [Pure,
}];
}
+//===----------------------------------------------------------------------===//
+// TernaryOp
+//===----------------------------------------------------------------------===//
+
+def TernaryOp : CIR_Op<"ternary",
+ [DeclareOpInterfaceMethods<RegionBranchOpInterface>,
+ RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments]> {
+ let summary = "The `cond ? a : b` C/C++ ternary operation";
+ let description = [{
+ The `cir.ternary` operation represents C/C++ ternary, much like a `select`
+ operation. The first argument is a `cir.bool` condition to evaluate,
followed
+ by two regions to execute (true or false). This is different from `cir.if`
+ since each region is one block sized and the `cir.yield` closing the block
+ scope should have one argument.
+
+ Example:
+
+ ```mlir
+ // x = cond ? a : b;
----------------
andykaylor wrote:
```suggestion
// cond = a && b;
```
Along with corresponding changes below. (See https://godbolt.org/z/TjxY77xEW)
https://github.com/llvm/llvm-project/pull/137184
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits