From 23aa5a744666b281af807b1f598f517bf0d597cb Mon Sep 17 00:00:00 2001 From: River Riddle Date: Sat, 26 Feb 2022 14:49:54 -0800 Subject: [PATCH] [mlir] Rename the Standard dialect to the Func dialect The last remaining operations in the standard dialect all revolve around FuncOp/function related constructs. This patch simply handles the initial renaming (which by itself is already huge), but there are a large number of cleanups unlocked/necessary afterwards: * Removing a bunch of unnecessary dependencies on Func * Cleaning up the From/ToStandard conversion passes * Preparing for the move of FuncOp to the Func dialect See the discussion at https://discourse.llvm.org/t/standard-dialect-the-final-chapter/6061 Differential Revision: https://reviews.llvm.org/D120624 --- flang/include/flang/Lower/Support/Utils.h | 2 +- .../include/flang/Optimizer/Builder/Factory.h | 2 +- .../Optimizer/Builder/Runtime/Character.h | 2 +- .../flang/Optimizer/Builder/Runtime/Numeric.h | 2 +- .../Optimizer/Builder/Runtime/Reduction.h | 2 +- .../Builder/Runtime/Transformational.h | 2 +- .../Dialect/CanonicalizationPatterns.td | 1 - .../include/flang/Optimizer/Dialect/FIROps.h | 2 +- .../flang/Optimizer/Dialect/FIROpsSupport.h | 4 +- .../include/flang/Optimizer/Support/InitFIR.h | 2 +- flang/include/flang/Optimizer/Support/Utils.h | 2 +- .../flang/Optimizer/Transforms/Passes.td | 10 +-- flang/lib/Lower/Bridge.cpp | 4 +- flang/lib/Lower/CMakeLists.txt | 2 +- flang/lib/Lower/ConvertExpr.cpp | 2 +- .../Optimizer/Builder/Runtime/Character.cpp | 2 +- .../lib/Optimizer/Builder/Runtime/Numeric.cpp | 2 +- .../Optimizer/Builder/Runtime/Reduction.cpp | 2 +- .../Builder/Runtime/Transformational.cpp | 2 +- flang/lib/Optimizer/CodeGen/CGOps.h | 2 +- flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp | 2 +- flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | 8 +- flang/lib/Optimizer/Dialect/FIRDialect.cpp | 2 +- flang/lib/Optimizer/Dialect/FIROps.cpp | 2 +- .../Optimizer/Transforms/AbstractResult.cpp | 14 +-- .../Optimizer/Transforms/AffineDemotion.cpp | 4 +- .../Optimizer/Transforms/AffinePromotion.cpp | 4 +- .../Optimizer/Transforms/ArrayValueCopy.cpp | 2 +- .../Transforms/CharacterConversion.cpp | 4 +- .../Transforms/MemRefDataFlowOpt.cpp | 2 +- .../Optimizer/Transforms/MemoryAllocation.cpp | 6 +- flang/lib/Optimizer/Transforms/PassDetail.h | 2 +- .../lib/Optimizer/Transforms/RewriteLoop.cpp | 4 +- mlir/benchmark/python/common.py | 10 +-- mlir/docs/Bindings/Python.md | 10 +-- mlir/docs/Bufferization.md | 2 +- mlir/docs/DialectConversion.md | 16 ++-- mlir/docs/Dialects/Affine.md | 2 +- mlir/docs/Dialects/Func.md | 15 ++++ mlir/docs/Dialects/Standard.md | 15 ---- mlir/docs/Dialects/Vector.md | 2 +- mlir/docs/Dialects/emitc.md | 8 +- mlir/docs/LangRef.md | 2 +- mlir/docs/OpDefinitions.md | 2 +- mlir/docs/Passes.md | 8 +- mlir/docs/SymbolsAndSymbolTables.md | 2 +- mlir/docs/TargetLLVMIR.md | 4 +- mlir/docs/Tutorials/CreatingADialect.md | 2 +- mlir/docs/Tutorials/Toy/Ch-5.md | 4 +- .../standalone-opt/standalone-opt.cpp | 2 +- .../toy/Ch5/mlir/LowerToAffineLoops.cpp | 12 +-- .../toy/Ch6/mlir/LowerToAffineLoops.cpp | 12 +-- mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp | 11 +-- .../toy/Ch7/mlir/LowerToAffineLoops.cpp | 12 +-- mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp | 11 +-- .../mlir-c/Dialect/{Standard.h => Func.h} | 12 +-- mlir/include/mlir-c/Registration.h | 2 +- .../Conversion/LLVMCommon/LoweringOptions.h | 4 +- .../Conversion/LLVMCommon/TypeConverter.h | 2 +- .../LinalgToStandard/LinalgToStandard.h | 2 +- mlir/include/mlir/Conversion/Passes.td | 12 +-- .../mlir/Conversion/VectorToSCF/VectorToSCF.h | 2 +- .../Dialect/Affine/Analysis/AffineAnalysis.h | 2 +- .../Dialect/Arithmetic/Transforms/Passes.td | 2 +- .../mlir/Dialect/ArmSVE/ArmSVEDialect.h | 2 +- mlir/include/mlir/Dialect/CMakeLists.txt | 2 +- .../Dialect/ControlFlow/IR/ControlFlowOps.td | 6 +- .../{StandardOps => Func}/CMakeLists.txt | 0 .../mlir/Dialect/Func/IR/CMakeLists.txt | 8 ++ .../IR/Ops.h => Func/IR/FuncOps.h} | 26 ++---- .../IR/Ops.td => Func/IR/FuncOps.td} | 87 ++++++++----------- .../Dialect/Func/Transforms/CMakeLists.txt | 5 ++ .../Transforms/DecomposeCallGraphTypes.h | 6 +- .../Transforms/FuncConversions.h | 10 +-- .../{StandardOps => Func}/Transforms/Passes.h | 12 +-- .../Transforms/Passes.td | 14 +-- .../Dialect/Linalg/Transforms/Transforms.h | 4 +- .../include/mlir/Dialect/Linalg/Utils/Utils.h | 2 +- mlir/include/mlir/Dialect/Math/IR/MathOps.td | 6 -- .../mlir/Dialect/MemRef/IR/MemRefOps.td | 2 +- .../mlir/Dialect/MemRef/Transforms/Passes.h | 4 +- .../mlir/Dialect/MemRef/Transforms/Passes.td | 4 +- mlir/include/mlir/Dialect/PDL/IR/PDLOps.td | 2 +- .../Dialect/StandardOps/IR/CMakeLists.txt | 10 --- .../StandardOps/Transforms/CMakeLists.txt | 5 -- .../mlir/Dialect/Tosa/Transforms/PassDetail.h | 2 +- .../mlir/Dialect/Tosa/Transforms/Passes.td | 2 +- .../mlir/Dialect/Tosa/Utils/CoversionUtils.h | 2 +- mlir/include/mlir/InitAllDialects.h | 4 +- mlir/include/mlir/InitAllPasses.h | 4 +- mlir/lib/CAPI/Dialect/CMakeLists.txt | 6 +- .../CAPI/Dialect/{Standard.cpp => Func.cpp} | 8 +- .../AffineToStandard/AffineToStandard.cpp | 8 +- .../AffineToStandard/CMakeLists.txt | 2 +- .../Conversion/AsyncToLLVM/AsyncToLLVM.cpp | 76 ++++++++-------- .../lib/Conversion/AsyncToLLVM/CMakeLists.txt | 2 +- .../Conversion/ComplexToLLVM/CMakeLists.txt | 2 +- .../ComplexToLLVM/ComplexToLLVM.cpp | 2 +- .../ComplexToStandard/CMakeLists.txt | 2 +- .../ComplexToStandard/ComplexToStandard.cpp | 4 +- .../ControlFlowToLLVM/ControlFlowToLLVM.cpp | 2 +- .../Conversion/GPUCommon/GPUOpsLowering.cpp | 2 +- .../GPUCommon/IndexIntrinsicsOpLowering.h | 2 +- .../GPUCommon/OpToFuncCallLowering.h | 4 +- .../lib/Conversion/GPUToVulkan/CMakeLists.txt | 2 +- ...ConvertGPULaunchFuncToVulkanLaunchFunc.cpp | 4 +- .../LinalgToSPIRV/LinalgToSPIRV.cpp | 2 +- .../LinalgToStandard/LinalgToStandard.cpp | 10 +-- mlir/lib/Conversion/MathToLibm/CMakeLists.txt | 2 +- mlir/lib/Conversion/MathToLibm/MathToLibm.cpp | 8 +- .../Conversion/MemRefToLLVM/MemRefToLLVM.cpp | 2 +- .../Conversion/OpenACCToSCF/OpenACCToSCF.cpp | 2 +- mlir/lib/Conversion/PassDetail.h | 5 +- mlir/lib/Conversion/SCFToGPU/CMakeLists.txt | 2 +- mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp | 2 +- mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp | 2 +- .../lib/Conversion/SCFToOpenMP/CMakeLists.txt | 2 +- .../Conversion/SCFToOpenMP/SCFToOpenMP.cpp | 2 +- mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt | 2 +- .../ConvertLaunchFuncToLLVMCalls.cpp | 2 +- .../Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp | 2 +- .../ConvertShapeConstraints.cpp | 2 +- .../ShapeToStandard/ShapeToStandard.cpp | 4 +- .../Conversion/StandardToLLVM/CMakeLists.txt | 2 +- .../StandardToLLVM/StandardToLLVM.cpp | 23 ++--- .../Conversion/StandardToSPIRV/CMakeLists.txt | 2 +- .../StandardToSPIRV/StandardToSPIRV.cpp | 12 +-- .../Conversion/TosaToLinalg/TosaToLinalg.cpp | 2 +- .../TosaToLinalg/TosaToLinalgNamed.cpp | 2 +- .../TosaToLinalg/TosaToLinalgNamedPass.cpp | 8 +- .../TosaToLinalg/TosaToLinalgPass.cpp | 8 +- mlir/lib/Conversion/TosaToSCF/CMakeLists.txt | 2 +- .../Conversion/TosaToStandard/CMakeLists.txt | 2 +- .../TosaToStandard/TosaToStandard.cpp | 4 +- .../TosaToStandard/TosaToStandardPass.cpp | 4 +- .../VectorToLLVM/ConvertVectorToLLVM.cpp | 2 +- .../VectorToLLVM/ConvertVectorToLLVMPass.cpp | 4 +- .../VectorToROCDL/VectorToROCDL.cpp | 2 +- .../AMX/Transforms/LegalizeForLLVMExport.cpp | 2 +- .../Affine/Analysis/AffineAnalysis.cpp | 2 +- .../Affine/Analysis/AffineStructures.cpp | 2 +- .../Dialect/Affine/Analysis/NestedMatcher.cpp | 2 +- mlir/lib/Dialect/Affine/Analysis/Utils.cpp | 2 +- .../Transforms/AffineDataCopyGeneration.cpp | 2 +- .../AffineLoopInvariantCodeMotion.cpp | 2 +- .../Dialect/Affine/Transforms/CMakeLists.txt | 2 +- .../Arithmetic/Transforms/ExpandOps.cpp | 4 +- .../Arithmetic/Transforms/PassDetail.h | 6 +- .../Dialect/ArmSVE/Transforms/CMakeLists.txt | 2 +- .../Transforms/LegalizeForLLVMExport.cpp | 6 +- .../Async/Transforms/AsyncParallelFor.cpp | 36 ++++---- .../Transforms/AsyncRuntimeRefCounting.cpp | 4 +- .../Transforms/AsyncRuntimeRefCountingOpt.cpp | 4 +- .../Async/Transforms/AsyncToAsyncRuntime.cpp | 18 ++-- .../Dialect/Async/Transforms/CMakeLists.txt | 2 +- .../Transforms/BufferResultsToOutParams.cpp | 12 +-- .../Bufferization/Transforms/Bufferize.cpp | 7 +- .../Bufferization/Transforms/CMakeLists.txt | 2 +- .../Bufferization/Transforms/PassDetail.h | 6 +- mlir/lib/Dialect/CMakeLists.txt | 2 +- mlir/lib/Dialect/Func/CMakeLists.txt | 2 + mlir/lib/Dialect/Func/IR/CMakeLists.txt | 17 ++++ .../IR/Ops.cpp => Func/IR/FuncOps.cpp} | 45 ++++------ .../Transforms/CMakeLists.txt | 8 +- .../Transforms/DecomposeCallGraphTypes.cpp | 5 +- .../Transforms/FuncBufferize.cpp | 13 +-- .../Transforms/FuncConversions.cpp | 11 +-- .../Transforms/PassDetail.h | 10 +-- mlir/lib/Dialect/GPU/CMakeLists.txt | 2 +- .../GPU/Transforms/KernelOutlining.cpp | 6 +- .../Dialect/Linalg/Analysis/CMakeLists.txt | 2 +- .../Linalg/Analysis/DependenceAnalysis.cpp | 2 +- .../ComprehensiveBufferize/CMakeLists.txt | 4 +- .../ModuleBufferization.cpp | 50 +++++------ .../Dialect/Linalg/Transforms/Bufferize.cpp | 6 +- .../Dialect/Linalg/Transforms/CMakeLists.txt | 4 +- .../Transforms/ComprehensiveBufferizePass.cpp | 2 +- .../Dialect/Linalg/Transforms/Detensorize.cpp | 2 +- .../Linalg/Transforms/ElementwiseToLinalg.cpp | 2 +- .../Linalg/Transforms/HoistPadding.cpp | 4 +- .../Dialect/Linalg/Transforms/Hoisting.cpp | 2 +- .../Linalg/Transforms/Vectorization.cpp | 6 +- mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt | 2 +- mlir/lib/Dialect/Linalg/Utils/Utils.cpp | 2 +- .../Dialect/Math/Transforms/CMakeLists.txt | 2 +- .../Dialect/Math/Transforms/ExpandTanh.cpp | 2 +- mlir/lib/Dialect/MemRef/IR/CMakeLists.txt | 1 - .../Dialect/MemRef/Transforms/CMakeLists.txt | 2 +- .../Dialect/MemRef/Transforms/ExpandOps.cpp | 4 +- .../MemRef/Transforms/NormalizeMemRefs.cpp | 15 ++-- .../Dialect/MemRef/Transforms/PassDetail.h | 5 +- mlir/lib/Dialect/SCF/CMakeLists.txt | 2 +- mlir/lib/Dialect/SCF/SCF.cpp | 2 +- mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp | 2 +- .../lib/Dialect/SCF/Transforms/CMakeLists.txt | 2 +- .../lib/Dialect/SCF/Transforms/ForToWhile.cpp | 2 +- .../Dialect/SCF/Transforms/LoopPipelining.cpp | 2 +- .../SCF/Transforms/LoopRangeFolding.cpp | 2 +- .../SCF/Transforms/LoopSpecialization.cpp | 2 +- .../SCF/Transforms/ParallelLoopFusion.cpp | 2 +- .../SCF/Transforms/ParallelLoopTiling.cpp | 2 +- .../Transforms/StructuralTypeConversions.cpp | 2 +- mlir/lib/Dialect/SCF/Utils/CMakeLists.txt | 2 +- mlir/lib/Dialect/SCF/Utils/Utils.cpp | 9 +- .../Shape/Transforms/ShapeToShapeLowering.cpp | 6 +- .../SparseTensor/Pipelines/CMakeLists.txt | 2 +- .../Pipelines/SparseTensorPipelines.cpp | 4 +- .../SparseTensor/Transforms/CMakeLists.txt | 2 +- .../Transforms/SparseTensorConversion.cpp | 29 ++++--- .../Transforms/SparseTensorPasses.cpp | 9 +- .../Transforms/Sparsification.cpp | 2 +- mlir/lib/Dialect/StandardOps/CMakeLists.txt | 22 ----- .../Dialect/Tensor/Transforms/Bufferize.cpp | 2 +- .../Dialect/Tosa/Transforms/CMakeLists.txt | 2 +- .../Tosa/Transforms/TosaInferShapes.cpp | 8 +- mlir/lib/Dialect/Vector/Utils/CMakeLists.txt | 2 +- mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp | 4 +- .../Transforms/LegalizeForLLVMExport.cpp | 1 - mlir/lib/ExecutionEngine/CMakeLists.txt | 2 +- mlir/lib/IR/Operation.cpp | 4 +- mlir/lib/Parser/Parser.cpp | 5 +- mlir/lib/Target/Cpp/CMakeLists.txt | 2 +- mlir/lib/Target/Cpp/TranslateRegistration.cpp | 4 +- mlir/lib/Target/Cpp/TranslateToCpp.cpp | 22 +++-- mlir/python/CMakeLists.txt | 20 ++--- .../dialects/{StandardOps.td => FuncOps.td} | 12 +-- mlir/python/mlir/dialects/_builtin_ops_ext.py | 8 +- .../{_std_ops_ext.py => _func_ops_ext.py} | 4 +- mlir/python/mlir/dialects/{std.py => func.py} | 2 +- .../dialects/linalg/opdsl/lang/emitter.py | 2 +- mlir/test/CAPI/CMakeLists.txt | 2 +- mlir/test/CAPI/ir.c | 22 ++--- mlir/test/CAPI/pass.c | 6 +- .../ArithmeticToLLVM/arith-to-llvm.mlir | 8 +- .../convert-nd-vector-to-llvmir.mlir | 2 +- .../Conversion/GPUToNVVM/gpu-to-nvvm.mlir | 46 +++++----- .../Conversion/GPUToROCDL/gpu-to-rocdl.mlir | 42 ++++----- .../Conversion/MathToLLVM/math-to-llvm.mlir | 30 +++---- .../MemRefToLLVM/memref-to-llvm.mlir | 2 +- .../ShapeToStandard/shape-to-standard.mlir | 2 +- .../StandardToLLVM/standard-to-llvm.mlir | 10 +-- .../StandardToSPIRV/std-ops-to-spirv.mlir | 6 +- mlir/test/Dialect/Arithmetic/ops.mlir | 4 +- mlir/test/Dialect/Tensor/invalid.mlir | 2 +- mlir/test/IR/core-ops.mlir | 6 +- mlir/test/IR/generic-visitors-interrupt.mlir | 6 +- mlir/test/IR/generic-visitors.mlir | 2 +- mlir/test/IR/invalid-ops.mlir | 6 +- mlir/test/IR/invalid.mlir | 6 +- mlir/test/IR/op-stats.mlir | 2 +- mlir/test/IR/parser.mlir | 14 +-- mlir/test/IR/print-op-generic.mlir | 2 +- mlir/test/IR/visitors.mlir | 20 ++--- .../SparseTensor/python/test_stress.py | 4 +- .../SparseTensor/taco/tools/mlir_pytaco.py | 2 +- .../taco/tools/mlir_pytaco_utils.py | 2 +- mlir/test/Transforms/test-legalizer.mlir | 30 +++---- .../StandardToLLVM/TestConvertCallOp.cpp | 6 +- .../lib/Dialect/Affine/TestLoopFusion.cpp | 2 +- mlir/test/lib/Dialect/CMakeLists.txt | 2 +- .../{StandardOps => Func}/CMakeLists.txt | 6 +- .../TestDecomposeCallGraphTypes.cpp | 10 +-- mlir/test/lib/Dialect/GPU/CMakeLists.txt | 2 +- .../Dialect/GPU/TestGpuMemoryPromotion.cpp | 4 +- mlir/test/lib/Dialect/GPU/TestGpuRewrite.cpp | 4 +- mlir/test/lib/Dialect/Linalg/CMakeLists.txt | 4 +- .../Linalg/TestLinalgCodegenStrategy.cpp | 4 +- .../Linalg/TestLinalgFusionTransforms.cpp | 4 +- .../Dialect/Linalg/TestLinalgTransforms.cpp | 4 +- .../lib/Dialect/SCF/TestLoopUnrolling.cpp | 4 +- mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp | 4 +- mlir/test/lib/Dialect/Test/CMakeLists.txt | 4 +- mlir/test/lib/Dialect/Test/TestDialect.cpp | 6 +- mlir/test/lib/Dialect/Test/TestPatterns.cpp | 10 +-- mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp | 2 +- mlir/test/lib/Dialect/Vector/CMakeLists.txt | 2 +- .../Dialect/Vector/TestVectorTransforms.cpp | 4 +- mlir/test/lib/IR/TestMatchers.cpp | 2 +- mlir/test/lib/IR/TestOperationEquals.cpp | 1 - mlir/test/lib/IR/TestPrintDefUse.cpp | 1 - mlir/test/lib/IR/TestPrintNesting.cpp | 1 - mlir/test/lib/IR/TestSlicing.cpp | 4 +- mlir/test/lib/Transforms/TestInlining.cpp | 7 +- mlir/test/mlir-opt/commandline.mlir | 2 +- mlir/test/python/dialects/builtin.py | 42 ++++----- mlir/test/python/dialects/{std.py => func.py} | 10 +-- .../dialects/linalg/opdsl/emit_convolution.py | 2 +- .../python/dialects/linalg/opdsl/emit_fill.py | 2 +- .../dialects/linalg/opdsl/emit_matmul.py | 2 +- .../python/dialects/linalg/opdsl/emit_misc.py | 2 +- .../dialects/linalg/opdsl/emit_pooling.py | 2 +- mlir/test/python/dialects/linalg/ops.py | 6 +- mlir/test/python/dialects/memref.py | 8 +- mlir/test/python/dialects/scf.py | 10 +-- mlir/test/python/dialects/vector.py | 10 +-- .../integration/dialects/linalg/opsrun.py | 2 +- mlir/test/python/ir/blocks.py | 13 ++- mlir/test/python/ir/dialects.py | 22 ++--- mlir/test/python/ir/operation.py | 6 +- mlir/test/python/pass_manager.py | 2 +- mlir/tools/mlir-opt/CMakeLists.txt | 2 +- .../mlir-spirv-cpu-runner/CMakeLists.txt | 2 +- .../mlir-spirv-cpu-runner.cpp | 4 +- mlir/tools/mlir-vulkan-runner/CMakeLists.txt | 2 +- .../mlir-vulkan-runner/mlir-vulkan-runner.cpp | 4 +- .../Conversion/PDLToPDLInterp/CMakeLists.txt | 2 +- mlir/unittests/Interfaces/CMakeLists.txt | 2 +- .../Interfaces/InferTypeOpInterfaceTest.cpp | 4 +- mlir/utils/vim/syntax/mlir.vim | 1 - 309 files changed, 959 insertions(+), 981 deletions(-) create mode 100644 mlir/docs/Dialects/Func.md delete mode 100644 mlir/docs/Dialects/Standard.md rename mlir/include/mlir-c/Dialect/{Standard.h => Func.h} (72%) rename mlir/include/mlir/Dialect/{StandardOps => Func}/CMakeLists.txt (100%) create mode 100644 mlir/include/mlir/Dialect/Func/IR/CMakeLists.txt rename mlir/include/mlir/Dialect/{StandardOps/IR/Ops.h => Func/IR/FuncOps.h} (51%) rename mlir/include/mlir/Dialect/{StandardOps/IR/Ops.td => Func/IR/FuncOps.td} (74%) create mode 100644 mlir/include/mlir/Dialect/Func/Transforms/CMakeLists.txt rename mlir/include/mlir/Dialect/{StandardOps => Func}/Transforms/DecomposeCallGraphTypes.h (95%) rename mlir/include/mlir/Dialect/{StandardOps => Func}/Transforms/FuncConversions.h (90%) rename mlir/include/mlir/Dialect/{StandardOps => Func}/Transforms/Passes.h (81%) rename mlir/include/mlir/Dialect/{StandardOps => Func}/Transforms/Passes.td (78%) delete mode 100644 mlir/include/mlir/Dialect/StandardOps/IR/CMakeLists.txt delete mode 100644 mlir/include/mlir/Dialect/StandardOps/Transforms/CMakeLists.txt rename mlir/lib/CAPI/Dialect/{Standard.cpp => Func.cpp} (60%) create mode 100644 mlir/lib/Dialect/Func/CMakeLists.txt create mode 100644 mlir/lib/Dialect/Func/IR/CMakeLists.txt rename mlir/lib/Dialect/{StandardOps/IR/Ops.cpp => Func/IR/FuncOps.cpp} (86%) rename mlir/lib/Dialect/{StandardOps => Func}/Transforms/CMakeLists.txt (63%) rename mlir/lib/Dialect/{StandardOps => Func}/Transforms/DecomposeCallGraphTypes.cpp (98%) rename mlir/lib/Dialect/{StandardOps => Func}/Transforms/FuncBufferize.cpp (85%) rename mlir/lib/Dialect/{StandardOps => Func}/Transforms/FuncConversions.cpp (95%) rename mlir/lib/Dialect/{StandardOps => Func}/Transforms/PassDetail.h (68%) delete mode 100644 mlir/lib/Dialect/StandardOps/CMakeLists.txt rename mlir/python/mlir/dialects/{StandardOps.td => FuncOps.td} (70%) rename mlir/python/mlir/dialects/{_std_ops_ext.py => _func_ops_ext.py} (97%) rename mlir/python/mlir/dialects/{std.py => func.py} (87%) rename mlir/test/lib/Dialect/{StandardOps => Func}/CMakeLists.txt (68%) rename mlir/test/lib/Dialect/{StandardOps => Func}/TestDecomposeCallGraphTypes.cpp (91%) rename mlir/test/python/dialects/{std.py => func.py} (92%) diff --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h index 0acd6076ca30..40968d42233d 100644 --- 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 index cc25c673c5ea..d0d5510d6d9a 100644 --- 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 index 42493025195b..b13a651daf4a 100644 --- 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 index 323cc2ce6d49..9380ad76ccd7 100644 --- 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 index 9907d674da90..1f15fddc7780 100644 --- 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 index 5f1f28b78656..1657dff0fd52 100644 --- 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 index 65f669c94cbe..8760c6a7c24c 100644 --- 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 index 3a67577d1c9a..a78c853149c8 100644 --- 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 index c99f2a39bc91..28fecd3ad93e 100644 --- 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 @@ inline bool nonVolatileLoad(mlir::Operation *op) { /// 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 index 30108ec2069b..f31251842a46 100644 --- a/flang/include/flang/Optimizer/Support/InitFIR.h +++ b/flang/include/flang/Optimizer/Support/InitFIR.h @@ -28,7 +28,7 @@ namespace fir::support { 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 index 26783d289cea..d25a4005f401 100644 --- 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 index fa92753e8eea..d81cb36dacc6 100644 --- a/flang/include/flang/Optimizer/Transforms/Passes.td +++ b/flang/include/flang/Optimizer/Transforms/Passes.td @@ -25,7 +25,7 @@ def AbstractResultOpt : Pass<"abstract-result-opt", "mlir::FuncOp"> { }]; 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 @@ def AffineDialectPromotion : Pass<"promote-to-affine", "::mlir::FuncOp"> { }]; let constructor = "::fir::createPromoteToAffinePass()"; let dependentDialects = [ - "fir::FIROpsDialect", "mlir::StandardOpsDialect", "mlir::AffineDialect" + "fir::FIROpsDialect", "mlir::func::FuncDialect", "mlir::AffineDialect" ]; } @@ -70,7 +70,7 @@ def AffineDialectDemotion : Pass<"demote-affine", "::mlir::FuncOp"> { }]; let constructor = "::fir::createAffineDemotionPass()"; let dependentDialects = [ - "fir::FIROpsDialect", "mlir::StandardOpsDialect", "mlir::AffineDialect" + "fir::FIROpsDialect", "mlir::func::FuncDialect", "mlir::AffineDialect" ]; } @@ -122,7 +122,7 @@ def CFGConversion : Pass<"cfg-conversion", "::mlir::FuncOp"> { }]; 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 @@ def MemRefDataFlowOpt : Pass<"fir-memref-dataflow-opt", "::mlir::FuncOp"> { }]; 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 index b8b52e48f99c..6e50e1c35e05 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -427,7 +427,7 @@ private: /// 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 @@ private: 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 index 031701e99902..e60087e3fc17 100644 --- a/flang/lib/Lower/CMakeLists.txt +++ b/flang/lib/Lower/CMakeLists.txt @@ -37,9 +37,9 @@ add_flang_library(FortranLower FortranEvaluate FortranSemantics MLIRAffineToStandard + MLIRFunc MLIRLLVMIR MLIRSCFToControlFlow - MLIRStandard LINK_COMPONENTS Support diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp index 60745b83cc11..dd8c6ced3cbc 100644 --- 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 index 5a2ea82932d3..2575e6538925 100644 --- 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 index 5c7da46cfc3f..f3db5412e7be 100644 --- 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 index c726d3c508e1..750968d13038 100644 --- 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 index 467f09ef2f7b..9d2a18caf145 100644 --- 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 index f5f552c63376..c6419aad9b37 100644 --- 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 index a4c9305daa70..5ebf14bf4b00 100644 --- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp @@ -262,7 +262,7 @@ public: 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 index 575d26749540..ef4b59ee7bf0 100644 --- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp @@ -599,20 +599,20 @@ public: 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 @@ public: 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 index 45320d52b022..6193924651cc 100644 --- a/flang/lib/Optimizer/Dialect/FIRDialect.cpp +++ b/flang/lib/Optimizer/Dialect/FIRDialect.cpp @@ -42,7 +42,7 @@ struct FIRInlinerInterface : public mlir::DialectInlinerInterface { /// 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 index 0f1f594fa9de..9a9a31e5d53f 100644 --- 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 index 156ff413d29c..f885ffbdd8cb 100644 --- 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 @@ public: } }; -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 @@ public: if (!replacedStorage) rewriter.create(ret.getLoc(), returnedValue, options.newArg); - rewriter.replaceOpWithNewOp(ret); + rewriter.replaceOpWithNewOp(ret); return mlir::success(); } @@ -239,8 +239,8 @@ public: 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 @@ public: // 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 index ceebc26bf25b..01f2c99eb756 100644 --- 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 @@ public: }); 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 index daf84b65ef6c..e771c2c92162 100644 --- 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 @@ public: 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 index 81e37f6f32bb..e9c4ef995ded 100644 --- a/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp +++ b/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp @@ -792,7 +792,7 @@ public: 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 index f58d03c5c4fe..650b990ef54c 100644 --- 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 @@ public: 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 index f3f86cb3047e..726fa015920d 100644 --- 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 index 76ca3fd5e1fc..408cdc6e2525 100644 --- 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 @@ public: 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 @@ public: 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 index 02d203f17097..c81993d239c1 100644 --- 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 index 4e20a4b862bf..c2a9cc7bac0d 100644 --- 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 @@ public: 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 index a34091106daa..9ab6b1aaea0d 100644 --- a/mlir/benchmark/python/common.py +++ b/mlir/benchmark/python/common.py @@ -6,9 +6,9 @@ import mlir.all_passes_registration 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 @@ def emit_benchmark_wrapped_main_func(func, timer_func): 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 index c9d38bbc7a54..f867948cc007 100644 --- a/mlir/docs/Bindings/Python.md +++ b/mlir/docs/Bindings/Python.md @@ -885,16 +885,16 @@ Each dialect with a mapping to python requires that an appropriate `_{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 index 2f1d7a17c4c4..3f39e8de2632 100644 --- a/mlir/docs/Bufferization.md +++ b/mlir/docs/Bufferization.md @@ -169,7 +169,7 @@ struct TensorBufferizePass : public TensorBufferizeBase { 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 index 4731ef5efbc5..1173a0d01dba 100644 --- a/mlir/docs/DialectConversion.md +++ b/mlir/docs/DialectConversion.md @@ -100,9 +100,9 @@ struct MyTarget : public ConversionTarget { /// 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 @@ Example output is shown below: ``` //===-------------------------------------------===// -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 @@ Legalizing operation : 'std.return'(0x608000002e20) { //===-------------------------------------------===// ``` -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 index 4e1ca8fe2393..89d9d89964f9 100644 --- a/mlir/docs/Dialects/Affine.md +++ b/mlir/docs/Dialects/Affine.md @@ -66,7 +66,7 @@ argument for an op with trait `AffineScope` (eg. `FuncOp`), 2. a value defined 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 index 000000000000..4d94d1a2b0cd --- /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 index 942a97676c8f..000000000000 --- 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 index 33289ab99103..c010c3cda53c 100644 --- a/mlir/docs/Dialects/Vector.md +++ b/mlir/docs/Dialects/Vector.md @@ -99,7 +99,7 @@ Some existing Standard and Vector Dialect on `n-D` `vector` types comprise: ```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 index e90fd32d3328..8974e82c0bf7 100644 --- a/mlir/docs/Dialects/emitc.md +++ b/mlir/docs/Dialects/emitc.md @@ -26,10 +26,10 @@ translating the following operations: * '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 index 2fe1c6248c8a..927d50f3bbe1 100644 --- a/mlir/docs/LangRef.md +++ b/mlir/docs/LangRef.md @@ -256,10 +256,10 @@ between, and within, different dialects. 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 index 09a3ca570060..87c33b557493 100644 --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -861,7 +861,7 @@ The `elements` of an optional group have the following requirements: - 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 index 13ec3ba4680d..aeed41a706a0 100644 --- a/mlir/docs/Passes.md +++ b/mlir/docs/Passes.md @@ -28,6 +28,10 @@ This document describes the available MLIR passes and their contracts. [include "ArithmeticPasses.md"] +## `func` Dialect Passes + +[include "FuncPasses.md"] + ## `gpu` Dialect Passes [include "GPUPasses.md"] @@ -68,10 +72,6 @@ This document describes the available MLIR passes and their contracts. [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 index 25df6e256df9..3786682f2369 100644 --- a/mlir/docs/SymbolsAndSymbolTables.md +++ b/mlir/docs/SymbolsAndSymbolTables.md @@ -33,7 +33,7 @@ result value, and may be referred to by other operations to provide a symbolic 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 index f56ada65ea8a..e3ebe9973ba2 100644 --- a/mlir/docs/TargetLLVMIR.md +++ b/mlir/docs/TargetLLVMIR.md @@ -348,7 +348,7 @@ individual scalar arguments. 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 @@ be returned from a function, the ranked descriptor it points to is copied into 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 index 3f39cfcec840..2926c3682ede 100644 --- a/mlir/docs/Tutorials/CreatingADialect.md +++ b/mlir/docs/Tutorials/CreatingADialect.md @@ -130,7 +130,7 @@ mlir/lib/Conversion/GPUCommon. 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 index b5ab60628a35..0d04738e1e8b 100644 --- a/mlir/docs/Tutorials/Toy/Ch-5.md +++ b/mlir/docs/Tutorials/Toy/Ch-5.md @@ -63,9 +63,9 @@ void ToyToAffineLoweringPass::runOnOperation() { // 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 index e279545d8a1f..5a1354d4648e 100644 --- a/mlir/examples/standalone/standalone-opt/standalone-opt.cpp +++ b/mlir/examples/standalone/standalone-opt/standalone-opt.cpp @@ -28,7 +28,7 @@ int main(int argc, char **argv) { 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 index 545a71445ac7..89941531cf49 100644 --- 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 @@ struct ReturnOpLowering : public OpRewritePattern { 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 @@ namespace { struct ToyToAffineLoweringPass : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() final; }; @@ -305,9 +305,9 @@ void ToyToAffineLoweringPass::runOnOperation() { // 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 index 78de920c2a25..fa7d4c784bfc 100644 --- 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 @@ struct ReturnOpLowering : public OpRewritePattern { 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 @@ namespace { struct ToyToAffineLoweringPass : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() final; }; @@ -305,9 +305,9 @@ void ToyToAffineLoweringPass::runOnOperation() { // 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 index 855566b3f46f..ca7a59863398 100644 --- 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 @@ public: // 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 @@ public: 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 index 78de920c2a25..fa7d4c784bfc 100644 --- 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 @@ struct ReturnOpLowering : public OpRewritePattern { 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 @@ namespace { struct ToyToAffineLoweringPass : public PassWrapper> { void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() final; }; @@ -305,9 +305,9 @@ void ToyToAffineLoweringPass::runOnOperation() { // 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 index 855566b3f46f..ca7a59863398 100644 --- 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 @@ public: // 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 @@ public: 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 similarity index 72% rename from mlir/include/mlir-c/Dialect/Standard.h rename to mlir/include/mlir-c/Dialect/Func.h index 200962177cb9..4bdac4268d0c 100644 --- 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 index 442449626632..ab37866d9c5e 100644 --- a/mlir/include/mlir-c/Registration.h +++ b/mlir/include/mlir-c/Registration.h @@ -20,7 +20,7 @@ extern "C" { // 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 index 89d884469770..9214b333cfde 100644 --- a/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h +++ b/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h @@ -25,8 +25,8 @@ class MLIRContext; /// 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 index aa59fda2d5fb..e5d4b5fd8e9d 100644 --- a/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h +++ b/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h @@ -26,7 +26,7 @@ namespace LLVM { 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 index ff538ac8ec1c..a891962634ff 100644 --- a/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h +++ b/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h @@ -20,7 +20,7 @@ class OperationPass; 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 index 09a5b9358b94..33bc5c28d745 100644 --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -67,9 +67,9 @@ def ConvertAffineToStandard : Pass<"lower-affine"> { }]; let constructor = "mlir::createLowerAffinePass()"; let dependentDialects = [ + "func::FuncDialect", "memref::MemRefDialect", "scf::SCFDialect", - "StandardOpsDialect", "vector::VectorDialect" ]; } @@ -227,9 +227,9 @@ def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm", "gpu::GPUModuleOp"> { 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 @@ def ConvertLinalgToStandard : Pass<"convert-linalg-to-std", "ModuleOp"> { 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 @@ def ConvertMathToLibm : Pass<"convert-math-to-libm", "ModuleOp"> { let constructor = "mlir::createConvertMathToLibmPass()"; let dependentDialects = [ "arith::ArithmeticDialect", - "StandardOpsDialect", + "func::FuncDialect", "vector::VectorDialect", ]; } @@ -553,7 +553,7 @@ def ConvertShapeToStandard : Pass<"convert-shape-to-std", "ModuleOp"> { "dialect"; let constructor = "mlir::createConvertShapeToStandardPass()"; let dependentDialects = [ - "StandardOpsDialect", + "func::FuncDialect", "scf::SCFDialect", ]; } @@ -705,7 +705,7 @@ def TosaToStandard : Pass<"tosa-to-standard"> { 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 index 66b82264445b..1f649f358a2a 100644 --- a/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h +++ b/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h @@ -74,7 +74,7 @@ struct VectorTransferToSCFOptions { } }; -/// 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 index 872b1f874395..af2bebbccaab 100644 --- 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 index 3452ccdca6da..ab45bebce892 100644 --- a/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Arithmetic/Transforms/Passes.td @@ -31,7 +31,7 @@ def ArithmeticBufferize : Pass<"arith-bufferize", "ModuleOp"> { 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 index 47686dd5424b..282623caf15a 100644 --- 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 index 7dd584328813..d61773dc416c 100644 --- a/mlir/include/mlir/Dialect/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/CMakeLists.txt @@ -9,6 +9,7 @@ add_subdirectory(Complex) 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(SCF) 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 index ba0ed638b7df..b7ca06448db4 100644 --- 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 @@ def SwitchOp : CF_Op<"switch", 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 similarity index 100% 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 index 000000000000..08a6123dd200 --- /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 similarity index 51% rename from mlir/include/mlir/Dialect/StandardOps/IR/Ops.h rename to mlir/include/mlir/Dialect/Func/IR/FuncOps.h index 6964621d6756..8e1bf85bda11 100644 --- 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 similarity index 74% rename from mlir/include/mlir/Dialect/StandardOps/IR/Ops.td rename to mlir/include/mlir/Dialect/Func/IR/FuncOps.td index 4fa909c56b69..a2fd77305daa 100644 --- 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 @@ def CallOp : Std_Op<"call", // 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 @@ def CallIndirectOp : Std_Op<"call_indirect", [ ]> { 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 @@ def CallIndirectOp : Std_Op<"call_indirect", [ }]; 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 @@ def ConstantOp : Std_Op<"constant", // 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 @@ def ReturnOp : Std_Op<"return", [NoSideEffect, HasParent<"FuncOp">, Example: ```mlir - func @foo() : (i32, f8) { + func.func @foo() : (i32, f8) { ... return %0, %1 : i32, f8 } @@ -239,12 +226,12 @@ def ReturnOp : Std_Op<"return", [NoSideEffect, HasParent<"FuncOp">, 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 index 000000000000..33c72e3c075c --- /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 similarity index 95% rename from mlir/include/mlir/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.h rename to mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h index d96e17604d12..3f811d7e12d8 100644 --- 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 @@ void populateDecomposeCallGraphTypesPatterns(MLIRContext *context, } // 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 similarity index 90% rename from mlir/include/mlir/Dialect/StandardOps/Transforms/FuncConversions.h rename to mlir/include/mlir/Dialect/Func/Transforms/FuncConversions.h index 8457805217be..adcd3087b7e2 100644 --- 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 isLegalForReturnOpTypeConversionPattern(Operation *op, 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 similarity index 81% rename from mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.h rename to mlir/include/mlir/Dialect/Func/Transforms/Passes.h index 57bd00313dc2..5dd3059a1f86 100644 --- 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 BufferizeTypeConverter; class RewritePatternSet; +namespace func { /// Creates an instance of func bufferization pass. std::unique_ptr createFuncBufferizePass(); @@ -32,8 +33,9 @@ std::unique_ptr createFuncBufferizePass(); /// 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 similarity index 78% rename from mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td rename to mlir/include/mlir/Dialect/Func/Transforms/Passes.td index c871379f4508..d928e2f06945 100644 --- 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 @@ def FuncBufferize : Pass<"func-bufferize", "ModuleOp"> { 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 index 4c0146056aa7..54c1fa9968ac 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h @@ -541,9 +541,9 @@ makeTiledLoopRanges(RewriterBase &b, Location loc, AffineMap map, /// 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 index dfc2a30c5c51..310d4d29202d 100644 --- 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 index d0bfdf454478..c636c70ded7e 100644 --- a/mlir/include/mlir/Dialect/Math/IR/MathOps.td +++ b/mlir/include/mlir/Dialect/Math/IR/MathOps.td @@ -732,12 +732,6 @@ def Math_SqrtOp : Math_FloatUnaryOp<"sqrt"> { 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 index ae4ce7d4b090..f4e126ee3f6a 100644 --- a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td +++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td @@ -903,7 +903,7 @@ def LoadOp : MemRef_Op<"load", 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 index 701a8c36d111..e7bfe739e24a 100644 --- 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 index 0f2e3a91a255..9cf6f3dfc513 100644 --- a/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td @@ -14,7 +14,7 @@ include "mlir/Pass/PassBase.td" 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 @@ def NormalizeMemRefs : Pass<"normalize-memrefs", "ModuleOp"> { 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 index 61fe1261e6dd..56100641281d 100644 --- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td +++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td @@ -314,7 +314,7 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> { ```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 index c1756e94ba12..000000000000 --- 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 index 4cfeeded772d..000000000000 --- 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 index b0508c067d90..218aa120718d 100644 --- 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 index 0de4d3229f13..8a929775b835 100644 --- a/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td @@ -24,7 +24,7 @@ def TosaInferShapes : Pass<"tosa-infer-shapes", "FuncOp"> { 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 index 0848979be31e..7182bb77de1c 100644 --- 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 index 7cc54c00aaa3..9487876ef32a 100644 --- 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 @@ inline void registerAllDialects(DialectRegistry ®istry) { complex::ComplexDialect, DLTIDialect, emitc::EmitCDialect, + func::FuncDialect, gpu::GPUDialect, LLVM::LLVMDialect, linalg::LinalgDialect, @@ -82,7 +83,6 @@ inline void registerAllDialects(DialectRegistry ®istry) { 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 index eb74ca02a8ea..ccbb74d5a7b2 100644 --- 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 @@ inline void registerAllPasses() { registerAsyncPasses(); arith::registerArithmeticPasses(); bufferization::registerBufferizationPasses(); + func::registerFuncPasses(); registerGPUPasses(); registerGpuSerializeToCubinPass(); registerGpuSerializeToHsacoPass(); @@ -69,7 +70,6 @@ inline void registerAllPasses() { 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 index f66f7b0b8722..9822f059e6cc 100644 --- a/mlir/lib/CAPI/Dialect/CMakeLists.txt +++ b/mlir/lib/CAPI/Dialect/CMakeLists.txt @@ -80,13 +80,13 @@ add_mlir_upstream_c_api_library(MLIRCAPISparseTensor 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 similarity index 60% rename from mlir/lib/CAPI/Dialect/Standard.cpp rename to mlir/lib/CAPI/Dialect/Func.cpp index 57083a8a21a3..a49d2f4258ee 100644 --- 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 index 7c91af4c49f0..78d8fd2c89b6 100644 --- 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 @@ class LowerAffinePass : public ConvertAffineToStandardBase { 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 index 9ad3f6b12106..36969a0be456 100644 --- a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt @@ -14,11 +14,11 @@ add_mlir_conversion_library(MLIRAffineToStandard 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 index a709a97c2fe0..6b2007a20809 100644 --- 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 @@ public: // 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 @@ public: 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 @@ public: 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 @@ public: .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 @@ public: .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 @@ public: .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 @@ public: .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 @@ public: 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 @@ public: // 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 @@ public: // 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 @@ public: // 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: //===----------------------------------------------------------------------===// 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 @@ void ConvertAsyncToLLVMPass::runOnOperation() { 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 @@ void ConvertAsyncToLLVMPass::runOnOperation() { // 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 index f86c652fb467..c797998b8551 100644 --- a/mlir/lib/Conversion/AsyncToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/AsyncToLLVM/CMakeLists.txt @@ -13,9 +13,9 @@ add_mlir_conversion_library(MLIRAsyncToLLVM 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 index 8f6a0d7edbdd..a02f97d259d0 100644 --- a/mlir/lib/Conversion/ComplexToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/ComplexToLLVM/CMakeLists.txt @@ -12,8 +12,8 @@ add_mlir_conversion_library(MLIRComplexToLLVM 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 index c061495fda0b..5e2f707f4493 100644 --- 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 index 8579ec8feacf..b592d3dd0051 100644 --- a/mlir/lib/Conversion/ComplexToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/ComplexToStandard/CMakeLists.txt @@ -10,8 +10,8 @@ add_mlir_conversion_library(MLIRComplexToStandard 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 index 63f862dcce6b..ae27bba06214 100644 --- 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 @@ void ConvertComplexToStandardPass::runOnOperation() { 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 index 2ba829567600..cc97ef73d7bf 100644 --- a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp +++ b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp @@ -29,7 +29,7 @@ using namespace mlir; #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 index 91926027d498..f0577a7533cd 100644 --- 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 index b3f3dd901e9b..97006b199b3f 100644 --- 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 index 00230c906dc2..7a707e5aa54b 100644 --- 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 @@ namespace mlir { /// 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 index c2249ae8333e..8ac1039cbe2a 100644 --- a/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt +++ b/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt @@ -6,13 +6,13 @@ add_mlir_conversion_library(MLIRGPUToVulkanTransforms 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 index e106ebf3c44c..c87922602278 100644 --- 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 @@ void ConvertGpuLaunchFuncToVulkanLaunchFunc::convertGpuLaunchFunc( 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 index c654a30c7b03..f8d81c57b774 100644 --- 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 index 7b3afe879534..cfa93c7e0ea6 100644 --- 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 @@ LogicalResult mlir::linalg::LinalgOpToLibraryCallRewrite::matchAndRewrite( // 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 @@ void ConvertLinalgToStandardPass::runOnOperation() { 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 index c195aa2d8299..2e283f8b7dda 100644 --- a/mlir/lib/Conversion/MathToLibm/CMakeLists.txt +++ b/mlir/lib/Conversion/MathToLibm/CMakeLists.txt @@ -13,8 +13,8 @@ add_mlir_conversion_library(MLIRMathToLibm 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 index 450f04bce624..569625ff0eb3 100644 --- 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 @@ ScalarOpToLibmCall::matchAndRewrite(Op op, } 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 @@ void ConvertMathToLibmPass::runOnOperation() { 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 index 56413c415590..c0d9a2953291 100644 --- a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp +++ b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp @@ -1753,7 +1753,7 @@ struct ViewOpLowering : public ConvertOpToLLVMPattern { // 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 index 68fed9b5f3aa..dc23a6ee7de4 100644 --- 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 index 99841f0ec34d..6eba8111293b 100644 --- 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 GPUDialect; 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 index b787ddfc2e62..fd26f310db1c 100644 --- a/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt @@ -13,12 +13,12 @@ add_mlir_conversion_library(MLIRSCFToGPU 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 index 99a8b8388297..523d234f27b0 100644 --- 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 index 6acfd3852f78..52234844892f 100644 --- 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 index 2e26b7553f43..c6ef843713b6 100644 --- a/mlir/lib/Conversion/SCFToOpenMP/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToOpenMP/CMakeLists.txt @@ -13,9 +13,9 @@ add_mlir_conversion_library(MLIRSCFToOpenMP 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 index c9c5017e0382..6cb90ed6767a 100644 --- 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 index 615c6b2a6d75..2f9412754926 100644 --- a/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt @@ -14,10 +14,10 @@ add_mlir_conversion_library(MLIRSCFToSPIRV 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 index 9f1f93f9abf7..867399821891 100644 --- 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 index 14ae384aa2dc..0120bbc123d9 100644 --- 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 index f24ae5bbd6cf..25d5d5b5856e 100644 --- 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 index a7cf8a80fe8c..bdeba081ca4c 100644 --- 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 @@ void ConvertShapeToStandardPass::runOnOperation() { // 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 index ec31d8170ec0..feb42b153e72 100644 --- a/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt @@ -16,9 +16,9 @@ add_mlir_conversion_library(MLIRStandardToLLVM 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 index 6caaa0bfc993..a98d89ea84af 100644 --- 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 @@ static void filterFuncAttributes(ArrayRef attrs, 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 @@ protected: 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 BarePtrFuncOpConversion : public FuncOpConversionBase { } }; -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 CallOpInterfaceLowering : public ConvertOpToLLVMPattern { } }; -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 @@ struct UnrealizedConversionCastOpLowering // 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 index 979780aea228..3589e9804d0b 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt @@ -12,6 +12,7 @@ add_mlir_conversion_library(MLIRStandardToSPIRV LINK_LIBS PUBLIC MLIRArithmeticToSPIRV MLIRControlFlowToSPIRV + MLIRFunc MLIRIR MLIRMathToSPIRV MLIRMemRef @@ -20,6 +21,5 @@ add_mlir_conversion_library(MLIRStandardToSPIRV MLIRSPIRVConversion MLIRSupport MLIRTransformUtils - MLIRStandard MLIRTensor ) diff --git a/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp index 36d39c85bfbd..e72863c8442a 100644 --- 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 @@ using namespace mlir; 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 @@ private: //===----------------------------------------------------------------------===// 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 index dad77e6612db..c7cef4171d7c 100644 --- 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 index a7fe498e9871..a3fd8b52b2f0 100644 --- 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 index ccf6424390a2..391b4ba5b641 100644 --- 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 @@ struct TosaToLinalgNamed : public TosaToLinalgNamedBase { 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 index 583ea05279d5..e8ceac2f257a 100644 --- 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 @@ struct TosaToLinalg : public TosaToLinalgBase { 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 index 189c25c2d89c..62d3e8616eed 100644 --- a/mlir/lib/Conversion/TosaToSCF/CMakeLists.txt +++ b/mlir/lib/Conversion/TosaToSCF/CMakeLists.txt @@ -11,8 +11,8 @@ add_mlir_conversion_library(MLIRTosaToSCF 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 index e57ab2008e09..4946be66ec70 100644 --- a/mlir/lib/Conversion/TosaToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/TosaToStandard/CMakeLists.txt @@ -11,8 +11,8 @@ add_mlir_conversion_library(MLIRTosaToStandard 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 index 6e1c4e99165f..0dec3fffb399 100644 --- 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 @@ Attribute getConstantAttr(Type type, int64_t value, PatternRewriter &rewriter) { 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 index 072df36798b4..fb1e9f3d1079 100644 --- 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 @@ public: 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 index 2487dd9401a3..99bb415d65e7 100644 --- 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 index 0045266bb539..cc4581318a81 100644 --- 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 @@ void LowerVectorToLLVMPass::runOnOperation() { 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 index 34d268bdc1ad..70203f91c0ff 100644 --- 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 index 5e60bed7b074..9ce623b562b0 100644 --- 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 index e1c489984c68..8609aa248a4e 100644 --- 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 index 30f95dd05fce..b46d91fbef09 100644 --- 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 index c38cdb7582d3..90a9e9dddd75 100644 --- 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 index 0eb5289f45c6..e9eb3d5954e1 100644 --- 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 index 587a0d2d67fa..1b329353153b 100644 --- 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 index bd331525b01c..c48074613241 100644 --- a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -82,7 +82,7 @@ bool isOpLoopInvariant(Operation &op, Value indVar, ValueRange iterArgs, } 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 index f4536a899b97..6faf612af87a 100644 --- a/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt @@ -26,12 +26,12 @@ add_mlir_dialect_library(MLIRAffineTransforms 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 index 42ab36297be4..478ca9fbebce 100644 --- 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 @@ struct ArithmeticExpandOpsPass 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 index 0947804f125f..8db4f122852e 100644 --- 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 index 80f6e305a188..7871cb004181 100644 --- a/mlir/lib/Dialect/ArmSVE/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/ArmSVE/Transforms/CMakeLists.txt @@ -6,8 +6,8 @@ add_mlir_dialect_library(MLIRArmSVETransforms 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 index 0145ec37422d..c019b5c9bf0d 100644 --- a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp +++ b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp @@ -71,9 +71,9 @@ void mlir::populateArmSVELegalizeForLLVMExportPatterns( // 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 @@ static FuncOp createAsyncDispatchFunction(ParallelComputeFunction &computeFunc, 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 @@ static FuncOp createAsyncDispatchFunction(ParallelComputeFunction &computeFunc, 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 @@ static void doAsyncDispatch(ImplicitLocOpBuilder &b, PatternRewriter &rewriter, 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 @@ static void doAsyncDispatch(ImplicitLocOpBuilder &b, PatternRewriter &rewriter, 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 @@ doSequentialDispatch(ImplicitLocOpBuilder &b, PatternRewriter &rewriter, // 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 @@ doSequentialDispatch(ImplicitLocOpBuilder &b, PatternRewriter &rewriter, 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 index 3fd80ea9f9ee..18c2f2eaf566 100644 --- 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 @@ AsyncRuntimeRefCountingPass::addAddRefBeforeFunctionCall(Value value) { 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 index 025dab515bc5..14fe91a90201 100644 --- 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 @@ LogicalResult AsyncRuntimeRefCountingOptPass::optimizeReferenceCounting( 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 index d1d3e4f5326a..3f0d089ed9a0 100644 --- 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 @@ static CoroMachinery setupCoroMachinery(FuncOp func) { // 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 @@ outlineExecuteOp(SymbolTable &symbolTable, ExecuteOp execute) { // 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 @@ private: }; //===----------------------------------------------------------------------===// -// 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 @@ static CoroMachinery rewriteFuncAsCoroutine(FuncOp func) { 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 @@ static CoroMachinery rewriteFuncAsCoroutine(FuncOp func) { /// /// 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 @@ funcsToCoroutines(ModuleOp module, }); // 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 @@ void AsyncToAsyncRuntimePass::runOnOperation() { 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 index e5f9c75af28e..de74c6180d52 100644 --- a/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt @@ -14,11 +14,11 @@ add_mlir_dialect_library(MLIRAsyncTransforms 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 index de3a2e1c0782..e233ef7ba88e 100644 --- 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 @@ static void updateFuncOp(FuncOp func, // 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 @@ static void updateReturnOps(FuncOp func, 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 @@ static void updateReturnOps(FuncOp func, // 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 @@ static LogicalResult updateCalls(ModuleOp module) { 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 index a10d322778b8..24ecadb5e8f4 100644 --- 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 @@ struct OneShotBufferizePass 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 index 56fc326b4fa9..c72292187776 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt @@ -15,10 +15,10 @@ add_mlir_dialect_library(MLIRBufferizationTransforms 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 index 37f88113c59b..d695f2a409cc 100644 --- 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 index 9d6a30ca3d7f..766dd263e7a2 100644 --- a/mlir/lib/Dialect/CMakeLists.txt +++ b/mlir/lib/Dialect/CMakeLists.txt @@ -9,6 +9,7 @@ add_subdirectory(Complex) 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(SCF) 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/lib/Dialect/Func/CMakeLists.txt b/mlir/lib/Dialect/Func/CMakeLists.txt new file mode 100644 index 000000000000..9f57627c321f --- /dev/null +++ b/mlir/lib/Dialect/Func/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(IR) +add_subdirectory(Transforms) diff --git a/mlir/lib/Dialect/Func/IR/CMakeLists.txt b/mlir/lib/Dialect/Func/IR/CMakeLists.txt new file mode 100644 index 000000000000..0045a9aebc15 --- /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 similarity index 86% rename from mlir/lib/Dialect/StandardOps/IR/Ops.cpp rename to mlir/lib/Dialect/Func/IR/FuncOps.cpp index cc304511c9f7..b1a557b3c6c2 100644 --- 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 @@ struct StdInlinerInterface : public DialectInlinerInterface { /// 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 @@ struct StdInlinerInterface : public DialectInlinerInterface { /// 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 @@ struct StdInlinerInterface : public DialectInlinerInterface { } // 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 @@ LogicalResult ReturnOp::verify() { //===----------------------------------------------------------------------===// #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 similarity index 63% rename from mlir/lib/Dialect/StandardOps/Transforms/CMakeLists.txt rename to mlir/lib/Dialect/Func/Transforms/CMakeLists.txt index 3ee725bc0489..dfc429c7a1d8 100644 --- 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 similarity index 98% rename from mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp rename to mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp index f9d9c5c31e66..d3df225d1920 100644 --- 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 similarity index 85% rename from mlir/lib/Dialect/StandardOps/Transforms/FuncBufferize.cpp rename to mlir/lib/Dialect/Func/Transforms/FuncBufferize.cpp index 9351b676b97a..15208b57ce7f 100644 --- 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 @@ struct FuncBufferizePass : public FuncBufferizeBase { }; } // 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 similarity index 95% rename from mlir/lib/Dialect/StandardOps/Transforms/FuncConversions.cpp rename to mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp index ee614fd27a76..c1e69d0ed0ba 100644 --- 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 similarity index 68% rename from mlir/lib/Dialect/StandardOps/Transforms/PassDetail.h rename to mlir/lib/Dialect/Func/Transforms/PassDetail.h index eadd026ead3c..d6020f89a87a 100644 --- 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 @@ class MemRefDialect; } // 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 index b08468c3a8eb..a2e706c67a47 100644 --- a/mlir/lib/Dialect/GPU/CMakeLists.txt +++ b/mlir/lib/Dialect/GPU/CMakeLists.txt @@ -69,6 +69,7 @@ add_mlir_dialect_library(MLIRGPUTransforms MLIRArithmetic MLIRAsync MLIRDataLayoutInterfaces + MLIRFunc MLIRGPUOps MLIRIR MLIRLLVMIR @@ -76,7 +77,6 @@ add_mlir_dialect_library(MLIRGPUTransforms MLIRMemRef MLIRPass MLIRSCF - MLIRStandard MLIRSupport MLIRTransformUtils ) diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index 3b0f51444e02..5278ad9b8db6 100644 --- 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 @@ static void injectGpuIndexOperations(Location loc, Region &launchFuncOpBody, /// 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 index 6e62e4a1aadb..2fccf2da7ceb 100644 --- a/mlir/lib/Dialect/Linalg/Analysis/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Analysis/CMakeLists.txt @@ -7,8 +7,8 @@ add_mlir_dialect_library(MLIRLinalgAnalysis 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 index ee5c6da544b0..46d4f67c57b2 100644 --- 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 index 74104ec1d5eb..066204d8b65d 100644 --- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt @@ -17,8 +17,8 @@ add_mlir_dialect_library(MLIRModuleBufferization 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 index 4abfec9c8fbd..5daa764c6d22 100644 --- 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 @@ static const ModuleBufferizationState & 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 @@ getModuleBufferizationState(const BufferizationState &state) { 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 @@ getFuncOpAnalysisState(const BufferizationState &state, FuncOp funcOp) { /// 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 @@ equivalentFuncOpBBArgsAnalysis(Operation *op, BufferizationState &state, // 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 @@ getBufferizedFunctionType(MLIRContext *ctx, TypeRange argumentTypes, 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 @@ static LogicalResult bufferizeFuncOpBoundary(FuncOp funcOp, } // 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 @@ static LogicalResult bufferizeFuncOpBoundary(FuncOp funcOp, 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 @@ getFuncOpsOrderedByCalls(ModuleOp moduleOp, 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 @@ getFuncOpsOrderedByCalls(ModuleOp moduleOp, 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 @@ getEquivalentFuncArgIdx(FuncOp funcOp, const ModuleBufferizationState &state, } 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 @@ struct CallOpInterface 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 @@ struct CallOpInterface 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 @@ struct CallOpInterface 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 @@ struct CallOpInterface /// 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 @@ struct CallOpInterface } // 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 CallOpInterface struct ReturnOpInterface : public BufferizableOpInterface::ExternalModel { + func::ReturnOp> { bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand, const BufferizationState &state) const { return true; @@ -924,7 +924,7 @@ struct ReturnOpInterface 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 @@ struct FuncOpInterface 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 index 42bb8dcdc8bd..31d3f8b4aa33 100644 --- 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 @@ struct LinalgBufferizePass : public LinalgBufferizeBase { 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 index a688eb59a6f1..f1fbbf3d158e 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt @@ -39,6 +39,8 @@ add_mlir_dialect_library(MLIRLinalgTransforms MLIRArithmeticTransforms MLIRBufferization MLIRComplex + MLIRFunc + MLIRFuncTransforms MLIRInferTypeOpInterface MLIRIR MLIRMemRef @@ -51,8 +53,6 @@ add_mlir_dialect_library(MLIRLinalgTransforms 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 index d7869b4a9f41..449a7ebda2f6 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp @@ -49,7 +49,7 @@ struct LinalgComprehensiveModuleBufferize .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 index afe82ff8bdfa..9a87871478cf 100644 --- 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 index 68fdd91e92ba..c7ff94c301f9 100644 --- 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 index da45a6c64e9c..f2a5937f7c0c 100644 --- 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 @@ HoistingAnalysis::getPackedTensorSizes(ImplicitLocOpBuilder &b) { } 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 index 8650d574de28..4e3c7c8497d5 100644 --- 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 index 0d8632df6b0e..c9d337be7f35 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @@ -365,7 +365,7 @@ vectorizeOneOp(OpBuilder &b, LinalgOp linalgOp, Operation *op, // 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 @@ static bool hasOnlyScalarElementwiseOp(Region &r) { 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 index dacabad7ddf8..510ddefebea7 100644 --- a/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt @@ -9,11 +9,11 @@ add_mlir_dialect_library(MLIRLinalgUtils 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 index 3dfb336a9bf1..3a54d66f6b6e 100644 --- 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 index 96bb17e650d1..2fb4c5e526c9 100644 --- a/mlir/lib/Dialect/Math/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Math/Transforms/CMakeLists.txt @@ -9,10 +9,10 @@ add_mlir_dialect_library(MLIRMathTransforms 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 index 9416ac544f17..7b6f96905a01 100644 --- 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 index d27f02edf9da..ceaede262a23 100644 --- a/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt @@ -6,7 +6,6 @@ add_mlir_dialect_library(MLIRMemRef ${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 index 834346d3d1d4..79789f61a305 100644 --- a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt @@ -16,11 +16,11 @@ add_mlir_dialect_library(MLIRMemRefTransforms 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 index ca490a28332c..7c969d3e30a7 100644 --- 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 @@ struct ExpandOpsPass : public ExpandOpsBase { 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 index 89936111fce5..3ac903877cf4 100644 --- a/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp +++ b/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp @@ -125,7 +125,7 @@ void NormalizeMemRefs::setCalleesAndCallersNonNormalizable( } // 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 @@ bool NormalizeMemRefs::areMemRefsNormalizable(FuncOp funcOp) { 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 @@ void NormalizeMemRefs::updateFunctionSignature(FuncOp funcOp, // 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 @@ void NormalizeMemRefs::updateFunctionSignature(FuncOp funcOp, // 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 @@ void NormalizeMemRefs::normalizeFuncOpMemRefs(FuncOp funcOp, // `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 index d1e5baa798fd..318469f67fdb 100644 --- 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 @@ namespace arith { 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 index 4288c0cc8022..595e8f79ba65 100644 --- a/mlir/lib/Dialect/SCF/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/CMakeLists.txt @@ -10,10 +10,10 @@ add_mlir_dialect_library(MLIRSCF 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 index f35d74879d99..ab00578d1a16 100644 --- 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 index b31593b90ea6..d6803031e894 100644 --- 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 index 4858954343c3..df087e57b436 100644 --- a/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt @@ -24,12 +24,12 @@ add_mlir_dialect_library(MLIRSCFTransforms 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 index faf0da11302c..aab11e708e90 100644 --- 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 index 493a1b891e34..4c2df93f8a38 100644 --- 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 index 34e79c775053..5e1dbf108527 100644 --- 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 index 503c9b05c483..106100ad92ad 100644 --- 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 index f4f87511603b..5435186ecae0 100644 --- 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 index 8e35efa852d5..5cee4ac8d6ec 100644 --- 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 index 3a963c70e114..50bc4f540897 100644 --- 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 index bad518fe8acf..6ad4606dd48f 100644 --- a/mlir/lib/Dialect/SCF/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/Utils/CMakeLists.txt @@ -11,9 +11,9 @@ add_mlir_dialect_library(MLIRSCFUtils 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 index 83766b18e2ed..f1f34eaf00be 100644 --- 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 @@ FailureOr mlir::outlineSingleBlockRegion(RewriterBase &rewriter, 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 @@ FailureOr mlir::outlineSingleBlockRegion(RewriterBase &rewriter, 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 index e9e7f00c6164..a0e93f8513ce 100644 --- 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 @@ void ShapeToShapeLowering::runOnOperation() { 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 index e76261f292fe..f5c4733af4d5 100644 --- a/mlir/lib/Dialect/SparseTensor/Pipelines/CMakeLists.txt +++ b/mlir/lib/Dialect/SparseTensor/Pipelines/CMakeLists.txt @@ -8,6 +8,7 @@ add_mlir_dialect_library(MLIRSparseTensorPipelines MLIRArithmeticTransforms MLIRAffineToStandard MLIRBufferizationTransforms + MLIRFuncTransforms MLIRLinalgTransforms MLIRMathToLLVM MLIRMemRefToLLVM @@ -16,7 +17,6 @@ add_mlir_dialect_library(MLIRSparseTensorPipelines 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 index ff6577abaa01..6d0d674c6d72 100644 --- 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 @@ void mlir::sparse_tensor::buildSparseCompiler( 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 index 15d57bc0fc73..51d7bd4fa872 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt @@ -13,6 +13,7 @@ add_mlir_dialect_library(MLIRSparseTensorTransforms LINK_LIBS PUBLIC MLIRArithmetic MLIRBufferization + MLIRFunc MLIRIR MLIRLLVMIR MLIRLinalg @@ -22,7 +23,6 @@ add_mlir_dialect_library(MLIRSparseTensorTransforms 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 index 07875fcfc727..ce76ef289348 100644 --- 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 @@ static FlatSymbolRefAttr getFunc(Operation *op, StringRef name, } /// 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 @@ static void insertScalarIntoDenseTensor(ConversionPatternRewriter &rewriter, //===----------------------------------------------------------------------===// /// 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 index 62bec937121c..d51be6b1b670 100644 --- 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 @@ struct SparseTensorConversionPass // 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 index 427ee3079594..1f7246bf8d4a 100644 --- 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 index f1689abb6e8b..000000000000 --- 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 index 41b11ea197b2..a28913cdabae 100644 --- 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 index 8b10f9da183d..e98d3dfe26a7 100644 --- a/mlir/lib/Dialect/Tosa/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Tosa/Transforms/CMakeLists.txt @@ -13,8 +13,8 @@ add_mlir_dialect_library(MLIRTosaTransforms 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 index c23830259f9a..67531ba2403a 100644 --- 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 @@ void propagateShapesInRegion(Region ®ion) { // 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 @@ public: // 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 @@ public: } 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 index a25198686dab..c1954407f4b6 100644 --- a/mlir/lib/Dialect/Vector/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/Vector/Utils/CMakeLists.txt @@ -9,9 +9,9 @@ add_mlir_dialect_library(MLIRVectorUtils 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 index 5388b7bd6ca1..774b1f361716 100644 --- 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 @@ bool matcher::operatesOnSuperVectorsOf(Operation &op, 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 index 0fbd54b2375b..bdd8d1fd31e6 100644 --- 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 index 7d758fdbdd61..f067a04bcdde 100644 --- a/mlir/lib/ExecutionEngine/CMakeLists.txt +++ b/mlir/lib/ExecutionEngine/CMakeLists.txt @@ -77,9 +77,9 @@ add_mlir_library(MLIRJitRunner 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 index 72738971db6d..89a6b27c5fea 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -608,8 +608,8 @@ void OpState::printOpName(Operation *op, OpAsmPrinter &p, 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 index 54e4e762d564..7a48aa92fa29 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -1672,8 +1672,9 @@ FailureOr OperationParser::parseCustomOperationName() { // 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 index da34dcc87c1d..8263ef4e8eda 100644 --- a/mlir/lib/Target/Cpp/CMakeLists.txt +++ b/mlir/lib/Target/Cpp/CMakeLists.txt @@ -9,10 +9,10 @@ add_mlir_translation_library(MLIRTargetCpp 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 index 889637bec550..82574091e646 100644 --- 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 @@ void registerToCppTranslation() { registry.insert(); // clang-format on }); diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp index 69b6cbfee64b..ce1483b733f1 100644 --- 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, } static LogicalResult printOperation(CppEmitter &emitter, - mlir::ConstantOp constantOp) { + func::ConstantOp constantOp) { Operation *operation = constantOp.getOperation(); Attribute value = constantOp.getValueAttr(); @@ -311,7 +311,7 @@ static LogicalResult printOperation(CppEmitter &emitter, 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 @@ static LogicalResult printOperation(CppEmitter &emitter, scf::YieldOp yieldOp) { 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::emitLabel(Block &block) { 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 index bf379e9b2ec8..1477ffea76f4 100644 --- a/mlir/python/CMakeLists.txt +++ b/mlir/python/CMakeLists.txt @@ -80,6 +80,15 @@ declare_mlir_dialect_python_bindings( 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 @@ declare_mlir_dialect_python_bindings( 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 @@ declare_mlir_python_extension(MLIRPythonExtension.Core 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 similarity index 70% rename from mlir/python/mlir/dialects/StandardOps.td rename to mlir/python/mlir/dialects/FuncOps.td index 5b7caabc2341..1728091f4444 100644 --- 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 index 78f8c95c42da..a3a147469266 100644 --- a/mlir/python/mlir/dialects/_builtin_ops_ext.py +++ b/mlir/python/mlir/dialects/_builtin_ops_ext.py @@ -162,7 +162,7 @@ class FuncOp: """ 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 @@ class FuncOp: 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 similarity index 97% rename from mlir/python/mlir/dialects/_std_ops_ext.py rename to mlir/python/mlir/dialects/_func_ops_ext.py index f4cb6186b165..850562673b7e 100644 --- a/mlir/python/mlir/dialects/_std_ops_ext.py +++ b/mlir/python/mlir/dialects/_func_ops_ext.py @@ -46,8 +46,8 @@ class CallOp: 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 similarity index 87% rename from mlir/python/mlir/dialects/std.py rename to mlir/python/mlir/dialects/func.py index 8e55807a0420..dc554c22173b 100644 --- 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 index 453a3e80cd9a..ff5c405d788a 100644 --- 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 typing import Callable, Dict, List, Sequence, Tuple, Union 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 index 9610df62457e..8a7a567f2a77 100644 --- a/mlir/test/CAPI/CMakeLists.txt +++ b/mlir/test/CAPI/CMakeLists.txt @@ -34,7 +34,7 @@ _add_capi_test_executable(mlir-capi-ir-test ir.c LINK_LIBS PRIVATE MLIRCAPIIR - MLIRCAPIStandard + MLIRCAPIFunc MLIRCAPIRegistration ) diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c index c8d27398d6fc..f2769d34cdd2 100644 --- 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 @@ MlirModule makeAndDumpAdd(MlirContext ctx, MlirLocation location) { 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 @@ int printBuiltinAttributes(MlirContext ctx) { 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 @@ int printBuiltinAttributes(MlirContext ctx) { 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 @@ int registerOnlyStd() { if (mlirContextGetNumLoadedDialects(ctx) != 1) return 1; - MlirDialectHandle stdHandle = mlirGetDialectHandle__std__(); + MlirDialectHandle stdHandle = mlirGetDialectHandle__func__(); MlirDialect std = mlirContextGetOrLoadDialect( ctx, mlirDialectHandleGetNamespace(stdHandle)); @@ -1546,10 +1546,10 @@ int registerOnlyStd() { 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 @@ int testClone() { 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 @@ int testDialectRegistry() { 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 index c4974488c5f2..d83d44d92931 100644 --- a/mlir/test/CAPI/pass.c +++ b/mlir/test/CAPI/pass.c @@ -43,7 +43,7 @@ void testRunPassOnModule() { // 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 @@ void testRunPassOnNestedModule() { // 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 @@ void testRunPassOnNestedModule() { // 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 index 14c0c3bd451a..be285b7d00e1 100644 --- a/mlir/test/Conversion/ArithmeticToLLVM/arith-to-llvm.mlir +++ b/mlir/test/Conversion/ArithmeticToLLVM/arith-to-llvm.mlir @@ -324,7 +324,7 @@ func @index_vector(%arg0: vector<4xindex>) { %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 @@ func @cmpf_2dvector(%arg0 : vector<4x3xf32>, %arg1 : vector<4x3xf32>) { // 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 @@ func @cmpi_0dvector(%arg0 : vector, %arg1 : vector) { // 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 @@ func @cmpi_2dvector(%arg0 : vector<4x3xi32>, %arg1 : vector<4x3xi32>) { // 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 index 1d40ba6f8a57..d754235d4602 100644 --- 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 @@ func @select_2d(%arg0 : vector<4x3xi1>, %arg1 : vector<4x3xi32>, %arg2 : vector< // 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 index 3c75bb944f08..6e6f0a967ab4 100644 --- a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir +++ b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir @@ -49,7 +49,7 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { %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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { builtin.func @gpu_sync() { // CHECK: nvvm.barrier0 gpu.barrier - std.return + func.return } } @@ -166,7 +166,7 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 index 42da06e2172f..89c1ee0212b5 100644 --- a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir +++ b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir @@ -49,7 +49,7 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { %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 @@ gpu.module @test_module { builtin.func @gpu_sync() { // CHECK: rocdl.barrier gpu.barrier - std.return + func.return } } @@ -93,7 +93,7 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 @@ gpu.module @test_module { // 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 index b2de213b4e34..002c3cd83d41 100644 --- a/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir +++ b/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir @@ -10,7 +10,7 @@ func @ops(%arg0: f32, %arg1: f32, %arg2: i32, %arg3: i32, %arg4: f64) { %19 = math.sqrt %arg0 : f32 // CHECK: = "llvm.intr.sqrt"(%{{.*}}) : (f64) -> f64 %20 = math.sqrt %arg4 : f64 - std.return + func.return } // ----- @@ -22,7 +22,7 @@ func @log1p(%arg0 : f32) { // 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 @@ func @log1p_2dvector(%arg0 : vector<4x3xf32>) { // 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 @@ func @expm1(%arg0 : f32) { // 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 @@ func @rsqrt(%arg0 : f32) { // 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 @rsqrt(%arg0 : f32) { func @sine(%arg0 : f32) { // CHECK: "llvm.intr.sin"(%arg0) : (f32) -> f32 %0 = math.sin %arg0 : f32 - std.return + func.return } // ----- @@ -80,7 +80,7 @@ func @ctlz(%arg0 : i32) { // 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 @@ func @cttz(%arg0 : i32) { // 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 @@ func @cttz_vec(%arg0 : vector<4xi32>) { // 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 @cttz_vec(%arg0 : vector<4xi32>) { 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(%arg0 : i32) { 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 @@ func @rsqrt_double(%arg0 : f64) { // 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 @@ func @rsqrt_vector(%arg0 : vector<4xf32>) { // 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 @@ func @rsqrt_multidim_vector(%arg0 : vector<4x3xf32>) { // 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 @rsqrt_multidim_vector(%arg0 : vector<4x3xf32>) { 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 index 85c6ca17747b..32f9c2fef058 100644 --- a/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir +++ b/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir @@ -571,7 +571,7 @@ func @address_space(%arg0 : memref<32xf32, affine_map<(d0) -> (d0)>, 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 index 97d4c9f69bab..5ebee9a4d5e2 100644 --- a/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir +++ b/mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir @@ -74,7 +74,7 @@ func @get_extent_shape_of(%arg : tensor<2x3xf32>, %idx : index) -> index { // ----- -// 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 index 479ccaad2da6..e774b9085db6 100644 --- a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir +++ b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir @@ -454,7 +454,7 @@ func @dfs_block_order(%arg0: i32) -> (i32) { 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 @ceilf(%arg0 : f32) { func @floorf(%arg0 : f32) { // CHECK: "llvm.intr.floor"(%arg0) : (f32) -> f32 %0 = math.floor %arg0 : f32 - std.return + func.return } // ----- @@ -507,7 +507,7 @@ func @fmaf(%arg0: f32, %arg1: vector<4xf32>) { %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 @@ func @switchi8(%arg0 : i8) -> i32 { ] ^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 index 4fc94af8f6a9..2f313e339cfb 100644 --- a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir +++ b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir @@ -264,7 +264,7 @@ func @shift_vector(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) { // ----- //===----------------------------------------------------------------------===// -// std.cmpf +// arith.cmpf //===----------------------------------------------------------------------===// module attributes { @@ -348,7 +348,7 @@ func @cmpf(%arg0 : f32, %arg1 : f32) { // ----- //===----------------------------------------------------------------------===// -// std.cmpi +// arith.cmpi //===----------------------------------------------------------------------===// module attributes { @@ -849,7 +849,7 @@ func @sitofp(%arg0 : i64) -> f64 { // ----- //===----------------------------------------------------------------------===// -// std.return +// func.return //===----------------------------------------------------------------------===// module attributes { diff --git a/mlir/test/Dialect/Arithmetic/ops.mlir b/mlir/test/Dialect/Arithmetic/ops.mlir index 3a7934286bb8..af8588dc62cc 100644 --- a/mlir/test/Dialect/Arithmetic/ops.mlir +++ b/mlir/test/Dialect/Arithmetic/ops.mlir @@ -903,8 +903,8 @@ func @test_constant() -> () { // 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 index 5c48a085d35a..3aaa18e78461 100644 --- 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) 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 index 55280b2ac8b8..74dde5c378e4 100644 --- a/mlir/test/IR/core-ops.mlir +++ b/mlir/test/IR/core-ops.mlir @@ -205,7 +205,7 @@ func @zero_dim_no_idx(%arg0 : memref, %arg1 : memref, %arg2 : memref 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 @@ func @calls(%arg0: i32) { // 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 @@ func @calls(%arg0: i32) { %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 index 3b4cb0496b71..35099f0e7a32 100644 --- a/mlir/test/IR/generic-visitors-interrupt.mlir +++ b/mlir/test/IR/generic-visitors-interrupt.mlir @@ -108,7 +108,7 @@ func @main(%arg0: f32) -> f32 { // 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 @@ func @main(%arg0: f32) -> f32 { // 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 @@ func @main(%arg0: f32) -> f32 { // 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 index c87bd559be9b..b14cf93bc34e 100644 --- a/mlir/test/IR/generic-visitors.mlir +++ b/mlir/test/IR/generic-visitors.mlir @@ -36,7 +36,7 @@ func @structured_cfg() { // 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 index 8415126f42fc..b5a0f1056c7d 100644 --- a/mlir/test/IR/invalid-ops.mlir +++ b/mlir/test/IR/invalid-ops.mlir @@ -37,8 +37,8 @@ func @unknown_custom_op() { // ----- 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 @func_with_ops(tensor<12xi1>, tensor<42xi32>, tensor<42xi32>) { 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 index c510ed69645c..bd422f9250c3 100644 --- a/mlir/test/IR/invalid.mlir +++ b/mlir/test/IR/invalid.mlir @@ -355,13 +355,13 @@ func @malformed_type(%a : intt) { // expected-error {{expected non-function type 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_type_mismatch() -> i32 { 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 index 19a4af28e35d..7f1cd0d2d1bb 100644 --- a/mlir/test/IR/op-stats.mlir +++ b/mlir/test/IR/op-stats.mlir @@ -31,6 +31,6 @@ func @main(tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32> { // 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 index 5e47d3761385..67c18a7644db 100644 --- a/mlir/test/IR/parser.mlir +++ b/mlir/test/IR/parser.mlir @@ -456,11 +456,11 @@ func @verbose_terminators() -> (i1, i17) { ^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 @@ func @default_dialect(%bool : i1) { // 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 index 7e90a19e9fbd..e12eda8f1781 100644 --- a/mlir/test/IR/print-op-generic.mlir +++ b/mlir/test/IR/print-op-generic.mlir @@ -9,5 +9,5 @@ func @pretty_names() { // 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 index 23903b898357..189b305bbe58 100644 --- a/mlir/test/IR/visitors.mlir +++ b/mlir/test/IR/visitors.mlir @@ -30,7 +30,7 @@ func @structured_cfg() { // 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 @@ func @structured_cfg() { // 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 @@ func @structured_cfg() { // 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 @@ func @structured_cfg() { // 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 @@ func @structured_cfg() { // 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 @@ func @unstructured_cfg() { // 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 @@ func @unstructured_cfg() { // 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 @@ func @unstructured_cfg() { // 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 @@ func @unstructured_cfg() { // 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 @@ func @unstructured_cfg() { // 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 index 7958e76862c4..2afcf5506ce4 100644 --- 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 import runtime as rt 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 @@ class StressTest: 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 index 3a936e6cda50..e93c9343dd49 100644 --- 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 ir 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 index 4236d710adf3..90a12cc329dd 100644 --- 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 @@ def _get_output_sparse_tensor_kernel( 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 index 556e820465da..59a892910948 100644 --- 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 @verifyDirectPattern() -> i32 { 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_input_1_to_1(%arg0: i64) { 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 @@ func @no_remap_nested() { // 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 @@ func @remap_moved_region_args() { ^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 @@ func @remap_cloned_region_args() { ^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 @@ func @remap_drop_region() { ^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 @@ func @up_to_date_replacement(%arg: i8) -> i8 { // 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 @@ func @remove_foldable_op(%arg0 : i32) -> (i32) { %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 @@ func @create_block() { // 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 @create_block() { 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 @@ func @create_illegal_block() { // 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 @@ func @undo_block_arg_replace() { "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_block_erase() { 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 @undo_child_created_before_parent() { 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 index dbe2a74cd55a..996967845666 100644 --- 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 @@ public: } 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 @@ public: 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 index 592f41ee547c..30a2e09cdbc3 100644 --- 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 index 87078f8cee68..4f5bbfba7406 100644 --- 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(MemRef) 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 similarity index 68% rename from mlir/test/lib/Dialect/StandardOps/CMakeLists.txt rename to mlir/test/lib/Dialect/Func/CMakeLists.txt index b85de09e10bf..4320ffaea010 100644 --- 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 @@ add_mlir_library(MLIRStandardOpsTestPasses 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 similarity index 91% rename from mlir/test/lib/Dialect/StandardOps/TestDecomposeCallGraphTypes.cpp rename to mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp index c6d61d9bba77..9236f8215f70 100644 --- 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 @@ struct TestDecomposeCallGraphTypes 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 index a3cf36b02840..97fc6699f6fb 100644 --- a/mlir/test/lib/Dialect/GPU/CMakeLists.txt +++ b/mlir/test/lib/Dialect/GPU/CMakeLists.txt @@ -10,6 +10,7 @@ add_mlir_library(MLIRGPUTestPasses LINK_LIBS PUBLIC MLIRAffine + MLIRFunc MLIRGPUOps MLIRGPUToGPURuntimeTransforms MLIRLLVMToLLVMIRTranslation @@ -19,6 +20,5 @@ add_mlir_library(MLIRGPUTestPasses MLIRROCDLIR MLIRROCDLToLLVMIRTranslation MLIRSCF - MLIRStandard MLIRTransformUtils ) diff --git a/mlir/test/lib/Dialect/GPU/TestGpuMemoryPromotion.cpp b/mlir/test/lib/Dialect/GPU/TestGpuMemoryPromotion.cpp index 6c3e6ff5de8b..b9c40350ecdc 100644 --- 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 @@ class TestGpuMemoryPromotionPass : 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 index 4d45c49e6623..0a68509cf2df 100644 --- 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 @@ namespace { 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 index 1fe3db2e9e67..56879a18883b 100644 --- a/mlir/test/lib/Dialect/Linalg/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Linalg/CMakeLists.txt @@ -16,6 +16,8 @@ add_mlir_library(MLIRLinalgTestPasses MLIRArithmeticTransforms MLIRBufferization MLIRBufferizationTransforms + MLIRFunc + MLIRFuncTransforms MLIRGPUTransforms MLIRLinalg MLIRLinalgTransforms @@ -24,8 +26,6 @@ add_mlir_library(MLIRLinalgTestPasses 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 index 3c0249e4825e..7e4ed8f7a38a 100644 --- 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 @@ struct TestLinalgCodegenStrategy 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 index f8a39b02aae8..d2784b64d65f 100644 --- a/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp @@ -114,8 +114,8 @@ struct TestLinalgFusionTransforms : 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 index 6f3d7c984009..1eb163424e84 100644 --- 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 @@ struct TestLinalgTransforms 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 index 120c44edbc78..7194c368c195 100644 --- 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 @@ public: } 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 index 0feb3e04bc71..e9d89f145ef5 100644 --- 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 @@ public: } 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 index 06fd28032e8d..de0e6d2f7ad0 100644 --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -59,6 +59,8 @@ add_mlir_library(MLIRTestDialect MLIRDerivedAttributeOpInterface MLIRDialect MLIRDLTI + MLIRFunc + MLIRFuncTransforms MLIRIR MLIRInferTypeOpInterface MLIRLinalg @@ -66,8 +68,6 @@ add_mlir_library(MLIRTestDialect 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 index f3f4d54d26e1..e0c5eea373b0 100644 --- 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 @@ struct FoldToCallOpPattern : public OpRewritePattern { 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 index 5e0c253a7786..69ad6ab4982f 100644 --- 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 @@ struct TestLegalizePatternDriver TestLegalizePatternDriver(ConversionMode mode) : mode(mode) {} void getDependentDialects(DialectRegistry ®istry) const override { - registry.insert(); + registry.insert(); } void runOnOperation() override { @@ -679,8 +679,8 @@ struct TestLegalizePatternDriver 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 index ba37c0fb9a23..974c3daa304f 100644 --- 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 index 762959587621..595bf54beb70 100644 --- a/mlir/test/lib/Dialect/Vector/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Vector/CMakeLists.txt @@ -7,13 +7,13 @@ add_mlir_library(MLIRVectorTestPasses 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 index 1791768da811..67e33d3aa0b4 100644 --- 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 @@ struct TestVectorToLoopPatterns 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 index f76078f02d00..4f8d97f6fdbd 100644 --- 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 index dc655ab3f706..ede4da7775d8 100644 --- 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 index 8a854e6a059d..bb180e0e19e5 100644 --- 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 index e2841feb01fa..f50d917e79c6 100644 --- 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 index a253c5970601..ac40c818d5e9 100644 --- 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 @@ static LogicalResult createBackwardSliceFunction(Operation *op, 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 index 9e43e8034721..f4d5eed024ab 100644 --- 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 @@ struct Inliner : public PassWrapper> { 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 index baee3d7f0187..29cef56b7ac6 100644 --- 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 index 7caf5b5d892c..d07c094850a4 100644 --- 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 @@ def testFromPyFunc(): # 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 @@ def testBuildFuncOp(): 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 @@ def testFuncArgumentAccess(): 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 similarity index 92% rename from mlir/test/python/dialects/std.py rename to mlir/test/python/dialects/func.py index 2a3b2df88e4b..c4d6417f0558 100644 --- 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 @@ def testFunctionCalls(): 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 index 25a3de05f049..6e3ba8fd72c9 100644 --- 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 index 1a0d08a0dce7..814a6d2a6cce 100644 --- 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 index 1b31ed040ad2..b3b453787428 100644 --- 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 index 85699493dd4d..81de8fc0f204 100644 --- 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 index d68b43de7535..b97b0188e0e8 100644 --- 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 index 08be2ccada5f..6f912c8bb129 100644 --- 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 builtin -from mlir.dialects import linalg -from mlir.dialects import std from mlir.dialects import arith +from mlir.dialects import builtin +from mlir.dialects import func +from mlir.dialects import linalg from mlir.dialects.linalg.opdsl.lang import * diff --git a/mlir/test/python/dialects/memref.py b/mlir/test/python/dialects/memref.py index f2eda0a62061..db917678ba18 100644 --- 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 @@ def testCustomBuidlers(): 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 index 562356f312f3..f434e806ed47 100644 --- 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 @@ def testOpsAsArguments(): 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 index b8db94070d6a..5c2043eec84b 100644 --- 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 @@ def testTransferReadOp(): 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 index c4e580f89c94..54e1c85b2956 100644 --- a/mlir/test/python/integration/dialects/linalg/opsrun.py +++ b/mlir/test/python/integration/dialects/linalg/opsrun.py @@ -4,8 +4,8 @@ import ctypes 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 index 5aa1bf82de77..9ccffaeb2ec0 100644 --- a/mlir/test/python/ir/blocks.py +++ b/mlir/test/python/ir/blocks.py @@ -6,8 +6,7 @@ import itertools 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 @@ def testBlockCreation(): 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 @@ def testFirstBlockCreation(): 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 index 10e1a67b931f..65e81e84354c 100644 --- a/mlir/test/python/ir/dialects.py +++ b/mlir/test/python/ir/dialects.py @@ -16,10 +16,10 @@ def run(f): @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 testDialectDescriptor(): 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 @@ def testUserDialectClass(): 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 @@ def testUserDialectClass(): assert False, "Expected exception" # Using the 'd' alias. - d = ctx.d["std"] - # CHECK: + d = ctx.d["func"] + # CHECK: print(d) @@ -102,5 +102,5 @@ def testIsRegisteredOperation(): # 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 index 7608bc56f0b7..2b63f15422da 100644 --- a/mlir/test/python/ir/operation.py +++ b/mlir/test/python/ir/operation.py @@ -128,7 +128,7 @@ def testBlockAndRegionOwners(): r""" builtin.module { builtin.func @f() { - std.return + func.return } } """, ctx) @@ -564,7 +564,7 @@ def testOperationPrint(): # 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 @@ def testKnownOpView(): """) 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 index cde6e1a31317..5e0ae1402280 100644 --- a/mlir/tools/mlir-vulkan-runner/CMakeLists.txt +++ b/mlir/tools/mlir-vulkan-runner/CMakeLists.txt @@ -58,6 +58,7 @@ if (MLIR_ENABLE_VULKAN_RUNNER) MLIRAnalysis MLIRArithmetic MLIRExecutionEngine + MLIRFunc MLIRGPUOps MLIRIR MLIRJitRunner @@ -69,7 +70,6 @@ if (MLIR_ENABLE_VULKAN_RUNNER) 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 index 1d72c3c93663..46b6e67bc043 100644 --- 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 @@ int main(int argc, char **argv) { 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 index 316003cdc3a5..aedd1852a8c2 100644 --- a/mlir/unittests/Conversion/PDLToPDLInterp/CMakeLists.txt +++ b/mlir/unittests/Conversion/PDLToPDLInterp/CMakeLists.txt @@ -3,6 +3,6 @@ add_mlir_unittest(MLIRPDLToPDLInterpTests ) target_link_libraries(MLIRPDLToPDLInterpTests PRIVATE - MLIRStandard + MLIRFunc MLIRPDLToPDLInterp ) diff --git a/mlir/unittests/Interfaces/CMakeLists.txt b/mlir/unittests/Interfaces/CMakeLists.txt index d86710c2781a..54a6837b0ed8 100644 --- a/mlir/unittests/Interfaces/CMakeLists.txt +++ b/mlir/unittests/Interfaces/CMakeLists.txt @@ -9,7 +9,7 @@ target_link_libraries(MLIRInterfacesTests MLIRControlFlowInterfaces MLIRDataLayoutInterfaces MLIRDLTI + MLIRFunc MLIRInferTypeOpInterface MLIRParser - MLIRStandard ) diff --git a/mlir/unittests/Interfaces/InferTypeOpInterfaceTest.cpp b/mlir/unittests/Interfaces/InferTypeOpInterfaceTest.cpp index 386253b9fdd0..c74f76cd5f76 100644 --- 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 @@ protected: } )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 index 8caa06e1a843..5246aa04510e 100644 --- a/mlir/utils/vim/syntax/mlir.vim +++ b/mlir/utils/vim/syntax/mlir.vim @@ -34,7 +34,6 @@ syn match mlirType /\/ 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