MLIR 22.0.0git
Pass.cpp
Go to the documentation of this file.
1//===- Pass.cpp - Pass related classes ------------------------------------===//
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
10#include "llvm/TableGen/Record.h"
11
12using namespace mlir;
13using namespace mlir::tblgen;
14
15//===----------------------------------------------------------------------===//
16// PassOption
17//===----------------------------------------------------------------------===//
18
20 return def->getValueAsString("cppName");
21}
22
23StringRef PassOption::getArgument() const {
24 return def->getValueAsString("argument");
25}
26
27StringRef PassOption::getType() const { return def->getValueAsString("type"); }
28
29std::optional<StringRef> PassOption::getDefaultValue() const {
30 StringRef defaultVal = def->getValueAsString("defaultValue");
31 return defaultVal.empty() ? std::optional<StringRef>() : defaultVal;
32}
33
34StringRef PassOption::getDescription() const {
35 return def->getValueAsString("description");
36}
37
38std::optional<StringRef> PassOption::getAdditionalFlags() const {
39 StringRef additionalFlags = def->getValueAsString("additionalOptFlags");
40 return additionalFlags.empty() ? std::optional<StringRef>() : additionalFlags;
41}
42
44 return def->isSubClassOf("ListOption");
45}
46
47//===----------------------------------------------------------------------===//
48// PassStatistic
49//===----------------------------------------------------------------------===//
50
52 return def->getValueAsString("cppName");
53}
54
55StringRef PassStatistic::getName() const {
56 return def->getValueAsString("name");
57}
58
60 return def->getValueAsString("description");
61}
62
63//===----------------------------------------------------------------------===//
64// Pass
65//===----------------------------------------------------------------------===//
66
67Pass::Pass(const llvm::Record *def) : def(def) {
68 for (auto *init : def->getValueAsListOfDefs("options"))
69 options.emplace_back(init);
70 for (auto *init : def->getValueAsListOfDefs("statistics"))
71 statistics.emplace_back(init);
72 for (StringRef dialect : def->getValueAsListOfStrings("dependentDialects"))
73 dependentDialects.push_back(dialect);
74}
75
76StringRef Pass::getArgument() const {
77 return def->getValueAsString("argument");
78}
79
80StringRef Pass::getBaseClass() const {
81 return def->getValueAsString("baseClass");
82}
83
84StringRef Pass::getSummary() const { return def->getValueAsString("summary"); }
85
86StringRef Pass::getDescription() const {
87 return def->getValueAsString("description");
88}
89
90StringRef Pass::getConstructor() const {
91 return def->getValueAsString("constructor");
92}
93
95 return dependentDialects;
96}
97
98ArrayRef<PassOption> Pass::getOptions() const { return options; }
99
100ArrayRef<PassStatistic> Pass::getStatistics() const { return statistics; }
for(Operation *op :ops)
StringRef getType() const
Return the C++ type of the option.
Definition Pass.cpp:27
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
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
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
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< PassStatistic > getStatistics() const
Return the statistics provided by this pass.
ArrayRef< PassOption > getOptions() const
Return the options provided by this pass.
Definition Pass.cpp:98
Include the generated interface declarations.