[clang] [CIR] Upstream support for while and do..while loops (PR #133157)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 27 02:59:37 PDT 2025
================
@@ -759,6 +761,84 @@ def BrCondOp : CIR_Op<"brcond",
}];
}
+//===----------------------------------------------------------------------===//
+// While & DoWhileOp
+//===----------------------------------------------------------------------===//
+
+class WhileOpBase<string mnemonic> : CIR_Op<mnemonic, [
+ LoopOpInterface,
+ NoRegionArguments,
+]> {
+ defvar isWhile = !eq(mnemonic, "while");
+ let summary = "C/C++ " # !if(isWhile, "while", "do-while") # " loop";
+ let builders = [
+ OpBuilder<(ins "llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)>":$condBuilder,
----------------
xlauko wrote:
Other option is to add type alias. Something like `BuilderCallbackRef`.
Then you need to define it before `CIROps.h.inc` is included in `CIRDialect.h`:
```
using BuilderCallbackRef = llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)>;
```
This turned out to be useful in vast on multiple places to make builders more readable.
https://github.com/llvm/llvm-project/pull/133157
More information about the cfe-commits
mailing list