xref: /llvm-project/mlir/lib/Dialect/Transform/LoopExtension/LoopExtensionOps.cpp (revision 2c1ae801e1b66a09a15028ae4ba614e0911eec00)
1b9fe461eSMatthias Springer //===- LoopExtensionOps.cpp - Loop extension for the Transform dialect ----===//
2b9fe461eSMatthias Springer //
3b9fe461eSMatthias Springer // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4b9fe461eSMatthias Springer // See https://llvm.org/LICENSE.txt for license information.
5b9fe461eSMatthias Springer // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6b9fe461eSMatthias Springer //
7b9fe461eSMatthias Springer //===----------------------------------------------------------------------===//
8b9fe461eSMatthias Springer 
9b9fe461eSMatthias Springer #include "mlir/Dialect/Transform/LoopExtension/LoopExtensionOps.h"
10b9fe461eSMatthias Springer 
11b9fe461eSMatthias Springer #include "mlir/IR/OpImplementation.h"
12b9fe461eSMatthias Springer #include "mlir/IR/PatternMatch.h"
13b9fe461eSMatthias Springer #include "mlir/Transforms/LoopInvariantCodeMotionUtils.h"
14b9fe461eSMatthias Springer 
15b9fe461eSMatthias Springer using namespace mlir;
16b9fe461eSMatthias Springer 
17b9fe461eSMatthias Springer #define GET_OP_CLASSES
18b9fe461eSMatthias Springer #include "mlir/Dialect/Transform/LoopExtension/LoopExtensionOps.cpp.inc"
19b9fe461eSMatthias Springer 
20b9fe461eSMatthias Springer //===----------------------------------------------------------------------===//
21b9fe461eSMatthias Springer // HoistLoopInvariantSubsetsOp
22b9fe461eSMatthias Springer //===----------------------------------------------------------------------===//
23b9fe461eSMatthias Springer 
applyToOne(transform::TransformRewriter & rewriter,LoopLikeOpInterface loopLikeOp,transform::ApplyToEachResultList & results,transform::TransformState & state)24b9fe461eSMatthias Springer DiagnosedSilenceableFailure transform::HoistLoopInvariantSubsetsOp::applyToOne(
25b9fe461eSMatthias Springer     transform::TransformRewriter &rewriter, LoopLikeOpInterface loopLikeOp,
26b9fe461eSMatthias Springer     transform::ApplyToEachResultList &results,
27b9fe461eSMatthias Springer     transform::TransformState &state) {
28b9fe461eSMatthias Springer   hoistLoopInvariantSubsets(rewriter, loopLikeOp);
29b9fe461eSMatthias Springer   return DiagnosedSilenceableFailure::success();
30b9fe461eSMatthias Springer }
31b9fe461eSMatthias Springer 
getEffects(SmallVectorImpl<MemoryEffects::EffectInstance> & effects)32b9fe461eSMatthias Springer void transform::HoistLoopInvariantSubsetsOp::getEffects(
33b9fe461eSMatthias Springer     SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
34*2c1ae801Sdonald chen   transform::onlyReadsHandle(getTargetMutable(), effects);
35b9fe461eSMatthias Springer   transform::modifiesPayload(effects);
36b9fe461eSMatthias Springer }
37