diff --git a/mlir/include/mlir/Dialect/Arith/IR/Arith.h b/mlir/include/mlir/Dialect/Arith/IR/Arith.h index 77241319851e6..a4332a8395576 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, int64_t value, Type type); + /// 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 9e53e195274aa..e36018654719d 100644 --- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp +++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp @@ -264,6 +264,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();