1//===-- PassBase.td - Base 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 defining pass registration and other
10// mechanisms.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_PASS_PASSBASE
15#define MLIR_PASS_PASSBASE
16
17//===----------------------------------------------------------------------===//
18// Options
19//===----------------------------------------------------------------------===//
20
21class Option<string varName, string arg, string valueType, string default,
22             string desc, string additionalFlags = ""> {
23  // The name for the C++ option variable.
24  string cppName = varName;
25
26  // The command line argument to use for this option.
27  string argument = arg;
28
29  // The C++ type of the option.
30  string type = valueType;
31
32  // The default value of the option. "" corresponds to no default.
33  string defaultValue = default;
34
35  // A description for this option.
36  string description = desc;
37
38  // A set of additional flags to pass along to the option constructor.
39  string additionalOptFlags = additionalFlags;
40}
41
42class ListOption<string varName, string arg, string valueType,
43                 string desc, string additionalFlags = "">
44  : Option<varName, arg, valueType, /*default=*/"", desc, additionalFlags> {}
45
46//===----------------------------------------------------------------------===//
47// Statistics
48//===----------------------------------------------------------------------===//
49
50class Statistic<string varName, string statName, string desc> {
51  // The C++ variable name for the statistic.
52  string cppName = varName;
53
54  // The displayed name of the statistic, similar to the argument of an option.
55  string name = statName;
56
57  // The description of the statistic.
58  string description = desc;
59}
60
61//===----------------------------------------------------------------------===//
62// Pass
63//===----------------------------------------------------------------------===//
64
65class PassBase<string passArg, string base> {
66  // The command line argument of the pass.
67  string argument = passArg;
68
69  // The C++ base class for the pass.
70  string baseClass = base;
71
72  // A short 1-line summary of the pass.
73  string summary = "";
74
75  // A human readable description of the pass.
76  string description = "";
77
78  // A C++ constructor call to create an instance of this pass.
79  code constructor = [{}];
80
81  // A list of dialects this pass may produce entities in.
82  list<string> dependentDialects = [];
83
84  // A set of options provided by this pass.
85  list<Option> options = [];
86
87  // A set of statistics provided by this pass.
88  list<Statistic> statistics = [];
89}
90
91// This class represents an mlir::OperationPass.
92class Pass<string passArg, string operation = "">
93  : PassBase<passArg, "::mlir::OperationPass<" # operation # ">">;
94
95// This class represents an mlir::FunctionPass.
96class FunctionPass<string passArg> : PassBase<passArg, "::mlir::FunctionPass">;
97
98#endif // MLIR_PASS_PASSBASE
99