47 #include "llvm/ADT/DenseMap.h"
48 #include "llvm/Support/CommandLine.h"
53 #define GEN_PASS_DEF_AFFINELOOPUNROLLANDJAM
54 #include "mlir/Dialect/Affine/Passes.h.inc"
58 #define DEBUG_TYPE "affine-loop-unroll-jam"
66 struct LoopUnrollAndJam
67 :
public affine::impl::AffineLoopUnrollAndJamBase<LoopUnrollAndJam> {
68 explicit LoopUnrollAndJam(
69 std::optional<unsigned> unrollJamFactor = std::nullopt) {
71 this->unrollJamFactor = *unrollJamFactor;
74 void runOnOperation()
override;
78 std::unique_ptr<OperationPass<func::FuncOp>>
80 return std::make_unique<LoopUnrollAndJam>(
81 unrollJamFactor == -1 ? std::nullopt
82 : std::optional<unsigned>(unrollJamFactor));
85 void LoopUnrollAndJam::runOnOperation() {
86 if (getOperation().isExternal())
92 auto &entryBlock = getOperation().front();
93 if (
auto forOp = dyn_cast<AffineForOp>(entryBlock.front()))
LogicalResult loopUnrollJamByFactor(AffineForOp forOp, uint64_t unrollJamFactor)
Unrolls and jams this loop by the specified factor.
std::unique_ptr< OperationPass< func::FuncOp > > createLoopUnrollAndJamPass(int unrollJamFactor=-1)
Creates a loop unroll jam pass to unroll jam by the specified factor.
Include the generated interface declarations.