18#ifndef LLVM_SANDBOXIR_PASSMANAGER_H
19#define LLVM_SANDBOXIR_PASSMANAGER_H
33template <
typename ParentPass,
typename ContainedPass>
77 static constexpr const char EndToken =
'\0';
78 static constexpr const char BeginArgsToken =
'<';
79 static constexpr const char EndArgsToken =
'>';
80 static constexpr const char PassDelimToken =
',';
83 "setPassPipeline called on a non-empty sandboxir::PassManager");
92 std::string PipelineStr = std::string(Pipeline) + EndToken;
97 errs() <<
"Found empty pass name.\n";
103 if (
Pass ==
nullptr) {
104 errs() <<
"Pass '" <<
PassName <<
"' not registered!\n";
114 } CurrentState = State::ScanName;
115 int PassBeginIdx = 0;
120 switch (CurrentState) {
121 case State::ScanName:
122 if (
C == BeginArgsToken) {
125 ArgsBeginIdx =
Idx + 1;
127 CurrentState = State::ScanArgs;
130 if (
C == EndArgsToken) {
131 errs() <<
"Unexpected '>' in pass pipeline.\n";
134 if (
C == EndToken ||
C == PassDelimToken) {
138 PassBeginIdx =
Idx + 1;
141 case State::ScanArgs:
144 if (
C == BeginArgsToken) {
148 if (
C == EndArgsToken) {
150 if (NestedArgs == 0) {
153 CurrentState = State::ArgsEnded;
154 }
else if (NestedArgs < 0) {
155 errs() <<
"Unexpected '>' in pass pipeline.\n";
161 errs() <<
"Missing '>' in pass pipeline. End-of-string reached while "
162 "reading arguments for pass '"
167 case State::ArgsEnded:
170 if (
C == EndToken ||
C == PassDelimToken) {
171 PassBeginIdx =
Idx + 1;
172 CurrentState = State::ScanName;
174 errs() <<
"Expected delimiter or end-of-string after pass "
199 for (
const auto &PassPtr :
Passes)
200 PassPtr->printPipeline(
OS);
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const char PassName[]
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
This class implements an extremely fast bulk output stream that can only output to a stream.
FunctionPassManager(StringRef Name, StringRef Pipeline, CreatePassFunc CreatePass)
FunctionPassManager(StringRef Name)
bool runOnFunction(Function &F, const Analyses &A) final
\Returns true if it modifies F.
PassManager(const PassManager &)=delete
void addPass(std::unique_ptr< ContainedPass > Pass)
Adds Pass to the pass pipeline.
void printPipeline(raw_ostream &OS) const override
Similar to print() but prints one pass per line. Used for testing.
std::function< std::unique_ptr< ContainedPass >(StringRef, StringRef)> CreatePassFunc
PassManager(StringRef Name)
void setPassPipeline(StringRef Pipeline, CreatePassFunc CreatePass)
Parses Pipeline as a comma-separated sequence of pass names and sets the pass pipeline,...
PassManager(PassManager &&)=default
void print(raw_ostream &OS) const override
PassManager(StringRef Name, StringRef Pipeline, CreatePassFunc CreatePass)
PassManager & operator=(const PassManager &)=delete
LLVM_DUMP_METHOD void dump() const override
virtual ~PassManager()=default
SmallVector< std::unique_ptr< ContainedPass > > Passes
The list of passes that this pass manager will run.
The base class of a Sandbox IR Pass.
const std::string Name
The pass name.
StringRef getName() const
\Returns the name of the pass.
RegionPassManager(StringRef Name)
bool runOnRegion(Region &R, const Analyses &A) final
\Returns true if it modifies R.
RegionPassManager(StringRef Name, StringRef Pipeline, CreatePassFunc CreatePass)
The main job of the Region is to point to new instructions generated by vectorization passes.
@ C
The default llvm calling convention, compatible with C.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
void interleave(ForwardIterator begin, ForwardIterator end, UnaryFunctor each_fn, NullaryFunctor between_fn)
An STL-style algorithm similar to std::for_each that applies a second functor between every pair of e...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.