Some "global" variables needed all over the place. More...
#include <mim/driver.h>
Classes | |
| struct | Names |
| class | Paths |
| An ordered list of directories. More... | |
| class | Imports |
Public Member Functions | |
Construction | |
| Driver (std::string name={}) | |
| Driver (const Driver &)=delete | |
| Driver (Driver &&)=delete | |
| Driver & | operator= (Driver)=delete |
Getters | |
| Flags & | flags () |
| const Flags & | flags () const |
| fe::Log & | log () |
| const fe::Log & | log () const |
| fe::Profiler & | profiler () |
| const fe::Profiler & | profiler () const |
| World & | world () |
| const Version & | version () const |
| MimIR Version. | |
| const Keys & | keys () const |
| Interned once here: every ast::Lexer borrows them. | |
Library | |
| World * | library () |
| nullptr before move_to_library(). | |
| const World * | library () const |
| void | move_to_library (World &world) |
Moves everything of world into library() and imports only its externals back. | |
Diagnostic Naming | |
Scratch state for PlainNames: which plain Def::sym each gid claimed while one message is formatted. It lives here - not in a global - so that concurrent Drivers never share it. | |
| Names & | names () const |
Manage Search Paths | |
A plain directory is probed as-is; a prefix root stands for an install tree and derives <root>/<libdir>/mim (plugins), <root>/<datadir>/mim (imports), and <root>/<libdir>/mim/rt (runtimes). Each lookup starts with the empty path, which probes the current working directory without an absolute path. Within a list, paths added first are searched first; CLI paths precede the environment and derived ones. | |
| void | add_plugin_path (fs::path path) |
| void | add_import_path (fs::path path) |
| void | add_prefix_path (fs::path path) |
| fe::Vector< fs::path > | plugin_paths () const |
| Where Driver::load looks for libmim_<name>. | |
| fe::Vector< fs::path > | import_paths () const |
| Where ast::Parser looks for <name>.mim; plugin directories are included, as a plugin ships both halves. | |
| fe::Vector< fs::path > | rt_paths () const |
| Where a backend looks for its runtime modules. | |
Manage Imports | |
Tracks the distinct import or plugin directives that World::dump should emit again later. | |
| const Imports & | imports () const |
| Imports & | imports () |
Manage Plugins | |
All these lookups yield nullptr if the key has not been found. | |
| auto | phase (flags_t flags) |
| const auto & | phases () const |
| auto | normalizer (flags_t flags) const |
| auto | normalizer (plugin_t d, tag_t t, sub_t s) const |
Plugin/Phase Arguments | |
Freeform command-line arguments addressed to a plugin/phase (-X <plugin>:<arg>). A Phase reads its own arguments via Phase::args(). | |
| void | add_arg (std::string_view plugin, std::string arg) |
| const fe::Vector< std::string > & | args (std::string_view plugin) const |
Yields an empty fe::Vector if plugin has none. | |
| std::optional< nat_t > | arg_nat (std::string_view plugin, std::string_view key) |
| The number passed as -X <plugin>:<key>=<n>, if any; warns about and ignores a non-number. | |
| const auto & | known_args () const |
| The PluginArgs each loaded Plugin declares, in load order; only for listing them, see PluginArg. | |
| const auto & | known_envs () const |
| The PluginEnvs each loaded Plugin declares, in load order; only for listing them, see PluginEnv. | |
Load Plugin | |
Finds and loads a shared object file that implements the MimIR Plugin
| |
| void | load (std::string_view name, Loc loc={}) |
| bool | is_loaded (std::string_view name) const |
| const fs::path * | plugin_dir (std::string_view name) const |
| Directory the Plugin was loaded from, so that its <name>.mim half cannot come from elsewhere. | |
| void * | get_fun_ptr (std::string_view plugin, const char *name) |
| template<class F> | |
| auto | get_fun_ptr (std::string_view plugin, const char *name) |
| static void | add_static_plugin (const char *name, Plugin(*get_plugin)()) |
Makes a Plugin linked into this binary available to Driver::load under name; see cmake/Mim.cmake. | |
| static std::string | plugin_name (std::string_view name) |
Bare plugin name of a possibly path-qualified name: foo/libmim_bar.so → bar. | |
Some "global" variables needed all over the place.
Well, there are not really global - that's the point of this class.
| struct mim::Driver::Names |
| mim::Driver::Driver | ( | std::string | name = {} | ) |
Definition at line 60 of file driver.cpp.
References add_import_path(), add_plugin_path(), add_prefix_path(), CODE, Driver(), MIM_INSTALL_PREFIX, MIM_KEY, MIM_SUBST, and MIM_VERSION.
Referenced by Driver(), Driver(), Driver(), and operator=().
|
delete |
References Driver().
|
delete |
References Driver().
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
Makes a Plugin linked into this binary available to Driver::load under name; see cmake/Mim.cmake.
Definition at line 148 of file driver.cpp.
| std::optional< nat_t > mim::Driver::arg_nat | ( | std::string_view | plugin, |
| std::string_view | key ) |
The number passed as -X <plugin>:<key>=<n>, if any; warns about and ignores a non-number.
Definition at line 227 of file driver.cpp.
References mim::arg_value(), args(), and log().
| const fe::Vector< std::string > & mim::Driver::args | ( | std::string_view | plugin | ) | const |
Yields an empty fe::Vector if plugin has none.
Definition at line 221 of file driver.cpp.
References args().
Referenced by arg_nat(), args(), and mim::Phase::args().
|
inline |
Definition at line 77 of file driver.h.
Referenced by mim::World::flags(), load(), mim::ast::load_plugins(), main(), normalizer(), phase(), mim::Phase::run(), mim::PhaseMan::start(), and mim::RWPhase::start().
|
inline |
Definition at line 203 of file driver.h.
References get_fun_ptr().
| void * mim::Driver::get_fun_ptr | ( | std::string_view | plugin, |
| const char * | name ) |
Definition at line 213 of file driver.cpp.
Referenced by get_fun_ptr().
| fe::Vector< fs::path > mim::Driver::import_paths | ( | ) | const |
Where ast::Parser looks for <name>.mim; plugin directories are included, as a plugin ships both halves.
Definition at line 110 of file driver.cpp.
References MIM_DATADIR, and MIM_LIBDIR.
Referenced by main().
|
inline |
Definition at line 177 of file driver.h.
Referenced by mim::ast::Parser::import().
|
inline |
Definition at line 193 of file driver.h.
Referenced by mim::plug::ll::Emitter::Emitter(), and load().
|
inline |
Interned once here: every ast::Lexer borrows them.
|
inline |
|
inline |
|
inline |
nullptr before move_to_library().
| void mim::Driver::load | ( | std::string_view | name, |
| Loc | loc = {} ) |
Definition at line 150 of file driver.cpp.
References flags(), is_loaded(), log(), mim::mim_get_plugin(), plugin_name(), plugin_paths(), and version().
Referenced by mim::plug::ll::Emitter::Emitter(), and mim::ast::Parser::import().
|
inline |
Definition at line 79 of file driver.h.
Referenced by arg_nat(), mim::World::Annexes::attach(), mim::ast::Parser::import(), mim::ast::Parser::import(), load(), mim::World::log(), and main().
| void mim::Driver::move_to_library | ( | World & | world | ) |
Moves everything of world into library() and imports only its externals back.
From then on, world imports an annex lazily when first looked up;
Definition at line 141 of file driver.cpp.
References mim::Def::as_mut(), mim::World::import(), mim::World::inherit(), and world().
Referenced by mim::optimize().
|
inline |
Definition at line 108 of file driver.h.
Referenced by mim::PlainNames::claim().
|
inline |
Definition at line 214 of file driver.h.
References mim::Annex::flags(), and normalizer().
Referenced by normalizer().
|
inline |
Definition at line 211 of file driver.h.
References flags().
Referenced by mim::Phase::recreate(), and mim::plug::gpu::phase::run_stage().
|
inline |
Definition at line 212 of file driver.h.
Referenced by mim::optimize().
|
inline |
|
static |
Bare plugin name of a possibly path-qualified name: foo/libmim_bar.so → bar.
Definition at line 134 of file driver.cpp.
Referenced by mim::ast::Parser::import(), and load().
| fe::Vector< fs::path > mim::Driver::plugin_paths | ( | ) | const |
Where Driver::load looks for libmim_<name>.
Definition at line 100 of file driver.cpp.
References MIM_LIBDIR.
|
inline |
Definition at line 81 of file driver.h.
Referenced by mim::Phase::profile_count(), and mim::Phase::run().
| fe::Vector< fs::path > mim::Driver::rt_paths | ( | ) | const |
Where a backend looks for its runtime modules.
Definition at line 124 of file driver.cpp.
References MIM_LIBDIR.
Referenced by main().
|
inline |
|
inline |
Definition at line 83 of file driver.h.
Referenced by main(), and move_to_library().