1 //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This header file defines a set of transforms specific for the AffineOps 10 // dialect. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef MLIR_DIALECT_AFFINE_TRANSFORMS_PASSES_H 15 #define MLIR_DIALECT_AFFINE_TRANSFORMS_PASSES_H 16 17 #include "mlir/Pass/Pass.h" 18 #include <limits> 19 20 namespace mlir { 21 22 class AffineForOp; 23 24 /// Creates a simplification pass for affine structures (maps and sets). In 25 /// addition, this pass also normalizes memrefs to have the trivial (identity) 26 /// layout map. 27 std::unique_ptr<OperationPass<FuncOp>> createSimplifyAffineStructuresPass(); 28 29 /// Creates a loop invariant code motion pass that hoists loop invariant 30 /// operations out of affine loops. 31 std::unique_ptr<OperationPass<FuncOp>> 32 createAffineLoopInvariantCodeMotionPass(); 33 34 /// Creates a pass to convert all parallel affine.for's into 1-d affine.parallel 35 /// ops. 36 std::unique_ptr<OperationPass<FuncOp>> createAffineParallelizePass(); 37 38 /// Apply normalization transformations to affine loop-like ops. 39 std::unique_ptr<OperationPass<FuncOp>> createAffineLoopNormalizePass(); 40 41 /// Performs packing (or explicit copying) of accessed memref regions into 42 /// buffers in the specified faster memory space through either pointwise copies 43 /// or DMA operations. 44 std::unique_ptr<OperationPass<FuncOp>> createAffineDataCopyGenerationPass( 45 unsigned slowMemorySpace, unsigned fastMemorySpace, 46 unsigned tagMemorySpace = 0, int minDmaTransferSize = 1024, 47 uint64_t fastMemCapacityBytes = std::numeric_limits<uint64_t>::max()); 48 /// Overload relying on pass options for initialization. 49 std::unique_ptr<OperationPass<FuncOp>> createAffineDataCopyGenerationPass(); 50 51 /// Creates a pass to perform tiling on loop nests. 52 std::unique_ptr<OperationPass<FuncOp>> 53 createLoopTilingPass(uint64_t cacheSizeBytes); 54 /// Overload relying on pass options for initialization. 55 std::unique_ptr<OperationPass<FuncOp>> createLoopTilingPass(); 56 57 /// Creates a loop unrolling pass with the provided parameters. 58 /// 'getUnrollFactor' is a function callback for clients to supply a function 59 /// that computes an unroll factor - the callback takes precedence over unroll 60 /// factors supplied through other means. If -1 is passed as the unrollFactor 61 /// and no callback is provided, anything passed from the command-line (if at 62 /// all) or the default unroll factor is used (LoopUnroll:kDefaultUnrollFactor). 63 std::unique_ptr<OperationPass<FuncOp>> createLoopUnrollPass( 64 int unrollFactor = -1, bool unrollUpToFactor = false, 65 bool unrollFull = false, 66 const std::function<unsigned(AffineForOp)> &getUnrollFactor = nullptr); 67 68 /// Creates a loop unroll jam pass to unroll jam by the specified factor. A 69 /// factor of -1 lets the pass use the default factor or the one on the command 70 /// line if provided. 71 std::unique_ptr<OperationPass<FuncOp>> 72 createLoopUnrollAndJamPass(int unrollJamFactor = -1); 73 74 /// Creates a pass to vectorize loops, operations and data types using a 75 /// target-independent, n-D super-vector abstraction. 76 std::unique_ptr<OperationPass<FuncOp>> 77 createSuperVectorizePass(ArrayRef<int64_t> virtualVectorSize); 78 /// Overload relying on pass options for initialization. 79 std::unique_ptr<OperationPass<FuncOp>> createSuperVectorizePass(); 80 81 //===----------------------------------------------------------------------===// 82 // Registration 83 //===----------------------------------------------------------------------===// 84 85 /// Generate the code for registering passes. 86 #define GEN_PASS_REGISTRATION 87 #include "mlir/Dialect/Affine/Passes.h.inc" 88 89 } // end namespace mlir 90 91 #endif // MLIR_DIALECT_AFFINE_RANSFORMS_PASSES_H 92