• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===-- Passes.td - Affine pass definition file ------------*- tablegen -*-===//
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 file contains definitions for passes within the Affine/ directory.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_DIALECT_AFFINE_PASSES
14#define MLIR_DIALECT_AFFINE_PASSES
15
16include "mlir/Pass/PassBase.td"
17
18def AffineDataCopyGeneration : FunctionPass<"affine-data-copy-generate"> {
19  let summary = "Generate explicit copying for affine memory operations";
20  let constructor = "mlir::createAffineDataCopyGenerationPass()";
21  let options = [
22    Option<"fastMemoryCapacity", "fast-mem-capacity", "uint64_t",
23           /*default=*/"std::numeric_limits<uint64_t>::max()",
24           "Set fast memory space capacity in KiB (default: unlimited)">,
25    Option<"fastMemorySpace", "fast-mem-space", "unsigned",
26           /*default=*/"1",
27           "Fast memory space identifier for copy generation (default: 1)">,
28    Option<"generateDma", "generate-dma", "bool",
29           /*default=*/"true", "Generate DMA instead of point-wise copy">,
30    Option<"minDmaTransferSize", "min-dma-transfer", "int",
31           /*default=*/"1024",
32           "Minimum DMA transfer size supported by the target in bytes">,
33    Option<"slowMemorySpace", "slow-mem-space", "unsigned",
34           /*default=*/"0",
35           "Slow memory space identifier for copy generation (default: 0)">,
36    Option<"skipNonUnitStrideLoops", "skip-non-unit-stride-loops", "bool",
37           /*default=*/"false", "Testing purposes: avoid non-unit stride loop "
38                                "choice depths for copy placement">,
39    Option<"tagMemorySpace", "tag-mem-space", "unsigned",
40           /*default=*/"0",
41           "Tag memory space identifier for copy generation (default: 0)">,
42  ];
43}
44
45def AffineLoopInvariantCodeMotion
46    : FunctionPass<"affine-loop-invariant-code-motion"> {
47  let summary = "Hoist loop invariant instructions outside of affine loops";
48  let constructor = "mlir::createAffineLoopInvariantCodeMotionPass()";
49}
50
51def AffineLoopTiling : FunctionPass<"affine-loop-tile"> {
52  let summary = "Tile affine loop nests";
53  let constructor = "mlir::createLoopTilingPass()";
54  let options = [
55    Option<"cacheSizeInKiB", "cache-size", "uint64_t", /*default=*/"512",
56           "Set size of cache to tile for in KiB">,
57    Option<"separate", "separate", "bool", /*default=*/"",
58           "Separate full and partial tiles">,
59    Option<"tileSize", "tile-size", "unsigned", /*default=*/"",
60           "Use this tile size for all loops">,
61    ListOption<"tileSizes", "tile-sizes", "unsigned",
62               "List of tile sizes for each perfect nest "
63               "(overridden by -tile-size)",
64               "llvm::cl::ZeroOrMore">,
65  ];
66}
67
68def AffineLoopUnroll : FunctionPass<"affine-loop-unroll"> {
69  let summary = "Unroll affine loops";
70  let constructor = "mlir::createLoopUnrollPass()";
71  let options = [
72    Option<"unrollFactor", "unroll-factor", "unsigned", /*default=*/"4",
73           "Use this unroll factor for all loops being unrolled">,
74    Option<"unrollUpToFactor", "unroll-up-to-factor", "bool",
75           /*default=*/"false", "Allow unrolling up to the factor specified">,
76    Option<"unrollFull", "unroll-full", "bool", /*default=*/"false",
77           "Fully unroll loops">,
78    Option<"numRepetitions", "unroll-num-reps", "unsigned", /*default=*/"1",
79           "Unroll innermost loops repeatedly this many times">,
80    Option<"unrollFullThreshold", "unroll-full-threshold", "unsigned",
81           /*default=*/"1",
82           "Unroll all loops with trip count less than or equal to this">,
83  ];
84}
85
86def AffineLoopUnrollAndJam : FunctionPass<"affine-loop-unroll-jam"> {
87  let summary = "Unroll and jam affine loops";
88  let constructor = "mlir::createLoopUnrollAndJamPass()";
89  let options = [
90    Option<"unrollJamFactor", "unroll-jam-factor", "unsigned",
91           /*default=*/"4",
92           "Use this unroll jam factor for all loops (default 4)">,
93  ];
94}
95
96def AffineVectorize : FunctionPass<"affine-super-vectorize"> {
97  let summary = "Vectorize to a target independent n-D vector abstraction";
98  let constructor = "mlir::createSuperVectorizePass()";
99  let dependentDialects = ["vector::VectorDialect"];
100  let options = [
101    ListOption<"vectorSizes", "virtual-vector-size", "int64_t",
102               "Specify an n-D virtual vector size for vectorization",
103               "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated">,
104    // Optionally, the fixed mapping from loop to fastest varying MemRef
105    // dimension for all the MemRefs within a loop pattern:
106    //   the index represents the loop depth, the value represents the k^th
107    //   fastest varying memory dimension.
108    // This is voluntarily restrictive and is meant to precisely target a
109    // particular loop/op pair, for testing purposes.
110    ListOption<"fastestVaryingPattern", "test-fastest-varying", "int64_t",
111               "Specify a 1-D, 2-D or 3-D pattern of fastest varying memory "
112               "dimensions to match. See defaultPatterns in Vectorize.cpp for "
113               "a description and examples. This is used for testing purposes",
114               "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated">
115  ];
116}
117
118def AffineParallelize : FunctionPass<"affine-parallelize"> {
119  let summary = "Convert affine.for ops into 1-D affine.parallel";
120  let constructor = "mlir::createAffineParallelizePass()";
121  let options = [
122    Option<"maxNested", "max-nested", "unsigned", /*default=*/"-1u",
123           "Maximum number of nested parallel loops to produce. "
124           "Defaults to unlimited (UINT_MAX).">,
125  ];
126}
127
128def AffineLoopNormalize : FunctionPass<"affine-loop-normalize"> {
129  let summary = "Apply normalization transformations to affine loop-like ops";
130  let constructor = "mlir::createAffineLoopNormalizePass()";
131}
132
133def SimplifyAffineStructures : FunctionPass<"simplify-affine-structures"> {
134  let summary = "Simplify affine expressions in maps/sets and normalize "
135                "memrefs";
136  let constructor = "mlir::createSimplifyAffineStructuresPass()";
137}
138
139#endif // MLIR_DIALECT_AFFINE_PASSES
140