================ @@ -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, ---------------- andykaylor wrote:
Yeah, we haven't been fitting the .td files in 80 columns, though I have also thought we probably should do so. It looks like tablegen will accept it like this: ``` let builders = [ OpBuilder<(ins "llvm::function_ref<void(mlir::OpBuilder &, " "mlir::Location)>":$condBuilder, "llvm::function_ref<void(mlir::OpBuilder &, " "mlir::Location)>":$bodyBuilder), [{ mlir::OpBuilder::InsertionGuard guard($_builder); $_builder.createBlock($_state.addRegion()); }] # !if(isWhile, [{ condBuilder($_builder, $_state.location); $_builder.createBlock($_state.addRegion()); bodyBuilder($_builder, $_state.location); }], [{ bodyBuilder($_builder, $_state.location); $_builder.createBlock($_state.addRegion()); condBuilder($_builder, $_state.location); }])> ]; ``` What do you think? Is that readable? https://github.com/llvm/llvm-project/pull/133157 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits