MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::Driver Class Reference

Some "global" variables needed all over the place. More...

#include <mim/driver.h>

Inheritance diagram for mim::Driver:
[legend]

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
Driveroperator= (Driver)=delete
Getters
Flagsflags ()
const Flagsflags () const
fe::Log & log ()
const fe::Log & log () const
fe::Profiler & profiler ()
const fe::Profiler & profiler () const
Worldworld ()
const Versionversion () const
 MimIR Version.
const Keyskeys () const
 Interned once here: every ast::Lexer borrows them.
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.

Namesnames () 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 Importsimports () const
Importsimports ()
Load Plugin

Finds and loads a shared object file that implements the MimIR Plugin name.

If name is an absolute path to a .so/.dll file, this is used. Otherwise, "name", "libmim_name.so" (Linux, Mac), "mim_name.dll" (Win) are searched for in Driver::search_paths().

void load (std::string_view name)
bool is_loaded (std::string_view name) const
const fs::path * plugin_dir (std::string_view name) const
 Directory libmim_<name> 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)
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.
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.

Detailed Description

Some "global" variables needed all over the place.

Well, there are not really global - that's the point of this class.

Definition at line 63 of file driver.h.


Class Documentation

◆ mim::Driver::Names

struct mim::Driver::Names

Definition at line 91 of file driver.h.

Class Members
bool clashed = false
size_t depth = 0
flat_hash_map< Sym, u32 > sym2gid

Constructor & Destructor Documentation

◆ Driver() [1/3]

mim::Driver::Driver ( std::string name = {})

◆ Driver() [2/3]

mim::Driver::Driver ( const Driver & )
delete

References Driver().

◆ Driver() [3/3]

mim::Driver::Driver ( Driver && )
delete

References Driver().

Member Function Documentation

◆ add_arg()

void mim::Driver::add_arg ( std::string_view plugin,
std::string arg )
inline

Definition at line 201 of file driver.h.

Referenced by main().

◆ add_import_path()

void mim::Driver::add_import_path ( fs::path path)
inline

Definition at line 125 of file driver.h.

Referenced by Driver(), and main().

◆ add_plugin_path()

void mim::Driver::add_plugin_path ( fs::path path)
inline

Definition at line 124 of file driver.h.

Referenced by Driver(), and main().

◆ add_prefix_path()

void mim::Driver::add_prefix_path ( fs::path path)
inline

Definition at line 126 of file driver.h.

Referenced by Driver(), and main().

◆ args()

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 185 of file driver.cpp.

Referenced by mim::Phase::args().

◆ flags() [1/2]

Flags & mim::Driver::flags ( )
inline

◆ flags() [2/2]

const Flags & mim::Driver::flags ( ) const
inline

Definition at line 77 of file driver.h.

◆ get_fun_ptr() [1/2]

template<class F>
auto mim::Driver::get_fun_ptr ( std::string_view plugin,
const char * name )
inline

Definition at line 183 of file driver.h.

References get_fun_ptr().

◆ get_fun_ptr() [2/2]

void * mim::Driver::get_fun_ptr ( std::string_view plugin,
const char * name )

Definition at line 180 of file driver.cpp.

Referenced by get_fun_ptr().

◆ import_paths()

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 102 of file driver.cpp.

References MIM_DATADIR, and MIM_LIBDIR.

Referenced by main().

◆ imports() [1/2]

Imports & mim::Driver::imports ( )
inline

Definition at line 167 of file driver.h.

◆ imports() [2/2]

const Imports & mim::Driver::imports ( ) const
inline

Definition at line 166 of file driver.h.

Referenced by mim::ast::Parser::import().

◆ is_loaded()

bool mim::Driver::is_loaded ( std::string_view name) const
inline

Definition at line 177 of file driver.h.

Referenced by mim::plug::ll::Emitter::Emitter(), and load().

◆ keys()

const Keys & mim::Driver::keys ( ) const
inline

Interned once here: every ast::Lexer borrows them.

Definition at line 84 of file driver.h.

◆ known_args()

const auto & mim::Driver::known_args ( ) const
inline

The PluginArgs each loaded Plugin declares, in load order; only for listing them, see PluginArg.

Definition at line 206 of file driver.h.

◆ known_envs()

const auto & mim::Driver::known_envs ( ) const
inline

The PluginEnvs each loaded Plugin declares, in load order; only for listing them, see PluginEnv.

Definition at line 209 of file driver.h.

◆ load()

void mim::Driver::load ( std::string_view name)

◆ log() [1/2]

fe::Log & mim::Driver::log ( )
inline

◆ log() [2/2]

const fe::Log & mim::Driver::log ( ) const
inline

Definition at line 79 of file driver.h.

◆ names()

Names & mim::Driver::names ( ) const
inline

Definition at line 97 of file driver.h.

Referenced by mim::PlainNames::claim().

◆ normalizer() [1/2]

auto mim::Driver::normalizer ( flags_t flags) const
inline

Definition at line 193 of file driver.h.

References flags().

◆ normalizer() [2/2]

auto mim::Driver::normalizer ( plugin_t d,
tag_t t,
sub_t s ) const
inline

Definition at line 194 of file driver.h.

References mim::Annex::flags(), and normalizer().

Referenced by normalizer().

◆ operator=()

Driver & mim::Driver::operator= ( Driver )
delete

References Driver().

◆ phase()

auto mim::Driver::phase ( flags_t flags)
inline

Definition at line 191 of file driver.h.

References flags().

Referenced by mim::optimize(), mim::Phase::recreate(), and mim::plug::gpu::phase::run_stage().

◆ phases()

const auto & mim::Driver::phases ( ) const
inline

Definition at line 192 of file driver.h.

◆ plugin_dir()

const fs::path * mim::Driver::plugin_dir ( std::string_view name) const
inline

Directory libmim_<name> was loaded from, so that its <name>.mim half cannot come from elsewhere.

Definition at line 179 of file driver.h.

◆ plugin_paths()

fe::Vector< fs::path > mim::Driver::plugin_paths ( ) const

Where Driver::load looks for libmim_<name>.

Definition at line 92 of file driver.cpp.

References MIM_LIBDIR.

Referenced by load(), and main().

◆ profiler() [1/2]

fe::Profiler & mim::Driver::profiler ( )
inline

Definition at line 80 of file driver.h.

Referenced by mim::Phase::profile_count(), and mim::Phase::run().

◆ profiler() [2/2]

const fe::Profiler & mim::Driver::profiler ( ) const
inline

Definition at line 81 of file driver.h.

◆ rt_paths()

fe::Vector< fs::path > mim::Driver::rt_paths ( ) const

Where a backend looks for its runtime modules.

Definition at line 116 of file driver.cpp.

References MIM_LIBDIR.

Referenced by main().

◆ version()

const Version & mim::Driver::version ( ) const
inline

MimIR Version.

Definition at line 83 of file driver.h.

Referenced by load(), and main().

◆ world()

World & mim::Driver::world ( )
inline

Definition at line 82 of file driver.h.

Referenced by main().


The documentation for this class was generated from the following files: