diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -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 @@ 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 @@ 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 --- 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 @@ 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 @@ 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 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h @@ -17,9 +17,9 @@ 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 @@ /// 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 @@ /// 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 --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -176,7 +176,7 @@ } 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 --- a/mlir/include/mlir/Dialect/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/CMakeLists.txt @@ -3,9 +3,9 @@ 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 --- a/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h +++ b/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h @@ -29,7 +29,7 @@ #include "mlir/Dialect/GPU/ParallelLoopMapperAttr.h.inc" -namespace loop { +namespace scf { class ParallelOp; } @@ -54,7 +54,7 @@ /// - 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 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h @@ -26,9 +26,9 @@ class BlockArgument; class SubViewOp; -namespace loop { +namespace scf { class ParallelOp; -} // namespace loop +} // namespace scf namespace edsc { class AffineLoopNestBuilder; @@ -85,7 +85,7 @@ 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 --- 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 --- 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 --- /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 rename from mlir/include/mlir/Dialect/LoopOps/EDSC/Builders.h rename to mlir/include/mlir/Dialect/SCF/EDSC/Builders.h --- 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 @@ } // 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 rename from mlir/include/mlir/Dialect/LoopOps/EDSC/Intrinsics.h rename to mlir/include/mlir/Dialect/SCF/EDSC/Intrinsics.h --- 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 rename from mlir/include/mlir/Dialect/LoopOps/Passes.h rename to mlir/include/mlir/Dialect/SCF/Passes.h --- 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 @@ } // 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 rename from mlir/include/mlir/Dialect/LoopOps/Passes.td rename to mlir/include/mlir/Dialect/SCF/Passes.td --- 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 @@ ]; } -#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 rename from mlir/include/mlir/Dialect/LoopOps/LoopOps.h rename to mlir/include/mlir/Dialect/SCF/SCF.h --- 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,14 +22,14 @@ #include "mlir/Interfaces/SideEffects.h" namespace mlir { -namespace loop { +namespace scf { class TerminatorOp; -#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, @@ -45,6 +45,6 @@ // 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 rename from mlir/include/mlir/Dialect/LoopOps/LoopOps.td rename to mlir/include/mlir/Dialect/SCF/SCFOps.td --- 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 @@ 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 IfOp : Loop_Op<"if", +def IfOp : SCF_Op<"if", [DeclareOpInterfaceMethods, SingleBlockImplicitTerminator<"YieldOp">, RecursiveSideEffects]> { let summary = "if-then-else operation"; @@ -250,7 +250,7 @@ }]; } -def ParallelOp : Loop_Op<"parallel", +def ParallelOp : SCF_Op<"parallel", [AttrSizedOperandSegments, DeclareOpInterfaceMethods, RecursiveSideEffects, @@ -324,7 +324,7 @@ }]; } -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 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 @@ 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 @@ [{ /* 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 rename from mlir/include/mlir/Dialect/LoopOps/Transforms.h rename to mlir/include/mlir/Dialect/SCF/Transforms.h --- 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 @@ class Region; -namespace loop { +namespace scf { class ParallelOp; @@ -42,7 +42,7 @@ /// 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 --- 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 @@ registerDialect(); registerDialect(); registerDialect(); - registerDialect(); + registerDialect(); registerDialect(); registerDialect(); registerDialect(); diff --git a/mlir/include/mlir/InitAllPasses.h b/mlir/include/mlir/InitAllPasses.h --- a/mlir/include/mlir/InitAllPasses.h +++ b/mlir/include/mlir/InitAllPasses.h @@ -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/Transforms/LocationSnapshot.h" #include "mlir/Transforms/Passes.h" @@ -77,7 +77,7 @@ // 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 --- a/mlir/include/mlir/Transforms/LoopUtils.h +++ b/mlir/include/mlir/Transforms/LoopUtils.h @@ -27,10 +27,10 @@ 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. @@ -55,8 +55,8 @@ /// 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. @@ -126,13 +126,13 @@ /// 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`. @@ -140,15 +140,15 @@ /// `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 { @@ -218,18 +218,17 @@ /// 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 @@ -263,7 +262,7 @@ /// ... /// } /// ``` -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 --- a/mlir/lib/Analysis/CMakeLists.txt +++ b/mlir/lib/Analysis/CMakeLists.txt @@ -27,7 +27,7 @@ MLIRCallInterfaces MLIRControlFlowInterfaces MLIRInferTypeOpInterface - MLIRLoopOps + MLIRSCF ) add_mlir_library(MLIRLoopAnalysis @@ -50,4 +50,4 @@ MLIRCallInterfaces MLIRControlFlowInterfaces MLIRInferTypeOpInterface - MLIRLoopOps) + MLIRSCF) diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp --- 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 @@ 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 @@ 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 @@ 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 --- 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 @@ LogicalResult matchAndRewrite(AffineTerminatorOp op, PatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(op); + rewriter.replaceOpWithNewOp(op); return success(); } }; @@ -347,7 +347,7 @@ 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 @@ : 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 @@ 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 --- a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt @@ -11,7 +11,7 @@ MLIRAffineToStandard PUBLIC MLIRAffineOps - MLIRLoopOps + MLIRSCF MLIRPass MLIRStandardOps MLIRTransforms diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp --- 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 @@ 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 @@ } // 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 @@ } //===----------------------------------------------------------------------===// -// 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 --- 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 --- a/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt @@ -10,7 +10,7 @@ target_link_libraries( MLIRLoopToStandard PUBLIC - MLIRLoopOps + MLIRSCF MLIRTransforms LLVMCore LLVMSupport diff --git a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp b/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp --- 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 @@ 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 --- 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 @@ 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 @@ 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 @@ } } 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 --- 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 @@ -103,8 +103,8 @@ 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 --- 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 @@ 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 --- a/mlir/lib/Dialect/CMakeLists.txt +++ b/mlir/lib/Dialect/CMakeLists.txt @@ -3,9 +3,9 @@ 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 --- a/mlir/lib/Dialect/GPU/CMakeLists.txt +++ b/mlir/lib/Dialect/GPU/CMakeLists.txt @@ -19,7 +19,7 @@ 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 --- 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 @@ 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 --- 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 @@ 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 --- 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::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 edsc { template <> -GenericLoopNestRangeBuilder::GenericLoopNestRangeBuilder( +GenericLoopNestRangeBuilder::GenericLoopNestRangeBuilder( MutableArrayRef ivs, ArrayRef ranges) { builder = std::make_unique(ivs, ranges); } @@ -102,7 +102,7 @@ } 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 --- a/mlir/lib/Dialect/Linalg/EDSC/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/EDSC/CMakeLists.txt @@ -15,7 +15,7 @@ MLIRAffineOps MLIRAffineEDSC MLIRLinalgOps - MLIRLoopOps + MLIRSCF MLIRStandardOps LLVMSupport ) diff --git a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt @@ -24,7 +24,7 @@ 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 --- 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 @@ /// 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 @@ // 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 @@ } 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 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 @@ 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 @@ LogicalResult mlir::linalg::linalgOpToParallelLoops(OpBuilder &builder, Operation *op) { Optional loops = - linalgLowerOpToLoops(builder, op); + linalgLowerOpToLoops(builder, op); return loops ? success() : failure(); } @@ -783,7 +783,7 @@ 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 --- 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::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 --- 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::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 @@ 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 @@ LinalgTilingPass(ArrayRef sizes) { tileSizes = sizes; } void runOnFunction() override { - tileLinalgOps(getFunction(), tileSizes); + tileLinalgOps(getFunction(), tileSizes); } }; @@ -530,7 +530,7 @@ } 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 --- a/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Utils/CMakeLists.txt @@ -13,7 +13,7 @@ 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 --- 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 rename from mlir/lib/Dialect/LoopOps/CMakeLists.txt rename to mlir/lib/Dialect/SCF/CMakeLists.txt --- 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,9 +7,9 @@ ${MLIR_MAIN_INCLUDE_DIR}/mlir/LoopOps DEPENDS - MLIRLoopOpsIncGen + MLIRSCFOpsIncGen ) -target_link_libraries(MLIRLoopOps +target_link_libraries(MLIRSCF PUBLIC MLIREDSC MLIRIR diff --git a/mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp b/mlir/lib/Dialect/SCF/EDSC/Builders.cpp rename from mlir/lib/Dialect/LoopOps/EDSC/Builders.cpp rename to mlir/lib/Dialect/SCF/EDSC/Builders.cpp --- 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 @@ 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 @@ 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 rename from mlir/lib/Dialect/LoopOps/LoopOps.cpp rename to mlir/lib/Dialect/SCF/SCF.cpp --- 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 @@ 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 @@ 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 @@ //===----------------------------------------------------------------------===// #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 rename from mlir/lib/Dialect/LoopOps/Transforms/CMakeLists.txt rename to mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/LoopOps/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt @@ -1,20 +1,20 @@ -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 ) -target_link_libraries(MLIRLoopOpsTransforms +target_link_libraries(MLIRSCFTransforms PUBLIC MLIRAffineOps MLIRIR MLIRPass - MLIRLoopOps + MLIRSCF MLIRStandardOps MLIRSupport LLVMSupport diff --git a/mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp rename from mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopFusion.cpp rename to mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp --- 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 @@ 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 rename from mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopSpecialization.cpp rename to mlir/lib/Dialect/SCF/Transforms/ParallelLoopSpecialization.cpp --- 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 @@ 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 rename from mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp rename to mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp --- 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 @@ /// 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 rename from mlir/lib/Dialect/LoopOps/Transforms/PassDetail.h rename to mlir/lib/Dialect/SCF/Transforms/PassDetail.h --- 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 --- a/mlir/lib/Dialect/Vector/CMakeLists.txt +++ b/mlir/lib/Dialect/Vector/CMakeLists.txt @@ -17,7 +17,7 @@ MLIRIR MLIRStandardOps MLIRAffineOps - MLIRLoopOps + MLIRSCF MLIRLoopAnalysis MLIRSideEffects ) diff --git a/mlir/lib/Transforms/CMakeLists.txt b/mlir/lib/Transforms/CMakeLists.txt --- a/mlir/lib/Transforms/CMakeLists.txt +++ b/mlir/lib/Transforms/CMakeLists.txt @@ -33,7 +33,7 @@ MLIRAffineOps MLIRAnalysis MLIRLoopLikeInterface - MLIRLoopOps + MLIRSCF MLIRPass MLIRTransformUtils MLIRVector diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp --- 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 @@ 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 --- 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 @@ 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 --- a/mlir/lib/Transforms/Utils/CMakeLists.txt +++ b/mlir/lib/Transforms/Utils/CMakeLists.txt @@ -19,7 +19,7 @@ MLIRAffineOps MLIRAnalysis MLIRLoopAnalysis - MLIRLoopOps + MLIRSCF MLIRPass MLIRStandardOps ) diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp --- 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" @@ -387,8 +387,8 @@ getPerfectlyNestedLoopsImpl(nestedLoops, root); } -void mlir::getPerfectlyNestedLoops(SmallVectorImpl &nestedLoops, - loop::ForOp root) { +void mlir::getPerfectlyNestedLoops(SmallVectorImpl &nestedLoops, + scf::ForOp root) { getPerfectlyNestedLoopsImpl(nestedLoops, root); } @@ -923,8 +923,8 @@ 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(); @@ -946,7 +946,7 @@ 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)); @@ -992,9 +992,9 @@ 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); } @@ -1015,15 +1015,15 @@ 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()) @@ -1065,7 +1065,7 @@ // 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(); @@ -1081,7 +1081,7 @@ 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. @@ -1124,11 +1124,11 @@ 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()) @@ -1226,8 +1226,7 @@ /// 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 = @@ -1239,12 +1238,12 @@ 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. @@ -1286,7 +1285,7 @@ // 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()), @@ -1295,8 +1294,7 @@ } void mlir::collapseParallelLoops( - loop::ParallelOp loops, - ArrayRef> combinedDimensions) { + scf::ParallelOp loops, ArrayRef> combinedDimensions) { OpBuilder outsideBuilder(loops); Location loc = loops.getLoc(); @@ -1339,8 +1337,8 @@ // 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); @@ -1375,7 +1373,7 @@ 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 rename from mlir/test/Dialect/Loops/invalid.mlir rename to mlir/test/Dialect/SCF/invalid.mlir diff --git a/mlir/test/Dialect/Loops/ops.mlir b/mlir/test/Dialect/SCF/ops.mlir 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 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 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 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 --- a/mlir/test/EDSC/CMakeLists.txt +++ b/mlir/test/EDSC/CMakeLists.txt @@ -12,7 +12,7 @@ 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 --- 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 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 --- a/mlir/test/lib/Transforms/CMakeLists.txt +++ b/mlir/test/lib/Transforms/CMakeLists.txt @@ -42,7 +42,7 @@ MLIRGPUtoCUDATransforms MLIRLinalgOps MLIRLinalgTransforms - MLIRLoopOps + MLIRSCF MLIRGPU MLIRPass MLIRStandardToStandard diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp --- 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 @@ 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 --- 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 @@ 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); });