add_subdirectory(Dialect)
add_subdirectory(IR)
add_subdirectory(Interfaces)
-add_subdirectory(Transforms)
#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;
#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";
#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 {
#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";
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_
//
//===----------------------------------------------------------------------===//
//
-// 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"
];
}
-#endif // MLIR_LOOPLIKEINTERFACE
+#endif // MLIR_INTERFACES_LOOPLIKEINTERFACE
+++ /dev/null
-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)
-
-
DEPENDS
MLIRAffineOpsIncGen
- MLIRLoopLikeInterfaceIncGen
)
target_link_libraries(MLIRAffineOps
PUBLIC
MLIREDSC
MLIRIR
+ MLIRLoopLikeInterface
MLIRSideEffects
MLIRStandardOps
)
${MLIR_MAIN_INCLUDE_DIR}/mlir/LoopOps
DEPENDS
- MLIRLoopLikeInterfaceIncGen
MLIRLoopOpsIncGen
)
target_link_libraries(MLIRLoopOps
PUBLIC
MLIREDSC
MLIRIR
+ MLIRLoopLikeInterface
MLIRSideEffects
MLIRStandardOps
LLVMSupport
ControlFlowInterfaces.cpp
DerivedAttributeOpInterface.cpp
InferTypeOpInterface.cpp
+ LoopLikeInterface.cpp
SideEffects.cpp
)
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
--- /dev/null
+//===- 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"
${MLIR_MAIN_INCLUDE_DIR}/mlir/Transforms
DEPENDS
- MLIRLoopLikeInterfaceIncGen
MLIRStandardOpsIncGen
)
PUBLIC
MLIRAffineOps
MLIRAnalysis
+ MLIRLoopLikeInterface
MLIRLoopOps
MLIRPass
MLIRTransformUtils
#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
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
});
}
-// 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>();
}