xref: /llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/Passes.td (revision 5468f8841353cd56350a6ebe6898d2563e5c34b0)
1//===-- Passes.td - Transform dialect pass definitions -----*- 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#ifndef MLIR_DIALECT_TRANSFORM_TRANSFORMS_PASSES
10#define MLIR_DIALECT_TRANSFORM_TRANSFORMS_PASSES
11
12include "mlir/Pass/PassBase.td"
13
14def CheckUsesPass : Pass<"transform-dialect-check-uses"> {
15  let summary = "warn about potential use-after-free in the transform dialect";
16  let description = [{
17    This pass analyzes operations from the transform dialect and its extensions
18    and warns if a transform IR value may be used by an operation after it was
19    "freed" by some other operation, as described by side effects on the
20    `TransformMappingResource`. This statically detects situations that lead to
21    errors when interpreting the Transform IR.
22
23    The pass is capable of handling branching control flow and reports all
24    _potential_ use-after-free situations, e.g., a may-use-after-free is
25    reported if at least one of the control flow paths between the definition of
26    a value and its use contains an operation with a "free" effect on the
27    `TransformMappingResource`. It does not currently perform an SCCP-style data
28    flow analysis to prove that some branches are not taken, however, SCCP and
29    other control flow simplifications can be performed on the transform IR
30    prior to this pass provided that transform ops implement the relevant
31    control flow interfaces.
32  }];
33}
34
35def InferEffectsPass : Pass<"transform-infer-effects"> {
36  let summary = "infer transform side effects for symbols";
37  let description = [{
38    This pass analyzes the definitions of transform dialect callable symbol
39    operations, such as `transform.named_sequence`, and annotates the symbol
40    arguments with attributes indicating the side effects that the nested
41    operations have on them.
42  }];
43}
44
45def PreloadLibraryPass : Pass<"transform-preload-library"> {
46  let summary = "preload transform dialect library";
47  let description = [{
48    This pass preloads a transform library and makes it available to subsequent
49    transform interpreter passes. The preloading occurs into the Transform
50    dialect and thus provides very limited functionality that does not scale.
51
52    Warning: Only a single such pass should exist for a given MLIR context.
53    This is a temporary solution until a resource-based solution is available.
54  }];
55  // TODO: investigate using a resource blob if some ownership mode allows it.
56  let dependentDialects = ["::mlir::transform::TransformDialect"];
57  let options = [
58    ListOption<"transformLibraryPaths", "transform-library-paths", "std::string",
59    "Optional paths to files with modules that should be merged into the "
60    "transform module to provide the definitions of external named sequences.">
61  ];
62}
63
64def InterpreterPass : Pass<"transform-interpreter"> {
65  let summary = "transform dialect interpreter";
66  let description = [{
67    This pass runs the transform dialect interpreter and applies the named
68    sequence transformation specified by the provided name (defaults to
69    `TransformDialect::kTransformEntryPointSymbolName`,
70    i.e. `__transform_main`).
71
72    Additional options can be used to narrow down the pass applicability for
73    debugging purposes:
74      * `debugPayloadRootTag` makes the transform script apply to the payload
75        operation that has a `transform.target_tag` string attribute with the
76        given value, rather than to the anchor operation of the pass.
77      * `debugBindTrailingArgs` allows one to bind values to trailing arguments
78        of the transform entry point as follows:
79        * arguments of `TransformHandleTypeInterface` type can be bound to all
80          payload operations with the name provided as a simple string;
81        * arguments of `TransformValueHandleTypeInterface` type can be bound to
82          a flattened list of results of all operations with the name provided
83          as a string prefixed with `^`;
84        * arguments of `TransformParamTypeInterface` type can be bound to
85          integer constants provided as `;`-separated list prefixed with `#`.
86      * `entryPoint` specifies the name of the transform symbol to serve as the
87        entry point.
88  }];
89  let dependentDialects = ["::mlir::transform::TransformDialect"];
90  let options = [
91    Option<"debugPayloadRootTag", "debug-payload-root-tag", "std::string",
92           /*default=*/[{""}],
93           "Select the operation with 'transform.target_tag' attribute having "
94           "the given value as payload IR root. If empty select the pass "
95           "anchor operation as the payload IR root.">,
96    ListOption<"debugBindTrailingArgs", "debug-bind-trailing-args",
97               "std::string",
98               "Binds trailing arguments of the entry point to the payload "
99               "operations with specified names.">,
100    Option<"disableExpensiveChecks", "disable-expensive-checks", "bool",
101           "false",
102           "Disable expensive checks in the interpreter for a faster run.">,
103    Option<"entryPoint", "entry-point", "std::string",
104           /*default=*/[{
105              TransformDialect::kTransformEntryPointSymbolName.str()
106            }],
107           "Entry point of the pass pipeline.">,
108  ];
109}
110#endif // MLIR_DIALECT_TRANSFORM_TRANSFORMS_PASSES
111