[Mlir-commits] [mlir] 43959a2 - [mlir][NFC] Move the LoopLike interface out of Transforms/ and into Interfaces/
River Riddle
llvmlistbot at llvm.org
Sat Mar 14 13:41:55 PDT 2020
Author: River Riddle
Date: 2020-03-14T13:37:56-07:00
New Revision: 43959a25927699def4feef8b9b9b25931118e887
URL: https://github.com/llvm/llvm-project/commit/43959a25927699def4feef8b9b9b25931118e887
DIFF: https://github.com/llvm/llvm-project/commit/43959a25927699def4feef8b9b9b25931118e887.diff
LOG: [mlir][NFC] Move the LoopLike interface out of Transforms/ and into Interfaces/
Differential Revision: https://reviews.llvm.org/D76155
Added:
mlir/include/mlir/Interfaces/LoopLikeInterface.h
mlir/include/mlir/Interfaces/LoopLikeInterface.td
mlir/lib/Interfaces/LoopLikeInterface.cpp
Modified:
mlir/include/mlir/CMakeLists.txt
mlir/include/mlir/Dialect/AffineOps/AffineOps.h
mlir/include/mlir/Dialect/AffineOps/AffineOps.td
mlir/include/mlir/Dialect/LoopOps/LoopOps.h
mlir/include/mlir/Dialect/LoopOps/LoopOps.td
mlir/include/mlir/Interfaces/CMakeLists.txt
mlir/lib/Dialect/AffineOps/CMakeLists.txt
mlir/lib/Dialect/LoopOps/CMakeLists.txt
mlir/lib/Interfaces/CMakeLists.txt
mlir/lib/Transforms/CMakeLists.txt
mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
Removed:
mlir/include/mlir/Transforms/CMakeLists.txt
mlir/include/mlir/Transforms/LoopLikeInterface.h
mlir/include/mlir/Transforms/LoopLikeInterface.td
################################################################################
diff --git a/mlir/include/mlir/CMakeLists.txt b/mlir/include/mlir/CMakeLists.txt
index 367207157415..4754391dc39f 100644
--- a/mlir/include/mlir/CMakeLists.txt
+++ b/mlir/include/mlir/CMakeLists.txt
@@ -1,4 +1,3 @@
add_subdirectory(Dialect)
add_subdirectory(IR)
add_subdirectory(Interfaces)
-add_subdirectory(Transforms)
diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h
index 04fb6afc046e..53a06fbf89f7 100644
--- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h
+++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h
@@ -19,8 +19,8 @@
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/StandardTypes.h"
+#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Interfaces/SideEffects.h"
-#include "mlir/Transforms/LoopLikeInterface.h"
namespace mlir {
class AffineApplyOp;
diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td
index 461ebf4acc85..4b94cf2530a4 100644
--- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td
+++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td
@@ -14,8 +14,8 @@
#define AFFINE_OPS
include "mlir/Dialect/AffineOps/AffineOpsBase.td"
+include "mlir/Interfaces/LoopLikeInterface.td"
include "mlir/Interfaces/SideEffects.td"
-include "mlir/Transforms/LoopLikeInterface.td"
def Affine_Dialect : Dialect {
let name = "affine";
diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h b/mlir/include/mlir/Dialect/LoopOps/LoopOps.h
index cf6e90bee362..f1fe8d5c12b0 100644
--- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h
+++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.h
@@ -17,8 +17,8 @@
#include "mlir/IR/Builders.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
+#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Interfaces/SideEffects.h"
-#include "mlir/Transforms/LoopLikeInterface.h"
namespace mlir {
namespace loop {
diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td
index 1fa69fabfc95..462ec5ddb7f1 100644
--- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td
+++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td
@@ -13,8 +13,8 @@
#ifndef LOOP_OPS
#define LOOP_OPS
+include "mlir/Interfaces/LoopLikeInterface.td"
include "mlir/Interfaces/SideEffects.td"
-include "mlir/Transforms/LoopLikeInterface.td"
def Loop_Dialect : Dialect {
let name = "loop";
diff --git a/mlir/include/mlir/Interfaces/CMakeLists.txt b/mlir/include/mlir/Interfaces/CMakeLists.txt
index 4fe1871ad40c..e2513a69b893 100644
--- a/mlir/include/mlir/Interfaces/CMakeLists.txt
+++ b/mlir/include/mlir/Interfaces/CMakeLists.txt
@@ -18,6 +18,11 @@ mlir_tablegen(InferTypeOpInterface.h.inc -gen-op-interface-decls)
mlir_tablegen(InferTypeOpInterface.cpp.inc -gen-op-interface-defs)
add_public_tablegen_target(MLIRInferTypeOpInterfaceIncGen)
+set(LLVM_TARGET_DEFINITIONS LoopLikeInterface.td)
+mlir_tablegen(LoopLikeInterface.h.inc -gen-op-interface-decls)
+mlir_tablegen(LoopLikeInterface.cpp.inc -gen-op-interface-defs)
+add_public_tablegen_target(MLIRLoopLikeInterfaceIncGen)
+
set(LLVM_TARGET_DEFINITIONS SideEffects.td)
mlir_tablegen(SideEffectInterfaces.h.inc -gen-op-interface-decls)
mlir_tablegen(SideEffectInterfaces.cpp.inc -gen-op-interface-defs)
diff --git a/mlir/include/mlir/Transforms/LoopLikeInterface.h b/mlir/include/mlir/Interfaces/LoopLikeInterface.h
similarity index 70%
rename from mlir/include/mlir/Transforms/LoopLikeInterface.h
rename to mlir/include/mlir/Interfaces/LoopLikeInterface.h
index 7474f6c9ed11..5891470c9c6e 100644
--- a/mlir/include/mlir/Transforms/LoopLikeInterface.h
+++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.h
@@ -10,17 +10,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_TRANSFORMS_LOOPLIKEINTERFACE_H_
-#define MLIR_TRANSFORMS_LOOPLIKEINTERFACE_H_
+#ifndef MLIR_INTERFACES_LOOPLIKEINTERFACE_H_
+#define MLIR_INTERFACES_LOOPLIKEINTERFACE_H_
#include "mlir/IR/OpDefinition.h"
-#include "mlir/Support/LogicalResult.h"
-#include "llvm/ADT/ArrayRef.h"
namespace mlir {
-#include "mlir/Transforms/LoopLikeInterface.h.inc"
+#include "mlir/Interfaces/LoopLikeInterface.h.inc"
} // namespace mlir
-#endif // MLIR_TRANSFORMS_LOOPLIKEINTERFACE_H_
+#endif // MLIR_INTERFACES_LOOPLIKEINTERFACE_H_
diff --git a/mlir/include/mlir/Transforms/LoopLikeInterface.td b/mlir/include/mlir/Interfaces/LoopLikeInterface.td
similarity index 90%
rename from mlir/include/mlir/Transforms/LoopLikeInterface.td
rename to mlir/include/mlir/Interfaces/LoopLikeInterface.td
index c3c98a87c11f..cc05030352e7 100644
--- a/mlir/include/mlir/Transforms/LoopLikeInterface.td
+++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.td
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
//
-// Defines the interface for loop-like operations as used by LICM.
+// Defines the interface for loop-like operations.
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_LOOPLIKEINTERFACE
-#define MLIR_LOOPLIKEINTERFACE
+#ifndef MLIR_INTERFACES_LOOPLIKEINTERFACE
+#define MLIR_INTERFACES_LOOPLIKEINTERFACE
include "mlir/IR/OpBase.td"
@@ -46,4 +46,4 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
];
}
-#endif // MLIR_LOOPLIKEINTERFACE
+#endif // MLIR_INTERFACES_LOOPLIKEINTERFACE
diff --git a/mlir/include/mlir/Transforms/CMakeLists.txt b/mlir/include/mlir/Transforms/CMakeLists.txt
deleted file mode 100644
index 9ac003a4140c..000000000000
--- a/mlir/include/mlir/Transforms/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-set(LLVM_TARGET_DEFINITIONS LoopLikeInterface.td)
-mlir_tablegen(LoopLikeInterface.h.inc -gen-op-interface-decls)
-mlir_tablegen(LoopLikeInterface.cpp.inc -gen-op-interface-defs)
-add_public_tablegen_target(MLIRLoopLikeInterfaceIncGen)
-
-
diff --git a/mlir/lib/Dialect/AffineOps/CMakeLists.txt b/mlir/lib/Dialect/AffineOps/CMakeLists.txt
index 7ca63d45785a..bf490a5c9795 100644
--- a/mlir/lib/Dialect/AffineOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/AffineOps/CMakeLists.txt
@@ -8,12 +8,12 @@ add_mlir_dialect_library(MLIRAffineOps
DEPENDS
MLIRAffineOpsIncGen
- MLIRLoopLikeInterfaceIncGen
)
target_link_libraries(MLIRAffineOps
PUBLIC
MLIREDSC
MLIRIR
+ MLIRLoopLikeInterface
MLIRSideEffects
MLIRStandardOps
)
diff --git a/mlir/lib/Dialect/LoopOps/CMakeLists.txt b/mlir/lib/Dialect/LoopOps/CMakeLists.txt
index 781dddb58cff..44de8ada2150 100644
--- a/mlir/lib/Dialect/LoopOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/LoopOps/CMakeLists.txt
@@ -7,13 +7,13 @@ add_mlir_dialect_library(MLIRLoopOps
${MLIR_MAIN_INCLUDE_DIR}/mlir/LoopOps
DEPENDS
- MLIRLoopLikeInterfaceIncGen
MLIRLoopOpsIncGen
)
target_link_libraries(MLIRLoopOps
PUBLIC
MLIREDSC
MLIRIR
+ MLIRLoopLikeInterface
MLIRSideEffects
MLIRStandardOps
LLVMSupport
diff --git a/mlir/lib/Interfaces/CMakeLists.txt b/mlir/lib/Interfaces/CMakeLists.txt
index ccbfcf83b429..853a03d3cbad 100644
--- a/mlir/lib/Interfaces/CMakeLists.txt
+++ b/mlir/lib/Interfaces/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_OPTIONAL_SOURCES
ControlFlowInterfaces.cpp
DerivedAttributeOpInterface.cpp
InferTypeOpInterface.cpp
+ LoopLikeInterface.cpp
SideEffects.cpp
)
@@ -62,6 +63,20 @@ target_link_libraries(MLIRInferTypeOpInterface
MLIRIR
)
+add_llvm_library(MLIRLoopLikeInterface
+ LoopLikeInterface.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${MLIR_MAIN_INCLUDE_DIR}/mlir/Interfaces
+ )
+add_dependencies(MLIRLoopLikeInterface
+ MLIRLoopLikeInterfaceIncGen
+ )
+target_link_libraries(MLIRLoopLikeInterface
+ PUBLIC
+ MLIRIR
+ )
+
add_llvm_library(MLIRSideEffects
SideEffects.cpp
diff --git a/mlir/lib/Interfaces/LoopLikeInterface.cpp b/mlir/lib/Interfaces/LoopLikeInterface.cpp
new file mode 100644
index 000000000000..4a0c5d3a1876
--- /dev/null
+++ b/mlir/lib/Interfaces/LoopLikeInterface.cpp
@@ -0,0 +1,18 @@
+//===- LoopLikeInterface.cpp - Loop-like operations in MLIR ---------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Interfaces/LoopLikeInterface.h"
+
+using namespace mlir;
+
+//===----------------------------------------------------------------------===//
+// LoopLike Interfaces
+//===----------------------------------------------------------------------===//
+
+/// Include the definitions of the loop-like interfaces.
+#include "mlir/Interfaces/LoopLikeInterface.cpp.inc"
diff --git a/mlir/lib/Transforms/CMakeLists.txt b/mlir/lib/Transforms/CMakeLists.txt
index 0200a0f7d528..1cd89a334eef 100644
--- a/mlir/lib/Transforms/CMakeLists.txt
+++ b/mlir/lib/Transforms/CMakeLists.txt
@@ -28,7 +28,6 @@ add_mlir_library(MLIRTransforms
${MLIR_MAIN_INCLUDE_DIR}/mlir/Transforms
DEPENDS
- MLIRLoopLikeInterfaceIncGen
MLIRStandardOpsIncGen
)
@@ -36,6 +35,7 @@ target_link_libraries(MLIRTransforms
PUBLIC
MLIRAffineOps
MLIRAnalysis
+ MLIRLoopLikeInterface
MLIRLoopOps
MLIRPass
MLIRTransformUtils
diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
index 73009484e7d9..e616663e11fc 100644
--- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
+++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
@@ -14,9 +14,9 @@
#include "mlir/IR/Builders.h"
#include "mlir/IR/Function.h"
+#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Interfaces/SideEffects.h"
#include "mlir/Pass/Pass.h"
-#include "mlir/Transforms/LoopLikeInterface.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
@@ -26,12 +26,12 @@
using namespace mlir;
namespace {
-
/// Loop invariant code motion (LICM) pass.
struct LoopInvariantCodeMotion : public OperationPass<LoopInvariantCodeMotion> {
public:
void runOnOperation() override;
};
+} // end anonymous namespace
// Checks whether the given op can be hoisted by checking that
// - the op and any of its contained operations do not depend on SSA values
@@ -107,8 +107,6 @@ static LogicalResult moveLoopInvariantCode(LoopLikeOpInterface looplike) {
return result;
}
-} // end anonymous namespace
-
void LoopInvariantCodeMotion::runOnOperation() {
// Walk through all loops in a function in innermost-loop-first order. This
// way, we first LICM from the inner loop, and place the ops in
@@ -120,11 +118,6 @@ void LoopInvariantCodeMotion::runOnOperation() {
});
}
-// Include the generated code for the loop-like interface here, as it otherwise
-// has no compilation unit. This works as loop-invariant code motion is the
-// only user of that interface.
-#include "mlir/Transforms/LoopLikeInterface.cpp.inc"
-
std::unique_ptr<Pass> mlir::createLoopInvariantCodeMotionPass() {
return std::make_unique<LoopInvariantCodeMotion>();
}
More information about the Mlir-commits
mailing list