@@ -750,8 +750,10 @@ def IfOp : CIR_Op<"if",
750750 }
751751 ```
752752
753- `cir.if` defines no values and the 'else' can be omitted. `cir.yield` must
754- explicitly terminate the region if it has more than one block.
753+ `cir.if` defines no values and the 'else' can be omitted. The if/else
754+ regions must be terminated. If the region has only one block, the terminator
755+ can be left out, and `cir.yield` terminator will be inserted implictly.
756+ Otherwise, the region must be explicitly terminated.
755757 }];
756758 let arguments = (ins CIR_BoolType:$condition);
757759 let regions = (region AnyRegion:$thenRegion, AnyRegion:$elseRegion);
@@ -1070,6 +1072,16 @@ def ScopeOp : CIR_Op<"scope", [
10701072 custom<OmittedTerminatorRegion>($scopeRegion) (`:` type($results)^)? attr-dict
10711073 }];
10721074
1075+ let extraClassDeclaration = [{
1076+ /// Determine whether the scope is empty, meaning it contains a single block
1077+ /// terminated by a cir.yield.
1078+ bool isEmpty() {
1079+ auto &entry = getRegion().front();
1080+ return getRegion().hasOneBlock() &&
1081+ llvm::isa<YieldOp>(entry.front());
1082+ }
1083+ }];
1084+
10731085 let builders = [
10741086 // Scopes for yielding values.
10751087 OpBuilder<(ins
@@ -1200,7 +1212,7 @@ def ShiftOp : CIR_Op<"shift", [Pure]> {
12001212 be either integer type or vector of integer type. However, they must be
12011213 either all vector of integer type, or all integer type. If they are vectors,
12021214 each vector element of the shift target is shifted by the corresponding
1203- shift amount in the shift amount vector.
1215+ shift amount in the shift amount vector.
12041216
12051217 ```mlir
12061218 %7 = cir.shift(left, %1 : !u64i, %4 : !s32i) -> !u64i
@@ -1879,17 +1891,17 @@ def SwitchOp : CIR_Op<"switch",
18791891 is an integral condition value.
18801892
18811893 The set of `cir.case` operations and their enclosing `cir.switch`
1882- represents the semantics of a C/C++ switch statement. Users can use
1894+ represents the semantics of a C/C++ switch statement. Users can use
18831895 `collectCases(llvm::SmallVector<CaseOp> &cases)` to collect the `cir.case`
18841896 operation in the `cir.switch` operation easily.
18851897
18861898 The `cir.case` operations doesn't have to be in the region of `cir.switch`
18871899 directly. However, when all the `cir.case` operations lives in the region
18881900 of `cir.switch` directly and there is no other operations except the ending
1889- `cir.yield` operation in the region of `cir.switch` directly, we call the
1890- `cir.switch` operation is in a simple form. Users can use
1901+ `cir.yield` operation in the region of `cir.switch` directly, we call the
1902+ `cir.switch` operation is in a simple form. Users can use
18911903 `bool isSimpleForm(llvm::SmallVector<CaseOp> &cases)` member function to
1892- detect if the `cir.switch` operation is in a simple form. The simple form
1904+ detect if the `cir.switch` operation is in a simple form. The simple form
18931905 makes analysis easier to handle the `cir.switch` operation
18941906 and makes the boundary to give up pretty clear.
18951907
@@ -1976,7 +1988,7 @@ def SwitchOp : CIR_Op<"switch",
19761988 switch(int cond) {
19771989 l:
19781990 b++;
1979-
1991+
19801992 case 4:
19811993 a++;
19821994 break;
@@ -4136,13 +4148,13 @@ def ReturnAddrOp : CIR_Op<"return_address"> {
41364148 let results = (outs Res<VoidPtr, "">:$result);
41374149
41384150 let description = [{
4139- Represents call to builtin function ` __builtin_return_address` in CIR.
4140- This builtin function returns the return address of the current function,
4141- or of one of its callers.
4151+ Represents call to builtin function ` __builtin_return_address` in CIR.
4152+ This builtin function returns the return address of the current function,
4153+ or of one of its callers.
41424154 The `level` argument is number of frames to scan up the call stack.
4143- For instance, value of 0 yields the return address of the current function,
4144- value of 1 yields the return address of the caller of the current function,
4145- and so forth.
4155+ For instance, value of 0 yields the return address of the current function,
4156+ value of 1 yields the return address of the caller of the current function,
4157+ and so forth.
41464158
41474159 Examples:
41484160
@@ -4282,8 +4294,8 @@ def AbsOp : CIR_Op<"abs", [Pure, SameOperandsAndResultType]> {
42824294 let summary = [{
42834295 libc builtin equivalent abs, labs, llabs
42844296
4285- The `poison` argument indicate whether the result value
4286- is a poison value if the first argument is statically or
4297+ The `poison` argument indicate whether the result value
4298+ is a poison value if the first argument is statically or
42874299 dynamically an INT_MIN value.
42884300
42894301 Example:
0 commit comments