-
Notifications
You must be signed in to change notification settings - Fork 14k
add arith::ConstantIntOp
constructor
#144638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-arith Author: Skrai Pardus (ashjeong) ChangesAdded a Full diff: https://github.com/llvm/llvm-project/pull/144638.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Arith/IR/Arith.h b/mlir/include/mlir/Dialect/Arith/IR/Arith.h
index 77241319851e6..4d88bbe507e2b 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/Arith.h
+++ b/mlir/include/mlir/Dialect/Arith/IR/Arith.h
@@ -56,6 +56,8 @@ class ConstantIntOp : public arith::ConstantOp {
using arith::ConstantOp::ConstantOp;
static ::mlir::TypeID resolveTypeID() { return TypeID::get<ConstantOp>(); }
+ using arith::ConstantOp::build;
+
/// Build a constant int op that produces an integer of the specified width.
static void build(OpBuilder &builder, OperationState &result, int64_t value,
unsigned width);
@@ -65,6 +67,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<IntegerAttr>(arith::ConstantOp::getValue()).getInt();
}
@@ -78,6 +84,8 @@ class ConstantFloatOp : public arith::ConstantOp {
using arith::ConstantOp::ConstantOp;
static ::mlir::TypeID resolveTypeID() { return TypeID::get<ConstantOp>(); }
+ using arith::ConstantOp::build;
+
/// Build a constant float op that produces a float of the specified type.
static void build(OpBuilder &builder, OperationState &result,
const APFloat &value, FloatType type);
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<arith::ConstantOp>(op))
return constOp.getType().isSignlessInteger();
|
arith::ConstantIntOp
constructor
@@ -56,6 +56,8 @@ class ConstantIntOp : public arith::ConstantOp { | |||
using arith::ConstantOp::ConstantOp; | |||
static ::mlir::TypeID resolveTypeID() { return TypeID::get<ConstantOp>(); } | |||
|
|||
using arith::ConstantOp::build; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? The base constructors may be intentionally hidden.
static void build(OpBuilder &builder, OperationState &result, Type type, | ||
const APInt &value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the order between type and value in this constructor with respect to other constructors is highly confusing. Please revise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I requested in a previous PR to change the order of type/value for the other constructors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using arith::ConstantOp::build; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make changes that are irrelevant to the PR description. It says ConstantIntOp
, it shouldn't touch ConstantFloatOp
or say otherwise.
0298d1b
to
a40e28d
Compare
Added a
build()
constructor forConstantIntOp
that takes in anAPInt
.To be merged after #144636