Loading...
Searching...
No Matches
plugin.h
Go to the documentation of this file.
30using Flags2Phases = ankerl::unordered_dense::map<flags_t, std::function<std::unique_ptr<Phase>(World&)>>;
33/// A Plugin declares these next to the code that picks them apart, so that `mim -p <plugin> -h` can list them.
40/// A Plugin declares these next to the code that reads them, so that `mim -p <plugin> -h` can list them.
60/// Each helper matches any of @p keys - `arg_value(args(), "o", "output")` - and the last occurrence wins.
195/// @p p must be the Plugin's name: a `MIM_STATIC_PLUGINS` build needs one entry point per Plugin.
224 /// Each `Char6x` is 6-bit wide and hence a plugin name has at most Axm::Max_Plugin_Size = 8 chars.
236 /// Reverts an Axm::mangle%d @p plugin back to its name; never longer than Annex::Max_Plugin_Size.
253 /// It consists of 48 relevant bits that are returned in the highest 6 bytes of a 64-bit integer.
257 static constexpr tag_t flags2tag(flags_t f) { return tag_t((f & 0x0000'0000'0000'ff00_u64) >> 8_u64); }
Out()=default
std::ostream * os()
The stream to write to; nullptr if this output was not requested, std::cout for "-".
Definition plugin.h:109
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:43
const char * descr
What it does; one sentence of Markdown, but no links: the terminal help prints it as is.
Definition plugin.h:36
bool arg_flag(fe::View< std::string > args, Keys... keys)
Whether any of keys occurs.
Definition plugin.h:89
ankerl::unordered_dense::map< flags_t, NormalizeFn > Normalizers
Definition plugin.h:27
mim::Plugin mim_get_plugin()
fe::SymTab< ast::Tok::Tag, ast::Num_Keys+ast::Num_Subst > Keys
The reserved words the ast::Lexer looks up, keyed by the Sym it has just interned.
Definition driver.h:28
const char * descr
What it does; one sentence of Markdown, but no links: the terminal help prints it as is.
Definition plugin.h:43
std::optional< bool > arg_bool(fe::View< std::string > args, std::initializer_list< std::string_view > on, std::initializer_list< std::string_view > off)
An on key ↦ true, an off key ↦ false; std::nullopt if neither occurs.
Definition plugin.h:74
std::optional< std::string_view > arg_value(fe::View< std::string > args, Keys... keys)
Definition plugin.h:64
ankerl::unordered_dense::map< flags_t, std::function< std::unique_ptr< Phase >(World &)> > Flags2Phases
Maps an axiom of a Phase to a function that creates one.
Definition plugin.h:30
One environment variable a Plugin reads; see Environment Variables.
Definition plugin.h:41
One symbol a Plugin offers to other Plugins; see Driver::get_fun_ptr.
Definition plugin.h:48
static constexpr flags_t flags(plugin_t p, tag_t t, sub_t s=0)
Assembles the full flags from its plugin, tag, and sub fields.
Definition plugin.h:266
Annex()=delete
static std::string demangle(plugin_t plugin)
Reverts an Axm::mangled plugin back to its name; never longer than Annex::Max_Plugin_Size.
Definition plugin.cpp:29
static std::optional< plugin_t > mangle(std::string_view plugin)
Mangles s into a dense 48-bit representation.
Definition plugin.cpp:9
static constexpr tag_t flags2tag(flags_t f)
Yields the tag part of the name as integer.
Definition plugin.h:257
static constexpr sub_t flags2sub(flags_t f)
Yields the sub part of the name as integer.
Definition plugin.h:260
static constexpr flags_t flags2base(flags_t f)
Includes Axm::plugin() and Axm::tag() but not Axm::sub.
Definition plugin.h:263
Basic info and registration function pointer to be returned from a specific plugin.
Definition plugin.h:155
const PluginEnv * envs
The environment variables this Plugin reads; see PluginEnv.
Definition plugin.h:171
const PluginArg * args
The -X arguments this Plugin understands; see PluginArg.
Definition plugin.h:169
void(*) register_normalizers(Normalizers &)
Callback for registering the mapping from axm ids to normalizer functions in the given normalizers ma...
Definition plugin.h:162
void(*) register_phases(Flags2Phases &)
Callback for registering the Plugin's callbacks for Phases.
Definition plugin.h:164
Definition plugin.h:124
friend std::ostream & operator<<(std::ostream &os, const Version &v)
Definition plugin.h:143
constexpr bool operator==(const Version &other) const noexcept
Compares major/minor/suffix, ignores hash.
Definition plugin.h:139
constexpr auto operator<=>(const Version &other) const noexcept
Compares major/minor/suffix, ignores hash.
Definition plugin.h:131
