diff --git a/mlir/include/mlir/IR/BuiltinOps.h b/mlir/include/mlir/IR/BuiltinOps.h index df187d637089..b182d1f709a0 100644 --- a/mlir/include/mlir/IR/BuiltinOps.h +++ b/mlir/include/mlir/IR/BuiltinOps.h @@ -273,8 +273,8 @@ class ConstantOp : public Op { 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"); } diff --git a/mlir/lib/IR/BuiltinOps.cpp b/mlir/lib/IR/BuiltinOps.cpp index 8d7d7d8be23f..94fa58139af4 100644 --- a/mlir/lib/IR/BuiltinOps.cpp +++ b/mlir/lib/IR/BuiltinOps.cpp @@ -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 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() && "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)); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/StandardOps/StandardOps.cpp b/mlir/lib/StandardOps/StandardOps.cpp index 6eff636263bc..249812e410fc 100644 --- a/mlir/lib/StandardOps/StandardOps.cpp +++ b/mlir/lib/StandardOps/StandardOps.cpp @@ -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(op, zeroAttr, type); + rewriter.replaceOpWithNewOp(op, type, zeroAttr); } }; diff --git a/mlir/lib/Transforms/ConstantFold.cpp b/mlir/lib/Transforms/ConstantFold.cpp index 8369e3ad43b0..4065068eb823 100644 --- a/mlir/lib/Transforms/ConstantFold.cpp +++ b/mlir/lib/Transforms/ConstantFold.cpp @@ -87,8 +87,8 @@ void ConstantFold::visitOperationInst(OperationInst *op) { if (res->use_empty()) // ignore dead uses. continue; - auto cst = builder.create(op->getLoc(), resultConstants[i], - res->getType()); + auto cst = builder.create(op->getLoc(), res->getType(), + resultConstants[i]); existingConstants.push_back(cst); res->replaceAllUsesWith(cst); } diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp index ce70fe65c13e..1756b3fdd2c4 100644 --- a/mlir/lib/Transforms/LowerAffine.cpp +++ b/mlir/lib/Transforms/LowerAffine.cpp @@ -187,7 +187,7 @@ public: auto valueAttr = builder.getIntegerAttr(builder.getIndexType(), expr.getValue()); auto op = - builder.create(loc, valueAttr, builder.getIndexType()); + builder.create(loc, builder.getIndexType(), valueAttr); return op->getResult(); } diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index 3cd6bc8bb685..4ee632b68ffa 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -213,8 +213,8 @@ void GreedyPatternRewriteDriver::simplifyFunction() { if (it != uniquedConstants.end()) cstValue = it->second->getResult(0); else - cstValue = create(op->getLoc(), resultConstants[i], - res->getType()); + cstValue = create(op->getLoc(), res->getType(), + resultConstants[i]); // Add all the users of the result to the worklist so we make sure to // revisit them.