MLIR  19.0.0git
Pass.h
Go to the documentation of this file.
1 //===- Pass.h - TableGen pass definitions -----------------------*- 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 #ifndef MLIR_TABLEGEN_PASS_H_
10 #define MLIR_TABLEGEN_PASS_H_
11 
12 #include "mlir/Support/LLVM.h"
13 #include <vector>
14 
15 namespace llvm {
16 class Record;
17 } // namespace llvm
18 
19 namespace mlir {
20 namespace tblgen {
21 //===----------------------------------------------------------------------===//
22 // PassOption
23 //===----------------------------------------------------------------------===//
24 class PassOption {
25 public:
26  explicit PassOption(const llvm::Record *def) : def(def) {}
27 
28  /// Return the name for the C++ option variable.
29  StringRef getCppVariableName() const;
30 
31  /// Return the command line argument to use for this option.
32  StringRef getArgument() const;
33 
34  /// Return the C++ type of the option.
35  StringRef getType() const;
36 
37  /// Return the default value of the option.
38  std::optional<StringRef> getDefaultValue() const;
39 
40  /// Return the description for this option.
41  StringRef getDescription() const;
42 
43  /// Return the additional flags passed to the option constructor.
44  std::optional<StringRef> getAdditionalFlags() const;
45 
46  /// Flag indicating if this is a list option.
47  bool isListOption() const;
48 
49 private:
50  const llvm::Record *def;
51 };
52 
53 //===----------------------------------------------------------------------===//
54 // PassStatistic
55 //===----------------------------------------------------------------------===//
57 public:
58  explicit PassStatistic(const llvm::Record *def) : def(def) {}
59 
60  /// Return the name for the C++ statistic variable.
61  StringRef getCppVariableName() const;
62 
63  /// Return the name of the statistic.
64  StringRef getName() const;
65 
66  /// Return the description for this statistic.
67  StringRef getDescription() const;
68 
69 private:
70  const llvm::Record *def;
71 };
72 
73 //===----------------------------------------------------------------------===//
74 // Pass
75 //===----------------------------------------------------------------------===//
76 
77 /// Wrapper class providing helper methods for Passes defined in TableGen.
78 class Pass {
79 public:
80  explicit Pass(const llvm::Record *def);
81 
82  /// Return the command line argument of the pass.
83  StringRef getArgument() const;
84 
85  /// Return the name for the C++ base class.
86  StringRef getBaseClass() const;
87 
88  /// Return the short 1-line summary of the pass.
89  StringRef getSummary() const;
90 
91  /// Return the description of the pass.
92  StringRef getDescription() const;
93 
94  /// Return the C++ constructor call to create an instance of this pass.
95  StringRef getConstructor() const;
96 
97  /// Return the dialects this pass needs to be registered.
99 
100  /// Return the options provided by this pass.
102 
103  /// Return the statistics provided by this pass.
105 
106  const llvm::Record *getDef() const { return def; }
107 
108 private:
109  const llvm::Record *def;
110  std::vector<StringRef> dependentDialects;
111  std::vector<PassOption> options;
112  std::vector<PassStatistic> statistics;
113 };
114 
115 } // namespace tblgen
116 } // namespace mlir
117 
118 #endif // MLIR_TABLEGEN_PASS_H_
StringRef getType() const
Return the C++ type of the option.
Definition: Pass.cpp:27
PassOption(const llvm::Record *def)
Definition: Pass.h:26
std::optional< StringRef > getDefaultValue() const
Return the default value of the option.
Definition: Pass.cpp:29
StringRef getCppVariableName() const
Return the name for the C++ option variable.
Definition: Pass.cpp:19
StringRef getDescription() const
Return the description for this option.
Definition: Pass.cpp:34
StringRef getArgument() const
Return the command line argument to use for this option.
Definition: Pass.cpp:23
bool isListOption() const
Flag indicating if this is a list option.
Definition: Pass.cpp:43
std::optional< StringRef > getAdditionalFlags() const
Return the additional flags passed to the option constructor.
Definition: Pass.cpp:38
PassStatistic(const llvm::Record *def)
Definition: Pass.h:58
StringRef getName() const
Return the name of the statistic.
Definition: Pass.cpp:55
StringRef getCppVariableName() const
Return the name for the C++ statistic variable.
Definition: Pass.cpp:51
StringRef getDescription() const
Return the description for this statistic.
Definition: Pass.cpp:59
Wrapper class providing helper methods for Passes defined in TableGen.
Definition: Pass.h:78
ArrayRef< PassStatistic > getStatistics() const
Return the statistics provided by this pass.
StringRef getArgument() const
Return the command line argument of the pass.
ArrayRef< StringRef > getDependentDialects() const
Return the dialects this pass needs to be registered.
Definition: Pass.cpp:94
StringRef getConstructor() const
Return the C++ constructor call to create an instance of this pass.
Definition: Pass.cpp:90
const llvm::Record * getDef() const
Definition: Pass.h:106
StringRef getDescription() const
Return the description of the pass.
StringRef getBaseClass() const
Return the name for the C++ base class.
Definition: Pass.cpp:80
Pass(const llvm::Record *def)
Definition: Pass.cpp:67
StringRef getSummary() const
Return the short 1-line summary of the pass.
Definition: Pass.cpp:84
ArrayRef< PassOption > getOptions() const
Return the options provided by this pass.
Definition: Pass.cpp:98
Include the generated interface declarations.
Definition: CallGraph.h:229
Include the generated interface declarations.