[mlir][NFC] Move the LoopLike interface out of Transforms/ and into Interfaces/
authorRiver Riddle <riddleriver@gmail.com>
Sat, 14 Mar 2020 20:36:42 +0000 (13:36 -0700)
committerRiver Riddle <riddleriver@gmail.com>
Sat, 14 Mar 2020 20:37:56 +0000 (13:37 -0700)
Differential Revision: https://reviews.llvm.org/D76155

15 files changed:
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/include/mlir/Interfaces/LoopLikeInterface.h [moved from mlir/include/mlir/Transforms/LoopLikeInterface.h with 70% similarity]
mlir/include/mlir/Interfaces/LoopLikeInterface.td [moved from mlir/include/mlir/Transforms/LoopLikeInterface.td with 90% similarity]
mlir/include/mlir/Transforms/CMakeLists.txt [deleted file]
mlir/lib/Dialect/AffineOps/CMakeLists.txt
mlir/lib/Dialect/LoopOps/CMakeLists.txt
mlir/lib/Interfaces/CMakeLists.txt
mlir/lib/Interfaces/LoopLikeInterface.cpp [new file with mode: 0644]
mlir/lib/Transforms/CMakeLists.txt
mlir/lib/Transforms/LoopInvariantCodeMotion.cpp

index 3672071..4754391 100644 (file)
@@ -1,4 +1,3 @@
 add_subdirectory(Dialect)
 add_subdirectory(IR)
 add_subdirectory(Interfaces)
-add_subdirectory(Transforms)
index 04fb6af..53a06fb 100644 (file)
@@ -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;
index 461ebf4..4b94cf2 100644 (file)
@@ -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";
index cf6e90b..f1fe8d5 100644 (file)
@@ -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 {
index 1fa69fa..462ec5d 100644 (file)
@@ -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";
index 4fe1871..e2513a6 100644 (file)
@@ -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)
 //
 //===----------------------------------------------------------------------===//
 
-#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_
@@ -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 (file)
index 9ac003a..0000000
+++ /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)
-
-
index 7ca63d4..bf490a5 100644 (file)
@@ -8,12 +8,12 @@ add_mlir_dialect_library(MLIRAffineOps
 
   DEPENDS
   MLIRAffineOpsIncGen
-  MLIRLoopLikeInterfaceIncGen
   )
 target_link_libraries(MLIRAffineOps
   PUBLIC
   MLIREDSC
   MLIRIR
+  MLIRLoopLikeInterface
   MLIRSideEffects
   MLIRStandardOps
   )
index 781dddb..44de8ad 100644 (file)
@@ -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
index ccbfcf8..853a03d 100644 (file)
@@ -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 (file)
index 0000000..4a0c5d3
--- /dev/null
@@ -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"
index 0200a0f..1cd89a3 100644 (file)
@@ -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
index 7300948..e616663 100644 (file)
@@ -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"
 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>();
 }