[clang] [CIR] Add binary operators (PR #132420)
Morris Hafner via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 24 07:26:25 PDT 2025
================
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+ return create<cir::BinOp>(lhs.getLoc(), lhs.getType(), kind, lhs,
+ getConstAPInt(lhs.getLoc(), lhs.getType(), rhs));
+ }
+
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ mlir::Value rhs) {
+ return create<cir::BinOp>(lhs.getLoc(), lhs.getType(), kind, lhs, rhs);
----------------
mmha wrote:
Very nice catch. The source locations of all binops except for division were not passed through. I changed the signature of the builder functions to require an `mlir::Location`. If there's a future need for an overload without a location we can add those later.
https://github.com/llvm/llvm-project/pull/132420
More information about the cfe-commits
mailing list