From 971b8dd4d881cdc21b6aa73a3797bf9a6d48ca14 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Thu, 14 Nov 2019 10:34:46 -0800 Subject: [PATCH] Move Affine to Standard conversion to lib/Conversion This is essentially a dialect conversion and conceptually belongs to conversions. PiperOrigin-RevId: 280460034 --- mlir/examples/toy/Ch6/CMakeLists.txt | 2 ++ mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp | 2 +- mlir/examples/toy/Ch7/CMakeLists.txt | 2 ++ mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp | 2 +- .../AffineToStandard/AffineToStandard.h} | 9 ++++----- .../AffineToStandard/AffineToStandard.cpp} | 5 +++-- mlir/lib/Conversion/CMakeLists.txt | 1 + mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp | 2 +- mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp | 2 +- mlir/lib/Transforms/CMakeLists.txt | 1 - mlir/tools/mlir-opt/CMakeLists.txt | 1 + 11 files changed, 17 insertions(+), 12 deletions(-) rename mlir/include/mlir/{Transforms/LowerAffine.h => Conversion/AffineToStandard/AffineToStandard.h} (89%) rename mlir/lib/{Transforms/LowerAffine.cpp => Conversion/AffineToStandard/AffineToStandard.cpp} (99%) diff --git a/mlir/examples/toy/Ch6/CMakeLists.txt b/mlir/examples/toy/Ch6/CMakeLists.txt index d66c921..c342ed1 100644 --- a/mlir/examples/toy/Ch6/CMakeLists.txt +++ b/mlir/examples/toy/Ch6/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/) target_link_libraries(toyc-ch6 PRIVATE MLIRAffineOps + MLIRAffineToStandard MLIRAnalysis MLIRExecutionEngine MLIRIR @@ -45,6 +46,7 @@ target_link_libraries(toyc-ch6 ) whole_archive_link(toyc-ch6 + MLIRAffineToStandard MLIRAffineOps MLIRLLVMIR MLIRStandardOps diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp index 091eada..ba79c34 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -24,6 +24,7 @@ #include "toy/Dialect.h" #include "toy/Passes.h" +#include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" @@ -33,7 +34,6 @@ #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" -#include "mlir/Transforms/LowerAffine.h" #include "llvm/ADT/Sequence.h" using namespace mlir; diff --git a/mlir/examples/toy/Ch7/CMakeLists.txt b/mlir/examples/toy/Ch7/CMakeLists.txt index fc26425..5956d7f 100644 --- a/mlir/examples/toy/Ch7/CMakeLists.txt +++ b/mlir/examples/toy/Ch7/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/) target_link_libraries(toyc-ch7 PRIVATE MLIRAffineOps + MLIRAffineToStandard MLIRAnalysis MLIRExecutionEngine MLIRIR @@ -45,6 +46,7 @@ target_link_libraries(toyc-ch7 ) whole_archive_link(toyc-ch7 + MLIRAffineToStandard MLIRAffineOps MLIRLLVMIR MLIRStandardOps diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp index 091eada..ba79c34 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -24,6 +24,7 @@ #include "toy/Dialect.h" #include "toy/Passes.h" +#include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" @@ -33,7 +34,6 @@ #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" -#include "mlir/Transforms/LowerAffine.h" #include "llvm/ADT/Sequence.h" using namespace mlir; diff --git a/mlir/include/mlir/Transforms/LowerAffine.h b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h similarity index 89% rename from mlir/include/mlir/Transforms/LowerAffine.h rename to mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h index 5fae476..b5c51ad 100644 --- a/mlir/include/mlir/Transforms/LowerAffine.h +++ b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h @@ -1,4 +1,4 @@ -//===- LowerAffine.h - Convert Affine to Standard dialect -------*- C++ -*-===// +//===- AffineToStandard.h - Convert Affine to Standard dialect --*- C++ -*-===// // // Copyright 2019 The MLIR Authors. // @@ -15,11 +15,10 @@ // limitations under the License. // ============================================================================= -#ifndef MLIR_TRANSFORMS_LOWERAFFINE_H -#define MLIR_TRANSFORMS_LOWERAFFINE_H +#ifndef MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H +#define MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H #include "mlir/Support/LLVM.h" -#include namespace mlir { class AffineExpr; @@ -55,4 +54,4 @@ Value *lowerAffineLowerBound(AffineForOp op, OpBuilder &builder); Value *lowerAffineUpperBound(AffineForOp op, OpBuilder &builder); } // namespace mlir -#endif // MLIR_TRANSFORMS_LOWERAFFINE_H +#endif // MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp similarity index 99% rename from mlir/lib/Transforms/LowerAffine.cpp rename to mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp index d50c5e0..98d80ed 100644 --- a/mlir/lib/Transforms/LowerAffine.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -1,4 +1,4 @@ -//===- LowerAffine.cpp - Lower affine constructs to primitives ------------===// +//===- AffineToStandard.cpp - Lower affine constructs to primitives -------===// // // Copyright 2019 The MLIR Authors. // @@ -20,7 +20,8 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Transforms/LowerAffine.h" +#include "mlir/Conversion/AffineToStandard/AffineToStandard.h" + #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt index c0fd6b8..1639a30 100644 --- a/mlir/lib/Conversion/CMakeLists.txt +++ b/mlir/lib/Conversion/CMakeLists.txt @@ -1,3 +1,4 @@ +add_subdirectory(AffineToStandard) add_subdirectory(GPUToCUDA) add_subdirectory(GPUToNVVM) add_subdirectory(GPUToROCDL) diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp index e33b840..eb0b0d5 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp @@ -23,6 +23,7 @@ #include "mlir/Conversion/LoopsToGPU/LoopsToGPU.h" +#include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LoopOps/LoopOps.h" @@ -30,7 +31,6 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/Builders.h" #include "mlir/Transforms/LoopUtils.h" -#include "mlir/Transforms/LowerAffine.h" #include "mlir/Transforms/RegionUtils.h" #include "llvm/ADT/Sequence.h" #include "llvm/Support/Debug.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp b/mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp index 61614aa..c0ed702 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LowerToLLVMDialect.cpp @@ -15,6 +15,7 @@ // limitations under the License. // ============================================================================= +#include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" @@ -40,7 +41,6 @@ #include "mlir/Pass/PassManager.h" #include "mlir/Support/LogicalResult.h" #include "mlir/Transforms/DialectConversion.h" -#include "mlir/Transforms/LowerAffine.h" #include "mlir/Transforms/Passes.h" #include "llvm/ADT/SetVector.h" diff --git a/mlir/lib/Transforms/CMakeLists.txt b/mlir/lib/Transforms/CMakeLists.txt index 10daf85..de7801b 100644 --- a/mlir/lib/Transforms/CMakeLists.txt +++ b/mlir/lib/Transforms/CMakeLists.txt @@ -13,7 +13,6 @@ add_llvm_library(MLIRTransforms LoopTiling.cpp LoopUnrollAndJam.cpp LoopUnroll.cpp - LowerAffine.cpp LowerVectorTransfers.cpp MaterializeVectors.cpp MemRefDataFlowOpt.cpp diff --git a/mlir/tools/mlir-opt/CMakeLists.txt b/mlir/tools/mlir-opt/CMakeLists.txt index a279b0f..23515b4 100644 --- a/mlir/tools/mlir-opt/CMakeLists.txt +++ b/mlir/tools/mlir-opt/CMakeLists.txt @@ -17,6 +17,7 @@ target_link_libraries(MLIRMlirOptLib ${LIB_LIBS}) set(LIBS MLIRAffineOps + MLIRAffineToStandard MLIRLoopsToGPU MLIRAnalysis MLIRLoopToStandard -- 2.7.4