llir-opt
0.0.1
Low-Level Post-Link Optimiser for OCaml and C
|
7 #include <llvm/ADT/ArrayRef.h>
10 #include <unordered_map>
16 #include "core/pass.h"
17 #include "core/analysis.h"
47 OptLevel
Opt = OptLevel::O0;
79 const std::string &saveBefore,
86 template<
typename T,
typename... Args>
87 void Add(
const Args &... args)
89 if constexpr (std::is_base_of<Analysis, T>::value) {
92 groups_.emplace_back(std::make_unique<T>(
this, args...),
nullptr, T::kPassID);
97 template<
typename... Ts>
100 std::vector<PassInfo> ps;
101 ((ps.emplace_back(std::make_unique<Ts>(
this),
nullptr, Ts::kPassID)), ...);
102 groups_.emplace_back(std::move(ps));
114 return static_cast<T *
>(it->second);
129 std::unique_ptr<Pass> P;
135 PassInfo(std::unique_ptr<Pass> &&pass,
const char *
id,
const char *name)
144 bool Run(PassInfo &pass,
Prog &prog);
149 std::vector<PassInfo> Passes;
153 GroupInfo(std::unique_ptr<Pass> &&pass,
const char *
id,
const char *name)
156 Passes.emplace_back(std::move(pass),
id, name);
159 GroupInfo(std::vector<PassInfo> &&passes)
160 : Passes(std::move(passes))
171 std::string saveBefore_;
179 std::vector<GroupInfo> groups_;
181 std::unordered_map<const char *, Pass *> analyses_;
183 std::unordered_map<const char *, std::vector<double>> times_;
185 std::set<std::string> disabled_;
Definition: analysis.h:12
Definition: pass_manager.h:74
void Add(const Args &... args)
Add an analysis into the pipeline.
Definition: pass_manager.h:87
bool Shared
Building a shared library.
Definition: pass_manager.h:51
Definition: pass_manager.h:45
T * getAnalysis()
Returns an available analysis.
Definition: pass_manager.h:191
T * getAnalysis()
Returns an available analysis.
Definition: pass_manager.h:111
const Target * GetTarget() const
Returns a reference to the target.
Definition: pass_manager.h:123
void Group()
Adds a group of passes to the pipeline.
Definition: pass_manager.h:98
const PassConfig & GetConfig() const
Returns a reference to the configuration.
Definition: pass_manager.h:121
void Run(Prog &prog)
Runs the pipeline.
Definition: pass_manager.cpp:45
bool Static
Building a static executable.
Definition: pass_manager.h:49
PassManager * passManager_
Pass manager scheduling this pass.
Definition: pass.h:51
std::string Entry
Name of the entry point.
Definition: pass_manager.h:53
OptLevel Opt
Optimisation level.
Definition: pass_manager.h:47