10#include <absl/container/flat_hash_map.h>
25using Flags2Stages = absl::flat_hash_map<flags_t, std::function<std::unique_ptr<Stage>(
World&)>>;
36 auto cmp = std::tie(
major,
minor) <=> std::tie(other.major, other.minor);
37 if (cmp != 0)
return cmp;
39 return std::strcmp(
suffix, other.suffix) <=> 0;
44 return major == other.major &&
minor == other.minor && std::strcmp(
suffix, other.suffix) == 0;
55 Version { MIM_VER_MAJOR, MIM_VER_MINOR, MIM_VER_SUFFIX, MIM_GIT_HASH }
60 using Handle = std::unique_ptr<void, void (*)(
void*)>;
107 static std::optional<plugin_t>
mangle(Sym plugin);
113 static std::tuple<Sym, Sym, Sym>
split(
Driver&, Sym);
147 template<
class Id>
static constexpr size_t Num = size_t(-1);
149 template<
class Id>
static consteval size_t num () {
return Num <Id>; }
158template<>
struct std::formatter<
mim::Version> : fe::ostream_formatter {};
Some "global" variables needed all over the place.
Common base for Phase and Pass.
The World represents the whole program and manages creation of MimIR nodes (Defs).
absl::flat_hash_map< flags_t, std::function< std::unique_ptr< Stage >(World &)> > Flags2Stages
Maps an an axiom of a Stage to a function that creates one.
mim::Plugin mim_get_plugin()
absl::flat_hash_map< flags_t, NormalizeFn > Normalizers
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.
static std::tuple< Sym, Sym, Sym > split(Driver &, Sym)
static constexpr plugin_t Global_Plugin
static constexpr tag_t flags2tag(flags_t f)
Yields the tag part of the name as integer.
static constexpr size_t Max_Plugin_Size
static constexpr sub_t flags2sub(flags_t f)
Yields the sub part of the name as integer.
static constexpr plugin_t flags2plugin(flags_t f)
static Sym demangle(Driver &, plugin_t plugin)
Reverts an Axm::mangled string to a Sym.
static std::optional< plugin_t > mangle(Sym plugin)
Mangles s into a dense 48-bit representation.
static consteval size_t num()
static constexpr size_t Num
Number of Axm::subtags.
static consteval flags_t base()
static constexpr flags_t Base
static constexpr flags_t flags2base(flags_t f)
Includes Axm::plugin() and Axm::tag() but not Axm::sub.
Basic info and registration function pointer to be returned from a specific plugin.
void(* register_stages)(Flags2Stages &)
Callback for registering the Plugin's callbacks for Passes and Phases.
std::unique_ptr< void, void(*)(void *)> Handle
const char * name
Name of the Plugin.
void(* register_normalizers)(Normalizers &)
Callback for registering the mapping from axm ids to normalizer functions in the given normalizers ma...
Version version
Version of the Plugin.
friend std::ostream & operator<<(std::ostream &os, const Version &v)
constexpr bool operator==(const Version &other) const noexcept
Compares major/minor/suffix, ignores hash.
constexpr auto operator<=>(const Version &other) const noexcept
Compares major/minor/suffix, ignores hash.