File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
include/clang/CIR/Dialect/IR Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1477,6 +1477,10 @@ def TernaryOp : CIR_Op<"ternary",
1477
1477
since each region is one block sized and the `cir.yield` closing the block
1478
1478
scope should have one argument.
1479
1479
1480
+ `cir.ternary` also represents the GNU binary conditional operator ?: which
1481
+ reuses the parent operation for both the condition and the true branch to
1482
+ evaluate it only once.
1483
+
1480
1484
Example:
1481
1485
1482
1486
```mlir
Original file line number Diff line number Diff line change @@ -1191,7 +1191,7 @@ LogicalResult cir::BinOp::verify() {
1191
1191
// TernaryOp
1192
1192
// ===----------------------------------------------------------------------===//
1193
1193
1194
- // / Given the region at `index `, or the parent operation if `index ` is None,
1194
+ // / Given the region at `point `, or the parent operation if `point ` is None,
1195
1195
// / return the successor regions. These are the regions that may be selected
1196
1196
// / during the flow of control. `operands` is a set of optional attributes that
1197
1197
// / correspond to a constant value for each operand, or null if that operand is
@@ -1204,7 +1204,8 @@ void cir::TernaryOp::getSuccessorRegions(
1204
1204
return ;
1205
1205
}
1206
1206
1207
- // If the condition isn't constant, both regions may be executed.
1207
+ // When branching from the parent operation, both the true and false
1208
+ // regions are considered possible successors
1208
1209
regions.push_back (RegionSuccessor (&getTrueRegion ()));
1209
1210
regions.push_back (RegionSuccessor (&getFalseRegion ()));
1210
1211
}
You can’t perform that action at this time.
0 commit comments