diff --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h --- a/flang/include/flang/Lower/Support/Utils.h +++ b/flang/include/flang/Lower/Support/Utils.h @@ -16,7 +16,7 @@ #include "flang/Common/indirection.h" #include "flang/Parser/char-block.h" #include "flang/Semantics/tools.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/BuiltinAttributes.h" #include "llvm/ADT/StringRef.h" #include diff --git a/flang/include/flang/Optimizer/Builder/Factory.h b/flang/include/flang/Optimizer/Builder/Factory.h --- a/flang/include/flang/Optimizer/Builder/Factory.h +++ b/flang/include/flang/Optimizer/Builder/Factory.h @@ -17,7 +17,7 @@ #include "flang/Optimizer/Dialect/FIROps.h" #include "flang/Optimizer/Dialect/FIRType.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "llvm/ADT/iterator_range.h" namespace mlir { diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Character.h b/flang/include/flang/Optimizer/Builder/Runtime/Character.h --- a/flang/include/flang/Optimizer/Builder/Runtime/Character.h +++ b/flang/include/flang/Optimizer/Builder/Runtime/Character.h @@ -9,7 +9,7 @@ #ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_CHARACTER_H #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_CHARACTER_H -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" namespace fir { class ExtendedValue; diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Numeric.h b/flang/include/flang/Optimizer/Builder/Runtime/Numeric.h --- a/flang/include/flang/Optimizer/Builder/Runtime/Numeric.h +++ b/flang/include/flang/Optimizer/Builder/Runtime/Numeric.h @@ -9,7 +9,7 @@ #ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_NUMERIC_H #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_NUMERIC_H -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" namespace fir { class ExtendedValue; diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h b/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h --- a/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h +++ b/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h @@ -16,7 +16,7 @@ #ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_REDUCTION_H #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_REDUCTION_H -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" namespace fir { class ExtendedValue; diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Transformational.h b/flang/include/flang/Optimizer/Builder/Runtime/Transformational.h --- a/flang/include/flang/Optimizer/Builder/Runtime/Transformational.h +++ b/flang/include/flang/Optimizer/Builder/Runtime/Transformational.h @@ -10,7 +10,7 @@ #ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_TRANSFORMATIONAL_H #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_TRANSFORMATIONAL_H -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" namespace fir { class ExtendedValue; diff --git a/flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td b/flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td --- a/flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td +++ b/flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td @@ -16,7 +16,6 @@ include "mlir/IR/OpBase.td" include "mlir/Dialect/Arithmetic/IR/ArithmeticOps.td" -include "mlir/Dialect/StandardOps/IR/Ops.td" include "flang/Optimizer/Dialect/FIROps.td" def IdenticalTypePred : Constraint>; diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.h b/flang/include/flang/Optimizer/Dialect/FIROps.h --- a/flang/include/flang/Optimizer/Dialect/FIROps.h +++ b/flang/include/flang/Optimizer/Dialect/FIROps.h @@ -11,7 +11,7 @@ #include "flang/Optimizer/Dialect/FIRType.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Interfaces/LoopLikeInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" diff --git a/flang/include/flang/Optimizer/Dialect/FIROpsSupport.h b/flang/include/flang/Optimizer/Dialect/FIROpsSupport.h --- a/flang/include/flang/Optimizer/Dialect/FIROpsSupport.h +++ b/flang/include/flang/Optimizer/Dialect/FIROpsSupport.h @@ -10,7 +10,7 @@ #define FORTRAN_OPTIMIZER_DIALECT_FIROPSSUPPORT_H #include "flang/Optimizer/Dialect/FIROps.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/BuiltinOps.h" namespace fir { @@ -25,7 +25,7 @@ /// return true iff the Operation is a call inline bool isaCall(mlir::Operation *op) { return isa(op) || isa(op) || - isa(op) || isa(op); + isa(op) || isa(op); } /// return true iff the Operation is a fir::CallOp, fir::DispatchOp, diff --git a/flang/include/flang/Optimizer/Support/InitFIR.h b/flang/include/flang/Optimizer/Support/InitFIR.h --- a/flang/include/flang/Optimizer/Support/InitFIR.h +++ b/flang/include/flang/Optimizer/Support/InitFIR.h @@ -28,7 +28,7 @@ mlir::AffineDialect, FIROpsDialect, mlir::acc::OpenACCDialect, \ mlir::omp::OpenMPDialect, mlir::scf::SCFDialect, \ mlir::arith::ArithmeticDialect, mlir::cf::ControlFlowDialect, \ - mlir::StandardOpsDialect, mlir::vector::VectorDialect + mlir::func::FuncDialect, mlir::vector::VectorDialect // The definitive list of dialects used by flang. #define FLANG_DIALECT_LIST \ diff --git a/flang/include/flang/Optimizer/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h --- a/flang/include/flang/Optimizer/Support/Utils.h +++ b/flang/include/flang/Optimizer/Support/Utils.h @@ -15,7 +15,7 @@ #include "flang/Common/default-kinds.h" #include "flang/Optimizer/Dialect/FIRType.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/BuiltinAttributes.h" namespace fir { diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td b/flang/include/flang/Optimizer/Transforms/Passes.td --- a/flang/include/flang/Optimizer/Transforms/Passes.td +++ b/flang/include/flang/Optimizer/Transforms/Passes.td @@ -25,7 +25,7 @@ }]; let constructor = "::fir::createAbstractResultOptPass()"; let dependentDialects = [ - "fir::FIROpsDialect", "mlir::StandardOpsDialect" + "fir::FIROpsDialect", "mlir::func::FuncDialect" ]; let options = [ Option<"passResultAsBox", "abstract-result-as-box", @@ -56,7 +56,7 @@ }]; let constructor = "::fir::createPromoteToAffinePass()"; let dependentDialects = [ - "fir::FIROpsDialect", "mlir::StandardOpsDialect", "mlir::AffineDialect" + "fir::FIROpsDialect", "mlir::func::FuncDialect", "mlir::AffineDialect" ]; } @@ -70,7 +70,7 @@ }]; let constructor = "::fir::createAffineDemotionPass()"; let dependentDialects = [ - "fir::FIROpsDialect", "mlir::StandardOpsDialect", "mlir::AffineDialect" + "fir::FIROpsDialect", "mlir::func::FuncDialect", "mlir::AffineDialect" ]; } @@ -122,7 +122,7 @@ }]; let constructor = "::fir::createFirToCfgPass()"; let dependentDialects = [ - "fir::FIROpsDialect", "mlir::StandardOpsDialect" + "fir::FIROpsDialect", "mlir::func::FuncDialect" ]; let options = [ Option<"forceLoopToExecuteOnce", "always-execute-loop-body", "bool", @@ -148,7 +148,7 @@ }]; let constructor = "::fir::createMemDataFlowOptPass()"; let dependentDialects = [ - "fir::FIROpsDialect", "mlir::StandardOpsDialect" + "fir::FIROpsDialect", "mlir::func::FuncDialect" ]; } diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -427,7 +427,7 @@ /// Generate the cleanup block before the program exits void genExitRoutine() { if (blockIsUnterminated()) - builder->create(toLocation()); + builder->create(toLocation()); } void genFIR(const Fortran::parser::EndProgramStmt &) { genExitRoutine(); } @@ -459,7 +459,7 @@ TODO(loc, "Convert to actual type"); return builder->create(loc, resultRef); }); - builder->create(loc, resultVal); + builder->create(loc, resultVal); } void genFIRProcedureExit(Fortran::lower::pft::FunctionLikeUnit &funit, diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt --- a/flang/lib/Lower/CMakeLists.txt +++ b/flang/lib/Lower/CMakeLists.txt @@ -37,9 +37,9 @@ FortranEvaluate FortranSemantics MLIRAffineToStandard + MLIRFunc MLIRLLVMIR MLIRSCFToControlFlow - MLIRStandard LINK_COMPONENTS Support diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -31,7 +31,7 @@ #include "flang/Semantics/symbol.h" #include "flang/Semantics/tools.h" #include "flang/Semantics/type.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "llvm/Support/Debug.h" #define DEBUG_TYPE "flang-lower-expr" diff --git a/flang/lib/Optimizer/Builder/Runtime/Character.cpp b/flang/lib/Optimizer/Builder/Runtime/Character.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Character.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Character.cpp @@ -13,7 +13,7 @@ #include "flang/Optimizer/Builder/FIRBuilder.h" #include "flang/Optimizer/Builder/Runtime/RTBuilder.h" #include "flang/Runtime/character.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" using namespace Fortran::runtime; diff --git a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp @@ -12,7 +12,7 @@ #include "flang/Optimizer/Builder/FIRBuilder.h" #include "flang/Optimizer/Builder/Runtime/RTBuilder.h" #include "flang/Runtime/numeric.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" using namespace Fortran::runtime; diff --git a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp @@ -13,7 +13,7 @@ #include "flang/Optimizer/Builder/FIRBuilder.h" #include "flang/Optimizer/Builder/Runtime/RTBuilder.h" #include "flang/Runtime/reduction.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" using namespace Fortran::runtime; diff --git a/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp b/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp @@ -15,7 +15,7 @@ #include "flang/Optimizer/Builder/Runtime/RTBuilder.h" #include "flang/Runtime/matmul.h" #include "flang/Runtime/transformational.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" using namespace Fortran::runtime; diff --git a/flang/lib/Optimizer/CodeGen/CGOps.h b/flang/lib/Optimizer/CodeGen/CGOps.h --- a/flang/lib/Optimizer/CodeGen/CGOps.h +++ b/flang/lib/Optimizer/CodeGen/CGOps.h @@ -14,7 +14,7 @@ #define OPTIMIZER_CODEGEN_CGOPS_H #include "flang/Optimizer/Dialect/FIRType.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" using namespace mlir; diff --git a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp --- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp @@ -262,7 +262,7 @@ mlir::OpBuilder rewriter(&context); mlir::ConversionTarget target(context); target.addLegalDialect(); + FIRCodeGenDialect, mlir::func::FuncDialect>(); target.addIllegalOp(); target.addIllegalOp(); target.addDynamicallyLegalOp([](EmboxOp embox) { diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp --- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp @@ -599,20 +599,20 @@ auto newArg = func.front().insertArgument(fixup.index, newInTys[fixup.index], loc); offset++; - func.walk([&](mlir::ReturnOp ret) { + func.walk([&](mlir::func::ReturnOp ret) { rewriter->setInsertionPoint(ret); auto oldOper = ret.getOperand(0); auto oldOperTy = ReferenceType::get(oldOper.getType()); auto cast = rewriter->create(loc, oldOperTy, newArg); rewriter->create(loc, oldOper, cast); - rewriter->create(loc); + rewriter->create(loc); ret.erase(); }); } break; case FixupTy::Codes::ReturnType: { // The function is still returning a value, but its type has likely // changed to suit the target ABI convention. - func.walk([&](mlir::ReturnOp ret) { + func.walk([&](mlir::func::ReturnOp ret) { rewriter->setInsertionPoint(ret); auto oldOper = ret.getOperand(0); auto oldOperTy = ReferenceType::get(oldOper.getType()); @@ -621,7 +621,7 @@ auto cast = rewriter->create(loc, oldOperTy, mem); rewriter->create(loc, oldOper, cast); mlir::Value load = rewriter->create(loc, mem); - rewriter->create(loc, load); + rewriter->create(loc, load); ret.erase(); }); } break; diff --git a/flang/lib/Optimizer/Dialect/FIRDialect.cpp b/flang/lib/Optimizer/Dialect/FIRDialect.cpp --- a/flang/lib/Optimizer/Dialect/FIRDialect.cpp +++ b/flang/lib/Optimizer/Dialect/FIRDialect.cpp @@ -42,7 +42,7 @@ /// return. void handleTerminator(mlir::Operation *op, llvm::ArrayRef valuesToRepl) const final { - auto returnOp = cast(op); + auto returnOp = cast(op); assert(returnOp.getNumOperands() == valuesToRepl.size()); for (const auto &it : llvm::enumerate(returnOp.getOperands())) valuesToRepl[it.index()].replaceAllUsesWith(it.value()); diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -16,7 +16,7 @@ #include "flang/Optimizer/Dialect/FIRType.h" #include "flang/Optimizer/Support/Utils.h" #include "mlir/Dialect/CommonFolders.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Diagnostics.h" diff --git a/flang/lib/Optimizer/Transforms/AbstractResult.cpp b/flang/lib/Optimizer/Transforms/AbstractResult.cpp --- a/flang/lib/Optimizer/Transforms/AbstractResult.cpp +++ b/flang/lib/Optimizer/Transforms/AbstractResult.cpp @@ -11,7 +11,7 @@ #include "flang/Optimizer/Dialect/FIROps.h" #include "flang/Optimizer/Dialect/FIRType.h" #include "flang/Optimizer/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/Diagnostics.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" @@ -149,14 +149,14 @@ } }; -class ReturnOpConversion : public mlir::OpRewritePattern { +class ReturnOpConversion : public mlir::OpRewritePattern { public: using OpRewritePattern::OpRewritePattern; ReturnOpConversion(mlir::MLIRContext *context, const AbstractResultOptions &opt) : OpRewritePattern(context), options{opt} {} mlir::LogicalResult - matchAndRewrite(mlir::ReturnOp ret, + matchAndRewrite(mlir::func::ReturnOp ret, mlir::PatternRewriter &rewriter) const override { rewriter.setInsertionPoint(ret); auto returnedValue = ret.getOperand(0); @@ -177,7 +177,7 @@ if (!replacedStorage) rewriter.create(ret.getLoc(), returnedValue, options.newArg); - rewriter.replaceOpWithNewOp(ret); + rewriter.replaceOpWithNewOp(ret); return mlir::success(); } @@ -239,8 +239,8 @@ rewriter.create(loc, bufferType, options.newArg); } patterns.insert(context, options); - target.addDynamicallyLegalOp( - [](mlir::ReturnOp ret) { return ret.operands().empty(); }); + target.addDynamicallyLegalOp( + [](mlir::func::ReturnOp ret) { return ret.operands().empty(); }); } } @@ -249,7 +249,7 @@ // Convert the calls and, if needed, the ReturnOp in the function body. target.addLegalDialect(); + mlir::func::FuncDialect>(); target.addIllegalOp(); target.addDynamicallyLegalOp([](fir::CallOp call) { return !mustConvertCallOrFunc(call.getFunctionType()); diff --git a/flang/lib/Optimizer/Transforms/AffineDemotion.cpp b/flang/lib/Optimizer/Transforms/AffineDemotion.cpp --- a/flang/lib/Optimizer/Transforms/AffineDemotion.cpp +++ b/flang/lib/Optimizer/Transforms/AffineDemotion.cpp @@ -23,9 +23,9 @@ #include "flang/Optimizer/Transforms/Passes.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/Utils.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/Visitors.h" @@ -158,7 +158,7 @@ }); target.addLegalDialect(); + mlir::func::FuncDialect>(); if (mlir::failed(mlir::applyPartialConversion(function, target, std::move(patterns)))) { diff --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp --- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp +++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp @@ -21,8 +21,8 @@ #include "flang/Optimizer/Dialect/FIRType.h" #include "flang/Optimizer/Transforms/Passes.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/Visitors.h" @@ -595,7 +595,7 @@ mlir::ConversionTarget target = *context; target.addLegalDialect< mlir::AffineDialect, FIROpsDialect, mlir::scf::SCFDialect, - mlir::arith::ArithmeticDialect, mlir::StandardOpsDialect>(); + mlir::arith::ArithmeticDialect, mlir::func::FuncDialect>(); target.addDynamicallyLegalOp([&functionAnalysis](fir::IfOp op) { return !(functionAnalysis.getChildIfAnalysis(op).canPromoteToAffine()); }); diff --git a/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp b/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp --- a/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp +++ b/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp @@ -792,7 +792,7 @@ mlir::ConversionTarget target(*context); target.addLegalDialect< FIROpsDialect, mlir::scf::SCFDialect, mlir::arith::ArithmeticDialect, - mlir::cf::ControlFlowDialect, mlir::StandardOpsDialect>(); + mlir::cf::ControlFlowDialect, mlir::func::FuncDialect>(); target.addIllegalOp(); // Rewrite the array fetch and array update ops. if (mlir::failed( diff --git a/flang/lib/Optimizer/Transforms/CharacterConversion.cpp b/flang/lib/Optimizer/Transforms/CharacterConversion.cpp --- a/flang/lib/Optimizer/Transforms/CharacterConversion.cpp +++ b/flang/lib/Optimizer/Transforms/CharacterConversion.cpp @@ -13,7 +13,7 @@ #include "flang/Optimizer/Support/FIRContext.h" #include "flang/Optimizer/Support/KindMapping.h" #include "flang/Optimizer/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/Diagnostics.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" @@ -107,7 +107,7 @@ mlir::ConversionTarget target(*context); target.addLegalDialect(); + mlir::func::FuncDialect>(); // apply the patterns target.addIllegalOp(); diff --git a/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp b/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp --- a/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp +++ b/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp @@ -11,7 +11,7 @@ #include "flang/Optimizer/Dialect/FIROps.h" #include "flang/Optimizer/Dialect/FIRType.h" #include "flang/Optimizer/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/Dominance.h" #include "mlir/IR/Operation.h" #include "mlir/Transforms/Passes.h" diff --git a/flang/lib/Optimizer/Transforms/MemoryAllocation.cpp b/flang/lib/Optimizer/Transforms/MemoryAllocation.cpp --- a/flang/lib/Optimizer/Transforms/MemoryAllocation.cpp +++ b/flang/lib/Optimizer/Transforms/MemoryAllocation.cpp @@ -11,7 +11,7 @@ #include "flang/Optimizer/Dialect/FIROps.h" #include "flang/Optimizer/Dialect/FIRType.h" #include "flang/Optimizer/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/Diagnostics.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" @@ -41,7 +41,7 @@ if (auto func = mlir::dyn_cast(op)) for (mlir::Block &block : func) for (mlir::Operation &i : block) - if (mlir::isa(i)) { + if (mlir::isa(i)) { returnMap[op].push_back(&i); break; } @@ -189,7 +189,7 @@ const auto &analysis = getAnalysis(); target.addLegalDialect(); + mlir::func::FuncDialect>(); target.addDynamicallyLegalOp([&](fir::AllocaOp alloca) { return keepStackAllocation(alloca, &func.front(), options); }); diff --git a/flang/lib/Optimizer/Transforms/PassDetail.h b/flang/lib/Optimizer/Transforms/PassDetail.h --- a/flang/lib/Optimizer/Transforms/PassDetail.h +++ b/flang/lib/Optimizer/Transforms/PassDetail.h @@ -10,10 +10,10 @@ #include "flang/Optimizer/Dialect/FIRDialect.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/OpenACC/OpenACC.h" #include "mlir/Dialect/OpenMP/OpenMPDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassRegistry.h" diff --git a/flang/lib/Optimizer/Transforms/RewriteLoop.cpp b/flang/lib/Optimizer/Transforms/RewriteLoop.cpp --- a/flang/lib/Optimizer/Transforms/RewriteLoop.cpp +++ b/flang/lib/Optimizer/Transforms/RewriteLoop.cpp @@ -12,7 +12,7 @@ #include "flang/Optimizer/Transforms/Passes.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/Support/CommandLine.h" @@ -304,7 +304,7 @@ context, forceLoopToExecuteOnce); mlir::ConversionTarget target(*context); target.addLegalDialect(); + FIROpsDialect, mlir::func::FuncDialect>(); // apply the patterns target.addIllegalOp(); diff --git a/mlir/benchmark/python/common.py b/mlir/benchmark/python/common.py --- a/mlir/benchmark/python/common.py +++ b/mlir/benchmark/python/common.py @@ -6,9 +6,9 @@ from mlir import ir from mlir.dialects import arith from mlir.dialects import builtin +from mlir.dialects import func from mlir.dialects import memref from mlir.dialects import scf -from mlir.dialects import std from mlir.passmanager import PassManager @@ -93,15 +93,15 @@ iter_args = list(wrapped_func.arguments[-num_results - 1:-1]) loop = scf.ForOp(zero, n_iterations, one, iter_args) with ir.InsertionPoint(loop.body): - start = std.CallOp(timer_func, []) - call = std.CallOp( + start = func.CallOp(timer_func, []) + call = func.CallOp( func, wrapped_func.arguments[:-num_results - 1] + loop.inner_iter_args ) - end = std.CallOp(timer_func, []) + end = func.CallOp(timer_func, []) time_taken = arith.SubIOp(end, start) memref.StoreOp(time_taken, timer_buffer, [loop.induction_variable]) scf.YieldOp(list(call.results)) - std.ReturnOp(loop) + func.ReturnOp(loop) return wrapped_func diff --git a/mlir/docs/Bindings/Python.md b/mlir/docs/Bindings/Python.md --- a/mlir/docs/Bindings/Python.md +++ b/mlir/docs/Bindings/Python.md @@ -885,16 +885,16 @@ `_{DIALECT_NAMESPACE}_ops_gen.py` wrapper module is created. This is done by invoking `mlir-tblgen` on a python-bindings specific tablegen wrapper that includes the boilerplate and actual dialect specific `td` file. An example, for -the `StandardOps` (which is assigned the namespace `std` as a special case): +the `Func` (which is assigned the namespace `func` as a special case): ```tablegen -#ifndef PYTHON_BINDINGS_STANDARD_OPS -#define PYTHON_BINDINGS_STANDARD_OPS +#ifndef PYTHON_BINDINGS_FUNC_OPS +#define PYTHON_BINDINGS_FUNC_OPS include "mlir/Bindings/Python/Attributes.td" -include "mlir/Dialect/StandardOps/IR/Ops.td" +include "mlir/Dialect/Func/IR/FuncOps.td" -#endif +#endif // PYTHON_BINDINGS_FUNC_OPS ``` In the main repository, building the wrapper is done via the CMake function diff --git a/mlir/docs/Bufferization.md b/mlir/docs/Bufferization.md --- a/mlir/docs/Bufferization.md +++ b/mlir/docs/Bufferization.md @@ -169,7 +169,7 @@ populateTensorBufferizePatterns(typeConverter, patterns); target.addIllegalOp(); - target.addLegalDialect(); + target.addLegalDialect(); if (failed( applyPartialConversion(getOperation(), target, std::move(patterns)))) diff --git a/mlir/docs/DialectConversion.md b/mlir/docs/DialectConversion.md --- a/mlir/docs/DialectConversion.md +++ b/mlir/docs/DialectConversion.md @@ -100,9 +100,9 @@ /// constraints. addDynamicallyLegalDialect([](Operation *op) { ... }); - /// Mark `std.return` as dynamically legal, but provide a specific legality + /// Mark `func.return` as dynamically legal, but provide a specific legality /// callback. - addDynamicallyLegalOp([](ReturnOp op) { ... }); + addDynamicallyLegalOp([](func::ReturnOp op) { ... }); /// Treat unknown operations, i.e. those without a legalization action /// directly set, as dynamically legal. @@ -424,15 +424,15 @@ ``` //===-------------------------------------------===// -Legalizing operation : 'std.return'(0x608000002e20) { - "std.return"() : () -> () +Legalizing operation : 'func.return'(0x608000002e20) { + "func.return"() : () -> () * Fold { } -> FAILURE : unable to fold - * Pattern : 'std.return -> ()' { + * Pattern : 'func.return -> ()' { ** Insert : 'spv.Return'(0x6070000453e0) - ** Replace : 'std.return'(0x608000002e20) + ** Replace : 'func.return'(0x608000002e20) //===-------------------------------------------===// Legalizing operation : 'spv.Return'(0x6070000453e0) { @@ -445,8 +445,8 @@ //===-------------------------------------------===// ``` -This output is describing the legalization of an `std.return` operation. We +This output is describing the legalization of an `func.return` operation. We first try to legalize by folding the operation, but that is unsuccessful for -`std.return`. From there, a pattern is applied that replaces the `std.return` +`func.return`. From there, a pattern is applied that replaces the `func.return` with a `spv.Return`. The newly generated `spv.Return` is then processed for legalization, but is found to already legal as per the target. diff --git a/mlir/docs/Dialects/Affine.md b/mlir/docs/Dialects/Affine.md --- a/mlir/docs/Dialects/Affine.md +++ b/mlir/docs/Dialects/Affine.md @@ -66,7 +66,7 @@ at the top level of an `AffineScope` op (i.e., immediately enclosed by the latter), 3. a value that dominates the `AffineScope` op enclosing the value's use, 4. the result of a -[`constant` operation](Standard.md/#stdconstant-constantop), 5. the result of an +constant operation, 5. the result of an [`affine.apply` operation](#affineapply-affineapplyop) that recursively takes as arguments any valid symbolic identifiers, or 6. the result of a [`dim` operation](MemRef.md/#memrefdim-mlirmemrefdimop) on either a memref that diff --git a/mlir/docs/Dialects/Func.md b/mlir/docs/Dialects/Func.md new file mode 100644 --- /dev/null +++ b/mlir/docs/Dialects/Func.md @@ -0,0 +1,15 @@ +# 'func' Dialect + +This dialect provides documentation for operations within the Func dialect. + +This dialect contains operations surrounding high order function +abstractions, such as calls. + +**Please post an RFC on the [forum](https://llvm.discourse.group/c/mlir/31) +before adding or changing any operation in this dialect.** + +[TOC] + +## Operations + +[include "Dialects/FuncOps.md"] diff --git a/mlir/docs/Dialects/Standard.md b/mlir/docs/Dialects/Standard.md deleted file mode 100644 --- a/mlir/docs/Dialects/Standard.md +++ /dev/null @@ -1,15 +0,0 @@ -# 'std' Dialect - -This dialect provides documentation for operations within the Standard dialect. - -Note: This dialect is a collection of operations for several different concepts, -and should be split into multiple more-focused dialects accordingly. - -**Please post an RFC on the [forum](https://llvm.discourse.group/c/mlir/31) -before adding or changing any operation in this dialect.** - -[TOC] - -## Operations - -[include "Dialects/StandardOps.md"] diff --git a/mlir/docs/Dialects/Vector.md b/mlir/docs/Dialects/Vector.md --- a/mlir/docs/Dialects/Vector.md +++ b/mlir/docs/Dialects/Vector.md @@ -99,7 +99,7 @@ ```mlir %2 = arith.addf %0, %1 : vector<3x7x8xf32> // -> vector<3x7x8xf32> %2 = -arith.mulf %0, %1 : vector<3x7x8xf32> // -> vector<3x7x8xf32> %2 = std.splat +arith.mulf %0, %1 : vector<3x7x8xf32> // -> vector<3x7x8xf32> %2 = vector.splat %1 : vector<3x7x8xf32> // -> vector<3x7x8xf32> %1 = vector.extract %0[1]: vector<3x7x8xf32> // -> vector<7x8xf32> %1 = diff --git a/mlir/docs/Dialects/emitc.md b/mlir/docs/Dialects/emitc.md --- a/mlir/docs/Dialects/emitc.md +++ b/mlir/docs/Dialects/emitc.md @@ -26,10 +26,10 @@ * 'cf' Dialect * `cf.br` * `cf.cond_br` -* 'std' Dialect - * `std.call` - * `std.constant` - * `std.return` +* 'func' Dialect + * `func.call` + * `func.constant` + * `func.return` * 'scf' Dialect * `scf.for` * `scf.if` diff --git a/mlir/docs/LangRef.md b/mlir/docs/LangRef.md --- a/mlir/docs/LangRef.md +++ b/mlir/docs/LangRef.md @@ -256,10 +256,10 @@ A few of the dialects supported by MLIR: * [Affine dialect](Dialects/Affine.md) +* [Func dialect](Dialects/Func.md) * [GPU dialect](Dialects/GPU.md) * [LLVM dialect](Dialects/LLVM.md) * [SPIR-V dialect](Dialects/SPIR-V.md) -* [Standard dialect](Dialects/Standard.md) * [Vector dialect](Dialects/Vector.md) ### Target specific operations diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -861,7 +861,7 @@ - All region variables can be used. When a non-variable length region is used, if the group is not present the region is empty. -An example of an operation with an optional group is `std.return`, which has a +An example of an operation with an optional group is `func.return`, which has a variadic number of operands. ```tablegen diff --git a/mlir/docs/Passes.md b/mlir/docs/Passes.md --- a/mlir/docs/Passes.md +++ b/mlir/docs/Passes.md @@ -28,6 +28,10 @@ [include "ArithmeticPasses.md"] +## `func` Dialect Passes + +[include "FuncPasses.md"] + ## `gpu` Dialect Passes [include "GPUPasses.md"] @@ -68,10 +72,6 @@ [include "SPIRVPasses.md"] -## `standard` Dialect Passes - -[include "StandardPasses.md"] - ## `tensor` Dialect Passes [include "TensorPasses.md"] diff --git a/mlir/docs/SymbolsAndSymbolTables.md b/mlir/docs/SymbolsAndSymbolTables.md --- a/mlir/docs/SymbolsAndSymbolTables.md +++ b/mlir/docs/SymbolsAndSymbolTables.md @@ -33,7 +33,7 @@ link, or use, to the symbol. An example of a `Symbol` operation is [`builtin.func`](Dialects/Builtin.md/#func-mlirfuncop). `builtin.func` defines a symbol name, which is [referred to](#referencing-a-symbol) by operations like -[`std.call`](Dialects/Standard.md/#stdcall-callop). +[`func.call`](Dialects/Func.md/#funccall-callop). ### Defining or declaring a Symbol diff --git a/mlir/docs/TargetLLVMIR.md b/mlir/docs/TargetLLVMIR.md --- a/mlir/docs/TargetLLVMIR.md +++ b/mlir/docs/TargetLLVMIR.md @@ -348,7 +348,7 @@ Examples: -This convention is implemented in the conversion of `std.func` and `std.call` to +This convention is implemented in the conversion of `builtin.func` and `func.call` to the LLVM dialect, with the former unpacking the descriptor into a set of individual values and the latter packing those values back into a descriptor so as to make it transparently usable by other operations. Conversions from other @@ -481,7 +481,7 @@ dynamically allocated memory, and the pointer in the unranked descriptor is updated accordingly. The allocation happens immediately before returning. It is the responsibility of the caller to free the dynamically allocated memory. The -default conversion of `std.call` and `std.call_indirect` copies the ranked +default conversion of `func.call` and `func.call_indirect` copies the ranked descriptor to newly allocated memory on the caller's stack. Thus, the convention of the ranked memref descriptor pointed to by an unranked memref descriptor being stored on stack is respected. diff --git a/mlir/docs/Tutorials/CreatingADialect.md b/mlir/docs/Tutorials/CreatingADialect.md --- a/mlir/docs/Tutorials/CreatingADialect.md +++ b/mlir/docs/Tutorials/CreatingADialect.md @@ -130,7 +130,7 @@ Each conversion typically exists in a separate library, declared with add_mlir_conversion_library(). Conversion libraries typically depend on their source and target dialects, but may also depend on other -dialects (e.g. MLIRStandard). Typically this dependence is specified +dialects (e.g. MLIRFunc). Typically this dependence is specified using target_link_libraries() and the PUBLIC keyword. For instance: ```cmake diff --git a/mlir/docs/Tutorials/Toy/Ch-5.md b/mlir/docs/Tutorials/Toy/Ch-5.md --- a/mlir/docs/Tutorials/Toy/Ch-5.md +++ b/mlir/docs/Tutorials/Toy/Ch-5.md @@ -63,9 +63,9 @@ // We define the specific operations, or dialects, that are legal targets for // this lowering. In our case, we are lowering to a combination of the - // `Affine`, `Arithmetic`, `MemRef`, and `Standard` dialects. + // `Affine`, `Arithmetic`, `Func`, and `MemRef` dialects. target.addLegalDialect(); + func::FuncDialect, memref::MemRefDialect>(); // We also define the Toy dialect as Illegal so that the conversion will fail // if any of these operations are *not* converted. Given that we actually want diff --git a/mlir/examples/standalone/standalone-opt/standalone-opt.cpp b/mlir/examples/standalone/standalone-opt/standalone-opt.cpp --- a/mlir/examples/standalone/standalone-opt/standalone-opt.cpp +++ b/mlir/examples/standalone/standalone-opt/standalone-opt.cpp @@ -28,7 +28,7 @@ mlir::DialectRegistry registry; registry.insert(); + mlir::arith::ArithmeticDialect, mlir::func::FuncDialect>(); // Add the following to include *all* MLIR Core dialects, or selectively // include what you need like above. You only need to register dialects that // will be *parsed* by the tool, not the one generated diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -17,8 +17,8 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/ADT/Sequence.h" @@ -229,8 +229,8 @@ if (op.hasOperand()) return failure(); - // We lower "toy.return" directly to "std.return". - rewriter.replaceOpWithNewOp(op); + // We lower "toy.return" directly to "func.return". + rewriter.replaceOpWithNewOp(op); return success(); } }; @@ -279,7 +279,7 @@ struct ToyToAffineLoweringPass : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() final; }; @@ -305,9 +305,9 @@ // We define the specific operations, or dialects, that are legal targets for // this lowering. In our case, we are lowering to a combination of the - // `Affine`, `Arithmetic`, `MemRef`, and `Standard` dialects. + // `Affine`, `Arithmetic`, `Func`, and `MemRef` dialects. target.addLegalDialect(); + func::FuncDialect, memref::MemRefDialect>(); // We also define the Toy dialect as Illegal so that the conversion will fail // if any of these operations are *not* converted. Given that we actually want diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -17,8 +17,8 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/ADT/Sequence.h" @@ -229,8 +229,8 @@ if (op.hasOperand()) return failure(); - // We lower "toy.return" directly to "std.return". - rewriter.replaceOpWithNewOp(op); + // We lower "toy.return" directly to "func.return". + rewriter.replaceOpWithNewOp(op); return success(); } }; @@ -279,7 +279,7 @@ struct ToyToAffineLoweringPass : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() final; }; @@ -305,9 +305,9 @@ // We define the specific operations, or dialects, that are legal targets for // this lowering. In our case, we are lowering to a combination of the - // `Affine`, `Arithmetic`, `MemRef`, and `Standard` dialects. + // `Affine`, `Arithmetic`, `Func`, and `MemRef` dialects. target.addLegalDialect(); + func::FuncDialect, memref::MemRefDialect>(); // We also define the Toy dialect as Illegal so that the conversion will fail // if any of these operations are *not* converted. Given that we actually want diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -35,10 +35,10 @@ #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/ADT/Sequence.h" @@ -91,8 +91,8 @@ // Insert a newline after each of the inner dimensions of the shape. if (i != e - 1) - rewriter.create(loc, printfRef, rewriter.getIntegerType(32), - newLineCst); + rewriter.create(loc, printfRef, + rewriter.getIntegerType(32), newLineCst); rewriter.create(loc); rewriter.setInsertionPointToStart(loop.getBody()); } @@ -101,8 +101,9 @@ auto printOp = cast(op); auto elementLoad = rewriter.create(loc, printOp.input(), loopIvs); - rewriter.create(loc, printfRef, rewriter.getIntegerType(32), - ArrayRef({formatSpecifierCst, elementLoad})); + rewriter.create( + loc, printfRef, rewriter.getIntegerType(32), + ArrayRef({formatSpecifierCst, elementLoad})); // Notify the rewriter that this operation has been removed. rewriter.eraseOp(op); diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -17,8 +17,8 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/ADT/Sequence.h" @@ -229,8 +229,8 @@ if (op.hasOperand()) return failure(); - // We lower "toy.return" directly to "std.return". - rewriter.replaceOpWithNewOp(op); + // We lower "toy.return" directly to "func.return". + rewriter.replaceOpWithNewOp(op); return success(); } }; @@ -279,7 +279,7 @@ struct ToyToAffineLoweringPass : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() final; }; @@ -305,9 +305,9 @@ // We define the specific operations, or dialects, that are legal targets for // this lowering. In our case, we are lowering to a combination of the - // `Affine`, `Arithmetic`, `MemRef`, and `Standard` dialects. + // `Affine`, `Arithmetic`, `Func`, and `MemRef` dialects. target.addLegalDialect(); + func::FuncDialect, memref::MemRefDialect>(); // We also define the Toy dialect as Illegal so that the conversion will fail // if any of these operations are *not* converted. Given that we actually want diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -35,10 +35,10 @@ #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/ADT/Sequence.h" @@ -91,8 +91,8 @@ // Insert a newline after each of the inner dimensions of the shape. if (i != e - 1) - rewriter.create(loc, printfRef, rewriter.getIntegerType(32), - newLineCst); + rewriter.create(loc, printfRef, + rewriter.getIntegerType(32), newLineCst); rewriter.create(loc); rewriter.setInsertionPointToStart(loop.getBody()); } @@ -101,8 +101,9 @@ auto printOp = cast(op); auto elementLoad = rewriter.create(loc, printOp.input(), loopIvs); - rewriter.create(loc, printfRef, rewriter.getIntegerType(32), - ArrayRef({formatSpecifierCst, elementLoad})); + rewriter.create( + loc, printfRef, rewriter.getIntegerType(32), + ArrayRef({formatSpecifierCst, elementLoad})); // Notify the rewriter that this operation has been removed. rewriter.eraseOp(op); diff --git a/mlir/include/mlir-c/Dialect/Standard.h b/mlir/include/mlir-c/Dialect/Func.h rename from mlir/include/mlir-c/Dialect/Standard.h rename to mlir/include/mlir-c/Dialect/Func.h --- a/mlir/include/mlir-c/Dialect/Standard.h +++ b/mlir/include/mlir-c/Dialect/Func.h @@ -1,4 +1,4 @@ -//===-- mlir-c/Dialect/Standard.h - C API for Standard dialect ----*- C -*-===// +//===-- mlir-c/Dialect/Func.h - C API for Func dialect ------------*- C -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM // Exceptions. @@ -8,15 +8,15 @@ //===----------------------------------------------------------------------===// // // This header declares the C interface for registering and accessing the -// Standard dialect. A dialect should be registered with a context to make it +// Func dialect. A dialect should be registered with a context to make it // available to users of the context. These users must load the dialect // before using any of its attributes, operations or types. Parser and pass // manager can load registered dialects automatically. // //===----------------------------------------------------------------------===// -#ifndef MLIR_C_DIALECT_STANDARD_H -#define MLIR_C_DIALECT_STANDARD_H +#ifndef MLIR_C_DIALECT_FUNC_H +#define MLIR_C_DIALECT_FUNC_H #include "mlir-c/Registration.h" @@ -24,10 +24,10 @@ extern "C" { #endif -MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Standard, std); +MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Func, func); #ifdef __cplusplus } #endif -#endif // MLIR_C_DIALECT_STANDARD_H +#endif // MLIR_C_DIALECT_FUNC_H diff --git a/mlir/include/mlir-c/Registration.h b/mlir/include/mlir-c/Registration.h --- a/mlir/include/mlir-c/Registration.h +++ b/mlir/include/mlir-c/Registration.h @@ -20,7 +20,7 @@ // Dialect registration declarations. // Registration entry-points for each dialect are declared using the common // MLIR_DECLARE_DIALECT_REGISTRATION_CAPI macro, which takes the dialect -// API name (i.e. "Standard", "Tensor", "Linalg") and namespace (i.e. "std", +// API name (i.e. "Func", "Tensor", "Linalg") and namespace (i.e. "func", // "tensor", "linalg"). The following declarations are produced: // // /// Gets the above hook methods in struct form for a dialect by namespace. diff --git a/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h b/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h --- a/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h +++ b/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h @@ -25,8 +25,8 @@ /// to derive the bitwidth from the LLVM data layout. static constexpr unsigned kDeriveIndexBitwidthFromDataLayout = 0; -/// Options to control the Standard dialect to LLVM lowering. The struct is used -/// to share lowering options between passes, patterns, and type converter. +/// Options to control the LLVM lowering. The struct is used to share lowering +/// options between passes, patterns, and type converter. class LowerToLLVMOptions { public: explicit LowerToLLVMOptions(MLIRContext *ctx); diff --git a/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h b/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h --- a/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h +++ b/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h @@ -26,7 +26,7 @@ class LLVMDialect; } // namespace LLVM -/// Conversion from types in the Standard dialect to the LLVM IR dialect. +/// Conversion from types to the LLVM IR dialect. class LLVMTypeConverter : public TypeConverter { /// Give structFuncArgTypeConverter access to memref-specific functions. friend LogicalResult diff --git a/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h b/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h --- a/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h +++ b/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h @@ -20,7 +20,7 @@ namespace linalg { //===----------------------------------------------------------------------===// -// Patterns to convert a LinalgOp to std.call @external library implementation. +// Patterns to convert a LinalgOp to func.call @external library implementation. //===----------------------------------------------------------------------===// // These patterns are exposed individually because they are expected to be // typically used individually. diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -67,9 +67,9 @@ }]; let constructor = "mlir::createLowerAffinePass()"; let dependentDialects = [ + "func::FuncDialect", "memref::MemRefDialect", "scf::SCFDialect", - "StandardOpsDialect", "vector::VectorDialect" ]; } @@ -227,9 +227,9 @@ let summary = "Generate NVVM operations for gpu operations"; let constructor = "mlir::createLowerGpuOpsToNVVMOpsPass()"; let dependentDialects = [ + "func::FuncDialect", "memref::MemRefDialect", "NVVM::NVVMDialect", - "StandardOpsDialect", ]; let options = [ Option<"indexBitwidth", "index-bitwidth", "unsigned", @@ -327,7 +327,7 @@ let summary = "Convert the operations from the linalg dialect into the " "Standard dialect"; let constructor = "mlir::createConvertLinalgToStandardPass()"; - let dependentDialects = ["memref::MemRefDialect", "StandardOpsDialect"]; + let dependentDialects = ["func::FuncDialect", "memref::MemRefDialect"]; } //===----------------------------------------------------------------------===// @@ -356,7 +356,7 @@ let constructor = "mlir::createConvertMathToLibmPass()"; let dependentDialects = [ "arith::ArithmeticDialect", - "StandardOpsDialect", + "func::FuncDialect", "vector::VectorDialect", ]; } @@ -553,7 +553,7 @@ "dialect"; let constructor = "mlir::createConvertShapeToStandardPass()"; let dependentDialects = [ - "StandardOpsDialect", + "func::FuncDialect", "scf::SCFDialect", ]; } @@ -705,7 +705,7 @@ let summary = "Lower TOSA to the Standard dialect"; let dependentDialects = [ "arith::ArithmeticDialect", - "StandardOpsDialect", + "func::FuncDialect", "tensor::TensorDialect", ]; let description = [{ diff --git a/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h b/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h --- a/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h +++ b/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h @@ -74,7 +74,7 @@ } }; -/// Collect a set of patterns to convert from the Vector dialect to SCF + std. +/// Collect a set of patterns to convert from the Vector dialect to SCF + func. void populateVectorToSCFConversionPatterns( RewritePatternSet &patterns, const VectorTransferToSCFOptions &options = VectorTransferToSCFOptions()); diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h b/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h --- a/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h +++ b/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h @@ -16,7 +16,7 @@ #define MLIR_DIALECT_AFFINE_ANALYSIS_AFFINEANALYSIS_H #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/Value.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" diff --git a/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td b/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td @@ -31,7 +31,7 @@ def ArithmeticExpandOps : Pass<"arith-expand"> { let summary = "Legalize Arithmetic ops to be convertible to LLVM."; let constructor = "mlir::arith::createArithmeticExpandOpsPass()"; - let dependentDialects = ["StandardOpsDialect"]; + let dependentDialects = ["func::FuncDialect"]; } #endif // MLIR_DIALECT_ARITHMETIC_TRANSFORMS_PASSES diff --git a/mlir/include/mlir/Dialect/ArmSVE/ArmSVEDialect.h b/mlir/include/mlir/Dialect/ArmSVE/ArmSVEDialect.h --- a/mlir/include/mlir/Dialect/ArmSVE/ArmSVEDialect.h +++ b/mlir/include/mlir/Dialect/ArmSVE/ArmSVEDialect.h @@ -19,7 +19,7 @@ #include "mlir/Interfaces/SideEffectInterfaces.h" #include "mlir/Dialect/ArmSVE/ArmSVEDialect.h.inc" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #define GET_OP_CLASSES #include "mlir/Dialect/ArmSVE/ArmSVE.h.inc" diff --git a/mlir/include/mlir/Dialect/CMakeLists.txt b/mlir/include/mlir/Dialect/CMakeLists.txt --- a/mlir/include/mlir/Dialect/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/CMakeLists.txt @@ -9,6 +9,7 @@ add_subdirectory(ControlFlow) add_subdirectory(DLTI) add_subdirectory(EmitC) +add_subdirectory(Func) add_subdirectory(GPU) add_subdirectory(Math) add_subdirectory(Linalg) @@ -23,7 +24,6 @@ add_subdirectory(Shape) add_subdirectory(SparseTensor) add_subdirectory(SPIRV) -add_subdirectory(StandardOps) add_subdirectory(Tensor) add_subdirectory(Tosa) add_subdirectory(Vector) diff --git a/mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td b/mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td --- a/mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td +++ b/mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef STANDARD_OPS -#define STANDARD_OPS +#ifndef MLIR_DIALECTS_CONTROLFLOW_IR_CONTROLFLOWOPS_TD +#define MLIR_DIALECTS_CONTROLFLOW_IR_CONTROLFLOWOPS_TD include "mlir/IR/OpAsmInterface.td" include "mlir/Interfaces/ControlFlowInterfaces.td" @@ -310,4 +310,4 @@ let hasVerifier = 1; } -#endif // STANDARD_OPS +#endif // MLIR_DIALECTS_CONTROLFLOW_IR_CONTROLFLOWOPS_TD diff --git a/mlir/include/mlir/Dialect/StandardOps/CMakeLists.txt b/mlir/include/mlir/Dialect/Func/CMakeLists.txt rename from mlir/include/mlir/Dialect/StandardOps/CMakeLists.txt rename to mlir/include/mlir/Dialect/Func/CMakeLists.txt diff --git a/mlir/include/mlir/Dialect/Func/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Func/IR/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/include/mlir/Dialect/Func/IR/CMakeLists.txt @@ -0,0 +1,8 @@ +set(LLVM_TARGET_DEFINITIONS FuncOps.td) +mlir_tablegen(FuncOps.h.inc -gen-op-decls) +mlir_tablegen(FuncOps.cpp.inc -gen-op-defs) +mlir_tablegen(FuncOpsDialect.h.inc -gen-dialect-decls) +mlir_tablegen(FuncOpsDialect.cpp.inc -gen-dialect-defs) +add_public_tablegen_target(MLIRFuncOpsIncGen) + +add_mlir_doc(FuncOps FuncOps Dialects/ -gen-op-doc) diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h b/mlir/include/mlir/Dialect/Func/IR/FuncOps.h rename from mlir/include/mlir/Dialect/StandardOps/IR/Ops.h rename to mlir/include/mlir/Dialect/Func/IR/FuncOps.h --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h +++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.h @@ -1,44 +1,32 @@ -//===- Ops.h - Standard MLIR Operations -------------------------*- C++ -*-===// +//===- FuncOps.h - Func Dialect Operations ----------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines convenience types for working with standard operations -// in the MLIR operation set. -// -//===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_STANDARDOPS_IR_OPS_H -#define MLIR_DIALECT_STANDARDOPS_IR_OPS_H +#ifndef MLIR_DIALECT_FUNC_IR_OPS_H +#define MLIR_DIALECT_FUNC_IR_OPS_H #include "mlir/Dialect/ControlFlow/IR/ControlFlow.h" #include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinOps.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" #include "mlir/IR/OpImplementation.h" #include "mlir/Interfaces/CallInterfaces.h" -#include "mlir/Interfaces/CastInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" -// Pull in all enum type definitions and utility function declarations. -#include "mlir/Dialect/StandardOps/IR/OpsEnums.h.inc" - namespace mlir { -class AffineMap; -class Builder; -class FuncOp; -class OpBuilder; class PatternRewriter; } // namespace mlir #define GET_OP_CLASSES -#include "mlir/Dialect/StandardOps/IR/Ops.h.inc" +#include "mlir/Dialect/Func/IR/FuncOps.h.inc" -#include "mlir/Dialect/StandardOps/IR/OpsDialect.h.inc" +#include "mlir/Dialect/Func/IR/FuncOpsDialect.h.inc" -#endif // MLIR_DIALECT_STANDARDOPS_IR_OPS_H +#endif // MLIR_DIALECT_FUNC_IR_OPS_H diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td rename from mlir/include/mlir/Dialect/StandardOps/IR/Ops.td rename to mlir/include/mlir/Dialect/Func/IR/FuncOps.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td @@ -1,56 +1,51 @@ -//===- Ops.td - Standard operation definitions -------------*- tablegen -*-===// +//===- FuncOps.td - Func operation definitions -------------*- tablegen -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// Defines some MLIR standard operations. -// -//===----------------------------------------------------------------------===// -#ifndef STANDARD_OPS -#define STANDARD_OPS +#ifndef MLIR_DIALECT_FUNC_IR_FUNCOPS_TD +#define MLIR_DIALECT_FUNC_IR_FUNCOPS_TD include "mlir/IR/OpAsmInterface.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" -include "mlir/Interfaces/CastInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/Interfaces/SideEffectInterfaces.td" -def StandardOps_Dialect : Dialect { - let name = "std"; - let cppNamespace = "::mlir"; +def Func_Dialect : Dialect { + let name = "func"; + let cppNamespace = "::mlir::func"; let dependentDialects = ["cf::ControlFlowDialect"]; let hasConstantMaterializer = 1; let emitAccessorPrefix = kEmitAccessorPrefix_Prefixed; } -// Base class for Standard dialect ops. -class Std_Op traits = []> : - Op; +// Base class for Func dialect ops. +class Func_Op traits = []> : + Op; //===----------------------------------------------------------------------===// // CallOp //===----------------------------------------------------------------------===// -def CallOp : Std_Op<"call", +def CallOp : Func_Op<"call", [CallOpInterface, MemRefsNormalizable, DeclareOpInterfaceMethods]> { let summary = "call operation"; let description = [{ - The `call` operation represents a direct call to a function that is within - the same symbol scope as the call. The operands and result types of the - call must match the specified function type. The callee is encoded as a + The `func.call` operation represents a direct call to a function that is + within the same symbol scope as the call. The operands and result types of + the call must match the specified function type. The callee is encoded as a symbol reference attribute named "callee". Example: ```mlir - %2 = call @my_add(%0, %1) : (f32, f32) -> f32 + %2 = func.call @my_add(%0, %1) : (f32, f32) -> f32 ``` }]; @@ -105,7 +100,7 @@ // CallIndirectOp //===----------------------------------------------------------------------===// -def CallIndirectOp : Std_Op<"call_indirect", [ +def CallIndirectOp : Func_Op<"call_indirect", [ CallOpInterface, TypesMatchWith<"callee input types match argument types", "callee", "callee_operands", @@ -116,19 +111,18 @@ ]> { let summary = "indirect call operation"; let description = [{ - The `call_indirect` operation represents an indirect call to a value of - function type. Functions are first class types in MLIR, and may be passed as - arguments and merged together with block arguments. The operands and result - types of the call must match the specified function type. + The `func.call_indirect` operation represents an indirect call to a value + of function type. The operands and result types of the call must match the + specified function type. Function values can be created with the - [`constant` operation](#stdconstant-constantop). + [`func.constant` operation](#funcconstant-constantop). Example: ```mlir - %31 = call_indirect %15(%0, %1) - : (tensor<16xf32>, tensor<16xf32>) -> tensor<16xf32> + %func = func.constant @my_func : (tensor<16xf32>, tensor<16xf32>) -> tensor<16xf32> + %result = func.call_indirect %func(%0, %1) : (tensor<16xf32>, tensor<16xf32>) -> tensor<16xf32> ``` }]; @@ -160,38 +154,31 @@ }]; let hasCanonicalizeMethod = 1; - - let assemblyFormat = - "$callee `(` $callee_operands `)` attr-dict `:` type($callee)"; + let assemblyFormat = [{ + $callee `(` $callee_operands `)` attr-dict `:` type($callee) + }]; } //===----------------------------------------------------------------------===// // ConstantOp //===----------------------------------------------------------------------===// -def ConstantOp : Std_Op<"constant", +def ConstantOp : Func_Op<"constant", [ConstantLike, NoSideEffect, DeclareOpInterfaceMethods]> { let summary = "constant"; let description = [{ - Syntax: - - ``` - operation ::= ssa-id `=` `std.constant` attribute-value `:` type - ``` - - The `constant` operation produces an SSA value from a symbol reference to a - `builtin.func` operation + The `func.constant` operation produces an SSA value from a symbol reference + to a `func.func` operation Example: ```mlir // Reference to function @myfn. - %2 = constant @myfn : (tensor<16xf32>, f32) -> tensor<16xf32> + %2 = func.constant @myfn : (tensor<16xf32>, f32) -> tensor<16xf32> // Equivalent generic forms - %2 = "std.constant"() {value = @myfn} - : () -> ((tensor<16xf32>, f32) -> tensor<16xf32>) + %2 = "func.constant"() { value = @myfn } : () -> ((tensor<16xf32>, f32) -> tensor<16xf32>) ``` MLIR does not allow direct references to functions in SSA operands because @@ -218,11 +205,11 @@ // ReturnOp //===----------------------------------------------------------------------===// -def ReturnOp : Std_Op<"return", [NoSideEffect, HasParent<"FuncOp">, +def ReturnOp : Func_Op<"return", [NoSideEffect, HasParent<"FuncOp">, MemRefsNormalizable, ReturnLike, Terminator]> { - let summary = "return operation"; + let summary = "Function return operation"; let description = [{ - The `return` operation represents a return operation within a function. + The `func.return` operation represents a return operation within a function. The operation takes variable number of operands and produces no results. The operand number and types must match the signature of the function that contains the operation. @@ -230,7 +217,7 @@ Example: ```mlir - func @foo() : (i32, f8) { + func.func @foo() : (i32, f8) { ... return %0, %1 : i32, f8 } @@ -239,12 +226,12 @@ let arguments = (ins Variadic:$operands); - let builders = [ - OpBuilder<(ins), - [{ build($_builder, $_state, llvm::None); }]>]; + let builders = [OpBuilder<(ins), [{ + build($_builder, $_state, llvm::None); + }]>]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; let hasVerifier = 1; } -#endif // STANDARD_OPS +#endif // MLIR_DIALECT_FUNC_IR_FUNCOPS_TD diff --git a/mlir/include/mlir/Dialect/Func/Transforms/CMakeLists.txt b/mlir/include/mlir/Dialect/Func/Transforms/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/include/mlir/Dialect/Func/Transforms/CMakeLists.txt @@ -0,0 +1,5 @@ +set(LLVM_TARGET_DEFINITIONS Passes.td) +mlir_tablegen(Passes.h.inc -gen-pass-decls -name Func) +add_public_tablegen_target(MLIRFuncTransformsIncGen) + +add_mlir_doc(Passes FuncPasses ./ -gen-pass-doc) diff --git a/mlir/include/mlir/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.h b/mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h rename from mlir/include/mlir/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.h rename to mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h --- a/mlir/include/mlir/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.h +++ b/mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h @@ -15,8 +15,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_STANDARDOPS_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H -#define MLIR_DIALECT_STANDARDOPS_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H +#ifndef MLIR_DIALECT_FUNC_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H +#define MLIR_DIALECT_FUNC_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H #include "mlir/Transforms/DialectConversion.h" @@ -88,4 +88,4 @@ } // namespace mlir -#endif // MLIR_DIALECT_STANDARDOPS_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H +#endif // MLIR_DIALECT_FUNC_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H diff --git a/mlir/include/mlir/Dialect/StandardOps/Transforms/FuncConversions.h b/mlir/include/mlir/Dialect/Func/Transforms/FuncConversions.h rename from mlir/include/mlir/Dialect/StandardOps/Transforms/FuncConversions.h rename to mlir/include/mlir/Dialect/Func/Transforms/FuncConversions.h --- a/mlir/include/mlir/Dialect/StandardOps/Transforms/FuncConversions.h +++ b/mlir/include/mlir/Dialect/Func/Transforms/FuncConversions.h @@ -1,4 +1,4 @@ -//===- FuncConversions.h - Patterns for converting std.funcs ----*- C++ -*-===// +//===- FuncConversions.h - Patterns for converting func.func ----*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,12 +6,12 @@ // //===----------------------------------------------------------------------===// // -// This files contains patterns for converting standard functions. +// This files contains patterns for converting functions. // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_STANDARDOPS_TRANSFORMS_FUNCCONVERSIONS_H_ -#define MLIR_DIALECT_STANDARDOPS_TRANSFORMS_FUNCCONVERSIONS_H_ +#ifndef MLIR_DIALECT_FUNC_TRANSFORMS_FUNCCONVERSIONS_H_ +#define MLIR_DIALECT_FUNC_TRANSFORMS_FUNCCONVERSIONS_H_ #include "mlir/Support/LLVM.h" #include "llvm/ADT/STLExtras.h" @@ -70,4 +70,4 @@ bool isNotBranchOpInterfaceOrReturnLikeOp(Operation *op); } // namespace mlir -#endif // MLIR_DIALECT_STANDARDOPS_TRANSFORMS_FUNCCONVERSIONS_H_ +#endif // MLIR_DIALECT_FUNC_TRANSFORMS_FUNCCONVERSIONS_H_ diff --git a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.h b/mlir/include/mlir/Dialect/Func/Transforms/Passes.h rename from mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.h rename to mlir/include/mlir/Dialect/Func/Transforms/Passes.h --- a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/Func/Transforms/Passes.h @@ -6,13 +6,13 @@ // //===----------------------------------------------------------------------===// // -// This header file defines prototypes that expose pass constructors in the loop +// This header file defines prototypes that expose pass constructors in the Func // transformation library. // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_STANDARDOPS_TRANSFORMS_PASSES_H -#define MLIR_DIALECT_STANDARDOPS_TRANSFORMS_PASSES_H +#ifndef MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_H +#define MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_H #include "mlir/Pass/Pass.h" @@ -23,6 +23,7 @@ class RewritePatternSet; +namespace func { /// Creates an instance of func bufferization pass. std::unique_ptr createFuncBufferizePass(); @@ -32,8 +33,9 @@ /// Generate the code for registering passes. #define GEN_PASS_REGISTRATION -#include "mlir/Dialect/StandardOps/Transforms/Passes.h.inc" +#include "mlir/Dialect/Func/Transforms/Passes.h.inc" +} // namespace func } // namespace mlir -#endif // MLIR_DIALECT_STANDARDOPS_TRANSFORMS_PASSES_H +#endif // MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_H diff --git a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td b/mlir/include/mlir/Dialect/Func/Transforms/Passes.td rename from mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td rename to mlir/include/mlir/Dialect/Func/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Func/Transforms/Passes.td @@ -1,4 +1,4 @@ -//===-- Passes.td - StandardOps pass definition file -------*- tablegen -*-===// +//===-- Passes.td - Func pass definition file --------------*- tablegen -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,17 +6,17 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_STANDARD_TRANSFORMS_PASSES -#define MLIR_DIALECT_STANDARD_TRANSFORMS_PASSES +#ifndef MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_TD +#define MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_TD include "mlir/Pass/PassBase.td" def FuncBufferize : Pass<"func-bufferize", "ModuleOp"> { let summary = "Bufferize func/call/return ops"; let description = [{ - A bufferize pass that bufferizes std.func and std.call ops. + A bufferize pass that bufferizes builtin.func and func.call ops. - Because this pass updates std.func ops, it must be a module pass. It is + Because this pass updates builtin.func ops, it must be a module pass. It is useful to keep this pass separate from other bufferizations so that the other ones can be run at function-level in parallel. @@ -35,9 +35,9 @@ Finally, this pass fails for unknown terminators, as we cannot decide whether they need rewriting. }]; - let constructor = "mlir::createFuncBufferizePass()"; + let constructor = "mlir::func::createFuncBufferizePass()"; let dependentDialects = ["bufferization::BufferizationDialect", "memref::MemRefDialect"]; } -#endif // MLIR_DIALECT_STANDARD_TRANSFORMS_PASSES +#endif // MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_TD diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h --- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h @@ -541,9 +541,9 @@ /// operand_dim_1 = dim %operand, 1 : memref<50x100xf32> /// scf.for %k = %c0 to operand_dim_0 step %c10 { /// scf.for %l = %c0 to operand_dim_1 step %c25 { -/// %4 = std.subview %operand[%k, %l][%c10, %c25][%c1, %c1] +/// %4 = memref.subview %operand[%k, %l][%c10, %c25][%c1, %c1] /// : memref<50x100xf32> to memref -/// %5 = std.subview %result[%k, %l][%c10, %c25][%c1, %c1] +/// %5 = memref.subview %result[%k, %l][%c10, %c25][%c1, %c1] /// : memref<50x100xf32> to memref /// linalg.generic pointwise_2d_trait %4, %5 { /// ^bb0(%operand_in: f32, %result_in: f32): diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -9,10 +9,10 @@ #ifndef MLIR_DIALECT_LINALG_UTILS_UTILS_H #define MLIR_DIALECT_LINALG_UTILS_UTILS_H +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SetVector.h" diff --git a/mlir/include/mlir/Dialect/Math/IR/MathOps.td b/mlir/include/mlir/Dialect/Math/IR/MathOps.td --- a/mlir/include/mlir/Dialect/Math/IR/MathOps.td +++ b/mlir/include/mlir/Dialect/Math/IR/MathOps.td @@ -732,12 +732,6 @@ def Math_TanhOp : Math_FloatUnaryOp<"tanh"> { let summary = "hyperbolic tangent of the specified value"; let description = [{ - Syntax: - - ``` - operation ::= ssa-id `=` `std.tanh` ssa-use `:` type - ``` - The `tanh` operation computes the hyperbolic tangent. It takes one operand and returns one result of the same type. This type may be a float scalar type, a vector whose element type is float, or a tensor of floats. It has 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 @@ -903,7 +903,7 @@ In an `affine.if` or `affine.for` body, the indices of a load are restricted to SSA values bound to surrounding loop induction variables, [symbols](Affine.md/#dimensions-and-symbols), results of a - [`constant` operation](Standard.md/#stdconstant-constantop), or the result of an + constant operations, or the result of an `affine.apply` operation that can in turn take as arguments all of the aforementioned SSA values or the recursively result of such an `affine.apply` operation. diff --git a/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h b/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h --- a/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h @@ -18,7 +18,9 @@ namespace mlir { class AffineDialect; -class StandardOpsDialect; +namespace func { +class FuncDialect; +} // namespace func namespace tensor { class TensorDialect; } // namespace tensor diff --git a/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td b/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td @@ -14,7 +14,7 @@ def ExpandOps : Pass<"memref-expand", "FuncOp"> { let summary = "Legalize memref operations to be convertible to LLVM."; let constructor = "mlir::memref::createExpandOpsPass()"; - let dependentDialects = ["StandardOpsDialect"]; + let dependentDialects = ["func::FuncDialect"]; } def FoldSubViewOps : Pass<"fold-memref-subview-ops"> { @@ -45,7 +45,7 @@ contained in the op. Operations marked with the [MemRefsNormalizable] (https://mlir.llvm.org/docs/Traits/#memrefsnormalizable) trait are expected to be normalizable. Supported operations include affine - operations, memref.alloc, memref.dealloc, and std.return. + operations, memref.alloc, memref.dealloc, and func.return. Given an appropriate layout map specified in the code, this transformation can express tiled or linearized access to multi-dimensional data diff --git a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td --- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td +++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td @@ -314,7 +314,7 @@ ```mlir // Define an instance with single range of operands. - %op = pdl.operation "std.return"(%allArgs : !pdl.range) + %op = pdl.operation "func.return"(%allArgs : !pdl.range) ``` 2) A variadic number of either !pdl.value or !pdl.range: diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/StandardOps/IR/CMakeLists.txt deleted file mode 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(LLVM_TARGET_DEFINITIONS Ops.td) -mlir_tablegen(Ops.h.inc -gen-op-decls) -mlir_tablegen(Ops.cpp.inc -gen-op-defs) -mlir_tablegen(OpsDialect.h.inc -gen-dialect-decls) -mlir_tablegen(OpsDialect.cpp.inc -gen-dialect-defs) -mlir_tablegen(OpsEnums.h.inc -gen-enum-decls) -mlir_tablegen(OpsEnums.cpp.inc -gen-enum-defs) -add_public_tablegen_target(MLIRStandardOpsIncGen) - -add_mlir_doc(Ops StandardOps Dialects/ -gen-op-doc) diff --git a/mlir/include/mlir/Dialect/StandardOps/Transforms/CMakeLists.txt b/mlir/include/mlir/Dialect/StandardOps/Transforms/CMakeLists.txt deleted file mode 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Transforms/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(LLVM_TARGET_DEFINITIONS Passes.td) -mlir_tablegen(Passes.h.inc -gen-pass-decls -name Standard) -add_public_tablegen_target(MLIRStandardTransformsIncGen) - -add_mlir_doc(Passes StandardPasses ./ -gen-pass-doc) diff --git a/mlir/include/mlir/Dialect/Tosa/Transforms/PassDetail.h b/mlir/include/mlir/Dialect/Tosa/Transforms/PassDetail.h --- a/mlir/include/mlir/Dialect/Tosa/Transforms/PassDetail.h +++ b/mlir/include/mlir/Dialect/Tosa/Transforms/PassDetail.h @@ -9,7 +9,7 @@ #ifndef MLIR_DIALECT_TOSA_TRANSFORMS_PASSDETAIL_H #define MLIR_DIALECT_TOSA_TRANSFORMS_PASSDETAIL_H -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td b/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td @@ -24,7 +24,7 @@ let constructor = "createTosaInferShapesPass()"; let dependentDialects = [ - "StandardOpsDialect", + "func::FuncDialect", "tensor::TensorDialect", "tosa::TosaDialect", ]; diff --git a/mlir/include/mlir/Dialect/Tosa/Utils/CoversionUtils.h b/mlir/include/mlir/Dialect/Tosa/Utils/CoversionUtils.h --- a/mlir/include/mlir/Dialect/Tosa/Utils/CoversionUtils.h +++ b/mlir/include/mlir/Dialect/Tosa/Utils/CoversionUtils.h @@ -14,7 +14,7 @@ #define DIALECT_TOSA_UTILS_COVERSION_UTILS_H_ #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Utils/StructuredOpsUtils.h" #include "mlir/IR/PatternMatch.h" diff --git a/mlir/include/mlir/InitAllDialects.h b/mlir/include/mlir/InitAllDialects.h --- a/mlir/include/mlir/InitAllDialects.h +++ b/mlir/include/mlir/InitAllDialects.h @@ -26,6 +26,7 @@ #include "mlir/Dialect/ControlFlow/IR/ControlFlow.h" #include "mlir/Dialect/DLTI/DLTI.h" #include "mlir/Dialect/EmitC/IR/EmitC.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/LLVMIR/NVVMDialect.h" @@ -44,7 +45,6 @@ #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/Shape/IR/Shape.h" #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.h" #include "mlir/Dialect/Tensor/IR/TensorTilingInterfaceImpl.h" @@ -71,6 +71,7 @@ complex::ComplexDialect, DLTIDialect, emitc::EmitCDialect, + func::FuncDialect, gpu::GPUDialect, LLVM::LLVMDialect, linalg::LinalgDialect, @@ -82,7 +83,6 @@ pdl_interp::PDLInterpDialect, quant::QuantizationDialect, spirv::SPIRVDialect, - StandardOpsDialect, arm_sve::ArmSVEDialect, vector::VectorDialect, NVVM::NVVMDialect, diff --git a/mlir/include/mlir/InitAllPasses.h b/mlir/include/mlir/InitAllPasses.h --- a/mlir/include/mlir/InitAllPasses.h +++ b/mlir/include/mlir/InitAllPasses.h @@ -19,6 +19,7 @@ #include "mlir/Dialect/Arithmetic/Transforms/Passes.h" #include "mlir/Dialect/Async/Passes.h" #include "mlir/Dialect/Bufferization/Transforms/Passes.h" +#include "mlir/Dialect/Func/Transforms/Passes.h" #include "mlir/Dialect/GPU/Passes.h" #include "mlir/Dialect/LLVMIR/Transforms/Passes.h" #include "mlir/Dialect/Linalg/Passes.h" @@ -29,7 +30,6 @@ #include "mlir/Dialect/Shape/Transforms/Passes.h" #include "mlir/Dialect/SparseTensor/Pipelines/Passes.h" #include "mlir/Dialect/SparseTensor/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/Transforms/Passes.h" #include "mlir/Dialect/Tensor/Transforms/Passes.h" #include "mlir/Dialect/Tosa/Transforms/Passes.h" #include "mlir/Dialect/Vector/Transforms/Passes.h" @@ -58,6 +58,7 @@ registerAsyncPasses(); arith::registerArithmeticPasses(); bufferization::registerBufferizationPasses(); + func::registerFuncPasses(); registerGPUPasses(); registerGpuSerializeToCubinPass(); registerGpuSerializeToHsacoPass(); @@ -69,7 +70,6 @@ registerSCFPasses(); registerShapePasses(); spirv::registerSPIRVPasses(); - registerStandardPasses(); tensor::registerTensorPasses(); tosa::registerTosaOptPasses(); vector::registerVectorPasses(); diff --git a/mlir/lib/CAPI/Dialect/CMakeLists.txt b/mlir/lib/CAPI/Dialect/CMakeLists.txt --- a/mlir/lib/CAPI/Dialect/CMakeLists.txt +++ b/mlir/lib/CAPI/Dialect/CMakeLists.txt @@ -80,13 +80,13 @@ MLIRSparseTensorTransforms ) -add_mlir_upstream_c_api_library(MLIRCAPIStandard - Standard.cpp +add_mlir_upstream_c_api_library(MLIRCAPIFunc + Func.cpp PARTIAL_SOURCES_INTENDED LINK_LIBS PUBLIC MLIRCAPIIR - MLIRStandard + MLIRFunc ) add_mlir_upstream_c_api_library(MLIRCAPITensor diff --git a/mlir/lib/CAPI/Dialect/Standard.cpp b/mlir/lib/CAPI/Dialect/Func.cpp rename from mlir/lib/CAPI/Dialect/Standard.cpp rename to mlir/lib/CAPI/Dialect/Func.cpp --- a/mlir/lib/CAPI/Dialect/Standard.cpp +++ b/mlir/lib/CAPI/Dialect/Func.cpp @@ -1,4 +1,4 @@ -//===- Standard.cpp - C Interface for Standard dialect --------------------===// +//===- Func.cpp - C Interface for Func dialect ----------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "mlir-c/Dialect/Standard.h" +#include "mlir-c/Dialect/Func.h" #include "mlir/CAPI/Registration.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" -MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Standard, std, mlir::StandardOpsDialect) +MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Func, func, mlir::func::FuncDialect) diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -16,9 +16,9 @@ #include "../PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/Utils.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/IntegerSet.h" @@ -553,9 +553,9 @@ populateAffineToStdConversionPatterns(patterns); populateAffineToVectorConversionPatterns(patterns); ConversionTarget target(getContext()); - target - .addLegalDialect(); + target.addLegalDialect(); if (failed(applyPartialConversion(getOperation(), target, std::move(patterns)))) signalPassFailure(); diff --git a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt --- a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt @@ -14,11 +14,11 @@ MLIRAffine MLIRAffineUtils MLIRArithmetic + MLIRFunc MLIRIR MLIRMemRef MLIRSCF MLIRPass - MLIRStandard MLIRTransforms MLIRVector ) diff --git a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp --- a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp +++ b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp @@ -14,10 +14,10 @@ #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Async/IR/Async.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/Dialect/Func/Transforms/FuncConversions.h" #include "mlir/Dialect/LLVMIR/FunctionCallUtils.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/Dialect/StandardOps/Transforms/FuncConversions.h" #include "mlir/IR/ImplicitLocOpBuilder.h" #include "mlir/IR/TypeUtilities.h" #include "mlir/Pass/Pass.h" @@ -549,8 +549,8 @@ // Tokens creation maps to a simple function call. if (resultType.isa()) { - rewriter.replaceOpWithNewOp(op, kCreateToken, - converter->convertType(resultType)); + rewriter.replaceOpWithNewOp( + op, kCreateToken, converter->convertType(resultType)); return success(); } @@ -574,8 +574,8 @@ return rewriter.create(loc, i64, gep); }; - rewriter.replaceOpWithNewOp(op, kCreateValue, resultType, - sizeOf(value)); + rewriter.replaceOpWithNewOp(op, kCreateValue, resultType, + sizeOf(value)); return success(); } @@ -601,9 +601,9 @@ TypeConverter *converter = getTypeConverter(); Type resultType = op.getResult().getType(); - rewriter.replaceOpWithNewOp(op, kCreateGroup, - converter->convertType(resultType), - adaptor.getOperands()); + rewriter.replaceOpWithNewOp( + op, kCreateGroup, converter->convertType(resultType), + adaptor.getOperands()); return success(); } }; @@ -627,8 +627,8 @@ .Case([](Type) { return kEmplaceToken; }) .Case([](Type) { return kEmplaceValue; }); - rewriter.replaceOpWithNewOp(op, apiFuncName, TypeRange(), - adaptor.getOperands()); + rewriter.replaceOpWithNewOp(op, apiFuncName, TypeRange(), + adaptor.getOperands()); return success(); } @@ -653,8 +653,8 @@ .Case([](Type) { return kSetTokenError; }) .Case([](Type) { return kSetValueError; }); - rewriter.replaceOpWithNewOp(op, apiFuncName, TypeRange(), - adaptor.getOperands()); + rewriter.replaceOpWithNewOp(op, apiFuncName, TypeRange(), + adaptor.getOperands()); return success(); } @@ -679,8 +679,8 @@ .Case([](Type) { return kIsGroupError; }) .Case([](Type) { return kIsValueError; }); - rewriter.replaceOpWithNewOp(op, apiFuncName, rewriter.getI1Type(), - adaptor.getOperands()); + rewriter.replaceOpWithNewOp( + op, apiFuncName, rewriter.getI1Type(), adaptor.getOperands()); return success(); } }; @@ -704,8 +704,8 @@ .Case([](Type) { return kAwaitValue; }) .Case([](Type) { return kAwaitGroup; }); - rewriter.create(op->getLoc(), apiFuncName, TypeRange(), - adaptor.getOperands()); + rewriter.create(op->getLoc(), apiFuncName, TypeRange(), + adaptor.getOperands()); rewriter.eraseOp(op); return success(); @@ -741,8 +741,9 @@ auto resumePtr = rewriter.create( op->getLoc(), LLVM::LLVMPointerType::get(resumeFnTy), kResume); - rewriter.create(op->getLoc(), apiFuncName, TypeRange(), - ValueRange({operand, handle, resumePtr.getRes()})); + rewriter.create( + op->getLoc(), apiFuncName, TypeRange(), + ValueRange({operand, handle, resumePtr.getRes()})); rewriter.eraseOp(op); return success(); @@ -770,7 +771,7 @@ // Call async runtime API to execute a coroutine in the managed thread. auto coroHdl = adaptor.handle(); - rewriter.replaceOpWithNewOp( + rewriter.replaceOpWithNewOp( op, TypeRange(), kExecute, ValueRange({coroHdl, resumePtr.getRes()})); return success(); @@ -795,8 +796,8 @@ // Get a pointer to the async value storage from the runtime. auto i8Ptr = AsyncAPI::opaquePointerType(rewriter.getContext()); auto storage = adaptor.storage(); - auto storagePtr = rewriter.create(loc, kGetValueStorage, - TypeRange(i8Ptr), storage); + auto storagePtr = rewriter.create(loc, kGetValueStorage, + TypeRange(i8Ptr), storage); // Cast from i8* to the LLVM pointer type. auto valueType = op.value().getType(); @@ -838,8 +839,8 @@ // Get a pointer to the async value storage from the runtime. auto i8Ptr = AsyncAPI::opaquePointerType(rewriter.getContext()); auto storage = adaptor.storage(); - auto storagePtr = rewriter.create(loc, kGetValueStorage, - TypeRange(i8Ptr), storage); + auto storagePtr = rewriter.create(loc, kGetValueStorage, + TypeRange(i8Ptr), storage); // Cast from i8* to the LLVM pointer type. auto valueType = op.result().getType(); @@ -878,7 +879,7 @@ return rewriter.notifyMatchFailure(op, "only token type is supported"); // Replace with a runtime API function call. - rewriter.replaceOpWithNewOp( + rewriter.replaceOpWithNewOp( op, kAddTokenToGroup, rewriter.getI64Type(), adaptor.getOperands()); return success(); @@ -902,8 +903,8 @@ ConversionPatternRewriter &rewriter) const override { // Replace with a runtime API function call. - rewriter.replaceOpWithNewOp(op, kGetNumWorkerThreads, - rewriter.getIndexType()); + rewriter.replaceOpWithNewOp(op, kGetNumWorkerThreads, + rewriter.getIndexType()); return success(); } @@ -932,8 +933,8 @@ rewriter.getI64IntegerAttr(op.count())); auto operand = adaptor.operand(); - rewriter.replaceOpWithNewOp(op, TypeRange(), apiFunctionName, - ValueRange({operand, count})); + rewriter.replaceOpWithNewOp(op, TypeRange(), apiFunctionName, + ValueRange({operand, count})); return success(); } @@ -961,14 +962,14 @@ //===----------------------------------------------------------------------===// namespace { -class ReturnOpOpConversion : public OpConversionPattern { +class ReturnOpOpConversion : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; LogicalResult - matchAndRewrite(ReturnOp op, OpAdaptor adaptor, + matchAndRewrite(func::ReturnOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(op, adaptor.getOperands()); + rewriter.replaceOpWithNewOp(op, adaptor.getOperands()); return success(); } }; @@ -1032,8 +1033,8 @@ converter, ctx); ConversionTarget target(*ctx); - target - .addLegalOp(); + target.addLegalOp(); target.addLegalDialect(); // All operations from Async dialect must be lowered to the runtime API and @@ -1043,9 +1044,10 @@ // Add dynamic legality constraints to apply conversions defined above. target.addDynamicallyLegalOp( [&](FuncOp op) { return converter.isSignatureLegal(op.getType()); }); - target.addDynamicallyLegalOp( - [&](ReturnOp op) { return converter.isLegal(op.getOperandTypes()); }); - target.addDynamicallyLegalOp([&](CallOp op) { + target.addDynamicallyLegalOp([&](func::ReturnOp op) { + return converter.isLegal(op.getOperandTypes()); + }); + target.addDynamicallyLegalOp([&](func::CallOp op) { return converter.isSignatureLegal(op.getCalleeType()); }); diff --git a/mlir/lib/Conversion/AsyncToLLVM/CMakeLists.txt b/mlir/lib/Conversion/AsyncToLLVM/CMakeLists.txt --- a/mlir/lib/Conversion/AsyncToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/AsyncToLLVM/CMakeLists.txt @@ -13,9 +13,9 @@ LINK_LIBS PUBLIC MLIRArithmetic MLIRAsync + MLIRFuncTransforms MLIRLLVMCommonConversion MLIRLLVMIR - MLIRStandardOpsTransforms MLIRStandardToLLVM MLIRTransforms ) diff --git a/mlir/lib/Conversion/ComplexToLLVM/CMakeLists.txt b/mlir/lib/Conversion/ComplexToLLVM/CMakeLists.txt --- a/mlir/lib/Conversion/ComplexToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/ComplexToLLVM/CMakeLists.txt @@ -12,8 +12,8 @@ LINK_LIBS PUBLIC MLIRComplex + MLIRFuncTransforms MLIRLLVMCommonConversion MLIRLLVMIR - MLIRStandardOpsTransforms MLIRTransforms ) diff --git a/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp b/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp --- a/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp +++ b/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp @@ -13,8 +13,8 @@ #include "mlir/Conversion/LLVMCommon/Pattern.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Complex/IR/Complex.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" using namespace mlir; using namespace mlir::LLVM; diff --git a/mlir/lib/Conversion/ComplexToStandard/CMakeLists.txt b/mlir/lib/Conversion/ComplexToStandard/CMakeLists.txt --- a/mlir/lib/Conversion/ComplexToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/ComplexToStandard/CMakeLists.txt @@ -10,8 +10,8 @@ LINK_LIBS PUBLIC MLIRArithmetic MLIRComplex + MLIRFunc MLIRIR MLIRMath - MLIRStandard MLIRTransforms ) diff --git a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp --- a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp +++ b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp @@ -14,8 +14,8 @@ #include "../PassDetail.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Complex/IR/Complex.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Math/IR/Math.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/ImplicitLocOpBuilder.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Transforms/DialectConversion.h" @@ -652,7 +652,7 @@ populateComplexToStandardConversionPatterns(patterns); ConversionTarget target(getContext()); - target.addLegalDialect(); target.addLegalOp(); if (failed(applyPartialConversion(function, target, std::move(patterns)))) diff --git a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp --- a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp +++ b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp @@ -29,7 +29,7 @@ #define PASS_NAME "convert-cf-to-llvm" namespace { -/// Lower `std.assert`. The default lowering calls the `abort` function if the +/// Lower `cf.assert`. The default lowering calls the `abort` function if the /// assertion is violated and has no effect otherwise. The failure message is /// ignored by the default lowering but should be propagated by any custom /// lowering. diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp --- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp +++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "GPUOpsLowering.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Builders.h" #include "llvm/Support/FormatVariadic.h" diff --git a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h --- a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h +++ b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h @@ -16,7 +16,7 @@ namespace mlir { // Rewriting that replaces Op with XOp, YOp, or ZOp depending on the dimension -// that Op operates on. Op is assumed to return an `std.index` value and +// that Op operates on. Op is assumed to return an `index` value and // XOp, YOp and ZOp are assumed to return an `llvm.i32` value. Depending on // `indexBitwidth`, sign-extend or truncate the resulting value to match the // bitwidth expected by the consumers of the value. diff --git a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h --- a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h +++ b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h @@ -9,9 +9,9 @@ #define MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ #include "mlir/Conversion/LLVMCommon/Pattern.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Builders.h" namespace mlir { @@ -24,7 +24,7 @@ /// function called and then the result casted back. /// /// Example with NVVM: -/// %exp_f32 = std.exp %arg_f32 : f32 +/// %exp_f32 = math.exp %arg_f32 : f32 /// /// will be transformed into /// llvm.call @__nv_expf(%arg_f32) : (f32) -> f32 diff --git a/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt b/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt --- a/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt +++ b/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt @@ -6,13 +6,13 @@ MLIRConversionPassIncGen LINK_LIBS PUBLIC + MLIRFunc MLIRGPUOps MLIRIR MLIRLLVMIR MLIRPass MLIRSPIRV MLIRSPIRVSerialization - MLIRStandard MLIRSupport MLIRTransforms MLIRTranslation diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp --- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp @@ -15,10 +15,10 @@ #include "../PassDetail.h" #include "mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinOps.h" @@ -170,7 +170,7 @@ gpuLaunchOperands.end()); // Create vulkan launch call op. - auto vulkanLaunchCallOp = builder.create( + auto vulkanLaunchCallOp = builder.create( loc, TypeRange{}, SymbolRefAttr::get(builder.getContext(), kVulkanLaunch), vulkanLaunchOperands); diff --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp --- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp +++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp @@ -7,12 +7,12 @@ //===----------------------------------------------------------------------===// #include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" #include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Utils/StructuredOpsUtils.h" #include "mlir/IR/AffineExpr.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp --- a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp +++ b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp @@ -10,11 +10,11 @@ #include "../PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" using namespace mlir; using namespace mlir::linalg; @@ -102,7 +102,7 @@ // TODO: Add support for more complex library call signatures that include // indices or captured values. - rewriter.replaceOpWithNewOp( + rewriter.replaceOpWithNewOp( op, libraryCallName.getValue(), TypeRange(), createTypeCanonicalizedMemRefOperands(rewriter, op->getLoc(), op->getOperands())); @@ -129,9 +129,9 @@ auto module = getOperation(); ConversionTarget target(getContext()); target.addLegalDialect(); - target.addLegalOp(); + func::FuncDialect, memref::MemRefDialect, + scf::SCFDialect>(); + target.addLegalOp(); RewritePatternSet patterns(&getContext()); populateLinalgToStandardConversionPatterns(patterns); if (failed(applyFullConversion(module, target, std::move(patterns)))) diff --git a/mlir/lib/Conversion/MathToLibm/CMakeLists.txt b/mlir/lib/Conversion/MathToLibm/CMakeLists.txt --- a/mlir/lib/Conversion/MathToLibm/CMakeLists.txt +++ b/mlir/lib/Conversion/MathToLibm/CMakeLists.txt @@ -13,8 +13,8 @@ LINK_LIBS PUBLIC MLIRArithmetic MLIRDialectUtils + MLIRFuncTransforms MLIRMath - MLIRStandardOpsTransforms MLIRVector MLIRVectorUtils ) diff --git a/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp b/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp --- a/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp +++ b/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp @@ -10,8 +10,8 @@ #include "../PassDetail.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Math/IR/Math.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Utils/IndexingUtils.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/Dialect/Vector/Utils/VectorUtils.h" @@ -107,8 +107,8 @@ } assert(isa(SymbolTable::lookupSymbolIn(module, name))); - rewriter.replaceOpWithNewOp(op, name, op.getType(), - op->getOperands()); + rewriter.replaceOpWithNewOp(op, name, op.getType(), + op->getOperands()); return success(); } @@ -142,7 +142,7 @@ ConversionTarget target(getContext()); target.addLegalDialect(); + func::FuncDialect, vector::VectorDialect>(); target.addIllegalDialect(); if (failed(applyPartialConversion(module, target, std::move(patterns)))) signalPassFailure(); diff --git a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp --- a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp +++ b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp @@ -1753,7 +1753,7 @@ // AtomicRMWOpLowering //===----------------------------------------------------------------------===// -/// Try to match the kind of a std.atomic_rmw to determine whether to use a +/// Try to match the kind of a memref.atomic_rmw to determine whether to use a /// lowering to llvm.atomicrmw or fallback to llvm.cmpxchg. static Optional matchSimpleAtomicOp(memref::AtomicRMWOp atomicOp) { diff --git a/mlir/lib/Conversion/OpenACCToSCF/OpenACCToSCF.cpp b/mlir/lib/Conversion/OpenACCToSCF/OpenACCToSCF.cpp --- a/mlir/lib/Conversion/OpenACCToSCF/OpenACCToSCF.cpp +++ b/mlir/lib/Conversion/OpenACCToSCF/OpenACCToSCF.cpp @@ -9,9 +9,9 @@ #include "../PassDetail.h" #include "mlir/Conversion/OpenACCToSCF/ConvertOpenACCToSCF.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/OpenACC/OpenACC.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/DialectConversion.h" using namespace mlir; diff --git a/mlir/lib/Conversion/PassDetail.h b/mlir/lib/Conversion/PassDetail.h --- a/mlir/lib/Conversion/PassDetail.h +++ b/mlir/lib/Conversion/PassDetail.h @@ -15,7 +15,6 @@ namespace mlir { class AffineDialect; -class StandardOpsDialect; // Forward declaration from Dialect.h template @@ -42,6 +41,10 @@ class GPUModuleOp; } // namespace gpu +namespace func { +class FuncDialect; +} // namespace func + namespace LLVM { class LLVMDialect; } // namespace LLVM diff --git a/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt b/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt --- a/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt @@ -13,12 +13,12 @@ MLIRAffineToStandard MLIRArithmetic MLIRComplex + MLIRFunc MLIRGPUTransforms MLIRIR MLIRLinalg MLIRMemRef MLIRPass - MLIRStandard MLIRSupport MLIRTransforms ) diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp --- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp @@ -17,11 +17,11 @@ #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/GPU/ParallelLoopMapper.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp --- a/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp @@ -12,9 +12,9 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Complex/IR/Complex.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/ADT/ArrayRef.h" diff --git a/mlir/lib/Conversion/SCFToOpenMP/CMakeLists.txt b/mlir/lib/Conversion/SCFToOpenMP/CMakeLists.txt --- a/mlir/lib/Conversion/SCFToOpenMP/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToOpenMP/CMakeLists.txt @@ -13,9 +13,9 @@ LINK_LIBS PUBLIC MLIRAnalysis MLIRArithmetic + MLIRFunc MLIRLLVMIR MLIROpenMP MLIRSCF - MLIRStandard MLIRTransforms ) diff --git a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp --- a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp +++ b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp @@ -16,11 +16,11 @@ #include "mlir/Analysis/SliceAnalysis.h" #include "mlir/Dialect/Affine/Analysis/LoopAnalysis.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/OpenMP/OpenMPDialect.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/ImplicitLocOpBuilder.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt --- a/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt @@ -14,10 +14,10 @@ MLIRSPIRV MLIRSPIRVConversion MLIRStandardToSPIRV + MLIRFunc MLIRIR MLIRPass MLIRSCF - MLIRStandard MLIRSupport MLIRTransforms ) diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp @@ -20,10 +20,10 @@ #include "mlir/Conversion/SPIRVToLLVM/SPIRVToLLVM.h" #include "mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp @@ -13,11 +13,11 @@ #include "mlir/Conversion/SPIRVToLLVM/SPIRVToLLVM.h" #include "mlir/Conversion/LLVMCommon/Pattern.h" #include "mlir/Conversion/LLVMCommon/TypeConverter.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" #include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Support/LogicalResult.h" diff --git a/mlir/lib/Conversion/ShapeToStandard/ConvertShapeConstraints.cpp b/mlir/lib/Conversion/ShapeToStandard/ConvertShapeConstraints.cpp --- a/mlir/lib/Conversion/ShapeToStandard/ConvertShapeConstraints.cpp +++ b/mlir/lib/Conversion/ShapeToStandard/ConvertShapeConstraints.cpp @@ -10,9 +10,9 @@ #include "../PassDetail.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/Shape/IR/Shape.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp b/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp --- a/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp +++ b/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp @@ -10,9 +10,9 @@ #include "../PassDetail.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/Shape/IR/Shape.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/ImplicitLocOpBuilder.h" @@ -668,7 +668,7 @@ // Setup target legality. MLIRContext &ctx = getContext(); ConversionTarget target(ctx); - target.addLegalDialect(); target.addLegalOp(); diff --git a/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt b/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt --- a/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt @@ -16,9 +16,9 @@ MLIRArithmeticToLLVM MLIRControlFlowToLLVM MLIRDataLayoutInterfaces + MLIRFunc MLIRLLVMCommonConversion MLIRLLVMIR MLIRMath - MLIRStandard MLIRTransforms ) diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -20,9 +20,9 @@ #include "mlir/Conversion/LLVMCommon/VectorPattern.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/FunctionCallUtils.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Utils/StaticValueUtils.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/BlockAndValueMapping.h" @@ -55,7 +55,7 @@ for (const auto &attr : attrs) { if (attr.getName() == SymbolTable::getSymbolAttrName() || attr.getName() == FunctionOpInterface::getTypeAttrName() || - attr.getName() == "std.varargs" || + attr.getName() == "func.varargs" || (filterArgAttrs && attr.getName() == FunctionOpInterface::getArgDictAttrName())) continue; @@ -228,7 +228,7 @@ ConversionPatternRewriter &rewriter) const { // Convert the original function arguments. They are converted using the // LLVMTypeConverter provided to this legalization pattern. - auto varargsAttr = funcOp->getAttrOfType("std.varargs"); + auto varargsAttr = funcOp->getAttrOfType("func.varargs"); TypeConverter::SignatureConversion result(funcOp.getNumArguments()); auto llvmType = getTypeConverter()->convertFunctionSignature( funcOp.getType(), varargsAttr && varargsAttr.getValue(), result); @@ -388,11 +388,11 @@ } }; -struct ConstantOpLowering : public ConvertOpToLLVMPattern { - using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; +struct ConstantOpLowering : public ConvertOpToLLVMPattern { + using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; LogicalResult - matchAndRewrite(ConstantOp op, OpAdaptor adaptor, + matchAndRewrite(func::ConstantOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { auto type = typeConverter->convertType(op.getResult().getType()); if (!type || !LLVM::isCompatibleType(type)) @@ -474,11 +474,12 @@ } }; -struct CallOpLowering : public CallOpInterfaceLowering { +struct CallOpLowering : public CallOpInterfaceLowering { using Super::Super; }; -struct CallIndirectOpLowering : public CallOpInterfaceLowering { +struct CallIndirectOpLowering + : public CallOpInterfaceLowering { using Super::Super; }; @@ -515,11 +516,11 @@ // can only return 0 or 1 value, we pack multiple values into a structure type. // Emit `UndefOp` followed by `InsertValueOp`s to create such structure if // necessary before returning it -struct ReturnOpLowering : public ConvertOpToLLVMPattern { - using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; +struct ReturnOpLowering : public ConvertOpToLLVMPattern { + using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; LogicalResult - matchAndRewrite(ReturnOp op, OpAdaptor adaptor, + matchAndRewrite(func::ReturnOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { Location loc = op.getLoc(); unsigned numArguments = op.getNumOperands(); diff --git a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt --- a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt @@ -12,6 +12,7 @@ LINK_LIBS PUBLIC MLIRArithmeticToSPIRV MLIRControlFlowToSPIRV + MLIRFunc MLIRIR MLIRMathToSPIRV MLIRMemRef @@ -20,6 +21,5 @@ MLIRSPIRVConversion MLIRSupport MLIRTransformUtils - MLIRStandard MLIRTensor ) diff --git a/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp --- a/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp @@ -11,11 +11,11 @@ //===----------------------------------------------------------------------===// #include "../SPIRVCommon/Pattern.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" #include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h" #include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/AffineMap.h" #include "mlir/Support/LogicalResult.h" @@ -36,13 +36,13 @@ namespace { -/// Converts std.return to spv.Return. -class ReturnOpPattern final : public OpConversionPattern { +/// Converts func.return to spv.Return. +class ReturnOpPattern final : public OpConversionPattern { public: - using OpConversionPattern::OpConversionPattern; + using OpConversionPattern::OpConversionPattern; LogicalResult - matchAndRewrite(ReturnOp returnOp, OpAdaptor adaptor, + matchAndRewrite(func::ReturnOp returnOp, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override; }; @@ -114,7 +114,7 @@ //===----------------------------------------------------------------------===// LogicalResult -ReturnOpPattern::matchAndRewrite(ReturnOp returnOp, OpAdaptor adaptor, +ReturnOpPattern::matchAndRewrite(func::ReturnOp returnOp, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const { if (returnOp.getNumOperands() > 1) return failure(); diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -12,10 +12,10 @@ #include "mlir/Conversion/TosaToLinalg/TosaToLinalg.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tensor/Utils/Utils.h" #include "mlir/Dialect/Tosa/IR/TosaOps.h" diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp @@ -12,10 +12,10 @@ #include "mlir/Conversion/TosaToLinalg/TosaToLinalg.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tensor/Utils/Utils.h" #include "mlir/Dialect/Tosa/IR/TosaOps.h" diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamedPass.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamedPass.cpp --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamedPass.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamedPass.cpp @@ -13,10 +13,10 @@ #include "../PassDetail.h" #include "mlir/Conversion/TosaToLinalg/TosaToLinalg.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/Dialect/Tosa/Transforms/PassDetail.h" @@ -34,14 +34,14 @@ public: void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); + math::MathDialect, func::FuncDialect, tensor::TensorDialect, + scf::SCFDialect>(); } void runOnOperation() override { RewritePatternSet patterns(&getContext()); ConversionTarget target(getContext()); - target.addLegalDialect(); diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp @@ -13,10 +13,10 @@ #include "../PassDetail.h" #include "mlir/Conversion/TosaToLinalg/TosaToLinalg.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/Dialect/Tosa/Transforms/PassDetail.h" @@ -35,14 +35,14 @@ public: void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); + math::MathDialect, func::FuncDialect, tensor::TensorDialect, + scf::SCFDialect>(); } void runOnOperation() override { RewritePatternSet patterns(&getContext()); ConversionTarget target(getContext()); - target.addLegalDialect(); target.addIllegalDialect(); diff --git a/mlir/lib/Conversion/TosaToSCF/CMakeLists.txt b/mlir/lib/Conversion/TosaToSCF/CMakeLists.txt --- a/mlir/lib/Conversion/TosaToSCF/CMakeLists.txt +++ b/mlir/lib/Conversion/TosaToSCF/CMakeLists.txt @@ -11,8 +11,8 @@ LINK_LIBS PUBLIC MLIRIR + MLIRFunc MLIRSCF - MLIRStandard MLIRPass MLIRTensor MLIRTosa diff --git a/mlir/lib/Conversion/TosaToStandard/CMakeLists.txt b/mlir/lib/Conversion/TosaToStandard/CMakeLists.txt --- a/mlir/lib/Conversion/TosaToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/TosaToStandard/CMakeLists.txt @@ -11,8 +11,8 @@ LINK_LIBS PUBLIC MLIRArithmetic + MLIRFunc MLIRIR - MLIRStandard MLIRPass MLIRTosa MLIRTosaTransforms diff --git a/mlir/lib/Conversion/TosaToStandard/TosaToStandard.cpp b/mlir/lib/Conversion/TosaToStandard/TosaToStandard.cpp --- a/mlir/lib/Conversion/TosaToStandard/TosaToStandard.cpp +++ b/mlir/lib/Conversion/TosaToStandard/TosaToStandard.cpp @@ -12,7 +12,7 @@ #include "mlir/Conversion/TosaToStandard/TosaToStandard.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/IR/PatternMatch.h" @@ -69,7 +69,7 @@ return rewriter.getIntegerAttr(type, value); } -// This converts the TOSA ApplyScale operator to a set of StandardOps ops, +// This converts the TOSA ApplyScale operator to a set of arithmetic ops, // using 64-bit operations to perform the necessary multiply, bias, and shift. // Multiple types are used to use minimal bit width operations. class ApplyScaleOpConverter : public OpRewritePattern { diff --git a/mlir/lib/Conversion/TosaToStandard/TosaToStandardPass.cpp b/mlir/lib/Conversion/TosaToStandard/TosaToStandardPass.cpp --- a/mlir/lib/Conversion/TosaToStandard/TosaToStandardPass.cpp +++ b/mlir/lib/Conversion/TosaToStandard/TosaToStandardPass.cpp @@ -13,7 +13,7 @@ #include "../PassDetail.h" #include "mlir/Conversion/TosaToStandard/TosaToStandard.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/Dialect/Tosa/Transforms/PassDetail.h" @@ -36,7 +36,7 @@ target.addIllegalOp(); target.addIllegalOp(); target.addLegalDialect(); - target.addLegalDialect(); + target.addLegalDialect(); target.addLegalDialect(); mlir::tosa::populateTosaToStandardConversionPatterns(&patterns); 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 @@ -10,10 +10,10 @@ #include "mlir/Conversion/LLVMCommon/VectorPattern.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/FunctionCallUtils.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/Transforms/VectorTransforms.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/Support/MathExtras.h" diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp @@ -18,9 +18,9 @@ #include "mlir/Dialect/ArmNeon/ArmNeonDialect.h" #include "mlir/Dialect/ArmSVE/ArmSVEDialect.h" #include "mlir/Dialect/ArmSVE/Transforms.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h" #include "mlir/Dialect/X86Vector/Transforms.h" #include "mlir/Dialect/X86Vector/X86VectorDialect.h" @@ -88,7 +88,7 @@ LLVMConversionTarget target(getContext()); target.addLegalDialect(); target.addLegalDialect(); - target.addLegalDialect(); + target.addLegalDialect(); target.addLegalOp(); if (armNeon) { // TODO: we may or may not want to include in-dialect lowering to diff --git a/mlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp b/mlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp --- a/mlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp +++ b/mlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp @@ -18,10 +18,10 @@ #include "mlir/Conversion/LLVMCommon/Pattern.h" #include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/LLVMIR/ROCDLDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Dialect/AMX/Transforms/LegalizeForLLVMExport.cpp b/mlir/lib/Dialect/AMX/Transforms/LegalizeForLLVMExport.cpp --- a/mlir/lib/Dialect/AMX/Transforms/LegalizeForLLVMExport.cpp +++ b/mlir/lib/Dialect/AMX/Transforms/LegalizeForLLVMExport.cpp @@ -11,8 +11,8 @@ #include "mlir/Conversion/LLVMCommon/ConversionTarget.h" #include "mlir/Conversion/LLVMCommon/Pattern.h" #include "mlir/Dialect/AMX/AMXDialect.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/PatternMatch.h" diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp --- a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp @@ -18,7 +18,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/IntegerSet.h" diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp --- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp @@ -17,7 +17,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/IntegerSet.h" #include "mlir/Support/LLVM.h" diff --git a/mlir/lib/Dialect/Affine/Analysis/NestedMatcher.cpp b/mlir/lib/Dialect/Affine/Analysis/NestedMatcher.cpp --- a/mlir/lib/Dialect/Affine/Analysis/NestedMatcher.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/NestedMatcher.cpp @@ -10,7 +10,7 @@ #include "mlir/Dialect/Affine/Analysis/NestedMatcher.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp --- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp @@ -18,7 +18,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/IntegerSet.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/Debug.h" diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp @@ -25,8 +25,8 @@ #include "mlir/Dialect/Affine/LoopUtils.h" #include "mlir/Dialect/Affine/Passes.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" #include "llvm/ADT/MapVector.h" #include "llvm/Support/CommandLine.h" diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -82,7 +82,7 @@ } else if (isa(op)) { // TODO: Support DMA ops. return false; - } else if (!isa(op)) { + } else if (!isa(op)) { // Register op in the set of ops that have users. opsWithUsers.insert(&op); if (isa(op)) { diff --git a/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt @@ -26,12 +26,12 @@ MLIRAffineAnalysis MLIRAffineUtils MLIRArithmetic + MLIRFunc MLIRIR MLIRMemRef MLIRPass MLIRSCFUtils MLIRSideEffectInterfaces - MLIRStandard MLIRTransformUtils MLIRVector MLIRVectorUtils diff --git a/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp b/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp --- a/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp +++ b/mlir/lib/Dialect/Arithmetic/Transforms/ExpandOps.cpp @@ -9,7 +9,7 @@ #include "PassDetail.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Arithmetic/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/TypeUtilities.h" #include "mlir/Transforms/DialectConversion.h" @@ -197,7 +197,7 @@ arith::populateArithmeticExpandOpsPatterns(patterns); - target.addLegalDialect(); + target.addLegalDialect(); // clang-format off target.addIllegalOp< arith::CeilDivSIOp, diff --git a/mlir/lib/Dialect/Arithmetic/Transforms/PassDetail.h b/mlir/lib/Dialect/Arithmetic/Transforms/PassDetail.h --- a/mlir/lib/Dialect/Arithmetic/Transforms/PassDetail.h +++ b/mlir/lib/Dialect/Arithmetic/Transforms/PassDetail.h @@ -13,12 +13,14 @@ namespace mlir { -class StandardOpsDialect; - namespace bufferization { class BufferizationDialect; } // namespace bufferization +namespace func { +class FuncDialect; +} // namespace func + namespace memref { class MemRefDialect; } // namespace memref diff --git a/mlir/lib/Dialect/ArmSVE/Transforms/CMakeLists.txt b/mlir/lib/Dialect/ArmSVE/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/ArmSVE/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/ArmSVE/Transforms/CMakeLists.txt @@ -6,8 +6,8 @@ LINK_LIBS PUBLIC MLIRArmSVE + MLIRFunc MLIRIR MLIRLLVMCommonConversion MLIRLLVMIR - MLIRStandard ) diff --git a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp --- a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp +++ b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp @@ -71,9 +71,9 @@ // Populate conversion patterns // clang-format off - patterns.add, - ForwardOperands, - ForwardOperands>(converter, + patterns.add, + ForwardOperands, + ForwardOperands>(converter, &converter.getContext()); patterns.add(blockFirstCoord[0], blockEndCoord[0], c1, ValueRange(), workLoopBuilder(0)); - b.create(ValueRange()); + b.create(ValueRange()); return {op.getNumLoops(), func, std::move(computeFuncType.captures)}; } @@ -541,8 +541,8 @@ operands[1] = midIndex; operands[2] = end; - executeBuilder.create(executeLoc, func.sym_name(), - func.getCallableResults(), operands); + executeBuilder.create(executeLoc, func.sym_name(), + func.getCallableResults(), operands); executeBuilder.create(executeLoc, ValueRange()); }; @@ -562,9 +562,10 @@ SmallVector computeFuncOperands = {blockStart}; computeFuncOperands.append(forwardedInputs.begin(), forwardedInputs.end()); - b.create(computeFunc.func.sym_name(), - computeFunc.func.getCallableResults(), computeFuncOperands); - b.create(ValueRange()); + b.create(computeFunc.func.sym_name(), + computeFunc.func.getCallableResults(), + computeFuncOperands); + b.create(ValueRange()); return func; } @@ -608,9 +609,9 @@ SmallVector operands = {c0, blockSize}; appendBlockComputeOperands(operands); - b.create(parallelComputeFunction.func.sym_name(), - parallelComputeFunction.func.getCallableResults(), - operands); + b.create(parallelComputeFunction.func.sym_name(), + parallelComputeFunction.func.getCallableResults(), + operands); b.create(); }; @@ -627,8 +628,9 @@ SmallVector operands = {group, c0, blockCount, blockSize}; appendBlockComputeOperands(operands); - b.create(asyncDispatchFunction.sym_name(), - asyncDispatchFunction.getCallableResults(), operands); + b.create(asyncDispatchFunction.sym_name(), + asyncDispatchFunction.getCallableResults(), + operands); // Wait for the completion of all parallel compute operations. b.create(group); @@ -685,9 +687,9 @@ // Call parallel compute function inside the async.execute region. auto executeBodyBuilder = [&](OpBuilder &executeBuilder, Location executeLoc, ValueRange executeArgs) { - executeBuilder.create(executeLoc, compute.sym_name(), - compute.getCallableResults(), - computeFuncOperands(iv)); + executeBuilder.create(executeLoc, compute.sym_name(), + compute.getCallableResults(), + computeFuncOperands(iv)); executeBuilder.create(executeLoc, ValueRange()); }; @@ -702,8 +704,8 @@ b.create(c1, blockCount, c1, ValueRange(), loopBuilder); // Call parallel compute function for the first block in the caller thread. - b.create(compute.sym_name(), compute.getCallableResults(), - computeFuncOperands(c0)); + b.create(compute.sym_name(), compute.getCallableResults(), + computeFuncOperands(c0)); // Wait for the completion of all async compute operations. b.create(group); diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp @@ -16,7 +16,7 @@ #include "mlir/Dialect/Async/IR/Async.h" #include "mlir/Dialect/Async/Passes.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/ImplicitLocOpBuilder.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" @@ -317,7 +317,7 @@ Location loc = value.getLoc(); for (Operation *user : value.getUsers()) { - if (!isa(user)) + if (!isa(user)) continue; // Add a reference before the function call to pass the value at `+1` diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp @@ -13,7 +13,7 @@ #include "PassDetail.h" #include "mlir/Dialect/Async/IR/Async.h" #include "mlir/Dialect/Async/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "llvm/ADT/SmallSet.h" #include "llvm/Support/Debug.h" @@ -139,7 +139,7 @@ break; // Find the first function call user of the reference counted value. - Operation *functionCall = dyn_cast(user); + Operation *functionCall = dyn_cast(user); if (functionCall && (!firstFunctionCallUser || functionCall->isBeforeInBlock(firstFunctionCallUser))) { diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp @@ -17,8 +17,8 @@ #include "mlir/Dialect/Async/IR/Async.h" #include "mlir/Dialect/Async/Passes.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/ImplicitLocOpBuilder.h" #include "mlir/IR/PatternMatch.h" @@ -175,7 +175,7 @@ // This will be the return value of a coroutine ramp function. SmallVector ret{retToken}; ret.insert(ret.end(), retValues.begin(), retValues.end()); - builder.create(ret); + builder.create(ret); // `async.await` op lowering will create resume blocks for async // continuations, and will conditionally branch to cleanup or suspend blocks. @@ -327,7 +327,7 @@ // Replace the original `async.execute` with a call to outlined function. { ImplicitLocOpBuilder callBuilder(loc, execute); - auto callOutlinedFunc = callBuilder.create( + auto callOutlinedFunc = callBuilder.create( func.getName(), execute.getResultTypes(), functionInputs.getArrayRef()); execute.replaceAllUsesWith(callOutlinedFunc.getResults()); execute.erase(); @@ -561,7 +561,7 @@ }; //===----------------------------------------------------------------------===// -// Convert std.assert operation to cf.cond_br into `set_error` block. +// Convert cf.assert operation to cf.cond_br into `set_error` block. //===----------------------------------------------------------------------===// class AssertOpLowering : public OpConversionPattern { @@ -618,7 +618,7 @@ func.insertResult(0, TokenType::get(ctx), {}); for (Block &block : func.getBlocks()) { Operation *terminator = block.getTerminator(); - if (auto returnOp = dyn_cast(*terminator)) { + if (auto returnOp = dyn_cast(*terminator)) { ImplicitLocOpBuilder builder(loc, returnOp); builder.create(returnOp.getOperands()); returnOp.erase(); @@ -631,10 +631,10 @@ /// /// The invocation of this function is safe only when call ops are traversed in /// reverse order of how they appear in a single block. See `funcsToCoroutines`. -static void rewriteCallsiteForCoroutine(CallOp oldCall, FuncOp func) { +static void rewriteCallsiteForCoroutine(func::CallOp oldCall, FuncOp func) { auto loc = func.getLoc(); ImplicitLocOpBuilder callBuilder(loc, oldCall); - auto newCall = callBuilder.create( + auto newCall = callBuilder.create( func.getName(), func.getCallableResults(), oldCall.getArgOperands()); // Await on the async token and all the value results and unwrap the latter. @@ -716,7 +716,7 @@ }); // Rewrite the callsites to await on results of the newly created coroutine. for (Operation *op : users) { - if (CallOp call = dyn_cast(*op)) { + if (func::CallOp call = dyn_cast(*op)) { FuncOp caller = call->getParentOfType(); rewriteCallsiteForCoroutine(call, func); // Careful, erases the call op. addToWorklist(caller); @@ -794,7 +794,7 @@ return !walkResult.wasInterrupted(); }); runtimeTarget.addLegalOp(); + func::ConstantOp, cf::BranchOp, cf::CondBranchOp>(); // Assertions must be converted to runtime errors inside async functions. runtimeTarget.addDynamicallyLegalOp( diff --git a/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt @@ -14,11 +14,11 @@ LINK_LIBS PUBLIC MLIRArithmetic MLIRAsync + MLIRFunc MLIRIR MLIRPass MLIRSCF MLIRSCFToControlFlow - MLIRStandard MLIRTransforms MLIRTransformUtils ) diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp @@ -8,8 +8,8 @@ #include "PassDetail.h" #include "mlir/Dialect/Bufferization/Transforms/Passes.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Operation.h" #include "mlir/Pass/Pass.h" @@ -62,7 +62,7 @@ // out-params. static void updateReturnOps(FuncOp func, ArrayRef appendedEntryArgs) { - func.walk([&](ReturnOp op) { + func.walk([&](func::ReturnOp op) { SmallVector copyIntoOutParams; SmallVector keepAsReturnOperands; for (Value operand : op.getOperands()) { @@ -75,7 +75,7 @@ for (auto t : llvm::zip(copyIntoOutParams, appendedEntryArgs)) builder.create(op.getLoc(), std::get<0>(t), std::get<1>(t)); - builder.create(op.getLoc(), keepAsReturnOperands); + builder.create(op.getLoc(), keepAsReturnOperands); op.erase(); }); } @@ -84,7 +84,7 @@ // temporary buffers for newly introduced out params. static LogicalResult updateCalls(ModuleOp module) { bool didFail = false; - module.walk([&](CallOp op) { + module.walk([&](func::CallOp op) { SmallVector replaceWithNewCallResults; SmallVector replaceWithOutParams; for (OpResult result : op.getResults()) { @@ -112,8 +112,8 @@ newOperands.append(outParams.begin(), outParams.end()); auto newResultTypes = llvm::to_vector<6>(llvm::map_range( replaceWithNewCallResults, [](Value v) { return v.getType(); })); - auto newCall = builder.create(op.getLoc(), op.getCalleeAttr(), - newResultTypes, newOperands); + auto newCall = builder.create(op.getLoc(), op.getCalleeAttr(), + newResultTypes, newOperands); for (auto t : llvm::zip(replaceWithNewCallResults, newCall.getResults())) std::get<0>(t).replaceAllUsesWith(std::get<1>(t)); op.erase(); diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp @@ -13,7 +13,7 @@ #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h" #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h" #include "mlir/Dialect/Bufferization/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/Operation.h" #include "mlir/Pass/PassManager.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" @@ -175,10 +175,9 @@ BufferizationOptions::OpFilterEntry::FilterFn filterFn = [&](Operation *op) { - // Disallow non-std dialect ops. I.e., no ops related to function + // Disallow non-func dialect ops. I.e., no ops related to function // calls. - if (op->getDialect()->getNamespace() == - StandardOpsDialect::getDialectNamespace()) + if (isa(op->getDialect())) return false; // Filter may be specified via options. if (this->dialectFilter.hasValue()) diff --git a/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt @@ -15,10 +15,10 @@ LINK_LIBS PUBLIC MLIRBufferization MLIRControlFlowInterfaces + MLIRFunc MLIRInferTypeOpInterface MLIRIR MLIRMemRef MLIRPass - MLIRStandard MLIRTransforms ) diff --git a/mlir/lib/Dialect/Bufferization/Transforms/PassDetail.h b/mlir/lib/Dialect/Bufferization/Transforms/PassDetail.h --- a/mlir/lib/Dialect/Bufferization/Transforms/PassDetail.h +++ b/mlir/lib/Dialect/Bufferization/Transforms/PassDetail.h @@ -13,12 +13,14 @@ namespace mlir { -class StandardOpsDialect; - namespace bufferization { class BufferizationDialect; } // namespace bufferization +namespace func { +class FuncDialect; +} // namespace func + namespace memref { class MemRefDialect; } // namespace memref diff --git a/mlir/lib/Dialect/CMakeLists.txt b/mlir/lib/Dialect/CMakeLists.txt --- a/mlir/lib/Dialect/CMakeLists.txt +++ b/mlir/lib/Dialect/CMakeLists.txt @@ -9,6 +9,7 @@ add_subdirectory(ControlFlow) add_subdirectory(DLTI) add_subdirectory(EmitC) +add_subdirectory(Func) add_subdirectory(GPU) add_subdirectory(Linalg) add_subdirectory(LLVMIR) @@ -23,7 +24,6 @@ add_subdirectory(Shape) add_subdirectory(SparseTensor) add_subdirectory(SPIRV) -add_subdirectory(StandardOps) add_subdirectory(Tensor) add_subdirectory(Tosa) add_subdirectory(Utils) diff --git a/mlir/include/mlir/Dialect/StandardOps/CMakeLists.txt b/mlir/lib/Dialect/Func/CMakeLists.txt rename from mlir/include/mlir/Dialect/StandardOps/CMakeLists.txt rename to mlir/lib/Dialect/Func/CMakeLists.txt diff --git a/mlir/lib/Dialect/Func/IR/CMakeLists.txt b/mlir/lib/Dialect/Func/IR/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/Func/IR/CMakeLists.txt @@ -0,0 +1,17 @@ +add_mlir_dialect_library(MLIRFunc + FuncOps.cpp + + ADDITIONAL_HEADER_DIRS + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Func + + DEPENDS + MLIRFuncOpsIncGen + + LINK_LIBS PUBLIC + MLIRCallInterfaces + MLIRControlFlow + MLIRControlFlowInterfaces + MLIRInferTypeOpInterface + MLIRIR + MLIRSideEffectInterfaces + ) diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/Func/IR/FuncOps.cpp rename from mlir/lib/Dialect/StandardOps/IR/Ops.cpp rename to mlir/lib/Dialect/Func/IR/FuncOps.cpp --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/Func/IR/FuncOps.cpp @@ -1,4 +1,4 @@ -//===- Ops.cpp - Standard MLIR Operations ---------------------------------===// +//===- FuncOps.cpp - Func Dialect Operations ------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,12 +6,9 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" -#include "mlir/Dialect/CommonFolders.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" -#include "mlir/IR/AffineExpr.h" -#include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinOps.h" @@ -30,33 +27,30 @@ #include "llvm/Support/raw_ostream.h" #include -#include "mlir/Dialect/StandardOps/IR/OpsDialect.cpp.inc" - -// Pull in all enum type definitions and utility function declarations. -#include "mlir/Dialect/StandardOps/IR/OpsEnums.cpp.inc" +#include "mlir/Dialect/Func/IR/FuncOpsDialect.cpp.inc" using namespace mlir; +using namespace mlir::func; //===----------------------------------------------------------------------===// -// StandardOpsDialect Interfaces +// FuncDialect Interfaces //===----------------------------------------------------------------------===// namespace { -/// This class defines the interface for handling inlining with standard -/// operations. -struct StdInlinerInterface : public DialectInlinerInterface { +/// This class defines the interface for handling inlining with func operations. +struct FuncInlinerInterface : public DialectInlinerInterface { using DialectInlinerInterface::DialectInlinerInterface; //===--------------------------------------------------------------------===// // Analysis Hooks //===--------------------------------------------------------------------===// - /// All call operations within standard ops can be inlined. + /// All call operations can be inlined. bool isLegalToInline(Operation *call, Operation *callable, bool wouldBeCloned) const final { return true; } - /// All operations within standard ops can be inlined. + /// All operations can be inlined. bool isLegalToInline(Operation *, Region *, bool, BlockAndValueMapping &) const final { return true; @@ -69,7 +63,7 @@ /// Handle the given inlined terminator by replacing it with a new operation /// as necessary. void handleTerminator(Operation *op, Block *newDest) const final { - // Only "std.return" needs to be handled here. + // Only return needs to be handled here. auto returnOp = dyn_cast(op); if (!returnOp) return; @@ -84,7 +78,7 @@ /// as necessary. void handleTerminator(Operation *op, ArrayRef valuesToRepl) const final { - // Only "std.return" needs to be handled here. + // Only return needs to be handled here. auto returnOp = cast(op); // Replace the values directly with the return operands. @@ -96,24 +90,21 @@ } // namespace //===----------------------------------------------------------------------===// -// StandardOpsDialect +// FuncDialect //===----------------------------------------------------------------------===// -void StandardOpsDialect::initialize() { +void FuncDialect::initialize() { addOperations< #define GET_OP_LIST -#include "mlir/Dialect/StandardOps/IR/Ops.cpp.inc" +#include "mlir/Dialect/Func/IR/FuncOps.cpp.inc" >(); - addInterfaces(); + addInterfaces(); } /// Materialize a single constant operation from a given attribute value with /// the desired resultant type. -Operation *StandardOpsDialect::materializeConstant(OpBuilder &builder, - Attribute value, Type type, - Location loc) { - if (arith::ConstantOp::isBuildableWith(value, type)) - return builder.create(loc, type, value); +Operation *FuncDialect::materializeConstant(OpBuilder &builder, Attribute value, + Type type, Location loc) { if (ConstantOp::isBuildableWith(value, type)) return builder.create(loc, type, value.cast()); @@ -247,4 +238,4 @@ //===----------------------------------------------------------------------===// #define GET_OP_CLASSES -#include "mlir/Dialect/StandardOps/IR/Ops.cpp.inc" +#include "mlir/Dialect/Func/IR/FuncOps.cpp.inc" diff --git a/mlir/lib/Dialect/StandardOps/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Func/Transforms/CMakeLists.txt rename from mlir/lib/Dialect/StandardOps/Transforms/CMakeLists.txt rename to mlir/lib/Dialect/Func/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/StandardOps/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Func/Transforms/CMakeLists.txt @@ -1,23 +1,23 @@ -add_mlir_dialect_library(MLIRStandardOpsTransforms +add_mlir_dialect_library(MLIRFuncTransforms DecomposeCallGraphTypes.cpp FuncBufferize.cpp FuncConversions.cpp ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/StandardOps/Transforms + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Func/Transforms DEPENDS - MLIRStandardTransformsIncGen + MLIRFuncTransformsIncGen LINK_LIBS PUBLIC MLIRAffine MLIRArithmeticTransforms MLIRBufferization MLIRBufferizationTransforms + MLIRFunc MLIRIR MLIRMemRef MLIRPass MLIRSCF - MLIRStandard MLIRTransforms ) diff --git a/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp b/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp rename from mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp rename to mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp --- a/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp +++ b/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp @@ -6,11 +6,12 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/BuiltinOps.h" using namespace mlir; +using namespace mlir::func; //===----------------------------------------------------------------------===// // ValueDecomposer diff --git a/mlir/lib/Dialect/StandardOps/Transforms/FuncBufferize.cpp b/mlir/lib/Dialect/Func/Transforms/FuncBufferize.cpp rename from mlir/lib/Dialect/StandardOps/Transforms/FuncBufferize.cpp rename to mlir/lib/Dialect/Func/Transforms/FuncBufferize.cpp --- a/mlir/lib/Dialect/StandardOps/Transforms/FuncBufferize.cpp +++ b/mlir/lib/Dialect/Func/Transforms/FuncBufferize.cpp @@ -1,4 +1,4 @@ -//===- Bufferize.cpp - Bufferization for std ops --------------------------===// +//===- Bufferize.cpp - Bufferization for func ops -------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,19 +6,20 @@ // //===----------------------------------------------------------------------===// // -// This file implements bufferization of std.func's and std.call's. +// This file implements bufferization of builtin.func's and func.call's. // //===----------------------------------------------------------------------===// #include "PassDetail.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/Dialect/StandardOps/Transforms/FuncConversions.h" -#include "mlir/Dialect/StandardOps/Transforms/Passes.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/Dialect/Func/Transforms/FuncConversions.h" +#include "mlir/Dialect/Func/Transforms/Passes.h" #include "mlir/Transforms/DialectConversion.h" using namespace mlir; +using namespace mlir::func; namespace { struct FuncBufferizePass : public FuncBufferizeBase { @@ -59,6 +60,6 @@ }; } // namespace -std::unique_ptr mlir::createFuncBufferizePass() { +std::unique_ptr mlir::func::createFuncBufferizePass() { return std::make_unique(); } diff --git a/mlir/lib/Dialect/StandardOps/Transforms/FuncConversions.cpp b/mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp rename from mlir/lib/Dialect/StandardOps/Transforms/FuncConversions.cpp rename to mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp --- a/mlir/lib/Dialect/StandardOps/Transforms/FuncConversions.cpp +++ b/mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp @@ -1,4 +1,4 @@ -//===- FuncConversions.cpp - Standard Function conversions ----------------===// +//===- FuncConversions.cpp - Function conversions -------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,16 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/StandardOps/Transforms/FuncConversions.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/Transforms/FuncConversions.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Transforms/DialectConversion.h" using namespace mlir; +using namespace mlir::func; namespace { -/// Converts the operand and result types of the Standard's CallOp, used -/// together with the FuncOpSignatureConversion. +/// Converts the operand and result types of the CallOp, used together with the +/// FuncOpSignatureConversion. struct CallOpSignatureConversion : public OpConversionPattern { using OpConversionPattern::OpConversionPattern; diff --git a/mlir/lib/Dialect/StandardOps/Transforms/PassDetail.h b/mlir/lib/Dialect/Func/Transforms/PassDetail.h rename from mlir/lib/Dialect/StandardOps/Transforms/PassDetail.h rename to mlir/lib/Dialect/Func/Transforms/PassDetail.h --- a/mlir/lib/Dialect/StandardOps/Transforms/PassDetail.h +++ b/mlir/lib/Dialect/Func/Transforms/PassDetail.h @@ -1,4 +1,4 @@ -//===- PassDetail.h - GPU Pass class details --------------------*- C++ -*-===// +//===- PassDetail.h - Func Pass class details -------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef DIALECT_STANDARD_TRANSFORMS_PASSDETAIL_H_ -#define DIALECT_STANDARD_TRANSFORMS_PASSDETAIL_H_ +#ifndef DIALECT_FUNC_TRANSFORMS_PASSDETAIL_H_ +#define DIALECT_FUNC_TRANSFORMS_PASSDETAIL_H_ #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Pass/Pass.h" @@ -25,8 +25,8 @@ } // namespace memref #define GEN_PASS_CLASSES -#include "mlir/Dialect/StandardOps/Transforms/Passes.h.inc" +#include "mlir/Dialect/Func/Transforms/Passes.h.inc" } // namespace mlir -#endif // DIALECT_STANDARD_TRANSFORMS_PASSDETAIL_H_ +#endif // DIALECT_FUNC_TRANSFORMS_PASSDETAIL_H_ diff --git a/mlir/lib/Dialect/GPU/CMakeLists.txt b/mlir/lib/Dialect/GPU/CMakeLists.txt --- a/mlir/lib/Dialect/GPU/CMakeLists.txt +++ b/mlir/lib/Dialect/GPU/CMakeLists.txt @@ -69,6 +69,7 @@ MLIRArithmetic MLIRAsync MLIRDataLayoutInterfaces + MLIRFunc MLIRGPUOps MLIRIR MLIRLLVMIR @@ -76,7 +77,6 @@ MLIRMemRef MLIRPass MLIRSCF - MLIRStandard MLIRSupport MLIRTransformUtils ) diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -14,11 +14,11 @@ #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" #include "mlir/Dialect/DLTI/DLTI.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/GPU/Passes.h" #include "mlir/Dialect/GPU/Utils.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" #include "mlir/IR/SymbolTable.h" @@ -60,8 +60,8 @@ /// operations may not have side-effects, as otherwise sinking (and hence /// duplicating them) is not legal. static bool isLikelyAnIndexComputation(Operation *op) { - return isa(op); + return isa(op); } /// For a given operation `op`, computes whether it is beneficial to sink the diff --git a/mlir/lib/Dialect/Linalg/Analysis/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Analysis/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/Analysis/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Analysis/CMakeLists.txt @@ -7,8 +7,8 @@ LINK_LIBS PUBLIC MLIRAffineAnalysis MLIRAnalysis + MLIRFunc MLIRIR MLIRLinalg MLIRMemRef - MLIRStandard ) diff --git a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp --- a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp +++ b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp @@ -12,8 +12,8 @@ #include "mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinOps.h" #include "llvm/Support/CommandLine.h" diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt @@ -17,8 +17,8 @@ LINK_LIBS PUBLIC MLIRBufferization MLIRBufferizationTransforms + MLIRFunc + MLIRFuncTransforms MLIRIR MLIRMemRef - MLIRStandard - MLIRStandardOpsTransforms ) diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.cpp b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.cpp --- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.cpp +++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.cpp @@ -76,8 +76,8 @@ #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h" #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Operation.h" using namespace mlir; @@ -122,7 +122,7 @@ getModuleBufferizationState(const BufferizationState &state) { Optional maybeState = state.getDialectState( - StandardOpsDialect::getDialectNamespace()); + func::FuncDialect::getDialectNamespace()); assert(maybeState.hasValue() && "ModuleBufferizationState does not exist"); return **maybeState; } @@ -131,7 +131,7 @@ static ModuleBufferizationState & getModuleBufferizationState(BufferizationState &state) { return state.getOrCreateDialectState( - StandardOpsDialect::getDialectNamespace()); + func::FuncDialect::getDialectNamespace()); } /// Return the state (phase) of analysis of the FuncOp. @@ -147,10 +147,10 @@ /// Return the unique ReturnOp that terminates `funcOp`. /// Return nullptr if there is no such unique ReturnOp. -static ReturnOp getAssumedUniqueReturnOp(FuncOp funcOp) { - ReturnOp returnOp; +static func::ReturnOp getAssumedUniqueReturnOp(FuncOp funcOp) { + func::ReturnOp returnOp; for (Block &b : funcOp.body()) { - if (auto candidateOp = dyn_cast(b.getTerminator())) { + if (auto candidateOp = dyn_cast(b.getTerminator())) { if (returnOp) return nullptr; returnOp = candidateOp; @@ -192,7 +192,7 @@ // Support only single return-terminated block in the function. auto funcOp = cast(op); - ReturnOp returnOp = getAssumedUniqueReturnOp(funcOp); + func::ReturnOp returnOp = getAssumedUniqueReturnOp(funcOp); assert(returnOp && "expected func with single return op"); for (OpOperand &returnVal : returnOp->getOpOperands()) @@ -350,7 +350,7 @@ static void equivalenceAnalysis(FuncOp funcOp, BufferizationAliasInfo &aliasInfo, ModuleBufferizationState &moduleState) { - funcOp->walk([&](CallOp callOp) { + funcOp->walk([&](func::CallOp callOp) { FuncOp calledFunction = getCalledFunction(callOp); assert(calledFunction && "could not retrieved called FuncOp"); @@ -424,7 +424,7 @@ } // Support only single return-terminated block in the function. - ReturnOp returnOp = getAssumedUniqueReturnOp(funcOp); + func::ReturnOp returnOp = getAssumedUniqueReturnOp(funcOp); assert(returnOp && "expected func with single return op"); // 1. For each FuncOp result, keep track of which inplace argument it reuses. @@ -454,7 +454,7 @@ funcOp.getContext(), funcOp.getType().getInputs(), retValues.getTypes(), state.getOptions()); OpBuilder b(returnOp); - b.create(returnOp.getLoc(), returnValues); + b.create(returnOp.getLoc(), returnValues); returnOp->erase(); // 3. Rewrite the bbArgs. @@ -528,7 +528,7 @@ DenseMap numberCallOpsContainedInFuncOp; WalkResult res = moduleOp.walk([&](FuncOp funcOp) -> WalkResult { if (!funcOp.body().empty()) { - ReturnOp returnOp = getAssumedUniqueReturnOp(funcOp); + func::ReturnOp returnOp = getAssumedUniqueReturnOp(funcOp); if (!returnOp) return funcOp->emitError() << "cannot bufferize a FuncOp with tensors and " @@ -538,7 +538,7 @@ numberCallOpsContainedInFuncOp[funcOp] = 0; return funcOp.walk([&](CallOpInterface callOp) -> WalkResult { // Only support CallOp for now. - if (!isa(callOp.getOperation())) + if (!isa(callOp.getOperation())) return callOp->emitError() << "expected a CallOp"; FuncOp calledFunction = getCalledFunction(callOp); assert(calledFunction && "could not retrieved called FuncOp"); @@ -690,10 +690,11 @@ } struct CallOpInterface - : public BufferizableOpInterface::ExternalModel { + : public BufferizableOpInterface::ExternalModel { bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand, const BufferizationState &state) const { - CallOp callOp = cast(op); + func::CallOp callOp = cast(op); FuncOp funcOp = getCalledFunction(callOp); assert(funcOp && "expected CallOp to a FuncOp"); @@ -709,7 +710,7 @@ bool bufferizesToMemoryWrite(Operation *op, OpOperand &opOperand, const BufferizationState &state) const { - CallOp callOp = cast(op); + func::CallOp callOp = cast(op); FuncOp funcOp = getCalledFunction(callOp); assert(funcOp && "expected CallOp to a FuncOp"); @@ -726,7 +727,7 @@ SmallVector getAliasingOpResult(Operation *op, OpOperand &opOperand, const BufferizationState &state) const { - CallOp callOp = cast(op); + func::CallOp callOp = cast(op); FuncOp funcOp = getCalledFunction(callOp); assert(funcOp && "expected CallOp to a FuncOp"); const ModuleBufferizationState &moduleState = @@ -746,7 +747,7 @@ SmallVector getAliasingOpOperand(Operation *op, OpResult opResult, const BufferizationState &state) const { - CallOp callOp = cast(op); + func::CallOp callOp = cast(op); FuncOp funcOp = getCalledFunction(callOp); assert(funcOp && "expected CallOp to a FuncOp"); const ModuleBufferizationState &moduleState = @@ -774,12 +775,11 @@ /// bufferization to allow FuncOp that are inplaceable to write inPlace. LogicalResult bufferize(Operation *op, RewriterBase &rewriter, const BufferizationState &state) const { - CallOp callOp = cast(op); + func::CallOp callOp = cast(op); unsigned numResults = callOp.getNumResults(); unsigned numOperands = callOp->getNumOperands(); FuncOp funcOp = getCalledFunction(callOp); - assert(isa(callOp.getOperation()) && funcOp && - "expected CallOp to a FuncOp"); + assert(funcOp && "expected CallOp to a FuncOp"); const ModuleBufferizationState &moduleState = getModuleBufferizationState(state); @@ -885,7 +885,7 @@ } // 4. Create the new CallOp. - Operation *newCallOp = rewriter.create( + Operation *newCallOp = rewriter.create( callOp.getLoc(), funcOp.sym_name(), resultTypes, newOperands); newCallOp->setAttrs(callOp->getAttrs()); // Get replacement values for non-tensor / non-equivalent results. @@ -904,7 +904,7 @@ struct ReturnOpInterface : public BufferizableOpInterface::ExternalModel { + func::ReturnOp> { bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand, const BufferizationState &state) const { return true; @@ -924,7 +924,7 @@ LogicalResult bufferize(Operation *op, RewriterBase &rewriter, const BufferizationState &state) const { #ifndef NDEBUG - auto returnOp = cast(op); + auto returnOp = cast(op); assert(isa(returnOp->getParentOp()) && "only support FuncOp parent for ReturnOp"); #endif // NDEBUG @@ -967,8 +967,8 @@ void mlir::linalg::comprehensive_bufferize::std_ext:: registerModuleBufferizationExternalModels(DialectRegistry ®istry) { - registry.addOpInterface(); - registry.addOpInterface(); + registry.addOpInterface(); + registry.addOpInterface(); registry.addOpInterface(); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp @@ -12,12 +12,12 @@ #include "mlir/Dialect/Arithmetic/Utils/Utils.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h" +#include "mlir/Dialect/Func/Transforms/Passes.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/Math/IR/Math.h" -#include "mlir/Dialect/StandardOps/Transforms/Passes.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/IR/BuiltinDialect.h" @@ -178,9 +178,9 @@ ConversionTarget target(context); bufferization::BufferizeTypeConverter typeConverter; - // Mark all Standard operations legal. + // Mark certain operations legal. target.addLegalDialect(); target.addIllegalOp(); diff --git a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt @@ -39,6 +39,8 @@ MLIRArithmeticTransforms MLIRBufferization MLIRComplex + MLIRFunc + MLIRFuncTransforms MLIRInferTypeOpInterface MLIRIR MLIRMemRef @@ -51,8 +53,6 @@ MLIRSCFUtils MLIRPass MLIRSparseTensor - MLIRStandard - MLIRStandardOpsTransforms MLIRStandardToLLVM MLIRTensor MLIRTensorTilingInterfaceImpl diff --git a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp @@ -49,7 +49,7 @@ .insert(); + arith::ArithmeticDialect, func::FuncDialect, AffineDialect>(); affine_ext::registerBufferizableOpInterfaceExternalModels(registry); arith::registerBufferizableOpInterfaceExternalModels(registry); linalg::registerBufferizableOpInterfaceExternalModels(registry); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp @@ -8,9 +8,9 @@ #include "PassDetail.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" +#include "mlir/Dialect/Func/Transforms/FuncConversions.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Passes.h" -#include "mlir/Dialect/StandardOps/Transforms/FuncConversions.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/OpDefinition.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp @@ -10,10 +10,10 @@ #include "PassDetail.h" #include "mlir/Dialect/Arithmetic/Utils/Utils.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/DialectConversion.h" using namespace mlir; diff --git a/mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp b/mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp @@ -12,11 +12,11 @@ #include "mlir/Dialect/Linalg/Transforms/HoistPadding.h" #include "mlir/Analysis/SliceAnalysis.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/Dialect/Vector/Utils/VectorUtils.h" @@ -368,7 +368,7 @@ } static bool isDefinedOutsideOrConstant(scf::ForOp outer, Value v) { - return outer.isDefinedOutsideOfLoop(v) || v.getDefiningOp(); + return outer.isDefinedOutsideOfLoop(v) || v.getDefiningOp(); } /// Return the current iteration number in the loop (iv - lb).ceilDiv(step). diff --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp @@ -15,11 +15,11 @@ #include "mlir/Analysis/SliceAnalysis.h" #include "mlir/Dialect/Affine/Analysis/AffineStructures.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/Dialect/Vector/Utils/VectorUtils.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @@ -365,7 +365,7 @@ // 2. Constant ops don't get vectorized but rather broadcasted at their users. // Clone so that the constant is not confined to the linalgOp block . - if (isa(op)) + if (isa(op)) return VectorizationResult{VectorizationStatus::NewOp, b.clone(*op)}; // 3. Only ElementwiseMappable are allowed in the generic vectorization. @@ -428,8 +428,8 @@ if (!llvm::hasSingleElement(r)) return false; for (Operation &op : r.front()) { - if (!(isa( - op) || + if (!(isa(op) || OpTrait::hasElementwiseMappableTraits(&op)) || llvm::any_of(op.getResultTypes(), [](Type type) { return !type.isIntOrIndexOrFloat(); })) diff --git a/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt @@ -9,11 +9,11 @@ MLIRAffineAnalysis MLIRAffineUtils MLIRArithmetic + MLIRFunc MLIRIR MLIRLinalg MLIRSCF MLIRPass - MLIRStandard MLIRTensorUtils MLIRTransformUtils ) diff --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp --- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp @@ -19,10 +19,10 @@ #include "mlir/Dialect/Affine/LoopUtils.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Arithmetic/Utils/Utils.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tensor/Utils/Utils.h" #include "mlir/Dialect/Utils/StaticValueUtils.h" diff --git a/mlir/lib/Dialect/Math/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Math/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Math/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Math/Transforms/CMakeLists.txt @@ -9,10 +9,10 @@ LINK_LIBS PUBLIC MLIRArithmetic MLIRDialectUtils + MLIRFunc MLIRIR MLIRMath MLIRPass - MLIRStandard MLIRTransforms MLIRX86Vector MLIRVector diff --git a/mlir/lib/Dialect/Math/Transforms/ExpandTanh.cpp b/mlir/lib/Dialect/Math/Transforms/ExpandTanh.cpp --- a/mlir/lib/Dialect/Math/Transforms/ExpandTanh.cpp +++ b/mlir/lib/Dialect/Math/Transforms/ExpandTanh.cpp @@ -11,9 +11,9 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/Math/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Builders.h" #include "mlir/Transforms/DialectConversion.h" diff --git a/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt b/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt --- a/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt @@ -6,7 +6,6 @@ ${PROJECT_SOURCE_DIR}/inlude/mlir/Dialect/MemRefDialect DEPENDS - MLIRStandardOpsIncGen MLIRMemRefOpsIncGen LINK_COMPONENTS diff --git a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt @@ -16,11 +16,11 @@ MLIRAffine MLIRAffineUtils MLIRArithmetic + MLIRFunc MLIRInferTypeOpInterface MLIRLoopLikeInterface MLIRMemRef MLIRPass - MLIRStandard MLIRTensor MLIRTransforms MLIRVector 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 @@ -16,9 +16,9 @@ #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Arithmetic/Transforms/Passes.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/MemRef/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/TypeUtilities.h" #include "mlir/Transforms/DialectConversion.h" @@ -129,7 +129,7 @@ ConversionTarget target(ctx); target.addLegalDialect(); + func::FuncDialect>(); target.addDynamicallyLegalOp( [](memref::AtomicRMWOp op) { return op.kind() != arith::AtomicRMWKind::maxf && diff --git a/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp b/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp --- a/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp +++ b/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp @@ -125,7 +125,7 @@ } // Functions called by this function. - funcOp.walk([&](CallOp callOp) { + funcOp.walk([&](func::CallOp callOp) { StringAttr callee = callOp.getCalleeAttr().getAttr(); for (FuncOp &funcOp : normalizableFuncs) { // We compare FuncOp and callee's name. @@ -161,7 +161,7 @@ return false; if (funcOp - .walk([&](CallOp callOp) -> WalkResult { + .walk([&](func::CallOp callOp) -> WalkResult { for (unsigned resIndex : llvm::seq(0, callOp.getNumResults())) { Value oldMemRef = callOp.getResult(resIndex); @@ -206,7 +206,7 @@ // Traverse ReturnOps to check if an update to the return type in the // function signature is required. - funcOp.walk([&](ReturnOp returnOp) { + funcOp.walk([&](func::ReturnOp returnOp) { for (const auto &operandEn : llvm::enumerate(returnOp.getOperands())) { Type opType = operandEn.value().getType(); MemRefType memrefType = opType.dyn_cast(); @@ -249,12 +249,12 @@ // that the non-CallOp has no memrefs to be replaced. // TODO: Handle cases where a non-CallOp symbol use of a function deals with // memrefs. - auto callOp = dyn_cast(userOp); + auto callOp = dyn_cast(userOp); if (!callOp) continue; Operation *newCallOp = - builder.create(userOp->getLoc(), callOp.getCalleeAttr(), - resultTypes, userOp->getOperands()); + builder.create(userOp->getLoc(), callOp.getCalleeAttr(), + resultTypes, userOp->getOperands()); bool replacingMemRefUsesFailed = false; bool returnTypeChanged = false; for (unsigned resIndex : llvm::seq(0, userOp->getNumResults())) { @@ -391,7 +391,8 @@ // `updateFunctionSignature()`. funcOp.walk([&](Operation *op) { if (op->hasTrait() && - op->getNumResults() > 0 && !isa(op) && !funcOp.isExternal()) { + op->getNumResults() > 0 && !isa(op) && + !funcOp.isExternal()) { // Create newOp containing normalized memref in the operation result. Operation *newOp = createOpResultsNormalized(funcOp, op); // When all of the operation results have no memrefs or memrefs without diff --git a/mlir/lib/Dialect/MemRef/Transforms/PassDetail.h b/mlir/lib/Dialect/MemRef/Transforms/PassDetail.h --- a/mlir/lib/Dialect/MemRef/Transforms/PassDetail.h +++ b/mlir/lib/Dialect/MemRef/Transforms/PassDetail.h @@ -14,7 +14,6 @@ namespace mlir { class AffineDialect; -class StandardOpsDialect; // Forward declaration from Dialect.h template @@ -24,6 +23,10 @@ class ArithmeticDialect; } // namespace arith +namespace func { +class FuncDialect; +} // namespace func + namespace memref { class MemRefDialect; } // namespace memref diff --git a/mlir/lib/Dialect/SCF/CMakeLists.txt b/mlir/lib/Dialect/SCF/CMakeLists.txt --- a/mlir/lib/Dialect/SCF/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/CMakeLists.txt @@ -10,10 +10,10 @@ LINK_LIBS PUBLIC MLIRArithmetic MLIRBufferization + MLIRFunc MLIRIR MLIRLoopLikeInterface MLIRSideEffectInterfaces - MLIRStandard ) add_subdirectory(Transforms) diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp --- a/mlir/lib/Dialect/SCF/SCF.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -10,7 +10,7 @@ #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/PatternMatch.h" diff --git a/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp b/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp @@ -9,11 +9,11 @@ #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h" #include "PassDetail.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/DialectConversion.h" using namespace mlir; diff --git a/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt b/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt @@ -24,12 +24,12 @@ MLIRBufferization MLIRBufferizationTransforms MLIRDialectUtils + MLIRFunc MLIRIR MLIRMemRef MLIRPass MLIRSCF MLIRSCFUtils - MLIRStandard MLIRSupport MLIRTensor MLIRTransforms diff --git a/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp b/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp --- a/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp @@ -12,10 +12,10 @@ #include "PassDetail.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" diff --git a/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp b/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp --- a/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp @@ -12,10 +12,10 @@ #include "PassDetail.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" #include "mlir/Dialect/SCF/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Support/MathExtras.h" diff --git a/mlir/lib/Dialect/SCF/Transforms/LoopRangeFolding.cpp b/mlir/lib/Dialect/SCF/Transforms/LoopRangeFolding.cpp --- a/mlir/lib/Dialect/SCF/Transforms/LoopRangeFolding.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/LoopRangeFolding.cpp @@ -12,11 +12,11 @@ #include "PassDetail.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" #include "mlir/Dialect/SCF/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" using namespace mlir; diff --git a/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp b/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp --- a/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp @@ -15,11 +15,11 @@ #include "mlir/Dialect/Affine/Analysis/AffineStructures.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" #include "mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Utils/StaticValueUtils.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/BlockAndValueMapping.h" diff --git a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp --- a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp @@ -11,11 +11,11 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" #include "mlir/IR/OpDefinition.h" diff --git a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp --- a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp @@ -13,11 +13,11 @@ #include "PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" #include "mlir/Dialect/SCF/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" using namespace mlir; using namespace mlir::scf; diff --git a/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp b/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp --- a/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp @@ -7,10 +7,10 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/DialectConversion.h" using namespace mlir; diff --git a/mlir/lib/Dialect/SCF/Utils/CMakeLists.txt b/mlir/lib/Dialect/SCF/Utils/CMakeLists.txt --- a/mlir/lib/Dialect/SCF/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/Utils/CMakeLists.txt @@ -11,9 +11,9 @@ MLIRAnalysis MLIRArithmetic MLIRDialectUtils + MLIRFunc MLIRIR MLIRSCF - MLIRStandard MLIRSupport MLIRTransforms ) diff --git a/mlir/lib/Dialect/SCF/Utils/Utils.cpp b/mlir/lib/Dialect/SCF/Utils/Utils.cpp --- a/mlir/lib/Dialect/SCF/Utils/Utils.cpp +++ b/mlir/lib/Dialect/SCF/Utils/Utils.cpp @@ -13,8 +13,8 @@ #include "mlir/Dialect/SCF/Utils/Utils.h" #include "mlir/Analysis/SliceAnalysis.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/PatternMatch.h" @@ -147,8 +147,8 @@ outlinedFuncBlockArgs.take_front(numOriginalBlockArguments)); // Explicitly set up a new ReturnOp terminator. rewriter.setInsertionPointToEnd(outlinedFuncBody); - rewriter.create(loc, originalTerminator->getResultTypes(), - originalTerminator->getOperands()); + rewriter.create(loc, originalTerminator->getResultTypes(), + originalTerminator->getOperands()); } // Reconstruct the block that was deleted and add a @@ -164,7 +164,8 @@ SmallVector callValues; llvm::append_range(callValues, newBlock->getArguments()); llvm::append_range(callValues, outlinedValues); - Operation *call = rewriter.create(loc, outlinedFunc, callValues); + Operation *call = + rewriter.create(loc, outlinedFunc, callValues); // `originalTerminator` was moved to `outlinedFuncBody` and is still valid. // Clone `originalTerminator` to take the callOp results then erase it from diff --git a/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp b/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp --- a/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp +++ b/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp @@ -8,9 +8,9 @@ #include "PassDetail.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Shape/IR/Shape.h" #include "mlir/Dialect/Shape/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Builders.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" @@ -66,8 +66,8 @@ populateShapeRewritePatterns(patterns); ConversionTarget target(getContext()); - target.addLegalDialect(); + target.addLegalDialect(); target.addIllegalOp(); if (failed(mlir::applyPartialConversion(getOperation(), target, std::move(patterns)))) diff --git a/mlir/lib/Dialect/SparseTensor/Pipelines/CMakeLists.txt b/mlir/lib/Dialect/SparseTensor/Pipelines/CMakeLists.txt --- a/mlir/lib/Dialect/SparseTensor/Pipelines/CMakeLists.txt +++ b/mlir/lib/Dialect/SparseTensor/Pipelines/CMakeLists.txt @@ -8,6 +8,7 @@ MLIRArithmeticTransforms MLIRAffineToStandard MLIRBufferizationTransforms + MLIRFuncTransforms MLIRLinalgTransforms MLIRMathToLLVM MLIRMemRefToLLVM @@ -16,7 +17,6 @@ MLIRSCFToControlFlow MLIRSparseTensor MLIRSparseTensorTransforms - MLIRStandardOpsTransforms MLIRTensorTransforms MLIRVectorToLLVM MLIRVectorTransforms diff --git a/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp b/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp --- a/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp +++ b/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp @@ -11,10 +11,10 @@ #include "mlir/Conversion/Passes.h" #include "mlir/Dialect/Arithmetic/Transforms/Passes.h" #include "mlir/Dialect/Bufferization/Transforms/Passes.h" +#include "mlir/Dialect/Func/Transforms/Passes.h" #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" #include "mlir/Dialect/SparseTensor/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/Transforms/Passes.h" #include "mlir/Dialect/Tensor/Transforms/Passes.h" #include "mlir/Dialect/Vector/Transforms/Passes.h" #include "mlir/Pass/PassManager.h" @@ -38,7 +38,7 @@ pm.addNestedPass(createConvertLinalgToLoopsPass()); pm.addNestedPass(createConvertVectorToSCFPass()); pm.addNestedPass(createConvertSCFToCFPass()); - pm.addPass(createFuncBufferizePass()); + pm.addPass(func::createFuncBufferizePass()); pm.addPass(arith::createConstantBufferizePass()); pm.addNestedPass(createTensorBufferizePass()); pm.addNestedPass( diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt @@ -13,6 +13,7 @@ LINK_LIBS PUBLIC MLIRArithmetic MLIRBufferization + MLIRFunc MLIRIR MLIRLLVMIR MLIRLinalg @@ -22,7 +23,6 @@ MLIRSCF MLIRSCFTransforms MLIRSCFUtils - MLIRStandard MLIRSparseTensor MLIRSparseTensorUtils MLIRTensor 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 @@ -17,13 +17,13 @@ #include "CodegenUtils.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" #include "mlir/Dialect/SparseTensor/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/ExecutionEngine/SparseTensorUtils.h" #include "mlir/Transforms/DialectConversion.h" @@ -71,21 +71,24 @@ } /// Creates a `CallOp` to the function reference returned by `getFunc()`. -static CallOp createFuncCall(OpBuilder &builder, Operation *op, StringRef name, - TypeRange resultType, ValueRange operands, - EmitCInterface emitCInterface) { +static func::CallOp createFuncCall(OpBuilder &builder, Operation *op, + StringRef name, TypeRange resultType, + ValueRange operands, + EmitCInterface emitCInterface) { auto fn = getFunc(op, name, resultType, operands, emitCInterface); - return builder.create(op->getLoc(), resultType, fn, operands); + return builder.create(op->getLoc(), resultType, fn, operands); } /// Replaces the `op` with a `CallOp` to the function reference returned /// by `getFunc()`. -static CallOp replaceOpWithFuncCall(PatternRewriter &rewriter, Operation *op, - StringRef name, TypeRange resultType, - ValueRange operands, - EmitCInterface emitCInterface) { +static func::CallOp replaceOpWithFuncCall(PatternRewriter &rewriter, + Operation *op, StringRef name, + TypeRange resultType, + ValueRange operands, + EmitCInterface emitCInterface) { auto fn = getFunc(op, name, resultType, operands, emitCInterface); - return rewriter.replaceOpWithNewOp(op, resultType, fn, operands); + return rewriter.replaceOpWithNewOp(op, resultType, fn, + operands); } /// Generates dimension size call. @@ -357,13 +360,13 @@ //===----------------------------------------------------------------------===// /// Sparse conversion rule for returns. -class SparseReturnConverter : public OpConversionPattern { +class SparseReturnConverter : public OpConversionPattern { public: using OpConversionPattern::OpConversionPattern; LogicalResult - matchAndRewrite(ReturnOp op, OpAdaptor adaptor, + matchAndRewrite(func::ReturnOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(op, adaptor.getOperands()); + rewriter.replaceOpWithNewOp(op, adaptor.getOperands()); return success(); } }; diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp @@ -7,11 +7,11 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/Bufferization/IR/Bufferization.h" +#include "mlir/Dialect/Func/Transforms/FuncConversions.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" #include "mlir/Dialect/SparseTensor/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/Transforms/FuncConversions.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" using namespace mlir; @@ -84,11 +84,12 @@ // all sparse tensor types have been fully rewritten. target.addDynamicallyLegalOp( [&](FuncOp op) { return converter.isSignatureLegal(op.getType()); }); - target.addDynamicallyLegalOp([&](CallOp op) { + target.addDynamicallyLegalOp([&](func::CallOp op) { return converter.isSignatureLegal(op.getCalleeType()); }); - target.addDynamicallyLegalOp( - [&](ReturnOp op) { return converter.isLegal(op.getOperandTypes()); }); + target.addDynamicallyLegalOp([&](func::ReturnOp op) { + return converter.isLegal(op.getOperandTypes()); + }); target.addDynamicallyLegalOp([&](tensor::DimOp op) { return converter.isLegal(op.getOperandTypes()); }); 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 @@ -15,6 +15,7 @@ #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" @@ -23,7 +24,6 @@ #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" #include "mlir/Dialect/SparseTensor/Transforms/Passes.h" #include "mlir/Dialect/SparseTensor/Utils/Merger.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/TensorEncoding.h" diff --git a/mlir/lib/Dialect/StandardOps/CMakeLists.txt b/mlir/lib/Dialect/StandardOps/CMakeLists.txt deleted file mode 100644 --- a/mlir/lib/Dialect/StandardOps/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -add_mlir_dialect_library(MLIRStandard - IR/Ops.cpp - - ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/StandardOps - - DEPENDS - MLIRStandardOpsIncGen - - LINK_LIBS PUBLIC - MLIRArithmetic - MLIRCallInterfaces - MLIRCastInterfaces - MLIRControlFlow - MLIRControlFlowInterfaces - MLIRInferTypeOpInterface - MLIRIR - MLIRSideEffectInterfaces - MLIRVectorInterfaces - ) - -add_subdirectory(Transforms) diff --git a/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp @@ -15,9 +15,9 @@ #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.h" #include "mlir/Dialect/Tensor/Transforms/Passes.h" diff --git a/mlir/lib/Dialect/Tosa/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Tosa/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Tosa/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Tosa/Transforms/CMakeLists.txt @@ -13,8 +13,8 @@ MLIRTosaPassIncGen LINK_LIBS PUBLIC + MLIRFunc MLIRPass MLIRTosa - MLIRStandard MLIRTransformUtils ) diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp --- a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp +++ b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Analysis/DataFlowAnalysis.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/Dialect/Tosa/Transforms/PassDetail.h" @@ -224,7 +224,7 @@ // being replaceable if it is used by a ReturnOp or a TosaOp. bool replaceable = true; for (auto *user : result.getUsers()) { - if (isa(user)) + if (isa(user)) continue; if (user->getDialect()->getNamespace() == TosaDialect::getDialectNamespace()) @@ -287,7 +287,7 @@ // Insert UnrealizedConversionCasts to guarantee ReturnOp agress with // the FuncOp type. - func.walk([&](ReturnOp op) { + func.walk([&](func::ReturnOp op) { FuncOp parent = dyn_cast(op->getParentOp()); if (!parent) return; @@ -315,7 +315,7 @@ } if (castAdded) { - rewriter.replaceOpWithNewOp(op, castedValues); + rewriter.replaceOpWithNewOp(op, castedValues); } }); } diff --git a/mlir/lib/Dialect/Vector/Utils/CMakeLists.txt b/mlir/lib/Dialect/Vector/Utils/CMakeLists.txt --- a/mlir/lib/Dialect/Vector/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/Vector/Utils/CMakeLists.txt @@ -9,9 +9,9 @@ MLIRAffineAnalysis MLIRArithmetic MLIRDialectUtils + MLIRFunc MLIRIR MLIRMemRef - MLIRStandard MLIRTensor MLIRVector MLIRVectorInterfaces diff --git a/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp b/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp --- a/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp +++ b/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp @@ -15,8 +15,8 @@ #include "mlir/Dialect/Affine/Analysis/LoopAnalysis.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/IR/Builders.h" @@ -283,7 +283,7 @@ superVectorType = transfer.getVectorType(); mustDivide = true; } else if (op.getNumResults() == 0) { - if (!isa(op)) { + if (!isa(op)) { op.emitError("NYI: assuming only return operations can have 0 " " results at this point"); } diff --git a/mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp b/mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp --- a/mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp +++ b/mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp @@ -12,7 +12,6 @@ #include "mlir/Conversion/LLVMCommon/Pattern.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/X86Vector/X86VectorDialect.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/PatternMatch.h" diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt --- a/mlir/lib/ExecutionEngine/CMakeLists.txt +++ b/mlir/lib/ExecutionEngine/CMakeLists.txt @@ -77,9 +77,9 @@ LINK_LIBS PUBLIC ${dialect_libs} MLIRExecutionEngine + MLIRFunc MLIRIR MLIRParser - MLIRStandard MLIRLLVMToLLVMIRTranslation MLIRTargetLLVMIRExport MLIRTransforms diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -608,8 +608,8 @@ name = name.drop_front(defaultDialect.size() + 1); // TODO: remove this special case (and update test/IR/parser.mlir) else if ((defaultDialect.empty() || defaultDialect == "builtin") && - name.startswith("std.")) - name = name.drop_front(4); + name.startswith("func.")) + name = name.drop_front(5); p.getStream() << name; } diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -1672,8 +1672,9 @@ // default dialect (set through OpAsmOpInterface). opInfo = RegisteredOperationName::lookup( Twine(defaultDialect + "." + opName).str(), getContext()); - if (!opInfo && getContext()->getOrLoadDialect("std")) { - opInfo = RegisteredOperationName::lookup(Twine("std." + opName).str(), + // FIXME: Remove this in favor of using default dialects. + if (!opInfo && getContext()->getOrLoadDialect("func")) { + opInfo = RegisteredOperationName::lookup(Twine("func." + opName).str(), getContext()); } if (opInfo) { diff --git a/mlir/lib/Target/Cpp/CMakeLists.txt b/mlir/lib/Target/Cpp/CMakeLists.txt --- a/mlir/lib/Target/Cpp/CMakeLists.txt +++ b/mlir/lib/Target/Cpp/CMakeLists.txt @@ -9,10 +9,10 @@ MLIRArithmetic MLIRControlFlow MLIREmitC + MLIRFunc MLIRIR MLIRMath MLIRSCF - MLIRStandard MLIRSupport MLIRTranslation ) diff --git a/mlir/lib/Target/Cpp/TranslateRegistration.cpp b/mlir/lib/Target/Cpp/TranslateRegistration.cpp --- a/mlir/lib/Target/Cpp/TranslateRegistration.cpp +++ b/mlir/lib/Target/Cpp/TranslateRegistration.cpp @@ -9,9 +9,9 @@ #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlow.h" #include "mlir/Dialect/EmitC/IR/EmitC.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Math/IR/Math.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Dialect.h" #include "mlir/Target/Cpp/CppEmitter.h" @@ -44,8 +44,8 @@ registry.insert(); // clang-format on }); diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp --- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp +++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp @@ -8,8 +8,8 @@ #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" #include "mlir/Dialect/EmitC/IR/EmitC.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" @@ -238,7 +238,7 @@ } static LogicalResult printOperation(CppEmitter &emitter, - mlir::ConstantOp constantOp) { + func::ConstantOp constantOp) { Operation *operation = constantOp.getOperation(); Attribute value = constantOp.getValueAttr(); @@ -311,7 +311,7 @@ return success(); } -static LogicalResult printOperation(CppEmitter &emitter, mlir::CallOp callOp) { +static LogicalResult printOperation(CppEmitter &emitter, func::CallOp callOp) { if (failed(emitter.emitAssignPrefix(*callOp.getOperation()))) return failure(); @@ -545,7 +545,8 @@ return success(); } -static LogicalResult printOperation(CppEmitter &emitter, ReturnOp returnOp) { +static LogicalResult printOperation(CppEmitter &emitter, + func::ReturnOp returnOp) { raw_ostream &os = emitter.ostream(); os << "return"; switch (returnOp.getNumOperands()) { @@ -909,17 +910,22 @@ LogicalResult CppEmitter::emitOperation(Operation &op, bool trailingSemicolon) { LogicalResult status = llvm::TypeSwitch(&op) + // Builtin ops. + .Case( + [&](auto op) { return printOperation(*this, op); }) + // CF ops. + .Case( + [&](auto op) { return printOperation(*this, op); }) // EmitC ops. .Case( [&](auto op) { return printOperation(*this, op); }) + // Func ops. + .Case( + [&](auto op) { return printOperation(*this, op); }) // SCF ops. .Case( [&](auto op) { return printOperation(*this, op); }) - // Standard ops. - .Case( - [&](auto op) { return printOperation(*this, op); }) // Arithmetic ops. .Case( [&](auto op) { return printOperation(*this, op); }) diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt --- a/mlir/python/CMakeLists.txt +++ b/mlir/python/CMakeLists.txt @@ -80,6 +80,15 @@ dialects/cf.py DIALECT_NAME cf) +declare_mlir_dialect_python_bindings( + ADD_TO_PARENT MLIRPythonSources.Dialects + ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir" + TD_FILE dialects/FuncOps.td + SOURCES + dialects/func.py + dialects/_func_ops_ext.py + DIALECT_NAME func) + declare_mlir_dialect_python_bindings( ADD_TO_PARENT MLIRPythonSources.Dialects ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir" @@ -164,15 +173,6 @@ SOURCES dialects/sparse_tensor.py DIALECT_NAME sparse_tensor) -declare_mlir_dialect_python_bindings( - ADD_TO_PARENT MLIRPythonSources.Dialects - ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir" - TD_FILE dialects/StandardOps.td - SOURCES - dialects/std.py - dialects/_std_ops_ext.py - DIALECT_NAME std) - declare_mlir_dialect_python_bindings( ADD_TO_PARENT MLIRPythonSources.Dialects ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir" @@ -232,7 +232,7 @@ MLIRCAPIRegistration # TODO: See about dis-aggregating # Dialects - MLIRCAPIStandard + MLIRCAPIFunc ) declare_mlir_python_extension(MLIRPythonExtension.Dialects.Linalg.Pybind diff --git a/mlir/python/mlir/dialects/StandardOps.td b/mlir/python/mlir/dialects/FuncOps.td rename from mlir/python/mlir/dialects/StandardOps.td rename to mlir/python/mlir/dialects/FuncOps.td --- a/mlir/python/mlir/dialects/StandardOps.td +++ b/mlir/python/mlir/dialects/FuncOps.td @@ -1,4 +1,4 @@ -//===-- StandardOps.td - Entry point for StandardOps bind --*- tablegen -*-===// +//===-- FuncOps.td - Entry point for Func bind -------------*- tablegen -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// // -// This is the main file from which the Python bindings for the Standard -// dialect are generated. +// This is the main file from which the Python bindings for the Func dialect +// are generated. // //===----------------------------------------------------------------------===// -#ifndef PYTHON_BINDINGS_STANDARD_OPS -#define PYTHON_BINDINGS_STANDARD_OPS +#ifndef PYTHON_BINDINGS_FUNC +#define PYTHON_BINDINGS_FUNC include "mlir/Bindings/Python/Attributes.td" -include "mlir/Dialect/StandardOps/IR/Ops.td" +include "mlir/Dialect/Func/IR/FuncOps.td" #endif diff --git a/mlir/python/mlir/dialects/_builtin_ops_ext.py b/mlir/python/mlir/dialects/_builtin_ops_ext.py --- a/mlir/python/mlir/dialects/_builtin_ops_ext.py +++ b/mlir/python/mlir/dialects/_builtin_ops_ext.py @@ -162,7 +162,7 @@ """ def decorator(f): - from . import std + from . import func # Introspect the callable for optional features. sig = inspect.signature(f) has_arg_func_op = False @@ -208,15 +208,15 @@ return_values = return_values.results else: return_values = list(return_values) - std.ReturnOp(return_values) + func.ReturnOp(return_values) # Recompute the function type. return_types = [v.type for v in return_values] function_type = FunctionType.get(inputs=inputs, results=return_types) func_op.attributes["type"] = TypeAttr.get(function_type) def emit_call_op(*call_args): - call_op = std.CallOp(return_types, FlatSymbolRefAttr.get(symbol_name), - call_args) + call_op = func.CallOp(return_types, FlatSymbolRefAttr.get(symbol_name), + call_args) if return_types is None: return None elif len(return_types) == 1: diff --git a/mlir/python/mlir/dialects/_std_ops_ext.py b/mlir/python/mlir/dialects/_func_ops_ext.py rename from mlir/python/mlir/dialects/_std_ops_ext.py rename to mlir/python/mlir/dialects/_func_ops_ext.py --- a/mlir/python/mlir/dialects/_std_ops_ext.py +++ b/mlir/python/mlir/dialects/_func_ops_ext.py @@ -46,8 +46,8 @@ For example f = builtin.FuncOp("foo", ...) - std.CallOp(f, [args]) - std.CallOp([result_types], "foo", [args]) + func.CallOp(f, [args]) + func.CallOp([result_types], "foo", [args]) In all cases, the location and insertion point may be specified as keyword arguments if not provided by the surrounding context managers. diff --git a/mlir/python/mlir/dialects/std.py b/mlir/python/mlir/dialects/func.py rename from mlir/python/mlir/dialects/std.py rename to mlir/python/mlir/dialects/func.py --- a/mlir/python/mlir/dialects/std.py +++ b/mlir/python/mlir/dialects/func.py @@ -2,4 +2,4 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -from ._std_ops_gen import * +from ._func_ops_gen import * diff --git a/mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py --- a/mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py +++ b/mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py @@ -6,8 +6,8 @@ from .....ir import * +from .... import func from .... import linalg -from .... import std from .... import math from .... import arith from ...._ods_common import get_op_result_or_value as _get_op_result_or_value, get_op_results_or_values as _get_op_results_or_values diff --git a/mlir/test/CAPI/CMakeLists.txt b/mlir/test/CAPI/CMakeLists.txt --- a/mlir/test/CAPI/CMakeLists.txt +++ b/mlir/test/CAPI/CMakeLists.txt @@ -34,7 +34,7 @@ ir.c LINK_LIBS PRIVATE MLIRCAPIIR - MLIRCAPIStandard + MLIRCAPIFunc MLIRCAPIRegistration ) diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c --- a/mlir/test/CAPI/ir.c +++ b/mlir/test/CAPI/ir.c @@ -16,7 +16,7 @@ #include "mlir-c/BuiltinAttributes.h" #include "mlir-c/BuiltinTypes.h" #include "mlir-c/Diagnostics.h" -#include "mlir-c/Dialect/Standard.h" +#include "mlir-c/Dialect/Func.h" #include "mlir-c/IntegerSet.h" #include "mlir-c/Registration.h" #include "mlir-c/Support.h" @@ -161,7 +161,7 @@ populateLoopBody(ctx, loopBody, location, funcBody); MlirOperationState retState = mlirOperationStateGet( - mlirStringRefCreateFromCString("std.return"), location); + mlirStringRefCreateFromCString("func.return"), location); MlirOperation ret = mlirOperationCreate(&retState); mlirBlockAppendOwnedOperation(funcBody, ret); @@ -837,10 +837,10 @@ const char data[] = "abcdefghijklmnopqestuvwxyz"; MlirAttribute opaque = - mlirOpaqueAttrGet(ctx, mlirStringRefCreateFromCString("std"), 3, data, + mlirOpaqueAttrGet(ctx, mlirStringRefCreateFromCString("func"), 3, data, mlirNoneTypeGet(ctx)); if (!mlirAttributeIsAOpaque(opaque) || - !stringIsEqual("std", mlirOpaqueAttrGetDialectNamespace(opaque))) + !stringIsEqual("func", mlirOpaqueAttrGetDialectNamespace(opaque))) return 4; MlirStringRef opaqueData = mlirOpaqueAttrGetData(opaque); @@ -848,7 +848,7 @@ strncmp(data, opaqueData.data, opaqueData.length)) return 5; mlirAttributeDump(opaque); - // CHECK: #std.abc + // CHECK: #func.abc MlirAttribute string = mlirStringAttrGet(ctx, mlirStringRefCreate(data + 3, 2)); @@ -1514,7 +1514,7 @@ if (mlirContextGetNumLoadedDialects(ctx) != 1) return 1; - MlirDialectHandle stdHandle = mlirGetDialectHandle__std__(); + MlirDialectHandle stdHandle = mlirGetDialectHandle__func__(); MlirDialect std = mlirContextGetOrLoadDialect( ctx, mlirDialectHandleGetNamespace(stdHandle)); @@ -1546,10 +1546,10 @@ mlirContextIsRegisteredOperation( ctx, mlirStringRefCreateFromCString("cf.cond_br"))); - // CHECK: std.not_existing_op is_registered: 0 - fprintf(stderr, "std.not_existing_op is_registered: %d\n", + // CHECK: func.not_existing_op is_registered: 0 + fprintf(stderr, "func.not_existing_op is_registered: %d\n", mlirContextIsRegisteredOperation( - ctx, mlirStringRefCreateFromCString("std.not_existing_op"))); + ctx, mlirStringRefCreateFromCString("func.not_existing_op"))); // CHECK: not_existing_dialect.not_existing_op is_registered: 0 fprintf(stderr, "not_existing_dialect.not_existing_op is_registered: %d\n", @@ -1674,7 +1674,7 @@ MlirContext ctx = mlirContextCreate(); mlirRegisterAllDialects(ctx); - mlirContextGetOrLoadDialect(ctx, mlirStringRefCreateFromCString("std")); + mlirContextGetOrLoadDialect(ctx, mlirStringRefCreateFromCString("func")); MlirLocation loc = mlirLocationUnknownGet(ctx); MlirType indexType = mlirIndexTypeGet(ctx); MlirStringRef valueStringRef = mlirStringRefCreateFromCString("value"); @@ -1923,7 +1923,7 @@ return 1; } - MlirDialectHandle stdHandle = mlirGetDialectHandle__std__(); + MlirDialectHandle stdHandle = mlirGetDialectHandle__func__(); mlirDialectHandleInsertDialect(stdHandle, registry); MlirContext ctx = mlirContextCreate(); diff --git a/mlir/test/CAPI/pass.c b/mlir/test/CAPI/pass.c --- a/mlir/test/CAPI/pass.c +++ b/mlir/test/CAPI/pass.c @@ -43,7 +43,7 @@ // CHECK-LABEL: Operations encountered: // CHECK: arith.addi , 1 // CHECK: builtin.func , 1 - // CHECK: std.return , 1 + // CHECK: func.return , 1 { MlirPassManager pm = mlirPassManagerCreate(ctx); MlirPass printOpStatPass = mlirCreateTransformsPrintOpStats(); @@ -85,7 +85,7 @@ // CHECK-LABEL: Operations encountered: // CHECK: arith.addi , 1 // CHECK: builtin.func , 1 - // CHECK: std.return , 1 + // CHECK: func.return , 1 { MlirPassManager pm = mlirPassManagerCreate(ctx); MlirOpPassManager nestedFuncPm = mlirPassManagerGetNestedUnder( @@ -101,7 +101,7 @@ // CHECK-LABEL: Operations encountered: // CHECK: arith.addf , 1 // CHECK: builtin.func , 1 - // CHECK: std.return , 1 + // CHECK: func.return , 1 { MlirPassManager pm = mlirPassManagerCreate(ctx); MlirOpPassManager nestedModulePm = mlirPassManagerGetNestedUnder( diff --git a/mlir/test/Conversion/ArithmeticToLLVM/arith-to-llvm.mlir b/mlir/test/Conversion/ArithmeticToLLVM/arith-to-llvm.mlir --- a/mlir/test/Conversion/ArithmeticToLLVM/arith-to-llvm.mlir +++ b/mlir/test/Conversion/ArithmeticToLLVM/arith-to-llvm.mlir @@ -324,7 +324,7 @@ %0 = arith.constant dense<[0, 1, 2, 3]> : vector<4xindex> // CHECK: %[[V:.*]] = llvm.add %{{.*}}, %[[CST]] : vector<4xi64> %1 = arith.addi %arg0, %0 : vector<4xindex> - std.return + func.return } // ----- @@ -347,7 +347,7 @@ // CHECK: %[[CMP:.*]] = llvm.fcmp "olt" %[[EXTRACT1]], %[[EXTRACT2]] : vector<3xf32> // CHECK: %[[INSERT:.*]] = llvm.insertvalue %[[CMP]], %2[0] : !llvm.array<4 x vector<3xi1>> %0 = arith.cmpf olt, %arg0, %arg1 : vector<4x3xf32> - std.return + func.return } // ----- @@ -358,7 +358,7 @@ // CHECK: %[[ARG1:.*]] = builtin.unrealized_conversion_cast // CHECK: %[[CMP:.*]] = llvm.icmp "ult" %[[ARG0]], %[[ARG1]] : vector<1xi32> %0 = arith.cmpi ult, %arg0, %arg1 : vector - std.return + func.return } // ----- @@ -372,7 +372,7 @@ // CHECK: %[[CMP:.*]] = llvm.icmp "ult" %[[EXTRACT1]], %[[EXTRACT2]] : vector<3xi32> // CHECK: %[[INSERT:.*]] = llvm.insertvalue %[[CMP]], %2[0] : !llvm.array<4 x vector<3xi1>> %0 = arith.cmpi ult, %arg0, %arg1 : vector<4x3xi32> - std.return + func.return } // ----- diff --git a/mlir/test/Conversion/ArithmeticToLLVM/convert-nd-vector-to-llvmir.mlir b/mlir/test/Conversion/ArithmeticToLLVM/convert-nd-vector-to-llvmir.mlir --- a/mlir/test/Conversion/ArithmeticToLLVM/convert-nd-vector-to-llvmir.mlir +++ b/mlir/test/Conversion/ArithmeticToLLVM/convert-nd-vector-to-llvmir.mlir @@ -208,5 +208,5 @@ // CHECK: %[[SELECT:.*]] = llvm.select %[[EXTRACT1]], %[[EXTRACT2]], %[[EXTRACT3]] : vector<3xi1>, vector<3xi32> // CHECK: %[[INSERT:.*]] = llvm.insertvalue %[[SELECT]], %{{.*}}[0] : !llvm.array<4 x vector<3xi32>> %0 = arith.select %arg0, %arg1, %arg2 : vector<4x3xi1>, vector<4x3xi32> - std.return + func.return } diff --git a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir --- a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir +++ b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir @@ -49,7 +49,7 @@ // CHECK: = llvm.sext %{{.*}} : i32 to i64 %gDimZ = gpu.grid_dim z - std.return %tIdX, %tIdY, %tIdZ, %bDimX, %bDimY, %bDimZ, + func.return %tIdX, %tIdY, %tIdZ, %bDimX, %bDimY, %bDimZ, %bIdX, %bIdY, %bIdZ, %gDimX, %gDimY, %gDimZ : index, index, index, index, index, index, index, index, index, index, index, index @@ -67,7 +67,7 @@ %0 = arith.addi %idx, %idx : index // CHECK: llvm.return %{{.*}} : i64 // CHECK32: llvm.return %{{.*}} : i32 - std.return %0 : index + func.return %0 : index } } @@ -140,7 +140,7 @@ // CHECK: nvvm.shfl.sync idx {{.*}} {return_value_and_is_valid} : f32 -> !llvm.struct<(f32, i1)> %shfli, %predi = gpu.shuffle idx %arg0, %arg1, %arg2 : f32 - std.return %shfl, %shflu, %shfld, %shfli : f32, f32,f32, f32 + func.return %shfl, %shflu, %shfld, %shfli : f32, f32,f32, f32 } } @@ -151,7 +151,7 @@ builtin.func @gpu_sync() { // CHECK: nvvm.barrier0 gpu.barrier - std.return + func.return } } @@ -166,7 +166,7 @@ // CHECK: llvm.call @__nv_fabsf(%{{.*}}) : (f32) -> f32 %result64 = math.abs %arg_f64 : f64 // CHECK: llvm.call @__nv_fabs(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -181,7 +181,7 @@ // CHECK: llvm.call @__nv_ceilf(%{{.*}}) : (f32) -> f32 %result64 = math.ceil %arg_f64 : f64 // CHECK: llvm.call @__nv_ceil(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -196,7 +196,7 @@ // CHECK: llvm.call @__nv_floorf(%{{.*}}) : (f32) -> f32 %result64 = math.floor %arg_f64 : f64 // CHECK: llvm.call @__nv_floor(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -211,7 +211,7 @@ // CHECK: llvm.call @__nv_cosf(%{{.*}}) : (f32) -> f32 %result64 = math.cos %arg_f64 : f64 // CHECK: llvm.call @__nv_cos(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -225,7 +225,7 @@ // CHECK: llvm.call @__nv_expf(%{{.*}}) : (f32) -> f32 %result64 = math.exp %arg_f64 : f64 // CHECK: llvm.call @__nv_exp(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -239,7 +239,7 @@ // CHECK: llvm.call @__nv_exp2f(%{{.*}}) : (f32) -> f32 %result64 = math.exp2 %arg_f64 : f64 // CHECK: llvm.call @__nv_exp2(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -254,7 +254,7 @@ // CHECK: llvm.call @__nv_logf(%{{.*}}) : (f32) -> f32 %result64 = math.log %arg_f64 : f64 // CHECK: llvm.call @__nv_log(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -269,7 +269,7 @@ // CHECK: llvm.call @__nv_log10f(%{{.*}}) : (f32) -> f32 %result64 = math.log10 %arg_f64 : f64 // CHECK: llvm.call @__nv_log10(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -284,7 +284,7 @@ // CHECK: llvm.call @__nv_log1pf(%{{.*}}) : (f32) -> f32 %result64 = math.log1p %arg_f64 : f64 // CHECK: llvm.call @__nv_log1p(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -299,7 +299,7 @@ // CHECK: llvm.call @__nv_log2f(%{{.*}}) : (f32) -> f32 %result64 = math.log2 %arg_f64 : f64 // CHECK: llvm.call @__nv_log2(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -314,7 +314,7 @@ // CHECK: llvm.call @__nv_sinf(%{{.*}}) : (f32) -> f32 %result64 = math.sin %arg_f64 : f64 // CHECK: llvm.call @__nv_sin(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -333,7 +333,7 @@ // CHECK: llvm.call @__nv_tanhf(%{{.*}}) : (f32) -> f32 %result64 = math.tanh %arg_f64 : f64 // CHECK: llvm.call @__nv_tanh(%{{.*}}) : (f64) -> f64 - std.return %result16, %result32, %result64 : f16, f32, f64 + func.return %result16, %result32, %result64 : f16, f32, f64 } } @@ -353,7 +353,7 @@ // CHECK: llvm.call @__nv_rsqrtf(%{{.*}}) : (f32) -> f32 %result64 = math.rsqrt %arg_f64 : f64 // CHECK: llvm.call @__nv_rsqrt(%{{.*}}) : (f64) -> f64 - std.return %result16, %result32, %result64 : f16, f32, f64 + func.return %result16, %result32, %result64 : f16, f32, f64 } } @@ -373,7 +373,7 @@ // CHECK: llvm.call @__nv_sqrtf(%{{.*}}) : (f32) -> f32 %result64 = math.sqrt %arg_f64 : f64 // CHECK: llvm.call @__nv_sqrt(%{{.*}}) : (f64) -> f64 - std.return %result16, %result32, %result64 : f16, f32, f64 + func.return %result16, %result32, %result64 : f16, f32, f64 } } @@ -393,7 +393,7 @@ // CHECK: llvm.call @__nv_atanf(%{{.*}}) : (f32) -> f32 %result64 = math.atan %arg_f64 : f64 // CHECK: llvm.call @__nv_atan(%{{.*}}) : (f64) -> f64 - std.return %result16, %result32, %result64 : f16, f32, f64 + func.return %result16, %result32, %result64 : f16, f32, f64 } } @@ -414,7 +414,7 @@ // CHECK: llvm.call @__nv_atan2f(%{{.*}}) : (f32, f32) -> f32 %result64 = math.atan2 %arg_f64, %arg_f64 : f64 // CHECK: llvm.call @__nv_atan2(%{{.*}}) : (f64, f64) -> f64 - std.return %result16, %result32, %result64 : f16, f32, f64 + func.return %result16, %result32, %result64 : f16, f32, f64 } } @@ -432,7 +432,7 @@ // CHECK: llvm.call @__nv_expf(%{{.*}}) : (f32) -> f32 %result64 = math.exp %arg_f64 : f64 // CHECK: llvm.call @__nv_exp(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } "test.finish" () : () -> () }) : () -> () @@ -449,7 +449,7 @@ // CHECK: llvm.call @__nv_expm1f(%{{.*}}) : (f32) -> f32 %result64 = math.expm1 %arg_f64 : f64 // CHECK: llvm.call @__nv_expm1(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -464,7 +464,7 @@ // CHECK: llvm.call @__nv_powf(%{{.*}}, %{{.*}}) : (f32, f32) -> f32 %result64 = math.powf %arg_f64, %arg_f64 : f64 // CHECK: llvm.call @__nv_pow(%{{.*}}, %{{.*}}) : (f64, f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } diff --git a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir --- a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir +++ b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir @@ -49,7 +49,7 @@ // CHECK: = llvm.sext %{{.*}} : i32 to i64 %gDimZ = gpu.grid_dim z - std.return %tIdX, %tIdY, %tIdZ, %bDimX, %bDimY, %bDimZ, + func.return %tIdX, %tIdY, %tIdZ, %bDimX, %bDimY, %bDimZ, %bIdX, %bIdY, %bIdZ, %gDimX, %gDimY, %gDimZ : index, index, index, index, index, index, index, index, index, index, index, index @@ -67,7 +67,7 @@ %0 = arith.addi %idx, %idx : index // CHECK: llvm.return %{{.*}} : i64 // CHECK32: llvm.return %{{.*}} : i32 - std.return %0 : index + func.return %0 : index } } @@ -78,7 +78,7 @@ builtin.func @gpu_sync() { // CHECK: rocdl.barrier gpu.barrier - std.return + func.return } } @@ -93,7 +93,7 @@ // CHECK: llvm.call @__ocml_fabs_f32(%{{.*}}) : (f32) -> f32 %result64 = math.abs %arg_f64 : f64 // CHECK: llvm.call @__ocml_fabs_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -108,7 +108,7 @@ // CHECK: llvm.call @__ocml_ceil_f32(%{{.*}}) : (f32) -> f32 %result64 = math.ceil %arg_f64 : f64 // CHECK: llvm.call @__ocml_ceil_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -123,7 +123,7 @@ // CHECK: llvm.call @__ocml_floor_f32(%{{.*}}) : (f32) -> f32 %result64 = math.floor %arg_f64 : f64 // CHECK: llvm.call @__ocml_floor_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -138,7 +138,7 @@ // CHECK: llvm.call @__ocml_cos_f32(%{{.*}}) : (f32) -> f32 %result64 = math.cos %arg_f64 : f64 // CHECK: llvm.call @__ocml_cos_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -155,7 +155,7 @@ // CHECK: llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 %result64 = math.exp %arg_f64 : f64 // CHECK: llvm.call @__ocml_exp_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -172,7 +172,7 @@ // CHECK: llvm.call @__ocml_exp2_f32(%{{.*}}) : (f32) -> f32 %result64 = math.exp2 %arg_f64 : f64 // CHECK: llvm.call @__ocml_exp2_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -192,7 +192,7 @@ // CHECK: llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 %result64 = math.exp %arg_f64 : f64 // CHECK: llvm.call @__ocml_exp_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } "test.finish" () : () -> () }) : () -> () @@ -211,7 +211,7 @@ // CHECK: llvm.call @__ocml_expm1_f32(%{{.*}}) : (f32) -> f32 %result64 = math.expm1 %arg_f64 : f64 // CHECK: llvm.call @__ocml_expm1_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -226,7 +226,7 @@ // CHECK: llvm.call @__ocml_log_f32(%{{.*}}) : (f32) -> f32 %result64 = math.log %arg_f64 : f64 // CHECK: llvm.call @__ocml_log_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -241,7 +241,7 @@ // CHECK: llvm.call @__ocml_log1p_f32(%{{.*}}) : (f32) -> f32 %result64 = math.log1p %arg_f64 : f64 // CHECK: llvm.call @__ocml_log1p_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -256,7 +256,7 @@ // CHECK: llvm.call @__ocml_log10_f32(%{{.*}}) : (f32) -> f32 %result64 = math.log10 %arg_f64 : f64 // CHECK: llvm.call @__ocml_log10_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -271,7 +271,7 @@ // CHECK: llvm.call @__ocml_log2_f32(%{{.*}}) : (f32) -> f32 %result64 = math.log2 %arg_f64 : f64 // CHECK: llvm.call @__ocml_log2_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -291,7 +291,7 @@ // CHECK: llvm.call @__ocml_rsqrt_f32(%{{.*}}) : (f32) -> f32 %result64 = math.rsqrt %arg_f64 : f64 // CHECK: llvm.call @__ocml_rsqrt_f64(%{{.*}}) : (f64) -> f64 - std.return %result16, %result32, %result64 : f16, f32, f64 + func.return %result16, %result32, %result64 : f16, f32, f64 } } @@ -311,7 +311,7 @@ // CHECK: llvm.call @__ocml_sqrt_f32(%{{.*}}) : (f32) -> f32 %result64 = math.sqrt %arg_f64 : f64 // CHECK: llvm.call @__ocml_sqrt_f64(%{{.*}}) : (f64) -> f64 - std.return %result16, %result32, %result64 : f16, f32, f64 + func.return %result16, %result32, %result64 : f16, f32, f64 } } @@ -326,7 +326,7 @@ // CHECK: llvm.call @__ocml_tanh_f32(%{{.*}}) : (f32) -> f32 %result64 = math.tanh %arg_f64 : f64 // CHECK: llvm.call @__ocml_tanh_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -341,7 +341,7 @@ // CHECK: llvm.call @__ocml_atan_f32(%{{.*}}) : (f32) -> f32 %result64 = math.atan %arg_f64 : f64 // CHECK: llvm.call @__ocml_atan_f64(%{{.*}}) : (f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -356,7 +356,7 @@ // CHECK: llvm.call @__ocml_atan2_f32(%{{.*}}) : (f32, f32) -> f32 %result64 = math.atan2 %arg_f64, %arg_f64 : f64 // CHECK: llvm.call @__ocml_atan2_f64(%{{.*}}) : (f64, f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } @@ -371,7 +371,7 @@ // CHECK: llvm.call @__ocml_pow_f32(%{{.*}}, %{{.*}}) : (f32, f32) -> f32 %result64 = math.powf %arg_f64, %arg_f64 : f64 // CHECK: llvm.call @__ocml_pow_f64(%{{.*}}, %{{.*}}) : (f64, f64) -> f64 - std.return %result32, %result64 : f32, f64 + func.return %result32, %result64 : f32, f64 } } diff --git a/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir b/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir --- a/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir +++ b/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir @@ -10,7 +10,7 @@ %19 = math.sqrt %arg0 : f32 // CHECK: = "llvm.intr.sqrt"(%{{.*}}) : (f64) -> f64 %20 = math.sqrt %arg4 : f64 - std.return + func.return } // ----- @@ -22,7 +22,7 @@ // CHECK: %[[ADD:.*]] = llvm.fadd %[[ONE]], %arg0 : f32 // CHECK: %[[LOG:.*]] = "llvm.intr.log"(%[[ADD]]) : (f32) -> f32 %0 = math.log1p %arg0 : f32 - std.return + func.return } // ----- @@ -35,7 +35,7 @@ // CHECK: %[[LOG:.*]] = "llvm.intr.log"(%[[ADD]]) : (vector<3xf32>) -> vector<3xf32> // CHECK: %[[INSERT:.*]] = llvm.insertvalue %[[LOG]], %{{.*}}[0] : !llvm.array<4 x vector<3xf32>> %0 = math.log1p %arg0 : vector<4x3xf32> - std.return + func.return } // ----- @@ -47,7 +47,7 @@ // CHECK: %[[EXP:.*]] = "llvm.intr.exp"(%arg0) : (f32) -> f32 // CHECK: %[[SUB:.*]] = llvm.fsub %[[EXP]], %[[ONE]] : f32 %0 = math.expm1 %arg0 : f32 - std.return + func.return } // ----- @@ -59,7 +59,7 @@ // CHECK: %[[SQRT:.*]] = "llvm.intr.sqrt"(%arg0) : (f32) -> f32 // CHECK: %[[DIV:.*]] = llvm.fdiv %[[ONE]], %[[SQRT]] : f32 %0 = math.rsqrt %arg0 : f32 - std.return + func.return } // ----- @@ -69,7 +69,7 @@ func @sine(%arg0 : f32) { // CHECK: "llvm.intr.sin"(%arg0) : (f32) -> f32 %0 = math.sin %arg0 : f32 - std.return + func.return } // ----- @@ -80,7 +80,7 @@ // CHECK: %[[ZERO:.+]] = llvm.mlir.constant(false) : i1 // CHECK: "llvm.intr.ctlz"(%arg0, %[[ZERO]]) : (i32, i1) -> i32 %0 = math.ctlz %arg0 : i32 - std.return + func.return } // ----- @@ -91,7 +91,7 @@ // CHECK: %[[ZERO:.+]] = llvm.mlir.constant(false) : i1 // CHECK: "llvm.intr.cttz"(%arg0, %[[ZERO]]) : (i32, i1) -> i32 %0 = math.cttz %arg0 : i32 - std.return + func.return } // ----- @@ -102,7 +102,7 @@ // CHECK: %[[ZERO:.+]] = llvm.mlir.constant(false) : i1 // CHECK: "llvm.intr.cttz"(%arg0, %[[ZERO]]) : (vector<4xi32>, i1) -> vector<4xi32> %0 = math.cttz %arg0 : vector<4xi32> - std.return + func.return } // ----- @@ -112,7 +112,7 @@ func @ctpop(%arg0 : i32) { // CHECK: "llvm.intr.ctpop"(%arg0) : (i32) -> i32 %0 = math.ctpop %arg0 : i32 - std.return + func.return } // ----- @@ -122,7 +122,7 @@ func @ctpop_vector(%arg0 : vector<3xi32>) { // CHECK: "llvm.intr.ctpop"(%arg0) : (vector<3xi32>) -> vector<3xi32> %0 = math.ctpop %arg0 : vector<3xi32> - std.return + func.return } // ----- @@ -134,7 +134,7 @@ // CHECK: %[[SQRT:.*]] = "llvm.intr.sqrt"(%arg0) : (f64) -> f64 // CHECK: %[[DIV:.*]] = llvm.fdiv %[[ONE]], %[[SQRT]] : f64 %0 = math.rsqrt %arg0 : f64 - std.return + func.return } // ----- @@ -146,7 +146,7 @@ // CHECK: %[[SQRT:.*]] = "llvm.intr.sqrt"(%arg0) : (vector<4xf32>) -> vector<4xf32> // CHECK: %[[DIV:.*]] = llvm.fdiv %[[ONE]], %[[SQRT]] : vector<4xf32> %0 = math.rsqrt %arg0 : vector<4xf32> - std.return + func.return } // ----- @@ -159,7 +159,7 @@ // CHECK: %[[DIV:.*]] = llvm.fdiv %[[ONE]], %[[SQRT]] : vector<3xf32> // CHECK: %[[INSERT:.*]] = llvm.insertvalue %[[DIV]], %{{.*}}[0] : !llvm.array<4 x vector<3xf32>> %0 = math.rsqrt %arg0 : vector<4x3xf32> - std.return + func.return } // ----- @@ -169,6 +169,6 @@ func @powf(%arg0 : f64) { // CHECK: %[[POWF:.*]] = "llvm.intr.pow"(%arg0, %arg0) : (f64, f64) -> f64 %0 = math.powf %arg0, %arg0 : f64 - std.return + func.return } diff --git a/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir b/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir --- a/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir +++ b/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir @@ -571,7 +571,7 @@ %1 = arith.constant 7 : index // CHECK: llvm.load %{{.*}} : !llvm.ptr %2 = memref.load %0[%1] : memref<32xf32, affine_map<(d0) -> (d0)>, 5> - std.return + func.return } // ----- diff --git a/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir b/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir --- a/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir +++ b/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir @@ -74,7 +74,7 @@ // ----- -// Express `get_extent` as `std.tensor.extract`. +// Express `get_extent` as `tensor.extract`. // CHECK-LABEL: @get_extent_from_extent_tensor // CHECK-SAME: (%[[EXTENTS:.*]]: tensor, %[[IDX:.*]]: index) -> index func @get_extent_from_extent_tensor(%extents : tensor, %idx : index) diff --git a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir --- a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir +++ b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir @@ -454,7 +454,7 @@ func @ceilf(%arg0 : f32) { // CHECK: "llvm.intr.ceil"(%arg0) : (f32) -> f32 %0 = math.ceil %arg0 : f32 - std.return + func.return } // ----- @@ -464,7 +464,7 @@ func @floorf(%arg0 : f32) { // CHECK: "llvm.intr.floor"(%arg0) : (f32) -> f32 %0 = math.floor %arg0 : f32 - std.return + func.return } // ----- @@ -507,7 +507,7 @@ %0 = math.fma %arg0, %arg0, %arg0 : f32 // CHECK: %[[V:.*]] = "llvm.intr.fma"(%[[ARG1]], %[[ARG1]], %[[ARG1]]) : (vector<4xf32>, vector<4xf32>, vector<4xf32>) -> vector<4xf32> %1 = math.fma %arg1, %arg1, %arg1 : vector<4xf32> - std.return + func.return } // ----- @@ -521,10 +521,10 @@ ] ^bb1: %c_1 = arith.constant 1 : i32 - std.return %c_1 : i32 + func.return %c_1 : i32 ^bb3: %c_42 = arith.constant 42 : i32 - std.return %c_42: i32 + func.return %c_42: i32 } // CHECK: llvm.switch %arg0 : i8, ^bb1 [ // CHECK-NEXT: 42: ^bb1, diff --git a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir --- a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir +++ b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir @@ -264,7 +264,7 @@ // ----- //===----------------------------------------------------------------------===// -// std.cmpf +// arith.cmpf //===----------------------------------------------------------------------===// module attributes { @@ -348,7 +348,7 @@ // ----- //===----------------------------------------------------------------------===// -// std.cmpi +// arith.cmpi //===----------------------------------------------------------------------===// module attributes { @@ -849,7 +849,7 @@ // ----- //===----------------------------------------------------------------------===// -// std.return +// func.return //===----------------------------------------------------------------------===// module attributes { diff --git a/mlir/test/Dialect/Arithmetic/ops.mlir b/mlir/test/Dialect/Arithmetic/ops.mlir --- a/mlir/test/Dialect/Arithmetic/ops.mlir +++ b/mlir/test/Dialect/Arithmetic/ops.mlir @@ -903,8 +903,8 @@ // CHECK: %c42_i32_0 = arith.constant 42 : i32 %1 = arith.constant 42 : i32 - // CHECK: %c43 = arith.constant {crazy = "std.foo"} 43 : index - %2 = arith.constant {crazy = "std.foo"} 43: index + // CHECK: %c43 = arith.constant {crazy = "func.foo"} 43 : index + %2 = arith.constant {crazy = "func.foo"} 43: index // CHECK: %cst = arith.constant 4.300000e+01 : bf16 %3 = arith.constant 43.0 : bf16 diff --git a/mlir/test/Dialect/Tensor/invalid.mlir b/mlir/test/Dialect/Tensor/invalid.mlir --- a/mlir/test/Dialect/Tensor/invalid.mlir +++ b/mlir/test/Dialect/Tensor/invalid.mlir @@ -91,7 +91,7 @@ func @tensor.generate(%m : index, %n : index) -> tensor { - // expected-error @+2 {{op expects regions to end with 'tensor.yield', found 'std.return'}} + // expected-error @+2 {{op expects regions to end with 'tensor.yield', found 'func.return'}} // expected-note @+1 {{in custom textual format, the absence of terminator implies 'tensor.yield'}} %tnsr = tensor.generate %m, %n { ^bb0(%i : index, %j : index, %k : index): diff --git a/mlir/test/IR/core-ops.mlir b/mlir/test/IR/core-ops.mlir --- a/mlir/test/IR/core-ops.mlir +++ b/mlir/test/IR/core-ops.mlir @@ -205,7 +205,7 @@ // CHECK-LABEL: func @return_op(%arg0: i32) -> i32 { func @return_op(%a : i32) -> i32 { // CHECK: return %arg0 : i32 - "std.return" (%a) : (i32)->() + "func.return" (%a) : (i32)->() } // CHECK-LABEL: func @calls(%arg0: i32) { @@ -215,7 +215,7 @@ // CHECK: %1 = call @return_op(%0) : (i32) -> i32 %y = call @return_op(%x) : (i32) -> i32 // CHECK: %2 = call @return_op(%0) : (i32) -> i32 - %z = "std.call"(%x) {callee = @return_op} : (i32) -> i32 + %z = "func.call"(%x) {callee = @return_op} : (i32) -> i32 // CHECK: %f = constant @affine_apply : () -> () %f = constant @affine_apply : () -> () @@ -230,7 +230,7 @@ %2 = call_indirect %f_0(%arg0) : (i32) -> i32 // CHECK: %4 = call_indirect %f_0(%arg0) : (i32) -> i32 - %3 = "std.call_indirect"(%f_0, %arg0) : ((i32) -> i32, i32) -> i32 + %3 = "func.call_indirect"(%f_0, %arg0) : ((i32) -> i32, i32) -> i32 return } diff --git a/mlir/test/IR/generic-visitors-interrupt.mlir b/mlir/test/IR/generic-visitors-interrupt.mlir --- a/mlir/test/IR/generic-visitors-interrupt.mlir +++ b/mlir/test/IR/generic-visitors-interrupt.mlir @@ -108,7 +108,7 @@ // CHECK: step 0 op 'builtin.module' before all regions // CHECK: step 1 op 'builtin.func' before all regions // CHECK: step 2 op 'arith.addf' before all regions -// CHECK: step 3 op 'std.return' before all regions +// CHECK: step 3 op 'func.return' before all regions // CHECK: step 4 op 'builtin.func' after all regions // CHECK: step 5 op 'builtin.module' after all regions @@ -131,7 +131,7 @@ // CHECK: step 4 op 'foo' before region #1 // CHECK: step 5 op 'bar1' before all regions // CHECK: step 6 op 'arith.addf' before all regions -// CHECK: step 7 op 'std.return' before all regions +// CHECK: step 7 op 'func.return' before all regions // CHECK: step 8 op 'builtin.func' after all regions // CHECK: step 9 op 'builtin.module' after all regions @@ -152,6 +152,6 @@ // CHECK: step 2 op 'foo' before all regions // CHECK: step 3 op 'bar0' before all regions // CHECK: step 4 op 'arith.addf' before all regions -// CHECK: step 5 op 'std.return' before all regions +// CHECK: step 5 op 'func.return' before all regions // CHECK: step 6 op 'builtin.func' after all regions // CHECK: step 7 op 'builtin.module' after all regions diff --git a/mlir/test/IR/generic-visitors.mlir b/mlir/test/IR/generic-visitors.mlir --- a/mlir/test/IR/generic-visitors.mlir +++ b/mlir/test/IR/generic-visitors.mlir @@ -36,7 +36,7 @@ // CHECK: step 14 op 'use3' before all regions // CHECK: step 15 op 'scf.yield' before all regions // CHECK: step 16 op 'scf.for' after all regions -// CHECK: step 17 op 'std.return' before all regions +// CHECK: step 17 op 'func.return' before all regions // CHECK: step 18 op 'builtin.func' after all regions // CHECK: step 19 op 'builtin.module' after all regions diff --git a/mlir/test/IR/invalid-ops.mlir b/mlir/test/IR/invalid-ops.mlir --- a/mlir/test/IR/invalid-ops.mlir +++ b/mlir/test/IR/invalid-ops.mlir @@ -37,8 +37,8 @@ // ----- func @unknown_std_op() { - // expected-error@+1 {{unregistered operation 'std.foo_bar_op' found in dialect ('std') that does not allow unknown operations}} - %0 = "std.foo_bar_op"() : () -> index + // expected-error@+1 {{unregistered operation 'func.foo_bar_op' found in dialect ('func') that does not allow unknown operations}} + %0 = "func.foo_bar_op"() : () -> index return } @@ -98,7 +98,7 @@ func @return_not_in_function() { "foo.region"() ({ - // expected-error@+1 {{'std.return' op expects parent op 'builtin.func'}} + // expected-error@+1 {{'func.return' op expects parent op 'builtin.func'}} return }): () -> () return diff --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir --- a/mlir/test/IR/invalid.mlir +++ b/mlir/test/IR/invalid.mlir @@ -355,13 +355,13 @@ func @resulterror() -> i32 { ^bb42: - return // expected-error {{'std.return' op has 0 operands, but enclosing function (@resulterror) returns 1}} + return // expected-error {{'func.return' op has 0 operands, but enclosing function (@resulterror) returns 1}} } // ----- func @func_resulterror() -> i32 { - return // expected-error {{'std.return' op has 0 operands, but enclosing function (@func_resulterror) returns 1}} + return // expected-error {{'func.return' op has 0 operands, but enclosing function (@func_resulterror) returns 1}} } // ----- @@ -536,7 +536,7 @@ func @return_inside_loop() { affine.for %i = 1 to 100 { - // expected-error@-1 {{op expects regions to end with 'affine.yield', found 'std.return'}} + // expected-error@-1 {{op expects regions to end with 'affine.yield', found 'func.return'}} // expected-note@-2 {{in custom textual format, the absence of terminator implies}} return } diff --git a/mlir/test/IR/op-stats.mlir b/mlir/test/IR/op-stats.mlir --- a/mlir/test/IR/op-stats.mlir +++ b/mlir/test/IR/op-stats.mlir @@ -31,6 +31,6 @@ // CHECK-LABEL: Operations encountered // CHECK: arith.addf , 6 +// CHECK: func.return , 1 // CHECK: long_op_name , 1 -// CHECK: std.return , 1 // CHECK: xla.add , 17 diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir --- a/mlir/test/IR/parser.mlir +++ b/mlir/test/IR/parser.mlir @@ -456,11 +456,11 @@ ^bb2(%a : i17): %true = arith.constant true // CHECK: return %{{.*}}, %{{.*}} : i1, i17 - "std.return"(%true, %a) : (i1, i17) -> () + "func.return"(%true, %a) : (i1, i17) -> () ^bb3(%b : i1, %c : i17): // CHECK: return %{{.*}}, %{{.*}} : i1, i17 - "std.return"(%b, %c) : (i1, i17) -> () + "func.return"(%b, %c) : (i1, i17) -> () } // CHECK-LABEL: func @condbr_simple @@ -1276,17 +1276,11 @@ // example. // CHECK: "test.op_with_attr"() {test.attr = "test.value"} : () -> () "test.op_with_attr"() {test.attr = "test.value"} : () -> () - - // TODO: remove this after removing the special casing for std in the printer. - // Verify that operations in the standard dialect keep the `std.` prefix. - // CHECK: cf.assert - cf.assert %bool, "Assertion" "test.terminator"() : ()->() } - // The same operation outside of the region does not have an std. prefix. - // CHECK-NOT: std.assert + // The same operation outside of the region does not have an func. prefix. // CHECK: return - std.return + func.return } // CHECK-LABEL: func @unreachable_dominance_violation_ok diff --git a/mlir/test/IR/print-op-generic.mlir b/mlir/test/IR/print-op-generic.mlir --- a/mlir/test/IR/print-op-generic.mlir +++ b/mlir/test/IR/print-op-generic.mlir @@ -9,5 +9,5 @@ // GENERIC: %0 = "test.string_attr_pretty_name"() return // CHECK: return - // GENERIC: "std.return"() + // GENERIC: "func.return"() } diff --git a/mlir/test/IR/visitors.mlir b/mlir/test/IR/visitors.mlir --- a/mlir/test/IR/visitors.mlir +++ b/mlir/test/IR/visitors.mlir @@ -30,7 +30,7 @@ // CHECK: Visiting op 'use1' // CHECK: Visiting op 'use2' // CHECK: Visiting op 'use3' -// CHECK: Visiting op 'std.return' +// CHECK: Visiting op 'func.return' // CHECK-LABEL: Block pre-order visits // CHECK: Visiting block ^bb0 from region 0 from operation 'builtin.module' @@ -53,7 +53,7 @@ // CHECK: Visiting op 'scf.if' // CHECK: Visiting op 'use3' // CHECK: Visiting op 'scf.for' -// CHECK: Visiting op 'std.return' +// CHECK: Visiting op 'func.return' // CHECK: Visiting op 'builtin.func' // CHECK: Visiting op 'builtin.module' @@ -73,7 +73,7 @@ // CHECK-LABEL: Op pre-order erasures // CHECK: Erasing op 'scf.for' -// CHECK: Erasing op 'std.return' +// CHECK: Erasing op 'func.return' // CHECK-LABEL: Block pre-order erasures // CHECK: Erasing block ^bb0 from region 0 from operation 'scf.for' @@ -85,7 +85,7 @@ // CHECK: Erasing op 'scf.if' // CHECK: Erasing op 'use3' // CHECK: Erasing op 'scf.for' -// CHECK: Erasing op 'std.return' +// CHECK: Erasing op 'func.return' // CHECK-LABEL: Block post-order erasures (skip) // CHECK: Erasing block ^bb0 from region 0 from operation 'scf.if' @@ -99,7 +99,7 @@ // CHECK: Erasing op 'scf.if' // CHECK: Erasing op 'use3' // CHECK: Erasing op 'scf.for' -// CHECK: Erasing op 'std.return' +// CHECK: Erasing op 'func.return' // CHECK: Erasing op 'builtin.func' // CHECK: Erasing op 'builtin.module' @@ -135,7 +135,7 @@ // CHECK: Visiting op 'op1' // CHECK: Visiting op 'cf.br' // CHECK: Visiting op 'op2' -// CHECK: Visiting op 'std.return' +// CHECK: Visiting op 'func.return' // CHECK-LABEL: Block pre-order visits // CHECK: Visiting block ^bb0 from region 0 from operation 'builtin.module' @@ -156,7 +156,7 @@ // CHECK: Visiting op 'cf.br' // CHECK: Visiting op 'op2' // CHECK: Visiting op 'regionOp0' -// CHECK: Visiting op 'std.return' +// CHECK: Visiting op 'func.return' // CHECK: Visiting op 'builtin.func' // CHECK: Visiting op 'builtin.module' @@ -174,7 +174,7 @@ // CHECK-LABEL: Op pre-order erasures (skip) // CHECK: Erasing op 'regionOp0' -// CHECK: Erasing op 'std.return' +// CHECK: Erasing op 'func.return' // CHECK-LABEL: Block pre-order erasures (skip) // CHECK: Erasing block ^bb0 from region 0 from operation 'regionOp0' @@ -188,7 +188,7 @@ // CHECK: Erasing op 'cf.br' // CHECK: Erasing op 'op2' // CHECK: Erasing op 'regionOp0' -// CHECK: Erasing op 'std.return' +// CHECK: Erasing op 'func.return' // CHECK-LABEL: Block post-order erasures (skip) // CHECK: Erasing block ^bb0 from region 0 from operation 'regionOp0' @@ -202,7 +202,7 @@ // CHECK: Erasing op 'cf.br' // CHECK: Erasing op 'op2' // CHECK: Erasing op 'regionOp0' -// CHECK: Erasing op 'std.return' +// CHECK: Erasing op 'func.return' // CHECK-LABEL: Block post-order erasures (no skip) // CHECK: Erasing block ^bb0 from region 0 from operation 'regionOp0' diff --git a/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py b/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py --- a/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py +++ b/mlir/test/Integration/Dialect/SparseTensor/python/test_stress.py @@ -16,7 +16,7 @@ from mlir.execution_engine import ExecutionEngine from mlir.dialects import builtin -from mlir.dialects import std +from mlir.dialects import func from mlir.dialects import sparse_tensor as st _SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) @@ -122,7 +122,7 @@ st.ReleaseOp(v.result) v = w self._assertEqualsRoundtripTp(v.result.type) - std.ReturnOp(v) + func.ReturnOp(v) return self def writeTo(self, filename): diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco.py b/mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco.py --- a/mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco.py +++ b/mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco.py @@ -34,8 +34,8 @@ from mlir import runtime from mlir.dialects import arith from mlir.dialects import builtin +from mlir.dialects import func from mlir.dialects import linalg -from mlir.dialects import std from mlir.dialects import sparse_tensor from mlir.dialects.linalg.opdsl import lang diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco_utils.py b/mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco_utils.py --- a/mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco_utils.py +++ b/mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco_utils.py @@ -314,7 +314,7 @@ func @{_ENTRY_NAME}(%t: tensor<{shape}x{type}, #enc>, %filename: !Ptr) attributes {{ llvm.emit_c_interface }} {{ sparse_tensor.out %t, %filename : tensor<{shape}x{type}, #enc>, !Ptr - std.return + func.return }}""" diff --git a/mlir/test/Transforms/test-legalizer.mlir b/mlir/test/Transforms/test-legalizer.mlir --- a/mlir/test/Transforms/test-legalizer.mlir +++ b/mlir/test/Transforms/test-legalizer.mlir @@ -4,7 +4,7 @@ func @verifyDirectPattern() -> i32 { // CHECK-NEXT: "test.legal_op_a"() {status = "Success"} %result = "test.illegal_op_a"() : () -> (i32) - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return %result : i32 } @@ -12,7 +12,7 @@ func @verifyLargerBenefit() -> i32 { // CHECK-NEXT: "test.legal_op_a"() {status = "Success"} %result = "test.illegal_op_c"() : () -> (i32) - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return %result : i32 } @@ -29,7 +29,7 @@ func @remap_call_1_to_1(%arg0: i64) { // CHECK-NEXT: call @remap_input_1_to_1(%arg0) : (f64) -> () call @remap_input_1_to_1(%arg0) : (i64) -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -78,7 +78,7 @@ // CHECK-NEXT: "test.valid"{{.*}} : (i64, i64) "test.invalid"(%i0, %i1) : (i64, i64) -> () }) : () -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -92,7 +92,7 @@ ^bb1(%i0: i64, %unused: i16, %i1: i64, %2: f32): "test.invalid"(%i0, %i1, %2) : (i64, i64, f32) -> () }) : () -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -106,7 +106,7 @@ ^bb1(%i0: i64, %unused: i16, %i1: i64, %2: f32): "test.invalid"(%i0, %i1, %2) : (i64, i64, f32) -> () }) {legalizer.should_clone} : () -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -118,7 +118,7 @@ ^bb1(%i0: i64, %unused: i16, %i1: i64, %2: f32): "test.invalid"(%i0, %i1, %2) : (i64, i64, f32) -> () }) : () -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -135,7 +135,7 @@ // CHECK-NEXT: return %repl_1 = "test.rewrite"(%arg) : (i8) -> i8 %repl_2 = "test.rewrite"(%repl_1) : (i8) -> i8 - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return %repl_2 : i8 } @@ -146,7 +146,7 @@ %0 = "test.op_with_region_fold"(%arg0) ({ "foo.op_with_region_terminator"() : () -> () }) : (i32) -> (i32) - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return %0 : i32 } @@ -157,7 +157,7 @@ // CHECK: ^{{.*}}(%{{.*}}: i32, %{{.*}}: i32): "test.create_block"() : () -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -165,7 +165,7 @@ func @bounded_recursion() { // CHECK: test.recursive_rewrite 0 test.recursive_rewrite 3 - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -227,7 +227,7 @@ // expected-remark@+1 {{op 'test.create_illegal_block' is not legalizable}} "test.create_illegal_block"() : () -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -243,7 +243,7 @@ "test.return"(%arg0) : (i32) -> () }) : () -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -279,7 +279,7 @@ func @undo_child_created_before_parent() { // expected-remark@+1 {{is not legalizable}} "test.illegal_op_with_region_anchor"() : () -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } @@ -291,7 +291,7 @@ func @blackhole() { %input = "test.blackhole_producer"() : () -> (i32) "test.blackhole"(%input) : (i32) -> () - // expected-remark@+1 {{op 'std.return' is not legalizable}} + // expected-remark@+1 {{op 'func.return' is not legalizable}} return } diff --git a/mlir/test/lib/Conversion/StandardToLLVM/TestConvertCallOp.cpp b/mlir/test/lib/Conversion/StandardToLLVM/TestConvertCallOp.cpp --- a/mlir/test/lib/Conversion/StandardToLLVM/TestConvertCallOp.cpp +++ b/mlir/test/lib/Conversion/StandardToLLVM/TestConvertCallOp.cpp @@ -10,8 +10,8 @@ #include "TestTypes.h" #include "mlir/Conversion/LLVMCommon/Pattern.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" using namespace mlir; @@ -40,7 +40,7 @@ } StringRef getArgument() const final { return "test-convert-call-op"; } StringRef getDescription() const final { - return "Tests conversion of `std.call` to `llvm.call` in " + return "Tests conversion of `func.call` to `llvm.call` in " "presence of custom types"; } @@ -65,7 +65,7 @@ ConversionTarget target(getContext()); target.addLegalDialect(); target.addIllegalDialect(); - target.addIllegalDialect(); + target.addIllegalDialect(); if (failed(applyPartialConversion(m, target, std::move(patterns)))) signalPassFailure(); diff --git a/mlir/test/lib/Dialect/Affine/TestLoopFusion.cpp b/mlir/test/lib/Dialect/Affine/TestLoopFusion.cpp --- a/mlir/test/lib/Dialect/Affine/TestLoopFusion.cpp +++ b/mlir/test/lib/Dialect/Affine/TestLoopFusion.cpp @@ -14,7 +14,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/LoopFusionUtils.h" #include "mlir/Dialect/Affine/LoopUtils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Pass/Pass.h" #define DEBUG_TYPE "test-loop-fusion" diff --git a/mlir/test/lib/Dialect/CMakeLists.txt b/mlir/test/lib/Dialect/CMakeLists.txt --- a/mlir/test/lib/Dialect/CMakeLists.txt +++ b/mlir/test/lib/Dialect/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(Affine) add_subdirectory(DLTI) +add_subdirectory(Func) add_subdirectory(GPU) add_subdirectory(Linalg) add_subdirectory(Math) @@ -7,7 +8,6 @@ add_subdirectory(SCF) add_subdirectory(Shape) add_subdirectory(SPIRV) -add_subdirectory(StandardOps) add_subdirectory(Tensor) add_subdirectory(Test) add_subdirectory(Tosa) diff --git a/mlir/test/lib/Dialect/StandardOps/CMakeLists.txt b/mlir/test/lib/Dialect/Func/CMakeLists.txt rename from mlir/test/lib/Dialect/StandardOps/CMakeLists.txt rename to mlir/test/lib/Dialect/Func/CMakeLists.txt --- a/mlir/test/lib/Dialect/StandardOps/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Func/CMakeLists.txt @@ -1,5 +1,5 @@ # Exclude tests from libMLIR.so -add_mlir_library(MLIRStandardOpsTestPasses +add_mlir_library(MLIRFuncTestPasses TestDecomposeCallGraphTypes.cpp EXCLUDE_FROM_LIBMLIR @@ -7,12 +7,12 @@ LINK_LIBS PUBLIC MLIRAffine MLIRPass - MLIRStandardOpsTransforms + MLIRFuncTransforms MLIRTestDialect MLIRTransformUtils ) -target_include_directories(MLIRStandardOpsTestPasses +target_include_directories(MLIRFuncTestPasses PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../Test ${CMAKE_CURRENT_BINARY_DIR}/../Test diff --git a/mlir/test/lib/Dialect/StandardOps/TestDecomposeCallGraphTypes.cpp b/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp rename from mlir/test/lib/Dialect/StandardOps/TestDecomposeCallGraphTypes.cpp rename to mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp --- a/mlir/test/lib/Dialect/StandardOps/TestDecomposeCallGraphTypes.cpp +++ b/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "TestDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h" #include "mlir/IR/Builders.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" @@ -43,11 +43,11 @@ target.addLegalDialect(); - target.addDynamicallyLegalOp([&](ReturnOp op) { + target.addDynamicallyLegalOp([&](func::ReturnOp op) { return typeConverter.isLegal(op.getOperandTypes()); }); - target.addDynamicallyLegalOp( - [&](CallOp op) { return typeConverter.isLegal(op); }); + target.addDynamicallyLegalOp( + [&](func::CallOp op) { return typeConverter.isLegal(op); }); target.addDynamicallyLegalOp([&](FuncOp op) { return typeConverter.isSignatureLegal(op.getType()); }); diff --git a/mlir/test/lib/Dialect/GPU/CMakeLists.txt b/mlir/test/lib/Dialect/GPU/CMakeLists.txt --- a/mlir/test/lib/Dialect/GPU/CMakeLists.txt +++ b/mlir/test/lib/Dialect/GPU/CMakeLists.txt @@ -10,6 +10,7 @@ LINK_LIBS PUBLIC MLIRAffine + MLIRFunc MLIRGPUOps MLIRGPUToGPURuntimeTransforms MLIRLLVMToLLVMIRTranslation @@ -19,6 +20,5 @@ MLIRROCDLIR MLIRROCDLToLLVMIRTranslation MLIRSCF - MLIRStandard MLIRTransformUtils ) diff --git a/mlir/test/lib/Dialect/GPU/TestGpuMemoryPromotion.cpp b/mlir/test/lib/Dialect/GPU/TestGpuMemoryPromotion.cpp --- a/mlir/test/lib/Dialect/GPU/TestGpuMemoryPromotion.cpp +++ b/mlir/test/lib/Dialect/GPU/TestGpuMemoryPromotion.cpp @@ -12,12 +12,12 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/GPU/MemoryPromotion.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Attributes.h" #include "mlir/Pass/Pass.h" @@ -32,7 +32,7 @@ : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); } StringRef getArgument() const final { return "test-gpu-memory-promotion"; } diff --git a/mlir/test/lib/Dialect/GPU/TestGpuRewrite.cpp b/mlir/test/lib/Dialect/GPU/TestGpuRewrite.cpp --- a/mlir/test/lib/Dialect/GPU/TestGpuRewrite.cpp +++ b/mlir/test/lib/Dialect/GPU/TestGpuRewrite.cpp @@ -11,9 +11,9 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/Passes.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" @@ -23,7 +23,7 @@ struct TestGpuRewritePass : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); } StringRef getArgument() const final { return "test-gpu-rewrite"; } diff --git a/mlir/test/lib/Dialect/Linalg/CMakeLists.txt b/mlir/test/lib/Dialect/Linalg/CMakeLists.txt --- a/mlir/test/lib/Dialect/Linalg/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Linalg/CMakeLists.txt @@ -16,6 +16,8 @@ MLIRArithmeticTransforms MLIRBufferization MLIRBufferizationTransforms + MLIRFunc + MLIRFuncTransforms MLIRGPUTransforms MLIRLinalg MLIRLinalgTransforms @@ -24,8 +26,6 @@ MLIRPass MLIRSCF MLIRSCFTransforms - MLIRStandard - MLIRStandardOpsTransforms MLIRTensor MLIRTensorTransforms MLIRTransformUtils diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp @@ -13,11 +13,11 @@ #include #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Transforms/CodegenStrategy.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" @@ -41,11 +41,11 @@ void getDependentDialects(DialectRegistry ®istry) const override { // clang-format off registry.insert(); // clang-format on } diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp @@ -114,8 +114,8 @@ : public PassWrapper, OperationPass> { void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } TestLinalgFusionTransforms() = default; TestLinalgFusionTransforms(const TestLinalgFusionTransforms &pass) {} diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp @@ -12,6 +12,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Passes.h" @@ -19,7 +20,6 @@ #include "mlir/Dialect/Linalg/Transforms/Hoisting.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/Pass/PassManager.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" @@ -39,9 +39,9 @@ void getDependentDialects(DialectRegistry ®istry) const override { // clang-format off registry.insert(); diff --git a/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp b/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp --- a/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp +++ b/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp @@ -11,9 +11,9 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Builders.h" #include "mlir/Pass/Pass.h" @@ -49,7 +49,7 @@ } void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() override { diff --git a/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp b/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp --- a/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp +++ b/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp @@ -11,10 +11,10 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" #include "mlir/Dialect/SCF/Utils/Utils.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Builders.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" @@ -146,7 +146,7 @@ } void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() override { diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -59,6 +59,8 @@ MLIRDerivedAttributeOpInterface MLIRDialect MLIRDLTI + MLIRFunc + MLIRFuncTransforms MLIRIR MLIRInferTypeOpInterface MLIRLinalg @@ -66,8 +68,6 @@ MLIRLLVMIR MLIRPass MLIRReduce - MLIRStandard - MLIRStandardOpsTransforms MLIRTensor MLIRTransformUtils MLIRTransforms diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -12,7 +12,7 @@ #include "TestTypes.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/Dialect/DLTI/DLTI.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/DialectImplementation.h" @@ -368,8 +368,8 @@ LogicalResult matchAndRewrite(FoldToCallOp op, PatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(op, TypeRange(), op.getCalleeAttr(), - ValueRange()); + rewriter.replaceOpWithNewOp(op, TypeRange(), + op.getCalleeAttr(), ValueRange()); return success(); } }; diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -9,8 +9,8 @@ #include "TestDialect.h" #include "TestTypes.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/Dialect/StandardOps/Transforms/FuncConversions.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/Dialect/Func/Transforms/FuncConversions.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/Matchers.h" #include "mlir/Pass/Pass.h" @@ -642,7 +642,7 @@ TestLegalizePatternDriver(ConversionMode mode) : mode(mode) {} void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() override { @@ -679,8 +679,8 @@ return converter.isSignatureLegal(op.getType()) && converter.isLegal(&op.getBody()); }); - target.addDynamicallyLegalOp( - [&](CallOp op) { return converter.isLegal(op); }); + target.addDynamicallyLegalOp( + [&](func::CallOp op) { return converter.isLegal(op); }); // TestCreateUnregisteredOp creates `arith.constant` operation, // which was not added to target intentionally to test diff --git a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp --- a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp +++ b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/Dialect/Tosa/Transforms/PassDetail.h" diff --git a/mlir/test/lib/Dialect/Vector/CMakeLists.txt b/mlir/test/lib/Dialect/Vector/CMakeLists.txt --- a/mlir/test/lib/Dialect/Vector/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Vector/CMakeLists.txt @@ -7,13 +7,13 @@ LINK_LIBS PUBLIC MLIRAffine MLIRAnalysis + MLIRFunc MLIRLinalg MLIRLinalgTransforms MLIRLLVMIR MLIRMemRef MLIRPass MLIRSCF - MLIRStandard MLIRTransformUtils MLIRVector MLIRVectorToSCF diff --git a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp --- a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp +++ b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp @@ -10,13 +10,13 @@ #include "mlir/Analysis/SliceAnalysis.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/Transforms/VectorTransforms.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" @@ -391,7 +391,7 @@ type.getNumElements() % multiplicity != 0) return mlir::WalkResult::advance(); auto filterAlloc = [](Operation *op) { - return !isa(op); + return !isa(op); }; auto dependentOps = getSlice(op, filterAlloc); // Create a loop and move instructions from the Op slice into the loop. diff --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp --- a/mlir/test/lib/IR/TestMatchers.cpp +++ b/mlir/test/lib/IR/TestMatchers.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Matchers.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/IR/TestOperationEquals.cpp b/mlir/test/lib/IR/TestOperationEquals.cpp --- a/mlir/test/lib/IR/TestOperationEquals.cpp +++ b/mlir/test/lib/IR/TestOperationEquals.cpp @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/IR/TestPrintDefUse.cpp b/mlir/test/lib/IR/TestPrintDefUse.cpp --- a/mlir/test/lib/IR/TestPrintDefUse.cpp +++ b/mlir/test/lib/IR/TestPrintDefUse.cpp @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/IR/TestPrintNesting.cpp b/mlir/test/lib/IR/TestPrintNesting.cpp --- a/mlir/test/lib/IR/TestPrintNesting.cpp +++ b/mlir/test/lib/IR/TestPrintNesting.cpp @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/IR/TestSlicing.cpp b/mlir/test/lib/IR/TestSlicing.cpp --- a/mlir/test/lib/IR/TestSlicing.cpp +++ b/mlir/test/lib/IR/TestSlicing.cpp @@ -11,8 +11,8 @@ //===----------------------------------------------------------------------===// #include "mlir/Analysis/SliceAnalysis.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/PatternMatch.h" @@ -39,7 +39,7 @@ getBackwardSlice(op, &slice); for (Operation *slicedOp : slice) builder.clone(*slicedOp, mapper); - builder.create(loc); + builder.create(loc); return success(); } diff --git a/mlir/test/lib/Transforms/TestInlining.cpp b/mlir/test/lib/Transforms/TestInlining.cpp --- a/mlir/test/lib/Transforms/TestInlining.cpp +++ b/mlir/test/lib/Transforms/TestInlining.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "TestDialect.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/Pass/Pass.h" @@ -34,8 +34,9 @@ auto function = getOperation(); // Collect each of the direct function calls within the module. - SmallVector callers; - function.walk([&](CallIndirectOp caller) { callers.push_back(caller); }); + SmallVector callers; + function.walk( + [&](func::CallIndirectOp caller) { callers.push_back(caller); }); // Build the inliner interface. InlinerInterface interface(&getContext()); diff --git a/mlir/test/mlir-opt/commandline.mlir b/mlir/test/mlir-opt/commandline.mlir --- a/mlir/test/mlir-opt/commandline.mlir +++ b/mlir/test/mlir-opt/commandline.mlir @@ -13,6 +13,7 @@ // CHECK-NEXT: complex // CHECK-NEXT: dlti // CHECK-NEXT: emitc +// CHECK-NEXT: func // CHECK-NEXT: gpu // CHECK-NEXT: linalg // CHECK-NEXT: llvm @@ -28,7 +29,6 @@ // CHECK-NEXT: shape // CHECK-NEXT: sparse_tensor // CHECK-NEXT: spv -// CHECK-NEXT: std // CHECK-NEXT: tensor // CHECK-NEXT: test // CHECK-NEXT: tosa diff --git a/mlir/test/python/dialects/builtin.py b/mlir/test/python/dialects/builtin.py --- a/mlir/test/python/dialects/builtin.py +++ b/mlir/test/python/dialects/builtin.py @@ -2,7 +2,7 @@ from mlir.ir import * import mlir.dialects.builtin as builtin -import mlir.dialects.std as std +import mlir.dialects.func as func def run(f): @@ -92,7 +92,7 @@ # CHECK: return %arg1 : f64 @builtin.FuncOp.from_py_func(f32, f64, results=[f64]) def explicit_results(a, b): - std.ReturnOp([b]) + func.ReturnOp([b]) print(m) @@ -125,42 +125,42 @@ f32 = F32Type.get() tensor_type = RankedTensorType.get((2, 3, 4), f32) with InsertionPoint.at_block_begin(m.body): - func = builtin.FuncOp(name="some_func", + f = builtin.FuncOp(name="some_func", type=FunctionType.get( inputs=[tensor_type, tensor_type], results=[tensor_type]), visibility="nested") # CHECK: Name is: "some_func" - print("Name is: ", func.name) + print("Name is: ", f.name) # CHECK: Type is: (tensor<2x3x4xf32>, tensor<2x3x4xf32>) -> tensor<2x3x4xf32> - print("Type is: ", func.type) + print("Type is: ", f.type) # CHECK: Visibility is: "nested" - print("Visibility is: ", func.visibility) + print("Visibility is: ", f.visibility) try: - entry_block = func.entry_block + entry_block = f.entry_block except IndexError as e: # CHECK: External function does not have a body print(e) - with InsertionPoint(func.add_entry_block()): - std.ReturnOp([func.entry_block.arguments[0]]) + with InsertionPoint(f.add_entry_block()): + func.ReturnOp([f.entry_block.arguments[0]]) pass try: - func.add_entry_block() + f.add_entry_block() except IndexError as e: # CHECK: The function already has an entry block! print(e) # Try the callback builder and passing type as tuple. - func = builtin.FuncOp(name="some_other_func", + f = builtin.FuncOp(name="some_other_func", type=([tensor_type, tensor_type], [tensor_type]), visibility="nested", - body_builder=lambda func: std.ReturnOp( - [func.entry_block.arguments[0]])) + body_builder=lambda f: func.ReturnOp( + [f.entry_block.arguments[0]])) # CHECK: module { # CHECK: func nested @some_func(%arg0: tensor<2x3x4xf32>, %arg1: tensor<2x3x4xf32>) -> tensor<2x3x4xf32> { @@ -181,34 +181,34 @@ f32 = F32Type.get() f64 = F64Type.get() with InsertionPoint(module.body): - func = builtin.FuncOp("some_func", ([f32, f32], [f32, f32])) - with InsertionPoint(func.add_entry_block()): - std.ReturnOp(func.arguments) - func.arg_attrs = ArrayAttr.get([ + f = builtin.FuncOp("some_func", ([f32, f32], [f32, f32])) + with InsertionPoint(f.add_entry_block()): + func.ReturnOp(f.arguments) + f.arg_attrs = ArrayAttr.get([ DictAttr.get({ "custom_dialect.foo": StringAttr.get("bar"), "custom_dialect.baz": UnitAttr.get() }), DictAttr.get({"custom_dialect.qux": ArrayAttr.get([])}) ]) - func.result_attrs = ArrayAttr.get([ + f.result_attrs = ArrayAttr.get([ DictAttr.get({"custom_dialect.res1": FloatAttr.get(f32, 42.0)}), DictAttr.get({"custom_dialect.res2": FloatAttr.get(f64, 256.0)}) ]) other = builtin.FuncOp("other_func", ([f32, f32], [])) with InsertionPoint(other.add_entry_block()): - std.ReturnOp([]) + func.ReturnOp([]) other.arg_attrs = [ DictAttr.get({"custom_dialect.foo": StringAttr.get("qux")}), DictAttr.get() ] # CHECK: [{custom_dialect.baz, custom_dialect.foo = "bar"}, {custom_dialect.qux = []}] - print(func.arg_attrs) + print(f.arg_attrs) # CHECK: [{custom_dialect.res1 = 4.200000e+01 : f32}, {custom_dialect.res2 = 2.560000e+02 : f64}] - print(func.result_attrs) + print(f.result_attrs) # CHECK: func @some_func( # CHECK: %[[ARG0:.*]]: f32 {custom_dialect.baz, custom_dialect.foo = "bar"}, diff --git a/mlir/test/python/dialects/std.py b/mlir/test/python/dialects/func.py rename from mlir/test/python/dialects/std.py rename to mlir/test/python/dialects/func.py --- a/mlir/test/python/dialects/std.py +++ b/mlir/test/python/dialects/func.py @@ -3,7 +3,7 @@ from mlir.ir import * from mlir.dialects import arith from mlir.dialects import builtin -from mlir.dialects import std +from mlir.dialects import func def constructAndPrintInModule(f): @@ -85,10 +85,10 @@ qux.sym_visibility = StringAttr.get("private") with InsertionPoint(builtin.FuncOp("caller", ([], [])).add_entry_block()): - std.CallOp(foo, []) - std.CallOp([IndexType.get()], "bar", []) - std.CallOp([F32Type.get()], FlatSymbolRefAttr.get("qux"), []) - std.ReturnOp([]) + func.CallOp(foo, []) + func.CallOp([IndexType.get()], "bar", []) + func.CallOp([F32Type.get()], FlatSymbolRefAttr.get("qux"), []) + func.ReturnOp([]) # CHECK: func private @foo() diff --git a/mlir/test/python/dialects/linalg/opdsl/emit_convolution.py b/mlir/test/python/dialects/linalg/opdsl/emit_convolution.py --- a/mlir/test/python/dialects/linalg/opdsl/emit_convolution.py +++ b/mlir/test/python/dialects/linalg/opdsl/emit_convolution.py @@ -2,8 +2,8 @@ from mlir.ir import * from mlir.dialects import builtin +from mlir.dialects import func from mlir.dialects import linalg -from mlir.dialects import std from mlir.dialects.linalg.opdsl.lang import * diff --git a/mlir/test/python/dialects/linalg/opdsl/emit_fill.py b/mlir/test/python/dialects/linalg/opdsl/emit_fill.py --- a/mlir/test/python/dialects/linalg/opdsl/emit_fill.py +++ b/mlir/test/python/dialects/linalg/opdsl/emit_fill.py @@ -2,8 +2,8 @@ from mlir.ir import * from mlir.dialects import builtin +from mlir.dialects import func from mlir.dialects import linalg -from mlir.dialects import std from mlir.dialects.linalg.opdsl.lang import * diff --git a/mlir/test/python/dialects/linalg/opdsl/emit_matmul.py b/mlir/test/python/dialects/linalg/opdsl/emit_matmul.py --- a/mlir/test/python/dialects/linalg/opdsl/emit_matmul.py +++ b/mlir/test/python/dialects/linalg/opdsl/emit_matmul.py @@ -2,8 +2,8 @@ from mlir.ir import * from mlir.dialects import builtin +from mlir.dialects import func from mlir.dialects import linalg -from mlir.dialects import std from mlir.dialects.linalg.opdsl.lang import * diff --git a/mlir/test/python/dialects/linalg/opdsl/emit_misc.py b/mlir/test/python/dialects/linalg/opdsl/emit_misc.py --- a/mlir/test/python/dialects/linalg/opdsl/emit_misc.py +++ b/mlir/test/python/dialects/linalg/opdsl/emit_misc.py @@ -2,8 +2,8 @@ from mlir.ir import * from mlir.dialects import builtin +from mlir.dialects import func from mlir.dialects import linalg -from mlir.dialects import std from mlir.dialects.linalg.opdsl.lang import * diff --git a/mlir/test/python/dialects/linalg/opdsl/emit_pooling.py b/mlir/test/python/dialects/linalg/opdsl/emit_pooling.py --- a/mlir/test/python/dialects/linalg/opdsl/emit_pooling.py +++ b/mlir/test/python/dialects/linalg/opdsl/emit_pooling.py @@ -2,8 +2,8 @@ from mlir.ir import * from mlir.dialects import builtin +from mlir.dialects import func from mlir.dialects import linalg -from mlir.dialects import std from mlir.dialects.linalg.opdsl.lang import * diff --git a/mlir/test/python/dialects/linalg/ops.py b/mlir/test/python/dialects/linalg/ops.py --- a/mlir/test/python/dialects/linalg/ops.py +++ b/mlir/test/python/dialects/linalg/ops.py @@ -1,10 +1,10 @@ # RUN: %PYTHON %s | FileCheck %s from mlir.ir import * +from mlir.dialects import arith from mlir.dialects import builtin +from mlir.dialects import func from mlir.dialects import linalg -from mlir.dialects import std -from mlir.dialects import arith from mlir.dialects.linalg.opdsl.lang import * diff --git a/mlir/test/python/dialects/memref.py b/mlir/test/python/dialects/memref.py --- a/mlir/test/python/dialects/memref.py +++ b/mlir/test/python/dialects/memref.py @@ -1,7 +1,7 @@ # RUN: %PYTHON %s | FileCheck %s from mlir.ir import * -import mlir.dialects.std as std +import mlir.dialects.func as func import mlir.dialects.memref as memref @@ -63,10 +63,10 @@ return } """) - func = module.body.operations[0] - func_body = func.regions[0].blocks[0] + f = module.body.operations[0] + func_body = f.regions[0].blocks[0] with InsertionPoint.at_block_terminator(func_body): - memref.LoadOp(func.arguments[0], func.arguments[1:]) + memref.LoadOp(f.arguments[0], f.arguments[1:]) # CHECK: func @f1(%[[ARG0:.*]]: memref, %[[ARG1:.*]]: index, %[[ARG2:.*]]: index) # CHECK: memref.load %[[ARG0]][%[[ARG1]], %[[ARG2]]] diff --git a/mlir/test/python/dialects/scf.py b/mlir/test/python/dialects/scf.py --- a/mlir/test/python/dialects/scf.py +++ b/mlir/test/python/dialects/scf.py @@ -2,8 +2,8 @@ from mlir.ir import * from mlir.dialects import arith +from mlir.dialects import func from mlir.dialects import scf -from mlir.dialects import std from mlir.dialects import builtin @@ -59,16 +59,16 @@ index_type = IndexType.get() callee = builtin.FuncOp( "callee", ([], [index_type, index_type]), visibility="private") - func = builtin.FuncOp("ops_as_arguments", ([], [])) - with InsertionPoint(func.add_entry_block()): + f = builtin.FuncOp("ops_as_arguments", ([], [])) + with InsertionPoint(f.add_entry_block()): lb = arith.ConstantOp.create_index(0) ub = arith.ConstantOp.create_index(42) step = arith.ConstantOp.create_index(2) - iter_args = std.CallOp(callee, []) + iter_args = func.CallOp(callee, []) loop = scf.ForOp(lb, ub, step, iter_args) with InsertionPoint(loop.body): scf.YieldOp(loop.inner_iter_args) - std.ReturnOp([]) + func.ReturnOp([]) # CHECK-LABEL: TEST: testOpsAsArguments diff --git a/mlir/test/python/dialects/vector.py b/mlir/test/python/dialects/vector.py --- a/mlir/test/python/dialects/vector.py +++ b/mlir/test/python/dialects/vector.py @@ -2,7 +2,7 @@ from mlir.ir import * import mlir.dialects.builtin as builtin -import mlir.dialects.std as std +import mlir.dialects.func as func import mlir.dialects.vector as vector def run(f): @@ -40,16 +40,16 @@ mask_type = VectorType.get(vector_type.shape, IntegerType.get_signless(1)) identity_map = AffineMap.get_identity(vector_type.rank) identity_map_attr = AffineMapAttr.get(identity_map) - func = builtin.FuncOp("transfer_read", + f = builtin.FuncOp("transfer_read", ([memref_type, index_type, F32Type.get(), mask_type], [])) - with InsertionPoint(func.add_entry_block()): - A, zero, padding, mask = func.arguments + with InsertionPoint(f.add_entry_block()): + A, zero, padding, mask = f.arguments vector.TransferReadOp(vector_type, A, [zero, zero], identity_map_attr, padding, mask, None) vector.TransferReadOp(vector_type, A, [zero, zero], identity_map_attr, padding, None, None) - std.ReturnOp([]) + func.ReturnOp([]) # CHECK: @transfer_read(%[[MEM:.*]]: memref, %[[IDX:.*]]: index, # CHECK: %[[PAD:.*]]: f32, %[[MASK:.*]]: vector<2x3xi1>) diff --git a/mlir/test/python/integration/dialects/linalg/opsrun.py b/mlir/test/python/integration/dialects/linalg/opsrun.py --- a/mlir/test/python/integration/dialects/linalg/opsrun.py +++ b/mlir/test/python/integration/dialects/linalg/opsrun.py @@ -4,8 +4,8 @@ import sys from mlir.ir import * from mlir.dialects import builtin +from mlir.dialects import func from mlir.dialects import linalg -from mlir.dialects import std from mlir.passmanager import * from mlir.execution_engine import * diff --git a/mlir/test/python/ir/blocks.py b/mlir/test/python/ir/blocks.py --- a/mlir/test/python/ir/blocks.py +++ b/mlir/test/python/ir/blocks.py @@ -6,8 +6,7 @@ from mlir.ir import * from mlir.dialects import builtin from mlir.dialects import cf -# Note: std dialect needed for terminators. -from mlir.dialects import std +from mlir.dialects import func def run(f): @@ -39,7 +38,7 @@ successor_block = entry_block.create_after(i32_arg.type) with InsertionPoint(successor_block) as successor_ip: assert successor_ip.block == successor_block - std.ReturnOp([]) + func.ReturnOp([]) middle_block = successor_block.create_before(i16_arg.type) with InsertionPoint(entry_block) as entry_ip: @@ -63,11 +62,11 @@ module = Module.create() f32 = F32Type.get() with InsertionPoint(module.body): - func = builtin.FuncOp("test", ([f32], [])) - entry_block = Block.create_at_start(func.operation.regions[0], [f32]) + f = builtin.FuncOp("test", ([f32], [])) + entry_block = Block.create_at_start(f.operation.regions[0], [f32]) with InsertionPoint(entry_block): - std.ReturnOp([]) + func.ReturnOp([]) print(module) assert module.operation.verify() - assert func.body.blocks[0] == entry_block + assert f.body.blocks[0] == entry_block diff --git a/mlir/test/python/ir/dialects.py b/mlir/test/python/ir/dialects.py --- a/mlir/test/python/ir/dialects.py +++ b/mlir/test/python/ir/dialects.py @@ -16,10 +16,10 @@ @run def testDialectDescriptor(): ctx = Context() - d = ctx.get_dialect_descriptor("std") - # CHECK: + d = ctx.get_dialect_descriptor("func") + # CHECK: print(d) - # CHECK: std + # CHECK: func print(d.namespace) try: _ = ctx.get_dialect_descriptor("not_existing") @@ -34,8 +34,8 @@ def testUserDialectClass(): ctx = Context() # Access using attribute. - d = ctx.dialects.std - # CHECK: + d = ctx.dialects.func + # CHECK: print(d) try: _ = ctx.dialects.not_existing @@ -45,8 +45,8 @@ assert False, "Expected exception" # Access using index. - d = ctx.dialects["std"] - # CHECK: + d = ctx.dialects["func"] + # CHECK: print(d) try: _ = ctx.dialects["not_existing"] @@ -56,8 +56,8 @@ assert False, "Expected exception" # Using the 'd' alias. - d = ctx.d["std"] - # CHECK: + d = ctx.d["func"] + # CHECK: print(d) @@ -102,5 +102,5 @@ # CHECK: cf.cond_br: True print(f"cf.cond_br: {ctx.is_registered_operation('cf.cond_br')}") - # CHECK: std.not_existing: False - print(f"std.not_existing: {ctx.is_registered_operation('std.not_existing')}") + # CHECK: func.not_existing: False + print(f"func.not_existing: {ctx.is_registered_operation('func.not_existing')}") diff --git a/mlir/test/python/ir/operation.py b/mlir/test/python/ir/operation.py --- a/mlir/test/python/ir/operation.py +++ b/mlir/test/python/ir/operation.py @@ -128,7 +128,7 @@ r""" builtin.module { builtin.func @f() { - std.return + func.return } } """, ctx) @@ -564,7 +564,7 @@ # Test get_asm with options. # CHECK: value = opaque<"elided_large_const", "0xDEADBEEF"> : tensor<4xi32> - # CHECK: "std.return"(%arg0) : (i32) -> () -:4:7 + # CHECK: "func.return"(%arg0) : (i32) -> () -:4:7 module.operation.print( large_elements_limit=2, enable_debug_info=True, @@ -587,7 +587,7 @@ """) print(module) - # addf should map to a known OpView class in the std dialect. + # addf should map to a known OpView class in the arithmetic dialect. # We know the OpView for it defines an 'lhs' attribute. addf = module.body.operations[2] # CHECK: (); + mlir::func::FuncDialect, mlir::memref::MemRefDialect>(); mlir::registerLLVMDialectTranslation(registry); return mlir::JitRunnerMain(argc, argv, registry, jitRunnerConfig); diff --git a/mlir/tools/mlir-vulkan-runner/CMakeLists.txt b/mlir/tools/mlir-vulkan-runner/CMakeLists.txt --- a/mlir/tools/mlir-vulkan-runner/CMakeLists.txt +++ b/mlir/tools/mlir-vulkan-runner/CMakeLists.txt @@ -58,6 +58,7 @@ MLIRAnalysis MLIRArithmetic MLIRExecutionEngine + MLIRFunc MLIRGPUOps MLIRIR MLIRJitRunner @@ -69,7 +70,6 @@ MLIRParser MLIRSPIRV MLIRSPIRVTransforms - MLIRStandard MLIRSupport MLIRTargetLLVMIRExport MLIRTransforms diff --git a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp --- a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp +++ b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp @@ -20,6 +20,7 @@ #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Conversion/StandardToSPIRV/StandardToSPIRVPass.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/GPU/Passes.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" @@ -28,7 +29,6 @@ #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" #include "mlir/Dialect/SPIRV/Transforms/Passes.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/ExecutionEngine/JitRunner.h" #include "mlir/ExecutionEngine/OptUtils.h" #include "mlir/Pass/Pass.h" @@ -75,7 +75,7 @@ mlir::DialectRegistry registry; registry.insert(); + mlir::func::FuncDialect, mlir::memref::MemRefDialect>(); mlir::registerLLVMDialectTranslation(registry); return mlir::JitRunnerMain(argc, argv, registry, jitRunnerConfig); diff --git a/mlir/unittests/Conversion/PDLToPDLInterp/CMakeLists.txt b/mlir/unittests/Conversion/PDLToPDLInterp/CMakeLists.txt --- a/mlir/unittests/Conversion/PDLToPDLInterp/CMakeLists.txt +++ b/mlir/unittests/Conversion/PDLToPDLInterp/CMakeLists.txt @@ -3,6 +3,6 @@ ) target_link_libraries(MLIRPDLToPDLInterpTests PRIVATE - MLIRStandard + MLIRFunc MLIRPDLToPDLInterp ) diff --git a/mlir/unittests/Interfaces/CMakeLists.txt b/mlir/unittests/Interfaces/CMakeLists.txt --- a/mlir/unittests/Interfaces/CMakeLists.txt +++ b/mlir/unittests/Interfaces/CMakeLists.txt @@ -9,7 +9,7 @@ MLIRControlFlowInterfaces MLIRDataLayoutInterfaces MLIRDLTI + MLIRFunc MLIRInferTypeOpInterface MLIRParser - MLIRStandard ) diff --git a/mlir/unittests/Interfaces/InferTypeOpInterfaceTest.cpp b/mlir/unittests/Interfaces/InferTypeOpInterfaceTest.cpp --- a/mlir/unittests/Interfaces/InferTypeOpInterfaceTest.cpp +++ b/mlir/unittests/Interfaces/InferTypeOpInterfaceTest.cpp @@ -8,7 +8,7 @@ #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" -#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Dialect.h" @@ -33,7 +33,7 @@ } )MLIR"; - registry.insert(); + registry.insert(); ctx.appendDialectRegistry(registry); module = parseSourceString(ir, &ctx); mapFn = cast(module->front()); diff --git a/mlir/utils/vim/syntax/mlir.vim b/mlir/utils/vim/syntax/mlir.vim --- a/mlir/utils/vim/syntax/mlir.vim +++ b/mlir/utils/vim/syntax/mlir.vim @@ -34,7 +34,6 @@ syn match mlirType /x\s*\zsvector/ " Operations. -" Standard dialect ops. " TODO: this list is not exhaustive. syn keyword mlirOps alloc alloca addf addi and call call_indirect cmpf cmpi syn keyword mlirOps constant dealloc divf dma_start dma_wait dim exp