• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===-- Passes.td - StandardOps 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#ifndef MLIR_DIALECT_STANDARD_TRANSFORMS_PASSES
10#define MLIR_DIALECT_STANDARD_TRANSFORMS_PASSES
11
12include "mlir/Pass/PassBase.td"
13
14def StdBufferize : FunctionPass<"std-bufferize"> {
15  let summary = "Bufferize the std dialect";
16  let constructor = "mlir::createStdBufferizePass()";
17  let dependentDialects = ["scf::SCFDialect"];
18}
19
20def StdExpandOps : FunctionPass<"std-expand"> {
21  let summary = "Legalize std operations to be convertible to LLVM.";
22  let constructor = "mlir::createStdExpandOpsPass()";
23}
24
25def FuncBufferize : Pass<"func-bufferize", "ModuleOp"> {
26  let summary = "Bufferize func/call/return ops";
27  let description = [{
28    A bufferize pass that bufferizes std.func and std.call ops.
29
30    Because this pass updates std.func ops, it must be a module pass. It is
31    useful to keep this pass separate from other bufferizations so that the
32    other ones can be run at function-level in parallel.
33
34    This pass must be done atomically because it changes func op signatures,
35    which requires atomically updating calls as well throughout the entire
36    module.
37
38    This pass also changes the type of block arguments, which requires that all
39    successor arguments of predecessors be converted. This is achieved by
40    rewriting terminators based on the information provided by the
41    `BranchOpInterface`.
42    As this pass rewrites function operations, it also rewrites the
43    corresponding return operations. Other return-like operations that
44    implement the `ReturnLike` trait are not rewritten in general, as they
45    require that the correspondign parent operation is also rewritten.
46    Finally, this pass fails for unknown terminators, as we cannot decide
47    whether they need rewriting.
48  }];
49  let constructor = "mlir::createFuncBufferizePass()";
50}
51
52def TensorConstantBufferize : Pass<"tensor-constant-bufferize", "ModuleOp"> {
53  let summary = "Bufferize tensor constants.";
54  let description = [{
55    This pass bufferizes tensor constants.
56
57    This pass needs to be a module pass because it inserts std.global_memref
58    ops into the module, which cannot be done safely from a function pass due to
59    multi-threading. Most other bufferization passes can run in parallel at
60    function granularity.
61  }];
62  let constructor = "mlir::createTensorConstantBufferizePass()";
63}
64
65#endif // MLIR_DIALECT_STANDARD_TRANSFORMS_PASSES
66