42 static std::tuple<const Axiom*, u8, u8>
get(
const Def* def);
59 template<
class T>
struct Match {
76template<
class Id,
class D>
class Match {
77 static_assert(
Annex::Num<Id> != size_t(-1),
"invalid number of sub tags");
90 operator const D*()
const {
return def_; }
91 explicit operator bool() {
return axiom_ !=
nullptr; }
101 auto id()
const {
return Id(
axiom()->flags()); }
105 const Axiom* axiom_ =
nullptr;
106 const D* def_ =
nullptr;
112template<
class Id,
bool DynCast = true>
auto match(
Ref def) {
118 assert(cond &&
"assumed to be correct axiom");
122template<
class Id,
bool DynCast = true>
auto match(Id
id,
Ref def) {
125 bool cond = axiom && curry == 0 && axiom->flags() == (
flags_t)
id;
128 assert(cond &&
"assumed to be correct axiom");
NormalizeFn normalizer() const
static std::pair< u8, u8 > infer_curry_and_trip(const Def *type)
static std::tuple< const Axiom *, u8, u8 > get(const Def *def)
Yields currying counter of def.
Ref rebuild_(World &, Ref, Defs) const override
static constexpr auto Node
static constexpr u8 Trip_End
Def * set(size_t i, const Def *def)
Successively set from left to right.
const Axiom * axiom() const
auto id() const
Axiom::flags cast to Id.
const D * operator->() const
Match(const Axiom *axiom, const D *def)
Helper class to retrieve Infer::arg if present.
CRTP-based Mixin to declare setters for Def::loc & Def::name using a covariant return type.
This is a thin wrapper for std::span<T, N> with the following additional features:
The World represents the whole program and manages creation of MimIR nodes (Defs).
constexpr bool is_commutative(Id)
constexpr bool is_associative(Id id)
Ref(*)(Ref, Ref, Ref) NormalizeFn
static sub_t flags2sub(flags_t f)
Yields the sub part of the name as integer.
static plugin_t flags2plugin(flags_t f)
static flags_t flags2base(flags_t f)
Includes Axiom::plugin() and Axiom::tag() but not Axiom::sub.
static constexpr size_t Num
static constexpr flags_t Base
static tag_t flags2tag(flags_t f)
Yields the tag part of the name as integer.