18#ifndef LLVM_SANDBOXIR_PASSMANAGER_H
19#define LLVM_SANDBOXIR_PASSMANAGER_H
34template <
typename ParentPass,
typename ContainedPass>
100 "setPassPipeline called on a non-empty sandboxir::PassManager");
105 if (Pipeline.
empty())
109 std::string PipelineStr = std::string(Pipeline) +
EndToken;
115 errs() <<
"Found empty pass name.\n";
121 if (
Pass ==
nullptr) {
122 errs() <<
"Pass '" <<
PassName <<
"' not registered!\n";
134 } CurrentState = State::ScanName;
135 int PassBeginIdx = 0;
137 int AuxArgsBeginIdx = 0;
141 int NestedAuxArgs = 0;
143 switch (CurrentState) {
144 case State::ScanName:
148 ArgsBeginIdx = Idx + 1;
150 CurrentState = State::ScanArgs;
156 AuxArgsBeginIdx = Idx + 1;
158 CurrentState = State::ScanAuxArgs;
163 errs() <<
"Unexpected '" <<
C <<
"' in pass pipeline.\n";
170 PassBeginIdx = Idx + 1;
173 case State::ScanArgs:
182 if (NestedArgs == 0) {
184 AddPass(
PassName, Pipeline.
slice(ArgsBeginIdx, Idx), AuxArg);
185 CurrentState = State::ArgsEnded;
186 }
else if (NestedArgs < 0) {
187 errs() <<
"Unexpected '>' in pass pipeline.\n";
193 errs() <<
"Missing '>' in pass pipeline. End-of-string reached while "
194 "reading arguments for pass '"
199 case State::ArgsEnded:
203 PassBeginIdx = Idx + 1;
205 CurrentState = State::ScanName;
207 errs() <<
"Expected delimiter or end-of-string after pass "
212 case State::ScanAuxArgs:
219 if (NestedAuxArgs == 0) {
220 AuxArg = Pipeline.
slice(AuxArgsBeginIdx, Idx);
221 CurrentState = State::AuxArgsEnded;
222 }
else if (NestedAuxArgs < 0) {
224 <<
"' in pass pipeline.\n";
231 <<
"' in pass pipeline. End-of-string reached while "
232 "reading arguments for pass '"
237 case State::AuxArgsEnded:
240 CurrentState = State::ScanArgs;
243 ArgsBeginIdx = Idx + 1;
244 CurrentState = State::ScanArgs;
246 errs() <<
"Expected delimiter, begin-of-args or end-of-string after "
247 "pass aux argument.\n";
271 for (
const auto &PassPtr :
Passes)
272 PassPtr->printPipeline(OS);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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.
This file defines the DenseMap class.
static bool runOnFunction(Function &F, bool PostInlining)
static StringRef getName(Value *V)
static const char PassName[]
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)
PassManager(const PassManager &)=delete
static constexpr char EndAuxArgsToken
void addPass(std::unique_ptr< ContainedPass > Pass)
Adds Pass to the pass pipeline.
std::function< std::unique_ptr< ContainedPass >( StringRef, StringRef, StringRef)> CreatePassFunc
void printPipeline(raw_ostream &OS) const override
Similar to print() but prints one pass per line. Used for testing.
static constexpr char EndToken
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
static constexpr char BeginArgsToken
void print(raw_ostream &OS) const override
~PassManager() override=default
PassManager(StringRef Name, StringRef Pipeline, CreatePassFunc CreatePass)
PassManager & operator=(const PassManager &)=delete
LLVM_DUMP_METHOD void dump() const override
static constexpr char PassDelimToken
SmallVector< std::unique_ptr< ContainedPass > > Passes
The list of passes that this pass manager will run.
static constexpr char BeginAuxArgsToken
static constexpr char EndArgsToken
The base class of a Sandbox IR Pass.
const std::string Name
The pass name.
virtual void print(raw_ostream &OS) const
RegionPassManager(StringRef Name)
RegionPassManager(StringRef Name, StringRef Pipeline, CreatePassFunc CreatePass)
The main job of the Region is to point to new instructions generated by vectorization passes.
A SandboxIR Value has users. This is the base class.
@ 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...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.