diff --git a/mlir/include/mlir/Dialect/Arith/IR/Arith.h b/mlir/include/mlir/Dialect/Arith/IR/Arith.h index 0bee876ac9bfa..4e32df1c3e30c 100644 --- a/mlir/include/mlir/Dialect/Arith/IR/Arith.h +++ b/mlir/include/mlir/Dialect/Arith/IR/Arith.h @@ -65,6 +65,10 @@ class ConstantIntOp : public arith::ConstantOp { static void build(OpBuilder &builder, OperationState &result, Type type, int64_t value); + /// Build a constant int op that produces an integer from an APInt + static void build(OpBuilder &builder, OperationState &result, Type type, + const APInt &value); + inline int64_t value() { return cast(arith::ConstantOp::getValue()).getInt(); } diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp index 5194f2b58669a..10f9c06d7f08c 100644 --- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp +++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp @@ -262,6 +262,12 @@ void arith::ConstantIntOp::build(OpBuilder &builder, OperationState &result, builder.getIntegerAttr(type, value)); } +void arith::ConstantIntOp::build(OpBuilder &builder, OperationState &result, + Type type, const APInt &value) { + arith::ConstantOp::build(builder, result, type, + builder.getIntegerAttr(type, value)); +} + bool arith::ConstantIntOp::classof(Operation *op) { if (auto constOp = dyn_cast_or_null(op)) return constOp.getType().isSignlessInteger();