Skip to content

Commit 25bca23

Browse files
committed
Address review feedback
1 parent 54454e4 commit 25bca23

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -477,20 +477,20 @@ def ConditionOp : CIR_Op<"condition", [
477477
`cir.bool` operand and, depending on its value, may branch to different
478478
regions:
479479

480-
- When in the `cond` region of a `cir.loop`, it continues the loop
480+
- When in the `cond` region of a loop, it continues the loop
481481
if true, or exits it if false.
482482
- When in the `ready` region of a `cir.await`, it branches to the `resume`
483483
region when true, and to the `suspend` region when false.
484484

485485
Example:
486486

487487
```mlir
488-
cir.loop for(cond : {
489-
cir.condition(%arg0) // Branches to `step` region or exits.
490-
}, step : {
491-
[...]
492-
}) {
493-
[...]
488+
cir.for cond {
489+
cir.condition(%val) // Branches to `step` region or exits.
490+
} body {
491+
cir.yield
492+
} step {
493+
cir.yield
494494
}
495495

496496
cir.await(user, ready : {
@@ -576,9 +576,9 @@ def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator,
576576
def BreakOp : CIR_Op<"break", [Terminator]> {
577577
let summary = "C/C++ `break` statement equivalent";
578578
let description = [{
579-
The `cir.break` operation is used to cease the control flow to the parent
580-
operation, exiting its region's control flow. It is only allowed if it is
581-
within a breakable operation (loops and `switch`).
579+
The `cir.break` operation is used to cease the execution of the current
580+
loop or switch and transfer control to the parent operation. It is only
581+
allowed within a breakable operations (loops and switches).
582582
}];
583583
let assemblyFormat = "attr-dict";
584584
let hasVerifier = 1;
@@ -591,8 +591,9 @@ def BreakOp : CIR_Op<"break", [Terminator]> {
591591
def ContinueOp : CIR_Op<"continue", [Terminator]> {
592592
let summary = "C/C++ `continue` statement equivalent";
593593
let description = [{
594-
The `cir.continue` operation is used to continue execution to the next
595-
iteration of a loop. It is only allowed within `cir.loop` regions.
594+
The `cir.continue` operation is used to end execution of the current
595+
iteration of a loop and resume execution beginning at the next iteration.
596+
It is only allowed within loop regions.
596597
}];
597598
let assemblyFormat = "attr-dict";
598599
let hasVerifier = 1;

clang/lib/CIR/CodeGen/CIRGenStmt.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ mlir::LogicalResult CIRGenFunction::emitStmt(const Stmt *s,
5656
return mlir::success();
5757

5858
switch (s->getStmtClass()) {
59+
case Stmt::BreakStmtClass:
60+
case Stmt::CompoundStmtClass:
61+
case Stmt::ContinueStmtClass:
62+
case Stmt::DeclStmtClass:
63+
case Stmt::ReturnStmtClass:
64+
llvm_unreachable("should have emitted these statements as simple");
65+
5966

6067
#define STMT(Type, Base)
6168
#define ABSTRACT_STMT(Op)
@@ -88,13 +95,9 @@ mlir::LogicalResult CIRGenFunction::emitStmt(const Stmt *s,
8895
case Stmt::SEHFinallyStmtClass:
8996
case Stmt::MSDependentExistsStmtClass:
9097
case Stmt::NullStmtClass:
91-
case Stmt::CompoundStmtClass:
92-
case Stmt::DeclStmtClass:
9398
case Stmt::LabelStmtClass:
9499
case Stmt::AttributedStmtClass:
95100
case Stmt::GotoStmtClass:
96-
case Stmt::BreakStmtClass:
97-
case Stmt::ContinueStmtClass:
98101
case Stmt::DefaultStmtClass:
99102
case Stmt::CaseStmtClass:
100103
case Stmt::SEHLeaveStmtClass:
@@ -106,7 +109,6 @@ mlir::LogicalResult CIRGenFunction::emitStmt(const Stmt *s,
106109
case Stmt::CXXTryStmtClass:
107110
case Stmt::CXXForRangeStmtClass:
108111
case Stmt::IndirectGotoStmtClass:
109-
case Stmt::ReturnStmtClass:
110112
case Stmt::GCCAsmStmtClass:
111113
case Stmt::MSAsmStmtClass:
112114
case Stmt::OMPParallelDirectiveClass:
@@ -219,7 +221,6 @@ mlir::LogicalResult CIRGenFunction::emitSimpleStmt(const Stmt *s,
219221
bool useCurrentScope) {
220222
switch (s->getStmtClass()) {
221223
default:
222-
// Only compound and return statements are supported right now.
223224
return mlir::failure();
224225
case Stmt::DeclStmtClass:
225226
return emitDeclStmt(cast<DeclStmt>(*s));

0 commit comments

Comments
 (0)