MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
plugin.h File Reference
#include <compare>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <tuple>
#include <ankerl/unordered_dense.h>
#include "mim/config.h"
#include "mim/def.h"
Include dependency graph for plugin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mim::PluginArg
 One -X <plugin>:<arg> a Plugin understands; see Arguments. More...
struct  mim::PluginEnv
 One environment variable a Plugin reads; see Environment Variables. More...
struct  mim::PluginSym
 One symbol a Plugin offers to other Plugins; see Driver::get_fun_ptr. More...
class  mim::Out
 A file name from the command line and the stream to write to;. More...
struct  mim::Version
struct  mim::Plugin
 Basic info and registration function pointer to be returned from a specific plugin. More...
struct  mim::Annex
 Holds info about an entity defined within a Plugin (called Annex). More...

Namespaces

namespace  mim

Macros

#define MIM_VERSION   Version { MIM_VER_MAJOR, MIM_VER_MINOR, MIM_VER_SUFFIX, MIM_GIT_HASH }
#define MIM_PLUGIN_ENTRY_NAME(p)
#define MIM_PLUGIN_ENTRY(p)
 Defines a Plugin's entry point; the body fills in the plugin handed to it, as in MIM_PLUGIN_ENTRY(demo) { plugin.register_normalizers = demo::register_normalizers; }.

Functions

Plugin Argument Lookup

Picks the -X <plugin>:<arg> strings of Driver::args / Phase::args apart.

Each helper matches any of keys - arg_value(args(), "o", "output") - and the last occurrence wins.

template<class... Keys>
std::optional< std::string_view > mim::arg_value (fe::View< std::string > args, Keys... keys)
std::optional< bool > mim::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.
template<class... Keys>
bool mim::arg_flag (fe::View< std::string > args, Keys... keys)
 Whether any of keys occurs.

Plugin Interface

See also
Plugin
#define MIM_PLUGIN_SYM(f)
 Builds a PluginSym for f, so name and address cannot drift apart.
using mim::Normalizers = ankerl::unordered_dense::map<flags_t, NormalizeFn>
using mim::Flags2Phases = ankerl::unordered_dense::map<flags_t, std::function<std::unique_ptr<Phase>(World&)>>
 Maps an axiom of a Phase to a function that creates one.
mim::Plugin mim::mim_get_plugin ()

Class Documentation

◆ mim::PluginArg

struct mim::PluginArg

One -X <plugin>:<arg> a Plugin understands; see Arguments.

A Plugin declares these next to the code that picks them apart, so that mim -p <plugin> -h can list them.

Definition at line 34 of file plugin.h.

Class Members
const char * descr What it does; one sentence of Markdown, but no links: the terminal help prints it as is.
const char * syntax How to spell the argument, e.g. "o=<file>, output=<file>".

◆ mim::PluginEnv

struct mim::PluginEnv

One environment variable a Plugin reads; see Environment Variables.

A Plugin declares these next to the code that reads them, so that mim -p <plugin> -h can list them.

Definition at line 41 of file plugin.h.

Class Members
const char * descr What it does; one sentence of Markdown, but no links: the terminal help prints it as is.
const char * name Name of the variable, e.g. "CUDA_HOME".

◆ mim::PluginSym

struct mim::PluginSym

One symbol a Plugin offers to other Plugins; see Driver::get_fun_ptr.

A statically linked Plugin has no shared object to look it up in.

Definition at line 48 of file plugin.h.

Class Members
const char * name Name of the symbol, e.g. "mim_ll_convert".
void * ptr Address of the symbol.

Macro Definition Documentation

◆ MIM_PLUGIN_ENTRY

#define MIM_PLUGIN_ENTRY ( p)
Value:
static void mim_plugin_##p(mim::Plugin&); \
auto plugin = mim::Plugin{}; \
plugin.name = #p; \
plugin.version = MIM_VERSION; \
mim_plugin_##p(plugin); \
return plugin; \
} \
static void mim_plugin_##p([[maybe_unused]] mim::Plugin& plugin)
#define MIM_EXPORT
Definition config.h:21
#define MIM_VERSION
Definition plugin.h:150
#define MIM_PLUGIN_ENTRY_NAME(p)
Definition plugin.h:189
Basic info and registration function pointer to be returned from a specific plugin.
Definition plugin.h:155
const char * name
Name of the Plugin.
Definition plugin.h:158

Defines a Plugin's entry point; the body fills in the plugin handed to it, as in MIM_PLUGIN_ENTRY(demo) { plugin.register_normalizers = demo::register_normalizers; }.

Plugin::name and Plugin::version are already set, and every other field is zeroed. p must be the Plugin's name: a MIM_STATIC_PLUGINS build needs one entry point per Plugin.

Definition at line 196 of file plugin.h.

Referenced by MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), MIM_PLUGIN_ENTRY(), and MIM_PLUGIN_ENTRY().

◆ MIM_PLUGIN_ENTRY_NAME

#define MIM_PLUGIN_ENTRY_NAME ( p)
Value:
mim_get_plugin

Definition at line 189 of file plugin.h.

◆ MIM_PLUGIN_SYM

#define MIM_PLUGIN_SYM ( f)
Value:
PluginSym { #f, (void*)&f }

Builds a PluginSym for f, so name and address cannot drift apart.

Definition at line 54 of file plugin.h.

◆ MIM_VERSION

#define MIM_VERSION   Version { MIM_VER_MAJOR, MIM_VER_MINOR, MIM_VER_SUFFIX, MIM_GIT_HASH }

Definition at line 150 of file plugin.h.

Referenced by mim::Driver::Driver().