https://github.com/E00N777 created https://github.com/llvm/llvm-project/pull/216457
### summary The cir.while example had cond and body swapped, and several loop examples used outdated cir.condition / cir.for syntax. Also add short examples of the optional per-iteration cleanup region. Generated by Grok 4.6, but manually reviewed. >From 5e88c11bb09cc3004df7cd5bed4abb3c9ea18500 Mon Sep 17 00:00:00 2001 From: E00N777 <[email protected]> Date: Sat, 15 Aug 2026 14:36:05 +0800 Subject: [PATCH] [CIR][NFC] Fix loop op examples in CIROps.td --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 30 +++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 0f034a4f1f7fa..aec0801fdb7be 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -996,8 +996,8 @@ def CIR_ConditionOp : CIR_Op<"condition", [ Example: ``` - cir.for cond { - cir.condition(%val) // Branches to `step` region or exits. + cir.for : cond { + cir.condition(%val) // Branches to `body` region or exits. } body { cir.yield } step { @@ -2224,11 +2224,17 @@ def CIR_WhileOp : CIR_WhileOpBase<"while"> { ``` cir.while { - cir.break - ^bb2: + cir.condition(%cond) + } do { cir.yield + } + + cir.while { + cir.condition(%cond) } do { - cir.condition %cond : cir.bool + cir.yield + } cleanup all { + cir.yield } ``` }]; @@ -2293,7 +2299,7 @@ def CIR_DoWhileOp : CIR_WhileOpBase<"do"> { ^bb2: cir.yield } while { - cir.condition %cond : cir.bool + cir.condition(%cond) } ``` }]; @@ -2324,7 +2330,7 @@ def CIR_ForOp : CIR_LoopOpBase<"for"> { Example: ``` - cir.for cond { + cir.for : cond { cir.condition(%val) } body { cir.break @@ -2333,6 +2339,16 @@ def CIR_ForOp : CIR_LoopOpBase<"for"> { } step { cir.yield } + + cir.for : cond { + cir.condition(%val) + } body { + cir.yield + } step { + cir.yield + } cleanup all { + cir.yield + } ``` }]; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
