From c25b20c0f6c13d68dbc2e185764082d61ae4a132 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Mon, 11 May 2020 15:00:48 +0200 Subject: [PATCH] [mlir] NFC: Rename LoopOps dialect to SCF (Structured Control Flow) This dialect contains various structured control flow operaitons, not only loops, reflect this in the name. Drop the Ops suffix for consistency with other dialects. Note that this only moves the files and changes the C++ namespace from 'loop' to 'scf'. The visible IR prefix remains the same and will be updated separately. The conversions will also be updated separately. Differential Revision: https://reviews.llvm.org/D79578 --- mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp | 6 +- mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp | 6 +- .../mlir/Conversion/LoopsToGPU/LoopsToGPU.h | 8 +-- mlir/include/mlir/Conversion/Passes.td | 2 +- mlir/include/mlir/Dialect/CMakeLists.txt | 2 +- .../mlir/Dialect/GPU/ParallelLoopMapper.h | 4 +- .../mlir/Dialect/Linalg/EDSC/Builders.h | 6 +- .../include/mlir/Dialect/Linalg/Utils/Utils.h | 2 +- .../mlir/Dialect/LoopOps/CMakeLists.txt | 9 --- mlir/include/mlir/Dialect/SCF/CMakeLists.txt | 9 +++ .../Dialect/{LoopOps => SCF}/EDSC/Builders.h | 12 ++-- .../{LoopOps => SCF}/EDSC/Intrinsics.h | 12 ++-- .../mlir/Dialect/{LoopOps => SCF}/Passes.h | 6 +- .../mlir/Dialect/{LoopOps => SCF}/Passes.td | 6 +- .../Dialect/{LoopOps/LoopOps.h => SCF/SCF.h} | 18 +++--- .../{LoopOps/LoopOps.td => SCF/SCFOps.td} | 30 +++++----- .../Dialect/{LoopOps => SCF}/Transforms.h | 14 ++--- mlir/include/mlir/InitAllDialects.h | 4 +- mlir/include/mlir/InitAllPasses.h | 4 +- mlir/include/mlir/Transforms/LoopUtils.h | 37 ++++++------ mlir/lib/Analysis/CMakeLists.txt | 4 +- mlir/lib/Analysis/SliceAnalysis.cpp | 8 +-- .../AffineToStandard/AffineToStandard.cpp | 10 ++-- .../AffineToStandard/CMakeLists.txt | 2 +- .../GPUToSPIRV/ConvertGPUToSPIRV.cpp | 42 ++++++------- .../GPUToSPIRV/ConvertGPUToSPIRVPass.cpp | 2 +- .../Conversion/LoopToStandard/CMakeLists.txt | 2 +- .../LoopToStandard/LoopToStandard.cpp | 10 ++-- mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp | 10 ++-- .../Conversion/LoopsToGPU/LoopsToGPUPass.cpp | 8 +-- .../VectorToLoops/ConvertVectorToLoops.cpp | 6 +- mlir/lib/Dialect/CMakeLists.txt | 2 +- mlir/lib/Dialect/GPU/CMakeLists.txt | 2 +- .../GPU/Transforms/MemoryPromotion.cpp | 4 +- .../GPU/Transforms/ParallelLoopMapper.cpp | 6 +- mlir/lib/Dialect/Linalg/EDSC/Builders.cpp | 8 +-- mlir/lib/Dialect/Linalg/EDSC/CMakeLists.txt | 2 +- .../Dialect/Linalg/Transforms/CMakeLists.txt | 2 +- mlir/lib/Dialect/Linalg/Transforms/Loops.cpp | 20 +++---- .../Dialect/Linalg/Transforms/Promotion.cpp | 4 +- mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp | 24 ++++---- mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt | 2 +- mlir/lib/Dialect/Linalg/Utils/Utils.cpp | 4 +- .../Dialect/{LoopOps => SCF}/CMakeLists.txt | 4 +- .../{LoopOps => SCF}/EDSC/Builders.cpp | 10 ++-- .../{LoopOps/LoopOps.cpp => SCF/SCF.cpp} | 18 +++--- .../Transforms/CMakeLists.txt | 8 +-- .../Transforms/ParallelLoopFusion.cpp | 10 ++-- .../Transforms/ParallelLoopSpecialization.cpp | 8 +-- .../Transforms/ParallelLoopTiling.cpp | 10 ++-- .../{LoopOps => SCF}/Transforms/PassDetail.h | 2 +- mlir/lib/Dialect/Vector/CMakeLists.txt | 2 +- mlir/lib/Transforms/CMakeLists.txt | 2 +- mlir/lib/Transforms/LoopCoalescing.cpp | 8 +-- .../lib/Transforms/ParallelLoopCollapsing.cpp | 4 +- mlir/lib/Transforms/Utils/CMakeLists.txt | 2 +- mlir/lib/Transforms/Utils/LoopUtils.cpp | 60 +++++++++---------- mlir/test/Dialect/{Loops => SCF}/invalid.mlir | 0 .../Dialect/{Loops => SCF}/loop-unroll.mlir | 0 mlir/test/Dialect/{Loops => SCF}/ops.mlir | 0 .../{Loops => SCF}/parallel-loop-fusion.mlir | 0 .../parallel-loop-specialization.mlir | 0 .../{Loops => SCF}/parallel-loop-tiling.mlir | 0 mlir/test/EDSC/CMakeLists.txt | 2 +- mlir/test/EDSC/builder-api-test.cpp | 4 +- mlir/test/lib/Transforms/CMakeLists.txt | 2 +- mlir/test/lib/Transforms/TestLoopMapping.cpp | 6 +- .../Transforms/TestLoopParametricTiling.cpp | 6 +- .../test/lib/Transforms/TestLoopUnrolling.cpp | 8 +-- 69 files changed, 277 insertions(+), 280 deletions(-) delete mode 100644 mlir/include/mlir/Dialect/LoopOps/CMakeLists.txt create mode 100644 mlir/include/mlir/Dialect/SCF/CMakeLists.txt rename mlir/include/mlir/Dialect/{LoopOps => SCF}/EDSC/Builders.h (89%) rename mlir/include/mlir/Dialect/{LoopOps => SCF}/EDSC/Intrinsics.h (58%) rename mlir/include/mlir/Dialect/{LoopOps => SCF}/Passes.h (89%) rename mlir/include/mlir/Dialect/{LoopOps => SCF}/Passes.td (92%) rename mlir/include/mlir/Dialect/{LoopOps/LoopOps.h => SCF/SCF.h} (79%) rename mlir/include/mlir/Dialect/{LoopOps/LoopOps.td => SCF/SCFOps.td} (95%) rename mlir/include/mlir/Dialect/{LoopOps => SCF}/Transforms.h (82%) rename mlir/lib/Dialect/{LoopOps => SCF}/CMakeLists.txt (82%) rename mlir/lib/Dialect/{LoopOps => SCF}/EDSC/Builders.cpp (94%) rename mlir/lib/Dialect/{LoopOps/LoopOps.cpp => SCF/SCF.cpp} (98%) rename mlir/lib/Dialect/{LoopOps => SCF}/Transforms/CMakeLists.txt (61%) rename mlir/lib/Dialect/{LoopOps => SCF}/Transforms/ParallelLoopFusion.cpp (96%) rename mlir/lib/Dialect/{LoopOps => SCF}/Transforms/ParallelLoopSpecialization.cpp (93%) rename mlir/lib/Dialect/{LoopOps => SCF}/Transforms/ParallelLoopTiling.cpp (95%) rename mlir/lib/Dialect/{LoopOps => SCF}/Transforms/PassDetail.h (93%) rename mlir/test/Dialect/{Loops => SCF}/invalid.mlir (100%) rename mlir/test/Dialect/{Loops => SCF}/loop-unroll.mlir (100%) rename mlir/test/Dialect/{Loops => SCF}/ops.mlir (100%) rename mlir/test/Dialect/{Loops => SCF}/parallel-loop-fusion.mlir (100%) rename mlir/test/Dialect/{Loops => SCF}/parallel-loop-specialization.mlir (100%) rename mlir/test/Dialect/{Loops => SCF}/parallel-loop-tiling.mlir (100%) diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp index 39917996b9da..65ba25ee426f 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -21,7 +21,7 @@ #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" @@ -68,7 +68,7 @@ public: auto upperBound = rewriter.create(loc, memRefShape[i]); auto step = rewriter.create(loc, 1); auto loop = - rewriter.create(loc, lowerBound, upperBound, step); + rewriter.create(loc, lowerBound, upperBound, step); loop.getBody()->clear(); loopIvs.push_back(loop.getInductionVar()); @@ -79,7 +79,7 @@ public: if (i != e - 1) rewriter.create(loc, printfRef, rewriter.getIntegerType(32), newLineCst); - rewriter.create(loc); + rewriter.create(loc); rewriter.setInsertionPointToStart(loop.getBody()); } diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp index 39917996b9da..65ba25ee426f 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -21,7 +21,7 @@ #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" @@ -68,7 +68,7 @@ public: auto upperBound = rewriter.create(loc, memRefShape[i]); auto step = rewriter.create(loc, 1); auto loop = - rewriter.create(loc, lowerBound, upperBound, step); + rewriter.create(loc, lowerBound, upperBound, step); loop.getBody()->clear(); loopIvs.push_back(loop.getInductionVar()); @@ -79,7 +79,7 @@ public: if (i != e - 1) rewriter.create(loc, printfRef, rewriter.getIntegerType(32), newLineCst); - rewriter.create(loc); + rewriter.create(loc); rewriter.setInsertionPointToStart(loop.getBody()); } diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h index 0bf49deb0762..f87b21d13d93 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h @@ -17,9 +17,9 @@ class OwningRewritePatternList; struct LogicalResult; class Value; -namespace loop { +namespace scf { class ForOp; -} // end namespace loop +} // end namespace scf /// Convert a perfect affine loop nest with the outermost loop identified by /// `forOp` into a gpu::Launch operation. Map `numBlockDims` outer loops to @@ -45,7 +45,7 @@ LogicalResult convertAffineLoopNestToGPULaunch(AffineForOp forOp, /// parallelization is performed, it is under the responsibility of the caller /// to strip-mine the loops and to perform the dependence analysis before /// calling the conversion. -LogicalResult convertLoopNestToGPULaunch(loop::ForOp forOp, +LogicalResult convertLoopNestToGPULaunch(scf::ForOp forOp, unsigned numBlockDims, unsigned numThreadDims); @@ -70,7 +70,7 @@ LogicalResult convertLoopNestToGPULaunch(loop::ForOp forOp, /// TODO(ravishankarm) : Add checks that verify 2(b) above. /// The above conditions are assumed to be satisfied by the computation rooted /// at `forOp`. -LogicalResult convertLoopToGPULaunch(loop::ForOp forOp, +LogicalResult convertLoopToGPULaunch(scf::ForOp forOp, ArrayRef numWorkGroups, ArrayRef workGroupSizes); diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td index 7a24e0f6e72e..a0d405b5fb48 100644 --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -176,7 +176,7 @@ def ConvertSimpleLoopsToGPU : FunctionPass<"convert-loops-to-gpu"> { } def ConvertLoopsToGPU : FunctionPass<"convert-loop-op-to-gpu"> { - let summary = "Convert top-level loop::ForOp to GPU kernels"; + let summary = "Convert top-level scf::ForOp to GPU kernels"; let constructor = "mlir::createLoopToGPUPass()"; let options = [ ListOption<"numWorkGroups", "gpu-num-workgroups", "int64_t", diff --git a/mlir/include/mlir/Dialect/CMakeLists.txt b/mlir/include/mlir/Dialect/CMakeLists.txt index f4a841de6c15..f0a24de73b27 100644 --- a/mlir/include/mlir/Dialect/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/CMakeLists.txt @@ -3,9 +3,9 @@ add_subdirectory(AVX512) add_subdirectory(GPU) add_subdirectory(Linalg) add_subdirectory(LLVMIR) -add_subdirectory(LoopOps) add_subdirectory(OpenMP) add_subdirectory(Quant) +add_subdirectory(SCF) add_subdirectory(Shape) add_subdirectory(SPIRV) add_subdirectory(StandardOps) diff --git a/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h b/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h index 6bbcafb91925..92c2f279b5d9 100644 --- a/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h +++ b/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h @@ -29,7 +29,7 @@ class Region; #include "mlir/Dialect/GPU/ParallelLoopMapperAttr.h.inc" -namespace loop { +namespace scf { class ParallelOp; } @@ -54,7 +54,7 @@ ParallelLoopDimMapping getParallelLoopDimMappingAttr(Processor processor, /// - the number of DimMapperAttr provided is same as the number of loops of /// the `ploopOp`. /// - the mapping does not map multiple loops to the same processor. -LogicalResult setMappingAttr(loop::ParallelOp ploopOp, +LogicalResult setMappingAttr(scf::ParallelOp ploopOp, ArrayRef mapping); } // end namespace gpu diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h index 5180c58b6498..696e7c16b720 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h @@ -26,9 +26,9 @@ class AffineForOp; class BlockArgument; class SubViewOp; -namespace loop { +namespace scf { class ParallelOp; -} // namespace loop +} // namespace scf namespace edsc { class AffineLoopNestBuilder; @@ -85,7 +85,7 @@ private: typename std::conditional_t::value, AffineLoopNestBuilder, LoopNestRangeBuilder>; using BuilderType = - typename std::conditional_t::value, + typename std::conditional_t::value, ParallelLoopNestBuilder, LoopOrAffineLoopBuilder>; diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h index 1a5b6d888c0c..9caec484659e 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -10,7 +10,7 @@ #define MLIR_DIALECT_LINALG_UTILS_H_ #include "mlir/Dialect/Linalg/IR/LinalgOps.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "llvm/ADT/SetVector.h" diff --git a/mlir/include/mlir/Dialect/LoopOps/CMakeLists.txt b/mlir/include/mlir/Dialect/LoopOps/CMakeLists.txt deleted file mode 100644 index 90de6b097a9d..000000000000 --- a/mlir/include/mlir/Dialect/LoopOps/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -add_mlir_dialect(LoopOps loop) -add_mlir_doc(LoopOps -gen-dialect-doc LoopDialect Dialects/) - -set(LLVM_TARGET_DEFINITIONS Passes.td) -mlir_tablegen(Passes.h.inc -gen-pass-decls) -add_public_tablegen_target(MLIRLoopPassIncGen) -add_dependencies(mlir-headers MLIRLoopPassIncGen) - -add_mlir_doc(Passes -gen-pass-doc LoopPasses ./) diff --git a/mlir/include/mlir/Dialect/SCF/CMakeLists.txt b/mlir/include/mlir/Dialect/SCF/CMakeLists.txt new file mode 100644 index 000000000000..b8c533ce7b98 --- /dev/null +++ b/mlir/include/mlir/Dialect/SCF/CMakeLists.txt @@ -0,0 +1,9 @@ +add_mlir_dialect(SCFOps loop Ops) +add_mlir_doc(SCFOps -gen-dialect-doc SCFDialect Dialects/) + +set(LLVM_TARGET_DEFINITIONS Passes.td) +mlir_tablegen(Passes.h.inc -gen-pass-decls) +add_public_tablegen_target(MLIRSCFPassIncGen) +add_dependencies(mlir-headers MLIRSCFPassIncGen) + +add_mlir_doc(Passes -gen-pass-doc SCFPasses ./) diff --git a/mlir/include/mlir/Dialect/LoopOps/EDSC/Builders.h b/mlir/include/mlir/Dialect/SCF/EDSC/Builders.h similarity index 89% rename from mlir/include/mlir/Dialect/LoopOps/EDSC/Builders.h rename to mlir/include/mlir/Dialect/SCF/EDSC/Builders.h index 3d884869d293..0bfc8b9f64e4 100644 --- a/mlir/include/mlir/Dialect/LoopOps/EDSC/Builders.h +++ b/mlir/include/mlir/Dialect/SCF/EDSC/Builders.h @@ -11,10 +11,10 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_LOOPOPS_EDSC_BUILDERS_H_ -#define MLIR_DIALECT_LOOPOPS_EDSC_BUILDERS_H_ +#ifndef MLIR_DIALECT_SCF_EDSC_BUILDERS_H_ +#define MLIR_DIALECT_SCF_EDSC_BUILDERS_H_ -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/EDSC/Builders.h" #include "mlir/IR/Builders.h" #include "mlir/IR/Types.h" @@ -22,13 +22,13 @@ namespace mlir { namespace edsc { -/// Constructs a new loop::ParallelOp and captures the associated induction +/// Constructs a new scf::ParallelOp and captures the associated induction /// variables. An array of Value pointers is passed as the first /// argument and is the *only* way to capture loop induction variables. LoopBuilder makeParallelLoopBuilder(MutableArrayRef ivs, ArrayRef lbs, ArrayRef ubs, ArrayRef steps); -/// Constructs a new loop::ForOp and captures the associated induction +/// Constructs a new scf::ForOp and captures the associated induction /// variable. A Value pointer is passed as the first argument and is the /// *only* way to capture the loop induction variable. LoopBuilder makeLoopBuilder(Value *iv, Value lb, Value ub, Value step, @@ -74,4 +74,4 @@ private: } // namespace edsc } // namespace mlir -#endif // MLIR_DIALECT_LOOPOPS_EDSC_BUILDERS_H_ +#endif // MLIR_DIALECT_SCF_EDSC_BUILDERS_H_ diff --git a/mlir/include/mlir/Dialect/LoopOps/EDSC/Intrinsics.h b/mlir/include/mlir/Dialect/SCF/EDSC/Intrinsics.h similarity index 58% rename from mlir/include/mlir/Dialect/LoopOps/EDSC/Intrinsics.h rename to mlir/include/mlir/Dialect/SCF/EDSC/Intrinsics.h index 1a1b3a0010b2..fcc2971963c6 100644 --- a/mlir/include/mlir/Dialect/LoopOps/EDSC/Intrinsics.h +++ b/mlir/include/mlir/Dialect/SCF/EDSC/Intrinsics.h @@ -1,4 +1,4 @@ -//===- Intrinsics.h - MLIR EDSC Intrinsics for Linalg -----------*- C++ -*-===// +//===- Intrinsics.h - MLIR EDSC Intrinsics for SCF --------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM // Exceptions. @@ -6,19 +6,19 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_LOOPOPS_EDSC_INTRINSICS_H_ -#define MLIR_DIALECT_LOOPOPS_EDSC_INTRINSICS_H_ +#ifndef MLIR_DIALECT_SCF_EDSC_INTRINSICS_H_ +#define MLIR_DIALECT_SCF_EDSC_INTRINSICS_H_ -#include "mlir/Dialect/LoopOps/EDSC/Builders.h" +#include "mlir/Dialect/SCF/EDSC/Builders.h" namespace mlir { namespace edsc { namespace intrinsics { -using loop_yield = OperationBuilder; +using loop_yield = OperationBuilder; } // namespace intrinsics } // namespace edsc } // namespace mlir -#endif // MLIR_DIALECT_LOOPOPS_EDSC_INTRINSICS_H_ +#endif // MLIR_DIALECT_SCF_EDSC_INTRINSICS_H_ diff --git a/mlir/include/mlir/Dialect/LoopOps/Passes.h b/mlir/include/mlir/Dialect/SCF/Passes.h similarity index 89% rename from mlir/include/mlir/Dialect/LoopOps/Passes.h rename to mlir/include/mlir/Dialect/SCF/Passes.h index 54c0fb480b41..e88297f07cf2 100644 --- a/mlir/include/mlir/Dialect/LoopOps/Passes.h +++ b/mlir/include/mlir/Dialect/SCF/Passes.h @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_LOOPOPS_PASSES_H_ -#define MLIR_DIALECT_LOOPOPS_PASSES_H_ +#ifndef MLIR_DIALECT_SCF_PASSES_H_ +#define MLIR_DIALECT_SCF_PASSES_H_ #include "llvm/ADT/ArrayRef.h" #include @@ -33,4 +33,4 @@ createParallelLoopTilingPass(llvm::ArrayRef tileSize = {}); } // namespace mlir -#endif // MLIR_DIALECT_LOOPOPS_PASSES_H_ +#endif // MLIR_DIALECT_SCF_PASSES_H_ diff --git a/mlir/include/mlir/Dialect/LoopOps/Passes.td b/mlir/include/mlir/Dialect/SCF/Passes.td similarity index 92% rename from mlir/include/mlir/Dialect/LoopOps/Passes.td rename to mlir/include/mlir/Dialect/SCF/Passes.td index 41001381ab94..5e6c8c1dd46f 100644 --- a/mlir/include/mlir/Dialect/LoopOps/Passes.td +++ b/mlir/include/mlir/Dialect/SCF/Passes.td @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_LOOP_PASSES -#define MLIR_DIALECT_LOOP_PASSES +#ifndef MLIR_DIALECT_SCF_PASSES +#define MLIR_DIALECT_SCF_PASSES include "mlir/Pass/PassBase.td" @@ -32,4 +32,4 @@ def LoopParallelLoopTiling : FunctionPass<"parallel-loop-tiling"> { ]; } -#endif // MLIR_DIALECT_LOOP_PASSES +#endif // MLIR_DIALECT_SCF_PASSES diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h b/mlir/include/mlir/Dialect/SCF/SCF.h similarity index 79% rename from mlir/include/mlir/Dialect/LoopOps/LoopOps.h rename to mlir/include/mlir/Dialect/SCF/SCF.h index 4b6464647454..142df41d7ad6 100644 --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h +++ b/mlir/include/mlir/Dialect/SCF/SCF.h @@ -1,4 +1,4 @@ -//===- Ops.h - Loop MLIR Operations -----------------------------*- C++ -*-===// +//===- SCFOps.h - Structured Control Flow -----------------------*- 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 file defines convenience types for working with loop operations. +// This file defines structured control flow operations. // //===----------------------------------------------------------------------===// -#ifndef MLIR_LOOPOPS_OPS_H_ -#define MLIR_LOOPOPS_OPS_H_ +#ifndef MLIR_DIALECT_SCF_H_ +#define MLIR_DIALECT_SCF_H_ #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" @@ -22,12 +22,12 @@ #include "mlir/Interfaces/SideEffects.h" namespace mlir { -namespace loop { +namespace scf { -#include "mlir/Dialect/LoopOps/LoopOpsDialect.h.inc" +#include "mlir/Dialect/SCF/SCFOpsDialect.h.inc" #define GET_OP_CLASSES -#include "mlir/Dialect/LoopOps/LoopOps.h.inc" +#include "mlir/Dialect/SCF/SCFOps.h.inc" // Insert `loop.terminator` at the end of the only region's only block if it // does not have a terminator already. If a new `loop.terminator` is inserted, @@ -43,6 +43,6 @@ ForOp getForInductionVarOwner(Value val); // value is not an induction variable, then return nullptr. ParallelOp getParallelForInductionVarOwner(Value val); -} // end namespace loop +} // end namespace scf } // end namespace mlir -#endif // MLIR_LOOPOPS_OPS_H_ +#endif // MLIR_DIALECT_SCF_H_ diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td b/mlir/include/mlir/Dialect/SCF/SCFOps.td similarity index 95% rename from mlir/include/mlir/Dialect/LoopOps/LoopOps.td rename to mlir/include/mlir/Dialect/SCF/SCFOps.td index f0005f6ee5d1..fb94f42aab36 100644 --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td +++ b/mlir/include/mlir/Dialect/SCF/SCFOps.td @@ -1,4 +1,4 @@ -//===- Ops.td - Loop operation definitions ---------------*- tablegen -*-===// +//===- SCFOps.td - Structured Control Flow operations ------*- 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,25 +6,25 @@ // //===----------------------------------------------------------------------===// // -// Defines MLIR loop operations. +// Defines MLIR structured control flow operations. // //===----------------------------------------------------------------------===// -#ifndef LOOP_OPS -#define LOOP_OPS +#ifndef MLIR_DIALECT_SCF_SCFOPS +#define MLIR_DIALECT_SCF_SCFOPS include "mlir/Interfaces/ControlFlowInterfaces.td" include "mlir/Interfaces/LoopLikeInterface.td" include "mlir/Interfaces/SideEffects.td" -def LoopOps_Dialect : Dialect { +def SCF_Dialect : Dialect { let name = "loop"; let cppNamespace = ""; } -// Base class for Loop dialect ops. -class Loop_Op traits = []> : - Op { +// Base class for SCF dialect ops. +class SCF_Op traits = []> : + Op { // For every standard op, there needs to be a: // * void print(OpAsmPrinter &p, ${C++ class of Op} op) // * LogicalResult verify(${C++ class of Op} op) @@ -36,7 +36,7 @@ class Loop_Op traits = []> : let parser = [{ return ::parse$cppClass(parser, result); }]; } -def ForOp : Loop_Op<"for", +def ForOp : SCF_Op<"for", [DeclareOpInterfaceMethods, DeclareOpInterfaceMethods, SingleBlockImplicitTerminator<"YieldOp">, @@ -176,7 +176,7 @@ def ForOp : Loop_Op<"for", }]; } -def IfOp : Loop_Op<"if", +def IfOp : SCF_Op<"if", [DeclareOpInterfaceMethods, SingleBlockImplicitTerminator<"YieldOp">, RecursiveSideEffects]> { let summary = "if-then-else operation"; @@ -250,7 +250,7 @@ def IfOp : Loop_Op<"if", }]; } -def ParallelOp : Loop_Op<"parallel", +def ParallelOp : SCF_Op<"parallel", [AttrSizedOperandSegments, DeclareOpInterfaceMethods, RecursiveSideEffects, @@ -324,7 +324,7 @@ def ParallelOp : Loop_Op<"parallel", }]; } -def ReduceOp : Loop_Op<"reduce", [HasParent<"ParallelOp">]> { +def ReduceOp : SCF_Op<"reduce", [HasParent<"ParallelOp">]> { let summary = "reduce operation for parallel for"; let description = [{ "loop.reduce" is an operation occurring inside "loop.parallel" operations. @@ -372,7 +372,7 @@ def ReduceOp : Loop_Op<"reduce", [HasParent<"ParallelOp">]> { } def ReduceReturnOp : - Loop_Op<"reduce.return", [HasParent<"ReduceOp">, NoSideEffect, + SCF_Op<"reduce.return", [HasParent<"ReduceOp">, NoSideEffect, Terminator]> { let summary = "terminator for reduce operation"; let description = [{ @@ -389,7 +389,7 @@ def ReduceReturnOp : let assemblyFormat = "$result attr-dict `:` type($result)"; } -def YieldOp : Loop_Op<"yield", [NoSideEffect, ReturnLike, Terminator]> { +def YieldOp : SCF_Op<"yield", [NoSideEffect, ReturnLike, Terminator]> { let summary = "loop yield and termination operation"; let description = [{ "loop.yield" yields an SSA value from a loop dialect op region and @@ -409,4 +409,4 @@ def YieldOp : Loop_Op<"yield", [NoSideEffect, ReturnLike, Terminator]> { [{ /* nothing to do */ }]> ]; } -#endif // LOOP_OPS +#endif // MLIR_DIALECT_SCF_SCFOPS diff --git a/mlir/include/mlir/Dialect/LoopOps/Transforms.h b/mlir/include/mlir/Dialect/SCF/Transforms.h similarity index 82% rename from mlir/include/mlir/Dialect/LoopOps/Transforms.h rename to mlir/include/mlir/Dialect/SCF/Transforms.h index 4a8c96e0d916..a3e1c0b03749 100644 --- a/mlir/include/mlir/Dialect/LoopOps/Transforms.h +++ b/mlir/include/mlir/Dialect/SCF/Transforms.h @@ -1,4 +1,4 @@ -//===- Transforms.h - Pass Entrypoints --------------------------*- C++ -*-===// +//===- Transforms.h - SCF dialect transformation utilities ------*- 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 header file defines transformations on loop operations. +// This header file defines transformations on SCF operations. // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_LOOPOPS_TRANSFORMS_H_ -#define MLIR_DIALECT_LOOPOPS_TRANSFORMS_H_ +#ifndef MLIR_DIALECT_SCF_TRANSFORMS_H_ +#define MLIR_DIALECT_SCF_TRANSFORMS_H_ #include "llvm/ADT/ArrayRef.h" @@ -19,7 +19,7 @@ namespace mlir { class Region; -namespace loop { +namespace scf { class ParallelOp; @@ -42,7 +42,7 @@ void naivelyFuseParallelOps(Region ®ion); /// The old loop is replaced with the new one. void tileParallelLoop(ParallelOp op, llvm::ArrayRef tileSizes); -} // namespace loop +} // namespace scf } // namespace mlir -#endif // MLIR_DIALECT_LOOPOPS_TRANSFORMS_H_ +#endif // MLIR_DIALECT_SCF_TRANSFORMS_H_ diff --git a/mlir/include/mlir/InitAllDialects.h b/mlir/include/mlir/InitAllDialects.h index 1d6fc549a17c..4a43cd2a27ba 100644 --- a/mlir/include/mlir/InitAllDialects.h +++ b/mlir/include/mlir/InitAllDialects.h @@ -22,9 +22,9 @@ #include "mlir/Dialect/LLVMIR/NVVMDialect.h" #include "mlir/Dialect/LLVMIR/ROCDLDialect.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/OpenMP/OpenMPDialect.h" #include "mlir/Dialect/Quant/QuantOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SDBM/SDBMDialect.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/Shape/IR/Shape.h" @@ -44,7 +44,7 @@ inline void registerAllDialects() { registerDialect(); registerDialect(); registerDialect(); - registerDialect(); + registerDialect(); registerDialect(); registerDialect(); registerDialect(); diff --git a/mlir/include/mlir/InitAllPasses.h b/mlir/include/mlir/InitAllPasses.h index 1acfc9905384..ef8fc8ceddd6 100644 --- a/mlir/include/mlir/InitAllPasses.h +++ b/mlir/include/mlir/InitAllPasses.h @@ -31,8 +31,8 @@ #include "mlir/Dialect/GPU/Passes.h" #include "mlir/Dialect/LLVMIR/Transforms/LegalizeForExport.h" #include "mlir/Dialect/Linalg/Passes.h" -#include "mlir/Dialect/LoopOps/Passes.h" #include "mlir/Dialect/Quant/Passes.h" +#include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SPIRV/Passes.h" #include "mlir/Dialect/StandardOps/Transforms/Passes.h" #include "mlir/Transforms/LocationSnapshot.h" @@ -78,7 +78,7 @@ inline void registerAllPasses() { // Loop #define GEN_PASS_REGISTRATION -#include "mlir/Dialect/LoopOps/Passes.h.inc" +#include "mlir/Dialect/SCF/Passes.h.inc" // Quant #define GEN_PASS_REGISTRATION diff --git a/mlir/include/mlir/Transforms/LoopUtils.h b/mlir/include/mlir/Transforms/LoopUtils.h index 7a07b6db23fc..9a3a3c7f6ba2 100644 --- a/mlir/include/mlir/Transforms/LoopUtils.h +++ b/mlir/include/mlir/Transforms/LoopUtils.h @@ -27,10 +27,10 @@ class Value; class ValueRange; struct MemRefRegion; -namespace loop { +namespace scf { class ForOp; class ParallelOp; -} // end namespace loop +} // end namespace scf /// Unrolls this for operation completely if the trip count is known to be /// constant. Returns failure otherwise. @@ -40,7 +40,7 @@ LogicalResult loopUnrollFull(AffineForOp forOp); /// if the loop cannot be unrolled either due to restrictions or due to invalid /// unroll factors. Requires positive loop bounds and step. LogicalResult loopUnrollByFactor(AffineForOp forOp, uint64_t unrollFactor); -LogicalResult loopUnrollByFactor(loop::ForOp forOp, uint64_t unrollFactor); +LogicalResult loopUnrollByFactor(scf::ForOp forOp, uint64_t unrollFactor); /// Unrolls this loop by the specified unroll factor or its trip count, /// whichever is lower. @@ -56,8 +56,8 @@ bool LLVM_ATTRIBUTE_UNUSED isPerfectlyNested(ArrayRef loops); /// AffineForOp, and the second op is a terminator). void getPerfectlyNestedLoops(SmallVectorImpl &nestedLoops, AffineForOp root); -void getPerfectlyNestedLoops(SmallVectorImpl &nestedLoops, - loop::ForOp root); +void getPerfectlyNestedLoops(SmallVectorImpl &nestedLoops, + scf::ForOp root); /// Unrolls and jams this loop by the specified factor. Returns success if the /// loop is successfully unroll-jammed. @@ -69,10 +69,10 @@ LogicalResult loopUnrollJamByFactor(AffineForOp forOp, LogicalResult loopUnrollJamUpToFactor(AffineForOp forOp, uint64_t unrollJamFactor); -/// Promotes the loop body of a AffineForOp/loop::ForOp to its containing block +/// Promotes the loop body of a AffineForOp/scf::ForOp to its containing block /// if the loop was known to have a single iteration. LogicalResult promoteIfSingleIteration(AffineForOp forOp); -LogicalResult promoteIfSingleIteration(loop::ForOp forOp); +LogicalResult promoteIfSingleIteration(scf::ForOp forOp); /// Promotes all single iteration AffineForOp's in the Function, i.e., moves /// their body into the containing Block. @@ -128,13 +128,13 @@ AffineForOp sinkSequentialLoops(AffineForOp forOp); /// occurrence in `forOps`, under each of the `targets`. /// Returns the new AffineForOps, one per each of (`forOps`, `targets`) pair, /// nested immediately under each of `targets`. -using Loops = SmallVector; +using Loops = SmallVector; using TileLoops = std::pair; SmallVector, 8> tile(ArrayRef forOps, ArrayRef sizes, ArrayRef targets); -SmallVector tile(ArrayRef forOps, ArrayRef sizes, - ArrayRef targets); +SmallVector tile(ArrayRef forOps, ArrayRef sizes, + ArrayRef targets); /// Performs tiling (with interchange) by strip-mining the `forOps` by `sizes` /// and sinking them, in their order of occurrence in `forOps`, under `target`. @@ -142,15 +142,15 @@ SmallVector tile(ArrayRef forOps, ArrayRef sizes, /// `target`. SmallVector tile(ArrayRef forOps, ArrayRef sizes, AffineForOp target); -Loops tile(ArrayRef forOps, ArrayRef sizes, - loop::ForOp target); +Loops tile(ArrayRef forOps, ArrayRef sizes, + scf::ForOp target); -/// Tile a nest of loop::ForOp loops rooted at `rootForOp` with the given +/// Tile a nest of scf::ForOp loops rooted at `rootForOp` with the given /// (parametric) sizes. Sizes are expected to be strictly positive values at /// runtime. If more sizes than loops are provided, discard the trailing values /// in sizes. Assumes the loop nest is permutable. /// Returns the newly created intra-tile loops. -Loops tilePerfectlyNested(loop::ForOp rootForOp, ArrayRef sizes); +Loops tilePerfectlyNested(scf::ForOp rootForOp, ArrayRef sizes); /// Explicit copy / DMA generation options for mlir::affineDataCopyGenerate. struct AffineCopyOptions { @@ -220,18 +220,17 @@ LogicalResult generateCopyForMemRegion(const MemRefRegion &memrefRegion, /// Tile a nest of standard for loops rooted at `rootForOp` by finding such /// parametric tile sizes that the outer loops have a fixed number of iterations /// as defined in `sizes`. -TileLoops extractFixedOuterLoops(loop::ForOp rootFOrOp, - ArrayRef sizes); +TileLoops extractFixedOuterLoops(scf::ForOp rootFOrOp, ArrayRef sizes); /// Replace a perfect nest of "for" loops with a single linearized loop. Assumes /// `loops` contains a list of perfectly nested loops with bounds and steps /// independent of any loop induction variable involved in the nest. -void coalesceLoops(MutableArrayRef loops); +void coalesceLoops(MutableArrayRef loops); /// Take the ParallelLoop and for each set of dimension indices, combine them /// into a single dimension. combinedDimensions must contain each index into /// loops exactly once. -void collapseParallelLoops(loop::ParallelOp loops, +void collapseParallelLoops(scf::ParallelOp loops, ArrayRef> combinedDimensions); /// Maps `forOp` for execution on a parallel grid of virtual `processorIds` of @@ -265,7 +264,7 @@ void collapseParallelLoops(loop::ParallelOp loops, /// ... /// } /// ``` -void mapLoopToProcessorIds(loop::ForOp forOp, ArrayRef processorId, +void mapLoopToProcessorIds(scf::ForOp forOp, ArrayRef processorId, ArrayRef numProcessors); /// Gathers all AffineForOps in 'func' grouped by loop depth. diff --git a/mlir/lib/Analysis/CMakeLists.txt b/mlir/lib/Analysis/CMakeLists.txt index 63ddcdaee3d3..a008bcd02468 100644 --- a/mlir/lib/Analysis/CMakeLists.txt +++ b/mlir/lib/Analysis/CMakeLists.txt @@ -22,7 +22,7 @@ add_mlir_library(MLIRAnalysis MLIRCallInterfaces MLIRControlFlowInterfaces MLIRInferTypeOpInterface - MLIRLoopOps + MLIRSCF ) add_mlir_library(MLIRLoopAnalysis @@ -40,5 +40,5 @@ add_mlir_library(MLIRLoopAnalysis MLIRCallInterfaces MLIRControlFlowInterfaces MLIRInferTypeOpInterface - MLIRLoopOps + MLIRSCF ) diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp index 876bacee70a8..5b630be5e9a5 100644 --- a/mlir/lib/Analysis/SliceAnalysis.cpp +++ b/mlir/lib/Analysis/SliceAnalysis.cpp @@ -12,7 +12,7 @@ #include "mlir/Analysis/SliceAnalysis.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/IR/Function.h" #include "mlir/IR/Operation.h" #include "mlir/Support/LLVM.h" @@ -44,7 +44,7 @@ static void getForwardSliceImpl(Operation *op, for (auto *ownerInst : forOp.getInductionVar().getUsers()) if (forwardSlice->count(ownerInst) == 0) getForwardSliceImpl(ownerInst, forwardSlice, filter); - } else if (auto forOp = dyn_cast(op)) { + } else if (auto forOp = dyn_cast(op)) { for (auto *ownerInst : forOp.getInductionVar().getUsers()) if (forwardSlice->count(ownerInst) == 0) getForwardSliceImpl(ownerInst, forwardSlice, filter); @@ -82,7 +82,7 @@ static void getBackwardSliceImpl(Operation *op, return; assert((op->getNumRegions() == 0 || isa(op) || - isa(op)) && + isa(op)) && "unexpected generic op with regions"); // Evaluate whether we should keep this def. @@ -99,7 +99,7 @@ static void getBackwardSliceImpl(Operation *op, auto *affOp = affIv.getOperation(); if (backwardSlice->count(affOp) == 0) getBackwardSliceImpl(affOp, backwardSlice, filter); - } else if (auto loopIv = loop::getForInductionVarOwner(operand)) { + } else if (auto loopIv = scf::getForInductionVarOwner(operand)) { auto *loopOp = loopIv.getOperation(); if (backwardSlice->count(loopOp) == 0) getBackwardSliceImpl(loopOp, backwardSlice, filter); diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp index 2fb99461647e..862d76c32cc4 100644 --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -15,7 +15,7 @@ #include "../PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/BlockAndValueMapping.h" @@ -332,7 +332,7 @@ public: LogicalResult matchAndRewrite(AffineTerminatorOp op, PatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(op); + rewriter.replaceOpWithNewOp(op); return success(); } }; @@ -347,7 +347,7 @@ public: Value lowerBound = lowerAffineLowerBound(op, rewriter); Value upperBound = lowerAffineUpperBound(op, rewriter); Value step = rewriter.create(loc, op.getStep()); - auto f = rewriter.create(loc, lowerBound, upperBound, step); + auto f = rewriter.create(loc, lowerBound, upperBound, step); f.region().getBlocks().clear(); rewriter.inlineRegionBefore(op.region(), f.region(), f.region().end()); rewriter.eraseOp(op); @@ -392,7 +392,7 @@ public: : rewriter.create(loc, /*value=*/1, /*width=*/1); bool hasElseRegion = !op.elseRegion().empty(); - auto ifOp = rewriter.create(loc, cond, hasElseRegion); + auto ifOp = rewriter.create(loc, cond, hasElseRegion); rewriter.inlineRegionBefore(op.thenRegion(), &ifOp.thenRegion().back()); ifOp.thenRegion().back().erase(); if (hasElseRegion) { @@ -582,7 +582,7 @@ class LowerAffinePass : public ConvertAffineToStandardBase { OwningRewritePatternList patterns; populateAffineToStdConversionPatterns(patterns, &getContext()); ConversionTarget target(getContext()); - target.addLegalDialect(); + target.addLegalDialect(); if (failed(applyPartialConversion(getFunction(), target, patterns))) signalPassFailure(); } diff --git a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt index 6b54324aa0d3..47a371fcea87 100644 --- a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt @@ -12,7 +12,7 @@ add_mlir_conversion_library(MLIRAffineToStandard LINK_LIBS PUBLIC MLIRAffineOps - MLIRLoopOps + MLIRSCF MLIRPass MLIRStandardOps MLIRTransforms diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp index 14f6474f95df..cae7239398f4 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h" #include "mlir/Dialect/GPU/GPUDialect.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVLowering.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" @@ -21,34 +21,34 @@ using namespace mlir; namespace { -/// Pattern to convert a loop::ForOp within kernel functions into spirv::LoopOp. -class ForOpConversion final : public SPIRVOpLowering { +/// Pattern to convert a scf::ForOp within kernel functions into spirv::LoopOp. +class ForOpConversion final : public SPIRVOpLowering { public: - using SPIRVOpLowering::SPIRVOpLowering; + using SPIRVOpLowering::SPIRVOpLowering; LogicalResult - matchAndRewrite(loop::ForOp forOp, ArrayRef operands, + matchAndRewrite(scf::ForOp forOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; -/// Pattern to convert a loop::IfOp within kernel functions into +/// Pattern to convert a scf::IfOp within kernel functions into /// spirv::SelectionOp. -class IfOpConversion final : public SPIRVOpLowering { +class IfOpConversion final : public SPIRVOpLowering { public: - using SPIRVOpLowering::SPIRVOpLowering; + using SPIRVOpLowering::SPIRVOpLowering; LogicalResult - matchAndRewrite(loop::IfOp IfOp, ArrayRef operands, + matchAndRewrite(scf::IfOp IfOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; -/// Pattern to erase a loop::YieldOp. -class TerminatorOpConversion final : public SPIRVOpLowering { +/// Pattern to erase a scf::YieldOp. +class TerminatorOpConversion final : public SPIRVOpLowering { public: - using SPIRVOpLowering::SPIRVOpLowering; + using SPIRVOpLowering::SPIRVOpLowering; LogicalResult - matchAndRewrite(loop::YieldOp terminatorOp, ArrayRef operands, + matchAndRewrite(scf::YieldOp terminatorOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { rewriter.eraseOp(terminatorOp); return success(); @@ -117,18 +117,18 @@ public: } // namespace //===----------------------------------------------------------------------===// -// loop::ForOp. +// scf::ForOp. //===----------------------------------------------------------------------===// LogicalResult -ForOpConversion::matchAndRewrite(loop::ForOp forOp, ArrayRef operands, +ForOpConversion::matchAndRewrite(scf::ForOp forOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { - // loop::ForOp can be lowered to the structured control flow represented by + // scf::ForOp can be lowered to the structured control flow represented by // spirv::LoopOp by making the continue block of the spirv::LoopOp the loop // latch and the merge block the exit block. The resulting spirv::LoopOp has a // single back edge from the continue to header block, and a single exit from // header to merge. - loop::ForOpOperandAdaptor forOperands(operands); + scf::ForOpOperandAdaptor forOperands(operands); auto loc = forOp.getLoc(); auto loopControl = rewriter.getI32IntegerAttr( static_cast(spirv::LoopControl::None)); @@ -190,16 +190,16 @@ ForOpConversion::matchAndRewrite(loop::ForOp forOp, ArrayRef operands, } //===----------------------------------------------------------------------===// -// loop::IfOp. +// scf::IfOp. //===----------------------------------------------------------------------===// LogicalResult -IfOpConversion::matchAndRewrite(loop::IfOp ifOp, ArrayRef operands, +IfOpConversion::matchAndRewrite(scf::IfOp ifOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { - // When lowering `loop::IfOp` we explicitly create a selection header block + // When lowering `scf::IfOp` we explicitly create a selection header block // before the control flow diverges and a merge block where control flow // subsequently converges. - loop::IfOpOperandAdaptor ifOperands(operands); + scf::IfOpOperandAdaptor ifOperands(operands); auto loc = ifOp.getLoc(); // Create `spv.selection` operation, selection header block and merge block. diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp index 687a32a98054..3147eede8819 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp @@ -16,7 +16,7 @@ #include "mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h" #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h" #include "mlir/Dialect/GPU/GPUDialect.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVLowering.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" diff --git a/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt b/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt index cf749b81b0fb..89d8cb9813d8 100644 --- a/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt @@ -11,6 +11,6 @@ add_mlir_conversion_library(MLIRLoopToStandard Core LINK_LIBS PUBLIC - MLIRLoopOps + MLIRSCF MLIRTransforms ) diff --git a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp b/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp index fbcad36c7bd5..9a3c3ba7e175 100644 --- a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp +++ b/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp @@ -13,7 +13,7 @@ #include "../PassDetail.h" #include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" @@ -25,7 +25,7 @@ #include "mlir/Transforms/Utils.h" using namespace mlir; -using namespace mlir::loop; +using namespace mlir::scf; namespace { @@ -195,10 +195,10 @@ struct IfLowering : public OpRewritePattern { PatternRewriter &rewriter) const override; }; -struct ParallelLowering : public OpRewritePattern { - using OpRewritePattern::OpRewritePattern; +struct ParallelLowering : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; - LogicalResult matchAndRewrite(mlir::loop::ParallelOp parallelOp, + LogicalResult matchAndRewrite(mlir::scf::ParallelOp parallelOp, PatternRewriter &rewriter) const override; }; } // namespace diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp index c789c90e4b9f..b52c264d8bab 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp @@ -18,7 +18,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/GPU/ParallelLoopMapper.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/BlockAndValueMapping.h" @@ -34,7 +34,7 @@ #define DEBUG_TYPE "loops-to-gpu" using namespace mlir; -using namespace mlir::loop; +using namespace mlir::scf; using llvm::seq; @@ -486,7 +486,7 @@ LogicalResult mlir::convertLoopNestToGPULaunch(ForOp forOp, return ::convertLoopNestToGPULaunch(forOp, numBlockDims, numThreadDims); } -LogicalResult mlir::convertLoopToGPULaunch(loop::ForOp forOp, +LogicalResult mlir::convertLoopToGPULaunch(scf::ForOp forOp, ArrayRef numWorkGroups, ArrayRef workGroupSizes) { return ::convertLoopToGPULaunch(forOp, numWorkGroups, workGroupSizes); @@ -704,7 +704,7 @@ static LogicalResult processParallelLoop( CmpIOp pred = rewriter.create( loc, CmpIPredicate::slt, newIndex, cloningMap.lookupOrDefault(originalBound)); - loop::IfOp ifOp = rewriter.create(loc, pred, false); + scf::IfOp ifOp = rewriter.create(loc, pred, false); rewriter.setInsertionPointToStart(&ifOp.thenRegion().front()); // Put a sentinel into the worklist so we know when to pop out of the // if body again. We use the launchOp here, as that cannot be part of @@ -714,7 +714,7 @@ static LogicalResult processParallelLoop( } } else { // Create a sequential for loop. - auto loopOp = rewriter.create( + auto loopOp = rewriter.create( loc, cloningMap.lookupOrDefault(lowerBound), cloningMap.lookupOrDefault(upperBound), cloningMap.lookupOrDefault(step)); diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp index 94c6a3b20f2b..71aefe72783b 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -11,7 +11,7 @@ #include "mlir/Conversion/LoopsToGPU/LoopsToGPU.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/DialectConversion.h" @@ -22,7 +22,7 @@ #define LOOPOP_TO_GPU_PASS_NAME "convert-loop-op-to-gpu" using namespace mlir; -using namespace mlir::loop; +using namespace mlir::scf; namespace { // A pass that traverses top-level loops in the function and converts them to @@ -98,8 +98,8 @@ struct ParallelLoopToGpuPass target.addLegalDialect(); target.addLegalDialect(); target.addLegalDialect(); - target.addLegalDialect(); - target.addIllegalOp(); + target.addLegalDialect(); + target.addIllegalOp(); if (failed(applyPartialConversion(getOperation(), target, patterns))) signalPassFailure(); } diff --git a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp b/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp index 5cb781b02b2a..dc929a2e6747 100644 --- a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp +++ b/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp @@ -14,8 +14,8 @@ #include "mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h" #include "mlir/Dialect/Affine/EDSC/Intrinsics.h" -#include "mlir/Dialect/LoopOps/EDSC/Builders.h" -#include "mlir/Dialect/LoopOps/EDSC/Intrinsics.h" +#include "mlir/Dialect/SCF/EDSC/Builders.h" +#include "mlir/Dialect/SCF/EDSC/Intrinsics.h" #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/Dialect/Vector/EDSC/Intrinsics.h" #include "mlir/Dialect/Vector/VectorOps.h" @@ -168,7 +168,7 @@ void NDTransferOpHelper::emitInBounds( inBounds = inBounds && inBounds2; } - auto ifOp = ScopedContext::getBuilderRef().create( + auto ifOp = ScopedContext::getBuilderRef().create( ScopedContext::getLocation(), TypeRange{}, inBounds, /*withElseRegion=*/std::is_same()); BlockBuilder(&ifOp.thenRegion().front(), diff --git a/mlir/lib/Dialect/CMakeLists.txt b/mlir/lib/Dialect/CMakeLists.txt index e9196f224ae0..b309454c504e 100644 --- a/mlir/lib/Dialect/CMakeLists.txt +++ b/mlir/lib/Dialect/CMakeLists.txt @@ -3,9 +3,9 @@ add_subdirectory(AVX512) add_subdirectory(GPU) add_subdirectory(Linalg) add_subdirectory(LLVMIR) -add_subdirectory(LoopOps) add_subdirectory(OpenMP) add_subdirectory(Quant) +add_subdirectory(SCF) add_subdirectory(SDBM) add_subdirectory(Shape) add_subdirectory(SPIRV) diff --git a/mlir/lib/Dialect/GPU/CMakeLists.txt b/mlir/lib/Dialect/GPU/CMakeLists.txt index 01863d4a3d56..6c9ed1aba13a 100644 --- a/mlir/lib/Dialect/GPU/CMakeLists.txt +++ b/mlir/lib/Dialect/GPU/CMakeLists.txt @@ -18,7 +18,7 @@ add_mlir_dialect_library(MLIRGPU MLIREDSC MLIRIR MLIRLLVMIR - MLIRLoopOps + MLIRSCF MLIRPass MLIRSideEffects MLIRStandardOps diff --git a/mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp b/mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp index e9f44d209021..271efbfddb19 100644 --- a/mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp @@ -13,7 +13,7 @@ #include "mlir/Dialect/GPU/MemoryPromotion.h" #include "mlir/Dialect/GPU/GPUDialect.h" -#include "mlir/Dialect/LoopOps/EDSC/Builders.h" +#include "mlir/Dialect/SCF/EDSC/Builders.h" #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" @@ -90,7 +90,7 @@ static void insertCopyLoops(OpBuilder &builder, Location loc, llvm::enumerate(llvm::reverse(llvm::makeArrayRef(ivs).take_back( GPUDialect::getNumWorkgroupDimensions())))) { Value v = en.value(); - auto loop = cast(v.getParentRegion()->getParentOp()); + auto loop = cast(v.getParentRegion()->getParentOp()); mapLoopToProcessorIds(loop, {threadIds[en.index()]}, {blockDims[en.index()]}); } diff --git a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp index 177fdf0d668f..bf079f7efb45 100644 --- a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp @@ -15,13 +15,13 @@ #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/GPU/Passes.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/IR/AffineMap.h" #include "mlir/Pass/Pass.h" using namespace mlir; using namespace mlir::gpu; -using namespace mlir::loop; +using namespace mlir::scf; #include "mlir/Dialect/GPU/ParallelLoopMapperEnums.cpp.inc" namespace mlir { @@ -41,7 +41,7 @@ ParallelLoopDimMapping getParallelLoopDimMappingAttr(Processor processor, AffineMapAttr::get(map), AffineMapAttr::get(bound), context); } -LogicalResult setMappingAttr(loop::ParallelOp ploopOp, +LogicalResult setMappingAttr(scf::ParallelOp ploopOp, ArrayRef mapping) { // Verify that each processor is mapped to only once. llvm::DenseSet specifiedMappings; diff --git a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp index dac139f2baa7..33d2eeb9228b 100644 --- a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp @@ -10,7 +10,7 @@ #include "mlir/Dialect/Affine/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/EDSC/Builders.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" -#include "mlir/Dialect/LoopOps/EDSC/Builders.h" +#include "mlir/Dialect/SCF/EDSC/Builders.h" #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/Dialect/Utils/StructuredOpsUtils.h" #include "mlir/IR/AffineExpr.h" @@ -19,7 +19,7 @@ using namespace mlir; using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using namespace mlir::loop; +using namespace mlir::scf; mlir::edsc::LoopRangeBuilder::LoopRangeBuilder(Value *iv, Value range) { assert(range.getType() && "expected !linalg.range type"); @@ -79,7 +79,7 @@ namespace mlir { namespace edsc { template <> -GenericLoopNestRangeBuilder::GenericLoopNestRangeBuilder( +GenericLoopNestRangeBuilder::GenericLoopNestRangeBuilder( MutableArrayRef ivs, ArrayRef ranges) { builder = std::make_unique(ivs, ranges); } @@ -102,7 +102,7 @@ GenericLoopNestRangeBuilder::GenericLoopNestRangeBuilder( } template <> -GenericLoopNestRangeBuilder::GenericLoopNestRangeBuilder( +GenericLoopNestRangeBuilder::GenericLoopNestRangeBuilder( MutableArrayRef ivs, ArrayRef ranges) { SmallVector lbs, ubs, steps; for (Value range : ranges) { diff --git a/mlir/lib/Dialect/Linalg/EDSC/CMakeLists.txt b/mlir/lib/Dialect/Linalg/EDSC/CMakeLists.txt index b3f3e5c0804f..91fdaa4f18a3 100644 --- a/mlir/lib/Dialect/Linalg/EDSC/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/EDSC/CMakeLists.txt @@ -10,6 +10,6 @@ add_mlir_dialect_library(MLIRLinalgEDSC MLIRAffineOps MLIRAffineEDSC MLIRLinalgOps - MLIRLoopOps + MLIRSCF MLIRStandardOps ) diff --git a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt index dcd28c015271..097fa355a131 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt @@ -23,7 +23,7 @@ add_mlir_dialect_library(MLIRLinalgTransforms MLIRLinalgEDSC MLIRLinalgOps MLIRLinalgUtils - MLIRLoopOps + MLIRSCF MLIRPass MLIRStandardOps MLIRStandardToLLVM diff --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp index c5e7958b84a1..a978143cd834 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp @@ -14,7 +14,7 @@ #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" -#include "mlir/Dialect/LoopOps/EDSC/Builders.h" +#include "mlir/Dialect/SCF/EDSC/Builders.h" #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" @@ -513,7 +513,7 @@ public: /// outer parallel loops. All other loops are generated using loop.for /// operation. template -class GenerateLoopNest { +class GenerateLoopNest { public: using IndexedValueTy = StdIndexedValue; @@ -534,9 +534,9 @@ public: // If there are no outer parallel loops, then number of loop ops is same as // the number of loops, and they are all loop.for ops. if (nOuterPar) { - GenericLoopNestRangeBuilder( + GenericLoopNestRangeBuilder( allIvs.take_front(nOuterPar), loopRanges.take_front(nOuterPar))([&] { - GenericLoopNestRangeBuilder( + GenericLoopNestRangeBuilder( allIvs.drop_front(nOuterPar), loopRanges.drop_front(nOuterPar))([&] { SmallVector allIvValues(allIvs.begin(), allIvs.end()); @@ -547,7 +547,7 @@ public: } else { // If there are no parallel loops then fallback to generating all loop.for // operations. - GenericLoopNestRangeBuilder(allIvs, loopRanges)([&] { + GenericLoopNestRangeBuilder(allIvs, loopRanges)([&] { SmallVector allIvValues(allIvs.begin(), allIvs.end()); LinalgScopedEmitter::emitScalarImplementation(allIvValues, @@ -715,13 +715,13 @@ struct LowerToAffineLoops }; struct LowerToLoops : public LinalgLowerToLoopsBase { void runOnFunction() override { - lowerLinalgToLoopsImpl(getFunction(), &getContext()); + lowerLinalgToLoopsImpl(getFunction(), &getContext()); } }; struct LowerToParallelLoops : public LinalgLowerToParallelLoopsBase { void runOnFunction() override { - lowerLinalgToLoopsImpl(getFunction(), &getContext()); + lowerLinalgToLoopsImpl(getFunction(), &getContext()); } }; } // namespace @@ -751,7 +751,7 @@ Optional mlir::linalg::linalgLowerOpToLoops(OpBuilder &builder, template LogicalResult mlir::linalg::linalgOpToLoops(OpBuilder &builder, Operation *op) { Optional loops = - linalgLowerOpToLoops(builder, op); + linalgLowerOpToLoops(builder, op); return loops ? success() : failure(); } @@ -769,7 +769,7 @@ template LogicalResult mlir::linalg::linalgOpToParallelLoops(OpBuilder &builder, Operation *op) { Optional loops = - linalgLowerOpToLoops(builder, op); + linalgLowerOpToLoops(builder, op); return loops ? success() : failure(); } @@ -783,7 +783,7 @@ LogicalResult mlir::linalg::linalgOpToParallelLoops(OpBuilder &builder, template LogicalResult mlir::linalg::linalgOpToParallelLoops( \ OpBuilder & builder, Operation * op); \ template Optional \ - mlir::linalg::linalgLowerOpToLoops( \ + mlir::linalg::linalgLowerOpToLoops( \ OpBuilder & builder, Operation * op); INSTANTIATE_LINALG_OP_TO_LOOPS(CopyOp) diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp index 5e277b187624..8e93ea355a12 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -18,7 +18,7 @@ #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineExprVisitor.h" @@ -33,7 +33,7 @@ using namespace mlir; using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using namespace mlir::loop; +using namespace mlir::scf; using llvm::SetVector; diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index b6977e01266f..1fdbcdcb94fa 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -17,7 +17,7 @@ #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" -#include "mlir/Dialect/LoopOps/EDSC/Builders.h" +#include "mlir/Dialect/SCF/EDSC/Builders.h" #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineExprVisitor.h" @@ -31,7 +31,7 @@ using namespace mlir; using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using namespace mlir::loop; +using namespace mlir::scf; using folded_affine_min = FoldedValueBuilder; @@ -468,29 +468,29 @@ Optional mlir::linalg::tileLinalgOp(OpBuilder &b, LinalgOp op, ArrayRef tileSizes, ArrayRef interchangeVector, OperationFolder *folder) { - return tileLinalgOpImpl(b, op, tileSizes, interchangeVector, - folder); + return tileLinalgOpImpl(b, op, tileSizes, interchangeVector, + folder); } Optional mlir::linalg::tileLinalgOpToParallelLoops( OpBuilder &b, LinalgOp op, ArrayRef tileSizes, ArrayRef interchangeVector, OperationFolder *folder) { - return tileLinalgOpImpl(b, op, tileSizes, interchangeVector, - folder); + return tileLinalgOpImpl(b, op, tileSizes, interchangeVector, + folder); } Optional mlir::linalg::tileLinalgOp( OpBuilder &b, LinalgOp op, ArrayRef tileSizes, ArrayRef interchangeVector, OperationFolder *folder) { - return tileLinalgOpImpl(b, op, tileSizes, interchangeVector, - folder); + return tileLinalgOpImpl(b, op, tileSizes, interchangeVector, + folder); } Optional mlir::linalg::tileLinalgOpToParallelLoops( OpBuilder &b, LinalgOp op, ArrayRef tileSizes, ArrayRef interchangeVector, OperationFolder *folder) { - return tileLinalgOpImpl(b, op, tileSizes, interchangeVector, - folder); + return tileLinalgOpImpl(b, op, tileSizes, interchangeVector, + folder); } template @@ -518,7 +518,7 @@ struct LinalgTilingPass : public LinalgTilingBase { LinalgTilingPass(ArrayRef sizes) { tileSizes = sizes; } void runOnFunction() override { - tileLinalgOps(getFunction(), tileSizes); + tileLinalgOps(getFunction(), tileSizes); } }; @@ -530,7 +530,7 @@ struct LinalgTilingToParallelLoopsPass } void runOnFunction() override { - tileLinalgOps(getFunction(), tileSizes); + tileLinalgOps(getFunction(), tileSizes); } }; diff --git a/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt index 3b740748c62c..61b6b61597f9 100644 --- a/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt @@ -9,7 +9,7 @@ add_mlir_dialect_library(MLIRLinalgUtils MLIREDSC MLIRIR MLIRLinalgOps - MLIRLoopOps + MLIRSCF MLIRPass MLIRStandardOps MLIRTransformUtils diff --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp index ea1608ca9dd6..4f86b934172b 100644 --- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp @@ -14,7 +14,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" @@ -25,7 +25,7 @@ using namespace mlir; using namespace mlir::linalg; -using namespace mlir::loop; +using namespace mlir::scf; Optional RegionMatcher::matchAsScalarBinaryOp(GenericOp op) { diff --git a/mlir/lib/Dialect/LoopOps/CMakeLists.txt b/mlir/lib/Dialect/SCF/CMakeLists.txt similarity index 82% rename from mlir/lib/Dialect/LoopOps/CMakeLists.txt rename to mlir/lib/Dialect/SCF/CMakeLists.txt index ea72f25a303a..9565a85b3f7b 100644 --- a/mlir/lib/Dialect/LoopOps/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/CMakeLists.txt @@ -1,5 +1,5 @@ file(GLOB globbed *.c *.cpp) -add_mlir_dialect_library(MLIRLoopOps +add_mlir_dialect_library(MLIRSCF ${globbed} EDSC/Builders.cpp @@ -7,7 +7,7 @@ add_mlir_dialect_library(MLIRLoopOps ${MLIR_MAIN_INCLUDE_DIR}/mlir/LoopOps DEPENDS - MLIRLoopOpsIncGen + MLIRSCFOpsIncGen LINK_LIBS PUBLIC MLIREDSC diff --git a/mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp b/mlir/lib/Dialect/SCF/EDSC/Builders.cpp similarity index 94% rename from mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp rename to mlir/lib/Dialect/SCF/EDSC/Builders.cpp index af1f39a00085..723cab0e26de 100644 --- a/mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/SCF/EDSC/Builders.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/LoopOps/EDSC/Builders.h" +#include "mlir/Dialect/SCF/EDSC/Builders.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" @@ -82,7 +82,7 @@ LoopBuilder mlir::edsc::makeParallelLoopBuilder(MutableArrayRef ivs, ArrayRef lbs, ArrayRef ubs, ArrayRef steps) { - loop::ParallelOp parallelOp = OperationBuilder( + scf::ParallelOp parallelOp = OperationBuilder( SmallVector(lbs.begin(), lbs.end()), SmallVector(ubs.begin(), ubs.end()), SmallVector(steps.begin(), steps.end())); @@ -98,10 +98,10 @@ mlir::edsc::makeLoopBuilder(Value *iv, Value lb, Value ub, Value step, MutableArrayRef iterArgsHandles, ValueRange iterArgsInitValues) { mlir::edsc::LoopBuilder result; - loop::ForOp forOp = - OperationBuilder(lb, ub, step, iterArgsInitValues); + scf::ForOp forOp = + OperationBuilder(lb, ub, step, iterArgsInitValues); *iv = Value(forOp.getInductionVar()); - auto *body = loop::getForInductionVarOwner(*iv).getBody(); + auto *body = scf::getForInductionVarOwner(*iv).getBody(); for (size_t i = 0, e = iterArgsHandles.size(); i < e; ++i) { // Skipping the induction variable. iterArgsHandles[i] = body->getArgument(i + 1); diff --git a/mlir/lib/Dialect/LoopOps/LoopOps.cpp b/mlir/lib/Dialect/SCF/SCF.cpp similarity index 98% rename from mlir/lib/Dialect/LoopOps/LoopOps.cpp rename to mlir/lib/Dialect/SCF/SCF.cpp index fb3945d33c9c..d93e1b835529 100644 --- a/mlir/lib/Dialect/LoopOps/LoopOps.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -1,4 +1,4 @@ -//===- Ops.cpp - Loop MLIR Operations -------------------------------------===// +//===- SCF.cpp - Structured Control Flow 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,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" @@ -21,17 +21,17 @@ #include "mlir/Support/MathExtras.h" using namespace mlir; -using namespace mlir::loop; +using namespace mlir::scf; //===----------------------------------------------------------------------===// -// LoopOpsDialect +// SCFDialect //===----------------------------------------------------------------------===// -LoopOpsDialect::LoopOpsDialect(MLIRContext *context) +SCFDialect::SCFDialect(MLIRContext *context) : Dialect(getDialectNamespace(), context) { addOperations< #define GET_OP_LIST -#include "mlir/Dialect/LoopOps/LoopOps.cpp.inc" +#include "mlir/Dialect/SCF/SCFOps.cpp.inc" >(); } @@ -187,7 +187,7 @@ LogicalResult ForOp::moveOutOfLoop(ArrayRef ops) { return success(); } -ForOp mlir::loop::getForInductionVarOwner(Value val) { +ForOp mlir::scf::getForInductionVarOwner(Value val) { auto ivArg = val.dyn_cast(); if (!ivArg) return ForOp(); @@ -542,7 +542,7 @@ LogicalResult ParallelOp::moveOutOfLoop(ArrayRef ops) { return success(); } -ParallelOp mlir::loop::getParallelForInductionVarOwner(Value val) { +ParallelOp mlir::scf::getParallelForInductionVarOwner(Value val) { auto ivArg = val.dyn_cast(); if (!ivArg) return ParallelOp(); @@ -682,4 +682,4 @@ static void print(OpAsmPrinter &p, YieldOp op) { //===----------------------------------------------------------------------===// #define GET_OP_CLASSES -#include "mlir/Dialect/LoopOps/LoopOps.cpp.inc" +#include "mlir/Dialect/SCF/SCFOps.cpp.inc" diff --git a/mlir/lib/Dialect/LoopOps/Transforms/CMakeLists.txt b/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt similarity index 61% rename from mlir/lib/Dialect/LoopOps/Transforms/CMakeLists.txt rename to mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt index 0339d15f1fdc..f2b0265ed74d 100644 --- a/mlir/lib/Dialect/LoopOps/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt @@ -1,19 +1,19 @@ -add_mlir_dialect_library(MLIRLoopOpsTransforms +add_mlir_dialect_library(MLIRSCFTransforms ParallelLoopFusion.cpp ParallelLoopSpecialization.cpp ParallelLoopTiling.cpp ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LoopOps + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SCF DEPENDS - MLIRLoopPassIncGen + MLIRSCFPassIncGen LINK_LIBS PUBLIC MLIRAffineOps MLIRIR MLIRPass - MLIRLoopOps + MLIRSCF MLIRStandardOps MLIRSupport ) diff --git a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp similarity index 96% rename from mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp rename to mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp index f16a11851771..204528f16238 100644 --- a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp @@ -11,16 +11,16 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" -#include "mlir/Dialect/LoopOps/Passes.h" -#include "mlir/Dialect/LoopOps/Transforms.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" using namespace mlir; -using namespace mlir::loop; +using namespace mlir::scf; /// Verify there are no nested ParallelOps. static bool hasNestedParallelOp(ParallelOp ploop) { @@ -128,7 +128,7 @@ static void fuseIfLegal(ParallelOp firstPloop, ParallelOp secondPloop, firstPloop.erase(); } -void mlir::loop::naivelyFuseParallelOps(Region ®ion) { +void mlir::scf::naivelyFuseParallelOps(Region ®ion) { OpBuilder b(region); // Consider every single block and attempt to fuse adjacent loops. for (auto &block : region) { diff --git a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopSpecialization.cpp similarity index 93% rename from mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp rename to mlir/lib/Dialect/SCF/Transforms/ParallelLoopSpecialization.cpp index 76c0be2feb4f..3c3140c052ee 100644 --- a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopSpecialization.cpp @@ -12,14 +12,14 @@ #include "PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" -#include "mlir/Dialect/LoopOps/Passes.h" +#include "mlir/Dialect/SCF/Passes.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/BlockAndValueMapping.h" using namespace mlir; -using loop::ParallelOp; +using scf::ParallelOp; /// Rewrite a loop with bounds defined by an affine.min with a constant into 2 /// loops after checking if the bounds are equal to that constant. This is @@ -52,7 +52,7 @@ static void specializeLoopForUnrolling(ParallelOp op) { cond = cond ? b.create(op.getLoc(), cond, cmp) : cmp; map.map(std::get<0>(bound), constant); } - auto ifOp = b.create(op.getLoc(), cond, /*withElseRegion=*/true); + auto ifOp = b.create(op.getLoc(), cond, /*withElseRegion=*/true); ifOp.getThenBodyBuilder().clone(*op.getOperation(), map); ifOp.getElseBodyBuilder().clone(*op.getOperation()); op.erase(); diff --git a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp similarity index 95% rename from mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp rename to mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp index d9cf6df642d4..22da511c8b41 100644 --- a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp @@ -12,15 +12,15 @@ #include "PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" -#include "mlir/Dialect/LoopOps/Passes.h" -#include "mlir/Dialect/LoopOps/Transforms.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/RegionUtils.h" #include "llvm/Support/CommandLine.h" using namespace mlir; -using namespace mlir::loop; +using namespace mlir::scf; /// Tile a parallel loop of the form /// loop.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3) @@ -34,7 +34,7 @@ using namespace mlir::loop; /// min(tileSize[1], %arg3-%j1)) /// step (%arg4, %arg5) /// The old loop is replaced with the new one. -void mlir::loop::tileParallelLoop(ParallelOp op, ArrayRef tileSizes) { +void mlir::scf::tileParallelLoop(ParallelOp op, ArrayRef tileSizes) { OpBuilder b(op); auto zero = b.create(op.getLoc(), 0); SmallVector tileSizeConstants; diff --git a/mlir/lib/Dialect/LoopOps/Transforms/PassDetail.h b/mlir/lib/Dialect/SCF/Transforms/PassDetail.h similarity index 93% rename from mlir/lib/Dialect/LoopOps/Transforms/PassDetail.h rename to mlir/lib/Dialect/SCF/Transforms/PassDetail.h index 9fa8a350d004..95f8636b27c1 100644 --- a/mlir/lib/Dialect/LoopOps/Transforms/PassDetail.h +++ b/mlir/lib/Dialect/SCF/Transforms/PassDetail.h @@ -14,7 +14,7 @@ namespace mlir { #define GEN_PASS_CLASSES -#include "mlir/Dialect/LoopOps/Passes.h.inc" +#include "mlir/Dialect/SCF/Passes.h.inc" } // end namespace mlir diff --git a/mlir/lib/Dialect/Vector/CMakeLists.txt b/mlir/lib/Dialect/Vector/CMakeLists.txt index 9ccbb76b7bd2..5cce45cc4a2f 100644 --- a/mlir/lib/Dialect/Vector/CMakeLists.txt +++ b/mlir/lib/Dialect/Vector/CMakeLists.txt @@ -16,7 +16,7 @@ add_mlir_dialect_library(MLIRVector MLIRIR MLIRStandardOps MLIRAffineOps - MLIRLoopOps + MLIRSCF MLIRLoopAnalysis MLIRSideEffects ) diff --git a/mlir/lib/Transforms/CMakeLists.txt b/mlir/lib/Transforms/CMakeLists.txt index 97e71a578070..de259f70023f 100644 --- a/mlir/lib/Transforms/CMakeLists.txt +++ b/mlir/lib/Transforms/CMakeLists.txt @@ -31,7 +31,7 @@ add_mlir_library(MLIRTransforms MLIRAffineOps MLIRAnalysis MLIRLoopLikeInterface - MLIRLoopOps + MLIRSCF MLIRPass MLIRTransformUtils MLIRVector diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp index d47b37742f62..59b2fb9333da 100644 --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Transforms/LoopUtils.h" #include "mlir/Transforms/Passes.h" #include "mlir/Transforms/RegionUtils.h" @@ -23,12 +23,12 @@ struct LoopCoalescingPass : public LoopCoalescingBase { void runOnFunction() override { FuncOp func = getFunction(); - func.walk([](loop::ForOp op) { + func.walk([](scf::ForOp op) { // Ignore nested loops. - if (op.getParentOfType()) + if (op.getParentOfType()) return; - SmallVector loops; + SmallVector loops; getPerfectlyNestedLoops(loops, op); LLVM_DEBUG(llvm::dbgs() << "found a perfect nest of depth " << loops.size() << '\n'); diff --git a/mlir/lib/Transforms/ParallelLoopCollapsing.cpp b/mlir/lib/Transforms/ParallelLoopCollapsing.cpp index 16ecb8475cfb..72070a9e291f 100644 --- a/mlir/lib/Transforms/ParallelLoopCollapsing.cpp +++ b/mlir/lib/Transforms/ParallelLoopCollapsing.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/Transforms/LoopUtils.h" #include "mlir/Transforms/Passes.h" #include "mlir/Transforms/RegionUtils.h" @@ -24,7 +24,7 @@ struct ParallelLoopCollapsing void runOnOperation() override { Operation *module = getOperation(); - module->walk([&](loop::ParallelOp op) { + module->walk([&](scf::ParallelOp op) { // The common case for GPU dialect will be simplifying the ParallelOp to 3 // arguments, so we do that here to simplify things. llvm::SmallVector, 3> combinedLoops; diff --git a/mlir/lib/Transforms/Utils/CMakeLists.txt b/mlir/lib/Transforms/Utils/CMakeLists.txt index a06523ed4aaa..3fc45a8c6676 100644 --- a/mlir/lib/Transforms/Utils/CMakeLists.txt +++ b/mlir/lib/Transforms/Utils/CMakeLists.txt @@ -17,7 +17,7 @@ add_mlir_library(MLIRTransformUtils MLIRAffineOps MLIRAnalysis MLIRLoopAnalysis - MLIRLoopOps + MLIRSCF MLIRPass MLIRStandardOps ) diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 35581eb2a392..209ed696c45a 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -18,7 +18,7 @@ #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Function.h" @@ -192,7 +192,7 @@ LogicalResult mlir::promoteIfSingleIteration(AffineForOp forOp) { /// Promotes the loop body of a forOp to its containing block if the forOp /// it can be determined that the loop has a single iteration. -LogicalResult mlir::promoteIfSingleIteration(loop::ForOp forOp) { +LogicalResult mlir::promoteIfSingleIteration(scf::ForOp forOp) { auto lbCstOp = dyn_cast_or_null(forOp.lowerBound().getDefiningOp()); auto ubCstOp = @@ -445,8 +445,8 @@ void mlir::getPerfectlyNestedLoops(SmallVectorImpl &nestedLoops, getPerfectlyNestedLoopsImpl(nestedLoops, root); } -void mlir::getPerfectlyNestedLoops(SmallVectorImpl &nestedLoops, - loop::ForOp root) { +void mlir::getPerfectlyNestedLoops(SmallVectorImpl &nestedLoops, + scf::ForOp root) { getPerfectlyNestedLoopsImpl(nestedLoops, root); } @@ -474,7 +474,7 @@ LogicalResult mlir::loopUnrollUpToFactor(AffineForOp forOp, return loopUnrollByFactor(forOp, unrollFactor); } -// Generates unrolled copies of AffineForOp or loop::ForOp 'loopBodyBlock', with +// Generates unrolled copies of AffineForOp or scf::ForOp 'loopBodyBlock', with // associated 'forOpIV' by 'unrollFactor', calling 'ivRemapFn' to remap // 'forOpIV' for each unrolled body. static void generateUnrolledLoop( @@ -571,7 +571,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp, } /// Unrolls 'forOp' by 'unrollFactor', returns success if the loop is unrolled. -LogicalResult mlir::loopUnrollByFactor(loop::ForOp forOp, +LogicalResult mlir::loopUnrollByFactor(scf::ForOp forOp, uint64_t unrollFactor) { assert(unrollFactor > 0 && "expected positive unroll factor"); if (unrollFactor == 1) @@ -649,7 +649,7 @@ LogicalResult mlir::loopUnrollByFactor(loop::ForOp forOp, if (generateEpilogueLoop) { OpBuilder epilogueBuilder(forOp.getOperation()->getBlock(), std::next(Block::iterator(forOp))); - auto epilogueForOp = cast(epilogueBuilder.clone(*forOp)); + auto epilogueForOp = cast(epilogueBuilder.clone(*forOp)); epilogueForOp.setLowerBound(upperBoundUnrolled); promoteIfSingleIteration(epilogueForOp); } @@ -1088,8 +1088,8 @@ stripmineSink(AffineForOp forOp, uint64_t factor, return innerLoops; } -static Loops stripmineSink(loop::ForOp forOp, Value factor, - ArrayRef targets) { +static Loops stripmineSink(scf::ForOp forOp, Value factor, + ArrayRef targets) { auto originalStep = forOp.step(); auto iv = forOp.getInductionVar(); @@ -1111,7 +1111,7 @@ static Loops stripmineSink(loop::ForOp forOp, Value factor, b.create(t.getLoc(), less, forOp.upperBound(), stepped); // Splice [begin, begin + nOps - 1) into `newForOp` and replace uses. - auto newForOp = b.create(t.getLoc(), iv, ub, originalStep); + auto newForOp = b.create(t.getLoc(), iv, ub, originalStep); newForOp.getBody()->getOperations().splice( newForOp.getBody()->getOperations().begin(), t.getBody()->getOperations(), begin, std::next(begin, nOps - 1)); @@ -1157,9 +1157,9 @@ mlir::tile(ArrayRef forOps, ArrayRef sizes, return tileImpl(forOps, sizes, targets); } -SmallVector mlir::tile(ArrayRef forOps, +SmallVector mlir::tile(ArrayRef forOps, ArrayRef sizes, - ArrayRef targets) { + ArrayRef targets) { return tileImpl(forOps, sizes, targets); } @@ -1180,15 +1180,15 @@ SmallVector mlir::tile(ArrayRef forOps, return tileImpl(forOps, sizes, target); } -Loops mlir::tile(ArrayRef forOps, ArrayRef sizes, - loop::ForOp target) { +Loops mlir::tile(ArrayRef forOps, ArrayRef sizes, + scf::ForOp target) { return tileImpl(forOps, sizes, target); } -Loops mlir::tilePerfectlyNested(loop::ForOp rootForOp, ArrayRef sizes) { +Loops mlir::tilePerfectlyNested(scf::ForOp rootForOp, ArrayRef sizes) { // Collect perfectly nested loops. If more size values provided than nested // loops available, truncate `sizes`. - SmallVector forOps; + SmallVector forOps; forOps.reserve(sizes.size()); getPerfectlyNestedLoopsImpl(forOps, rootForOp, sizes.size()); if (forOps.size() < sizes.size()) @@ -1202,7 +1202,7 @@ Loops mlir::tilePerfectlyNested(loop::ForOp rootForOp, ArrayRef sizes) { // Ops that come from triangular loops (i.e. that belong to the program slice // rooted at `outer`) and ops that have side effects cannot be hoisted. // Return failure when any op fails to hoist. -static LogicalResult hoistOpsBetween(loop::ForOp outer, loop::ForOp inner) { +static LogicalResult hoistOpsBetween(scf::ForOp outer, scf::ForOp inner) { SetVector forwardSlice; getForwardSlice(outer.getOperation(), &forwardSlice, [&inner](Operation *op) { return op != inner.getOperation(); @@ -1218,7 +1218,7 @@ static LogicalResult hoistOpsBetween(loop::ForOp outer, loop::ForOp inner) { status = failure(); continue; } - // Skip loop::ForOp, these are not considered a failure. + // Skip scf::ForOp, these are not considered a failure. if (op.getNumRegions() > 0) continue; // Skip other ops with regions. @@ -1261,11 +1261,11 @@ static LogicalResult tryIsolateBands(const TileLoops &tileLoops) { return status; } -TileLoops mlir::extractFixedOuterLoops(loop::ForOp rootForOp, +TileLoops mlir::extractFixedOuterLoops(scf::ForOp rootForOp, ArrayRef sizes) { // Collect perfectly nested loops. If more size values provided than nested // loops available, truncate `sizes`. - SmallVector forOps; + SmallVector forOps; forOps.reserve(sizes.size()); getPerfectlyNestedLoopsImpl(forOps, rootForOp, sizes.size()); if (forOps.size() < sizes.size()) @@ -1363,8 +1363,7 @@ static LoopParams normalizeLoop(OpBuilder &boundsBuilder, /// expected to be either `loop` or another loop perfectly nested under `loop`. /// Insert the definition of new bounds immediate before `outer`, which is /// expected to be either `loop` or its parent in the loop nest. -static void normalizeLoop(loop::ForOp loop, loop::ForOp outer, - loop::ForOp inner) { +static void normalizeLoop(scf::ForOp loop, scf::ForOp outer, scf::ForOp inner) { OpBuilder builder(outer); OpBuilder innerBuilder = OpBuilder::atBlockBegin(inner.getBody()); auto loopPieces = @@ -1376,12 +1375,12 @@ static void normalizeLoop(loop::ForOp loop, loop::ForOp outer, loop.setStep(loopPieces.step); } -void mlir::coalesceLoops(MutableArrayRef loops) { +void mlir::coalesceLoops(MutableArrayRef loops) { if (loops.size() < 2) return; - loop::ForOp innermost = loops.back(); - loop::ForOp outermost = loops.front(); + scf::ForOp innermost = loops.back(); + scf::ForOp outermost = loops.front(); // 1. Make sure all loops iterate from 0 to upperBound with step 1. This // allows the following code to assume upperBound is the number of iterations. @@ -1423,7 +1422,7 @@ void mlir::coalesceLoops(MutableArrayRef loops) { // 4. Move the operations from the innermost just above the second-outermost // loop, delete the extra terminator and the second-outermost loop. - loop::ForOp second = loops[1]; + scf::ForOp second = loops[1]; innermost.getBody()->back().erase(); outermost.getBody()->getOperations().splice( Block::iterator(second.getOperation()), @@ -1432,8 +1431,7 @@ void mlir::coalesceLoops(MutableArrayRef loops) { } void mlir::collapseParallelLoops( - loop::ParallelOp loops, - ArrayRef> combinedDimensions) { + scf::ParallelOp loops, ArrayRef> combinedDimensions) { OpBuilder outsideBuilder(loops); Location loc = loops.getLoc(); @@ -1476,8 +1474,8 @@ void mlir::collapseParallelLoops( // value. The remainders then determine based on that range, which iteration // of the original induction value this represents. This is a normalized value // that is un-normalized already by the previous logic. - auto newPloop = outsideBuilder.create(loc, lowerBounds, - upperBounds, steps); + auto newPloop = outsideBuilder.create(loc, lowerBounds, + upperBounds, steps); OpBuilder insideBuilder(newPloop.region()); for (unsigned i = 0, e = combinedDimensions.size(); i < e; ++i) { Value previous = newPloop.getBody()->getArgument(i); @@ -1512,7 +1510,7 @@ void mlir::collapseParallelLoops( loops.erase(); } -void mlir::mapLoopToProcessorIds(loop::ForOp forOp, ArrayRef processorId, +void mlir::mapLoopToProcessorIds(scf::ForOp forOp, ArrayRef processorId, ArrayRef numProcessors) { assert(processorId.size() == numProcessors.size()); if (processorId.empty()) diff --git a/mlir/test/Dialect/Loops/invalid.mlir b/mlir/test/Dialect/SCF/invalid.mlir similarity index 100% rename from mlir/test/Dialect/Loops/invalid.mlir rename to mlir/test/Dialect/SCF/invalid.mlir diff --git a/mlir/test/Dialect/Loops/loop-unroll.mlir b/mlir/test/Dialect/SCF/loop-unroll.mlir similarity index 100% rename from mlir/test/Dialect/Loops/loop-unroll.mlir rename to mlir/test/Dialect/SCF/loop-unroll.mlir diff --git a/mlir/test/Dialect/Loops/ops.mlir b/mlir/test/Dialect/SCF/ops.mlir similarity index 100% rename from mlir/test/Dialect/Loops/ops.mlir rename to mlir/test/Dialect/SCF/ops.mlir diff --git a/mlir/test/Dialect/Loops/parallel-loop-fusion.mlir b/mlir/test/Dialect/SCF/parallel-loop-fusion.mlir similarity index 100% rename from mlir/test/Dialect/Loops/parallel-loop-fusion.mlir rename to mlir/test/Dialect/SCF/parallel-loop-fusion.mlir diff --git a/mlir/test/Dialect/Loops/parallel-loop-specialization.mlir b/mlir/test/Dialect/SCF/parallel-loop-specialization.mlir similarity index 100% rename from mlir/test/Dialect/Loops/parallel-loop-specialization.mlir rename to mlir/test/Dialect/SCF/parallel-loop-specialization.mlir diff --git a/mlir/test/Dialect/Loops/parallel-loop-tiling.mlir b/mlir/test/Dialect/SCF/parallel-loop-tiling.mlir similarity index 100% rename from mlir/test/Dialect/Loops/parallel-loop-tiling.mlir rename to mlir/test/Dialect/SCF/parallel-loop-tiling.mlir diff --git a/mlir/test/EDSC/CMakeLists.txt b/mlir/test/EDSC/CMakeLists.txt index dda2a25fdb04..96a89d333600 100644 --- a/mlir/test/EDSC/CMakeLists.txt +++ b/mlir/test/EDSC/CMakeLists.txt @@ -16,7 +16,7 @@ target_link_libraries(mlir-edsc-builder-api-test MLIRIR MLIRLinalgEDSC MLIRLinalgOps - MLIRLoopOps + MLIRSCF MLIRStandardOps MLIRTransforms MLIRVector diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index cca6c2092b93..a4c98e6cc413 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -11,7 +11,7 @@ #include "mlir/Dialect/Affine/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/EDSC/Builders.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" -#include "mlir/Dialect/LoopOps/EDSC/Intrinsics.h" +#include "mlir/Dialect/SCF/EDSC/Intrinsics.h" #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/Dialect/Vector/EDSC/Intrinsics.h" #include "mlir/EDSC/Builders.h" @@ -39,7 +39,7 @@ static MLIRContext &globalContext() { static bool init_once = []() { registerDialect(); registerDialect(); - registerDialect(); + registerDialect(); registerDialect(); registerDialect(); return true; diff --git a/mlir/test/lib/Transforms/CMakeLists.txt b/mlir/test/lib/Transforms/CMakeLists.txt index e7b31b3d0bcf..a749d81d4f6a 100644 --- a/mlir/test/lib/Transforms/CMakeLists.txt +++ b/mlir/test/lib/Transforms/CMakeLists.txt @@ -39,7 +39,7 @@ add_mlir_library(MLIRTestTransforms MLIRGPUtoCUDATransforms MLIRLinalgOps MLIRLinalgTransforms - MLIRLoopOps + MLIRSCF MLIRGPU MLIRPass MLIRStandardToStandard diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp index 184234807130..98fe5b539f5a 100644 --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/IR/Builders.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" @@ -41,9 +41,9 @@ public: numProcessors.push_back(op->getResult(1)); }); - func.walk([&processorIds, &numProcessors](loop::ForOp op) { + func.walk([&processorIds, &numProcessors](scf::ForOp op) { // Ignore nested loops. - if (op.getParentRegion()->getParentOfType()) + if (op.getParentRegion()->getParentOfType()) return; mapLoopToProcessorIds(op, processorIds, numProcessors); }); diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp index 61d34bcfcd37..a49a38ad50b4 100644 --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/IR/Builders.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" @@ -33,9 +33,9 @@ public: void runOnFunction() override { FuncOp func = getFunction(); - func.walk([this](loop::ForOp op) { + func.walk([this](scf::ForOp op) { // Ignore nested loops. - if (op.getParentRegion()->getParentOfType()) + if (op.getParentRegion()->getParentOfType()) return; extractFixedOuterLoops(op, sizes); }); diff --git a/mlir/test/lib/Transforms/TestLoopUnrolling.cpp b/mlir/test/lib/Transforms/TestLoopUnrolling.cpp index 7cd221f37f8c..712fddb97028 100644 --- a/mlir/test/lib/Transforms/TestLoopUnrolling.cpp +++ b/mlir/test/lib/Transforms/TestLoopUnrolling.cpp @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/LoopOps/LoopOps.h" +#include "mlir/Dialect/SCF/SCF.h" #include "mlir/IR/Builders.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/LoopUtils.h" @@ -24,7 +24,7 @@ static unsigned getNestingDepth(Operation *op) { Operation *currOp = op; unsigned depth = 0; while ((currOp = currOp->getParentOp())) { - if (isa(currOp)) + if (isa(currOp)) depth++; } return depth; @@ -43,8 +43,8 @@ public: void runOnFunction() override { FuncOp func = getFunction(); - SmallVector loops; - func.walk([&](loop::ForOp forOp) { + SmallVector loops; + func.walk([&](scf::ForOp forOp) { if (getNestingDepth(forOp) == loopDepth) loops.push_back(forOp); });