aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiver Riddle <riddleriver@gmail.com>2020-03-14 13:36:42 -0700
committerRiver Riddle <riddleriver@gmail.com>2020-03-14 13:37:56 -0700
commit43959a25927699def4feef8b9b9b25931118e887 (patch)
tree9e55300ebc1cabc27b58bbc519a129a38072020a
parenteda58ac04cfa95298583223ba6779916e4721550 (diff)
downloadllvm-43959a25927699def4feef8b9b9b25931118e887.zip
llvm-43959a25927699def4feef8b9b9b25931118e887.tar.gz
llvm-43959a25927699def4feef8b9b9b25931118e887.tar.bz2
[mlir][NFC] Move the LoopLike interface out of Transforms/ and into Interfaces/
Differential Revision: https://reviews.llvm.org/D76155
-rw-r--r--mlir/include/mlir/CMakeLists.txt1
-rw-r--r--mlir/include/mlir/Dialect/AffineOps/AffineOps.h2
-rw-r--r--mlir/include/mlir/Dialect/AffineOps/AffineOps.td2
-rw-r--r--mlir/include/mlir/Dialect/LoopOps/LoopOps.h2
-rw-r--r--mlir/include/mlir/Dialect/LoopOps/LoopOps.td2
-rw-r--r--mlir/include/mlir/Interfaces/CMakeLists.txt5
-rw-r--r--mlir/include/mlir/Interfaces/LoopLikeInterface.h (renamed from mlir/include/mlir/Transforms/LoopLikeInterface.h)10
-rw-r--r--mlir/include/mlir/Interfaces/LoopLikeInterface.td (renamed from mlir/include/mlir/Transforms/LoopLikeInterface.td)8
-rw-r--r--mlir/include/mlir/Transforms/CMakeLists.txt6
-rw-r--r--mlir/lib/Dialect/AffineOps/CMakeLists.txt2
-rw-r--r--mlir/lib/Dialect/LoopOps/CMakeLists.txt2
-rw-r--r--mlir/lib/Interfaces/CMakeLists.txt15
-rw-r--r--mlir/lib/Interfaces/LoopLikeInterface.cpp18
-rw-r--r--mlir/lib/Transforms/CMakeLists.txt2
-rw-r--r--mlir/lib/Transforms/LoopInvariantCodeMotion.cpp11
15 files changed, 55 insertions, 33 deletions
diff --git a/mlir/include/mlir/CMakeLists.txt b/mlir/include/mlir/CMakeLists.txt
index 3672071..4754391 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 04fb6af..53a06fbf 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 461ebf4..4b94cf2 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 cf6e90b..f1fe8d5 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 1fa69fa..462ec5d 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 4fe1871..e2513a6 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
index 7474f6c..5891470 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
index c3c98a8..cc05030 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 9ac003a..0000000
--- 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 7ca63d4..bf490a5 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 781dddb..44de8ad 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 ccbfcf8..853a03d3 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 0000000..4a0c5d3
--- /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 0200a0f..1cd89a3 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 7300948..e616663 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>();
}