Skip to content

Commit a40e28d

Browse files
committed
add ConstantIntOp constructor for APInt types
1 parent ad9e591 commit a40e28d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

mlir/include/mlir/Dialect/Arith/IR/Arith.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ class ConstantIntOp : public arith::ConstantOp {
6565
static void build(OpBuilder &builder, OperationState &result, int64_t value,
6666
Type type);
6767

68+
/// Build a constant int op that produces an integer from an APInt
69+
static void build(OpBuilder &builder, OperationState &result, Type type,
70+
const APInt &value);
71+
6872
inline int64_t value() {
6973
return cast<IntegerAttr>(arith::ConstantOp::getValue()).getInt();
7074
}

mlir/lib/Dialect/Arith/IR/ArithOps.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ void arith::ConstantIntOp::build(OpBuilder &builder, OperationState &result,
264264
builder.getIntegerAttr(type, value));
265265
}
266266

267+
void arith::ConstantIntOp::build(OpBuilder &builder, OperationState &result,
268+
Type type, const APInt &value) {
269+
arith::ConstantOp::build(builder, result, type,
270+
builder.getIntegerAttr(type, value));
271+
}
272+
267273
bool arith::ConstantIntOp::classof(Operation *op) {
268274
if (auto constOp = dyn_cast_or_null<arith::ConstantOp>(op))
269275
return constOp.getType().isSignlessInteger();

0 commit comments

Comments
 (0)