21 #define GEN_PASS_DEF_LOOPINVARIANTCODEMOTION
22 #define GEN_PASS_DEF_LOOPINVARIANTSUBSETHOISTING
23 #include "mlir/Transforms/Passes.h.inc"
30 struct LoopInvariantCodeMotion
31 :
public impl::LoopInvariantCodeMotionBase<LoopInvariantCodeMotion> {
32 void runOnOperation()
override;
35 struct LoopInvariantSubsetHoisting
36 :
public impl::LoopInvariantSubsetHoistingBase<
37 LoopInvariantSubsetHoisting> {
38 void runOnOperation()
override;
42 void LoopInvariantCodeMotion::runOnOperation() {
50 void LoopInvariantSubsetHoisting::runOnOperation() {
55 getOperation()->walk([&](LoopLikeOpInterface loopLike) {
61 return std::make_unique<LoopInvariantCodeMotion>();
65 return std::make_unique<LoopInvariantSubsetHoisting>();
static MLIRContext * getContext(OpFoldResult val)
This class coordinates rewriting a piece of IR outside of a pattern rewrite, providing a way to keep ...
Include the generated interface declarations.
LoopLikeOpInterface hoistLoopInvariantSubsets(RewriterBase &rewriter, LoopLikeOpInterface loopLike)
Hoist loop-invariant tensor subsets (subset extraction and subset insertion ops) from loop-like ops.
std::unique_ptr< Pass > createLoopInvariantCodeMotionPass()
Creates a loop invariant code motion pass that hoists loop invariant instructions out of the loop.
std::unique_ptr< Pass > createLoopInvariantSubsetHoistingPass()
Creates a pass that hoists loop-invariant subset ops.
size_t moveLoopInvariantCode(ArrayRef< Region * > regions, function_ref< bool(Value, Region *)> isDefinedOutsideRegion, function_ref< bool(Operation *, Region *)> shouldMoveOutOfRegion, function_ref< void(Operation *, Region *)> moveOutOfRegion)
Given a list of regions, perform loop-invariant code motion.