diff --git a/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td b/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td --- a/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td +++ b/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.td @@ -73,12 +73,6 @@ DeclareOpInterfaceMethods]>, Arguments<(ins From:$in)>, Results<(outs To:$out)> { - let builders = [ - OpBuilder<(ins "Value":$source, "Type":$destType), [{ - impl::buildCastOp($_builder, $_state, source, destType); - }]> - ]; - let assemblyFormat = "$in attr-dict `:` type($in) `to` type($out)"; } diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td --- a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td +++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td @@ -374,11 +374,6 @@ let arguments = (ins AnyRankedOrUnrankedMemRef:$source); let results = (outs AnyRankedOrUnrankedMemRef:$dest); let assemblyFormat = "$source attr-dict `:` type($source) `to` type($dest)"; - let builders = [ - OpBuilder<(ins "Value":$source, "Type":$destType), [{ - impl::buildCastOp($_builder, $_state, source, destType); - }]> - ]; let extraClassDeclaration = [{ /// Fold the given CastOp into consumer op. diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -1003,11 +1003,11 @@ switch (conversion) { case PrintConversion::ZeroExt64: value = rewriter.create( - loc, value, IntegerType::get(rewriter.getContext(), 64)); + loc, IntegerType::get(rewriter.getContext(), 64), value); break; case PrintConversion::SignExt64: value = rewriter.create( - loc, value, IntegerType::get(rewriter.getContext(), 64)); + loc, IntegerType::get(rewriter.getContext(), 64), value); break; case PrintConversion::None: break; diff --git a/mlir/lib/Dialect/Arithmetic/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arithmetic/Transforms/BufferizableOpInterfaceImpl.cpp --- a/mlir/lib/Dialect/Arithmetic/Transforms/BufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Arithmetic/Transforms/BufferizableOpInterfaceImpl.cpp @@ -94,8 +94,8 @@ getMemRefType(castOp.getType().cast(), state.getOptions(), layout, sourceType.getMemorySpace()); - replaceOpWithNewBufferizedOp(rewriter, op, source, - resultType); + replaceOpWithNewBufferizedOp(rewriter, op, resultType, + source); return success(); } }; diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp @@ -835,15 +835,15 @@ scalingFactor); } Value numWorkersIndex = - b.create(numWorkerThreadsVal, b.getI32Type()); + b.create(b.getI32Type(), numWorkerThreadsVal); Value numWorkersFloat = - b.create(numWorkersIndex, b.getF32Type()); + b.create(b.getF32Type(), numWorkersIndex); Value scaledNumWorkers = b.create(scalingFactor, numWorkersFloat); Value scaledNumInt = - b.create(scaledNumWorkers, b.getI32Type()); + b.create(b.getI32Type(), scaledNumWorkers); Value scaledWorkers = - b.create(scaledNumInt, b.getIndexType()); + b.create(b.getIndexType(), scaledNumInt); Value maxComputeBlocks = b.create( b.create(1), scaledWorkers); diff --git a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp --- a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp +++ b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp @@ -887,7 +887,7 @@ auto i32Vec = broadcast(builder.getI32Type(), shape); // exp2(k) - Value k = builder.create(kF32, i32Vec); + Value k = builder.create(i32Vec, kF32); Value exp2KValue = exp2I32(builder, k); // exp(x) = exp(y) * exp2(k) @@ -1042,7 +1042,7 @@ auto i32Vec = broadcast(builder.getI32Type(), shape); auto fPToSingedInteger = [&](Value a) -> Value { - return builder.create(a, i32Vec); + return builder.create(i32Vec, a); }; auto modulo4 = [&](Value a) -> Value { diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp --- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp +++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp @@ -164,7 +164,7 @@ alloc.alignmentAttr()); // Insert a cast so we have the same type as the old alloc. auto resultCast = - rewriter.create(alloc.getLoc(), newAlloc, alloc.getType()); + rewriter.create(alloc.getLoc(), alloc.getType(), newAlloc); rewriter.replaceOp(alloc, {resultCast}); return success(); @@ -2155,8 +2155,8 @@ rewriter.replaceOp(subViewOp, subViewOp.source()); return success(); } - rewriter.replaceOpWithNewOp(subViewOp, subViewOp.source(), - subViewOp.getType()); + rewriter.replaceOpWithNewOp(subViewOp, subViewOp.getType(), + subViewOp.source()); return success(); } }; @@ -2176,7 +2176,7 @@ /// A canonicalizer wrapper to replace SubViewOps. struct SubViewCanonicalizer { void operator()(PatternRewriter &rewriter, SubViewOp op, SubViewOp newOp) { - rewriter.replaceOpWithNewOp(op, newOp, op.getType()); + rewriter.replaceOpWithNewOp(op, op.getType(), newOp); } }; @@ -2421,7 +2421,7 @@ viewOp.getOperand(0), viewOp.byte_shift(), newOperands); // Insert a cast so we have the same type as the old memref type. - rewriter.replaceOpWithNewOp(viewOp, newViewOp, viewOp.getType()); + rewriter.replaceOpWithNewOp(viewOp, viewOp.getType(), newViewOp); return success(); } }; diff --git a/mlir/lib/Dialect/MemRef/Transforms/ExpandOps.cpp b/mlir/lib/Dialect/MemRef/Transforms/ExpandOps.cpp --- a/mlir/lib/Dialect/MemRef/Transforms/ExpandOps.cpp +++ b/mlir/lib/Dialect/MemRef/Transforms/ExpandOps.cpp @@ -101,8 +101,8 @@ Value index = rewriter.create(loc, i); size = rewriter.create(loc, op.shape(), index); if (!size.getType().isa()) - size = rewriter.create(loc, size, - rewriter.getIndexType()); + size = rewriter.create( + loc, rewriter.getIndexType(), size); sizes[i] = size; } else { sizes[i] = rewriter.getIndexAttr(op.getType().getDimSize(i)); diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp @@ -309,7 +309,7 @@ Value val = rewriter.create(loc, indices, ValueRange{ivs[0], idx}); val = - rewriter.create(loc, val, rewriter.getIndexType()); + rewriter.create(loc, rewriter.getIndexType(), val); rewriter.create(loc, val, ind, idx); } return rewriter.create(loc, values, ivs[0]); diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp @@ -831,11 +831,11 @@ if (!etp.isa()) { if (etp.getIntOrFloatBitWidth() < 32) vload = rewriter.create( - loc, vload, vectorType(codegen, rewriter.getI32Type())); + loc, vectorType(codegen, rewriter.getI32Type()), vload); else if (etp.getIntOrFloatBitWidth() < 64 && !codegen.options.enableSIMDIndex32) vload = rewriter.create( - loc, vload, vectorType(codegen, rewriter.getI64Type())); + loc, vectorType(codegen, rewriter.getI64Type()), vload); } return vload; } @@ -846,9 +846,9 @@ Value load = rewriter.create(loc, ptr, s); if (!load.getType().isa()) { if (load.getType().getIntOrFloatBitWidth() < 64) - load = rewriter.create(loc, load, rewriter.getI64Type()); + load = rewriter.create(loc, rewriter.getI64Type(), load); load = - rewriter.create(loc, load, rewriter.getIndexType()); + rewriter.create(loc, rewriter.getIndexType(), load); } return load; } @@ -868,7 +868,7 @@ Value mul = rewriter.create(loc, size, p); if (auto vtp = i.getType().dyn_cast()) { Value inv = - rewriter.create(loc, mul, vtp.getElementType()); + rewriter.create(loc, vtp.getElementType(), mul); mul = genVectorInvariantValue(codegen, rewriter, inv); } return rewriter.create(loc, mul, i); diff --git a/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp b/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp --- a/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp +++ b/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp @@ -671,25 +671,25 @@ rewriter.getZeroAttr(v0.getType())), v0); case kTruncF: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); case kExtF: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); case kCastFS: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); case kCastFU: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); case kCastSF: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); case kCastUF: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); case kCastS: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); case kCastU: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); case kTruncI: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); case kBitCast: - return rewriter.create(loc, v0, inferType(e, v0)); + return rewriter.create(loc, inferType(e, v0), v0); // Binary ops. case kMulF: return rewriter.create(loc, v0, v1); diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp --- a/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp @@ -255,7 +255,7 @@ [&](OpBuilder &b, Location loc) { Value res = memref; if (compatibleMemRefType != xferOp.getShapedType()) - res = b.create(loc, memref, compatibleMemRefType); + res = b.create(loc, compatibleMemRefType, memref); scf::ValueVector viewAndIndices{res}; viewAndIndices.insert(viewAndIndices.end(), xferOp.indices().begin(), xferOp.indices().end()); @@ -271,7 +271,7 @@ alloc); b.create(loc, copyArgs.first, copyArgs.second); Value casted = - b.create(loc, alloc, compatibleMemRefType); + b.create(loc, compatibleMemRefType, alloc); scf::ValueVector viewAndIndices{casted}; viewAndIndices.insert(viewAndIndices.end(), xferOp.getTransferRank(), zero); @@ -309,7 +309,7 @@ [&](OpBuilder &b, Location loc) { Value res = memref; if (compatibleMemRefType != xferOp.getShapedType()) - res = b.create(loc, memref, compatibleMemRefType); + res = b.create(loc, compatibleMemRefType, memref); scf::ValueVector viewAndIndices{res}; viewAndIndices.insert(viewAndIndices.end(), xferOp.indices().begin(), xferOp.indices().end()); @@ -324,7 +324,7 @@ loc, MemRefType::get({}, vector.getType()), alloc)); Value casted = - b.create(loc, alloc, compatibleMemRefType); + b.create(loc, compatibleMemRefType, alloc); scf::ValueVector viewAndIndices{casted}; viewAndIndices.insert(viewAndIndices.end(), xferOp.getTransferRank(), zero); @@ -360,7 +360,7 @@ [&](OpBuilder &b, Location loc) { Value res = memref; if (compatibleMemRefType != xferOp.getShapedType()) - res = b.create(loc, memref, compatibleMemRefType); + res = b.create(loc, compatibleMemRefType, memref); scf::ValueVector viewAndIndices{res}; viewAndIndices.insert(viewAndIndices.end(), xferOp.indices().begin(), @@ -369,7 +369,7 @@ }, [&](OpBuilder &b, Location loc) { Value casted = - b.create(loc, alloc, compatibleMemRefType); + b.create(loc, compatibleMemRefType, alloc); scf::ValueVector viewAndIndices{casted}; viewAndIndices.insert(viewAndIndices.end(), xferOp.getTransferRank(), zero);