mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-13 05:40:59 +00:00
Swap the type and attribute parameter in ConstantOp::build()
This is to keep consistent with other TableGen generated builders so that we can also use this builder in TableGen rules. PiperOrigin-RevId: 229244630
This commit is contained in:
parent
ed26dd0421
commit
61ec6c0992
@ -273,8 +273,8 @@ class ConstantOp : public Op<ConstantOp, OpTrait::ZeroOperands,
|
||||
OpTrait::OneResult, OpTrait::HasNoSideEffect> {
|
||||
public:
|
||||
/// Builds a constant op with the specified attribute value and result type.
|
||||
static void build(Builder *builder, OperationState *result, Attribute value,
|
||||
Type type);
|
||||
static void build(Builder *builder, OperationState *result, Type type,
|
||||
Attribute value);
|
||||
|
||||
Attribute getValue() const { return getAttr("value"); }
|
||||
|
||||
|
@ -445,8 +445,8 @@ void CondBranchOp::eraseFalseOperand(unsigned index) {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// Builds a constant op with the specified attribute value and result type.
|
||||
void ConstantOp::build(Builder *builder, OperationState *result,
|
||||
Attribute value, Type type) {
|
||||
void ConstantOp::build(Builder *builder, OperationState *result, Type type,
|
||||
Attribute value) {
|
||||
result->addAttribute("value", value);
|
||||
result->types.push_back(type);
|
||||
}
|
||||
@ -541,7 +541,7 @@ Attribute ConstantOp::constantFold(ArrayRef<Attribute> operands,
|
||||
|
||||
void ConstantFloatOp::build(Builder *builder, OperationState *result,
|
||||
const APFloat &value, FloatType type) {
|
||||
ConstantOp::build(builder, result, builder->getFloatAttr(type, value), type);
|
||||
ConstantOp::build(builder, result, type, builder->getFloatAttr(type, value));
|
||||
}
|
||||
|
||||
bool ConstantFloatOp::isClassFor(const OperationInst *op) {
|
||||
@ -558,8 +558,8 @@ bool ConstantIntOp::isClassFor(const OperationInst *op) {
|
||||
void ConstantIntOp::build(Builder *builder, OperationState *result,
|
||||
int64_t value, unsigned width) {
|
||||
Type type = builder->getIntegerType(width);
|
||||
ConstantOp::build(builder, result, builder->getIntegerAttr(type, value),
|
||||
type);
|
||||
ConstantOp::build(builder, result, type,
|
||||
builder->getIntegerAttr(type, value));
|
||||
}
|
||||
|
||||
/// Build a constant int op producing an integer with the specified type,
|
||||
@ -567,8 +567,8 @@ void ConstantIntOp::build(Builder *builder, OperationState *result,
|
||||
void ConstantIntOp::build(Builder *builder, OperationState *result,
|
||||
int64_t value, Type type) {
|
||||
assert(type.isa<IntegerType>() && "ConstantIntOp can only have integer type");
|
||||
ConstantOp::build(builder, result, builder->getIntegerAttr(type, value),
|
||||
type);
|
||||
ConstantOp::build(builder, result, type,
|
||||
builder->getIntegerAttr(type, value));
|
||||
}
|
||||
|
||||
/// ConstantIndexOp only matches values whose result type is Index.
|
||||
@ -579,8 +579,8 @@ bool ConstantIndexOp::isClassFor(const OperationInst *op) {
|
||||
void ConstantIndexOp::build(Builder *builder, OperationState *result,
|
||||
int64_t value) {
|
||||
Type type = builder->getIndexType();
|
||||
ConstantOp::build(builder, result, builder->getIntegerAttr(type, value),
|
||||
type);
|
||||
ConstantOp::build(builder, result, type,
|
||||
builder->getIntegerAttr(type, value));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -1197,7 +1197,7 @@ struct SimplifyMulX0 : public RewritePattern {
|
||||
void rewrite(OperationInst *op, PatternRewriter &rewriter) const override {
|
||||
auto type = op->getOperand(0)->getType();
|
||||
auto zeroAttr = rewriter.getZeroAttr(type);
|
||||
rewriter.replaceOpWithNewOp<ConstantOp>(op, zeroAttr, type);
|
||||
rewriter.replaceOpWithNewOp<ConstantOp>(op, type, zeroAttr);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -87,8 +87,8 @@ void ConstantFold::visitOperationInst(OperationInst *op) {
|
||||
if (res->use_empty()) // ignore dead uses.
|
||||
continue;
|
||||
|
||||
auto cst = builder.create<ConstantOp>(op->getLoc(), resultConstants[i],
|
||||
res->getType());
|
||||
auto cst = builder.create<ConstantOp>(op->getLoc(), res->getType(),
|
||||
resultConstants[i]);
|
||||
existingConstants.push_back(cst);
|
||||
res->replaceAllUsesWith(cst);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public:
|
||||
auto valueAttr =
|
||||
builder.getIntegerAttr(builder.getIndexType(), expr.getValue());
|
||||
auto op =
|
||||
builder.create<ConstantOp>(loc, valueAttr, builder.getIndexType());
|
||||
builder.create<ConstantOp>(loc, builder.getIndexType(), valueAttr);
|
||||
return op->getResult();
|
||||
}
|
||||
|
||||
|
@ -213,8 +213,8 @@ void GreedyPatternRewriteDriver::simplifyFunction() {
|
||||
if (it != uniquedConstants.end())
|
||||
cstValue = it->second->getResult(0);
|
||||
else
|
||||
cstValue = create<ConstantOp>(op->getLoc(), resultConstants[i],
|
||||
res->getType());
|
||||
cstValue = create<ConstantOp>(op->getLoc(), res->getType(),
|
||||
resultConstants[i]);
|
||||
|
||||
// Add all the users of the result to the worklist so we make sure to
|
||||
// revisit them.
|
||||
|
Loading…
x
Reference in New Issue
Block a user