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

A function. More...

#include <mim/lam.h>

Inheritance diagram for mim::Lam:
[legend]

Public Member Functions

Lamstub (Ref type)
 
ops & type
Ref filter () const
 
Ref body () const
 
const Pitype () const
 
dom & codom

See also
proj
Ref dom () const
 
Ref codom () const
 
Return Continuation
const Piret_pi () const
 
Ref ret_dom () const
 
Ref ret_var ()
 Yields the Lam::var of the Lam::ret_pi.
 
Type Checking
Ref check (size_t, Ref) override
 
- Public Member Functions inherited from mim::Def
Worldworld () const
 
flags_t flags () const
 
u32 gid () const
 
size_t hash () const
 
node_t node () const
 
std::string_view node_name () const
 
Ref type () const
 
Ref unfold_type () const
 Yields the type of this Def and builds a new Type (UInc n) if necessary.
 
bool is_term () const
 Yields true if this:T and T:(Type 0).
 
Ref arity () const
 
std::optional< nat_tisa_lit_arity () const
 
nat_t as_lit_arity () const
 
template<size_t N = std::dynamic_extent>
auto ops () const
 
Ref op (size_t i) const
 
size_t num_ops () const
 
Defset (size_t i, Ref)
 Successively set from left to right.
 
Defreset (size_t i, Ref def)
 Successively reset from left to right.
 
Defset (Defs ops)
 Def::set ops all at once.
 
Defreset (Defs ops)
 Def::reset ops all at once.
 
Defunset ()
 Unsets all Def::ops; works even, if not set at all or partially.
 
bool is_set () const
 Yields true if empty or the last op is set.
 
Defs extended_ops () const
 
Ref extended_op (size_t i) const
 
size_t num_extended_ops () const
 
Defs partial_ops () const
 
Ref partial_op (size_t i) const
 
size_t num_partial_ops () const
 
const Usesuses () const
 
size_t num_uses () const
 
unsigned dep () const
 
bool has_dep (Dep d) const
 
bool has_dep (unsigned u) const
 
bool dep_const () const
 
nat_t num_projs () const
 
nat_t num_tprojs () const
 As above but yields 1, if Flags::scalarize_threshold is exceeded.
 
Ref proj (nat_t a, nat_t i) const
 Similar to World::extract while assuming an arity of a, but also works on Sigmas and Arrays.
 
Ref proj (nat_t i) const
 As above but takes Def::num_projs as arity.
 
Ref tproj (nat_t i) const
 As above but takes Def::num_tprojs.
 
template<nat_t A = std::dynamic_extent, class F >
auto projs (F f) const
 Splits this Def via Def::projections into an Array (if A == std::dynamic_extent) or std::array (otherwise).
 
template<class F >
auto tprojs (F f) const
 
template<class F >
auto projs (nat_t a, F f) const
 
template<nat_t A = std::dynamic_extent>
auto projs () const
 
auto tprojs () const
 
auto projs (nat_t a) const
 
nat_t num_vars ()
 
nat_t num_tvars ()
 
Ref var (nat_t a, nat_t i)
 
Ref var (nat_t i)
 
Ref tvar (nat_t i)
 
template<nat_t A = std::dynamic_extent, class F >
auto vars (F f)
 
template<class F >
auto tvars (F f)
 
template<nat_t A = std::dynamic_extent>
auto vars ()
 
auto tvars ()
 
template<class F >
auto vars (nat_t a, F f)
 
auto vars (nat_t a)
 
Ref var ()
 Not necessarily a Var: E.g., if the return type is [], this will yield ().
 
const Varhas_var ()
 Only returns not nullptr, if Var of this mutable has ever been created.
 
const Varhas_var () const
 As above if this is a mutable.
 
Muts local_muts () const
 Mutables reachable by following immutable extended_ops().
 
Vars local_vars () const
 Vars reachable by following immutable extended_ops().
 
Vars free_vars () const
 Compute a global solution, i.e., by transitively following mutables as well.
 
Vars free_vars ()
 
bool is_open () const
 Has free_vars()?
 
bool is_closed () const
 Has no free_vars()?
 
Muts fv_consumers ()
 
bool is_external () const
 
void make_external ()
 
void make_internal ()
 
void transfer_external (Def *to)
 
template<class T = Def>
const T * isa_imm () const
 
template<class T = Def>
const T * as_imm () const
 
template<class T = Def, class R >
const T * isa_imm (R(T::*f)() const) const
 
template<class T = Def, bool invert = false>
T * isa_mut () const
 If this is *mut*able, it will cast constness away and perform a dynamic_cast to T.
 
template<class T = Def, bool invert = false>
T * as_mut () const
 Asserts that this is a mutable, casts constness away and performs a static_cast to T.
 
Dbg dbg () const
 
Loc loc () const
 
Sym sym () const
 
std::string unique_name () const
 name + "_" + Def::gid
 
template<bool Ow = false>
const Defset (Loc l) const
 
template<bool Ow = false>
Defset (Loc l)
 
template<bool Ow = false>
const Defset (Sym s) const
 
template<bool Ow = false>
Defset (Sym s)
 
template<bool Ow = false>
const Defset (std::string s) const
 
template<bool Ow = false>
Defset (std::string s)
 
template<bool Ow = false>
const Defset (Loc l, Sym s) const
 
template<bool Ow = false>
Defset (Loc l, Sym s)
 
template<bool Ow = false>
const Defset (Loc l, std::string s) const
 
template<bool Ow = false>
Defset (Loc l, std::string s)
 
template<bool Ow = false>
const Defset (Dbg d) const
 
template<bool Ow = false>
Defset (Dbg d)
 
const Defdebug_prefix (std::string) const
 
const Defdebug_suffix (std::string) const
 
Defstub (World &w, Ref type)
 
Defstub (Ref type)
 
Ref rebuild (World &w, Ref type, Defs ops) const
 Def::rebuilds this Def while using new_op as substitute for its i'th Def::op.
 
Ref rebuild (Ref type, Defs ops) const
 
virtual const Defimmutabilize ()
 Tries to make an immutable from a mutable.
 
bool is_immutabilizable ()
 
Ref refine (size_t i, Ref new_op) const
 
DefVec reduce (Ref arg) const
 Rewrites Def::ops by substituting this mutable's Var with arg.
 
DefVec reduce (Ref arg)
 
Ref reduce (size_t i, Ref arg) const
 As above but only rewrites this->op(i).
 
virtual Ref check ()
 
const Defzonk () const
 
void dump () const
 
void dump (int max) const
 
void write (int max) const
 
void write (int max, const char *file) const
 
std::ostream & stream (std::ostream &, int max) const
 
void dot (std::ostream &os, uint32_t max=0xFFFFFF, bool types=false) const
 
void dot (const char *file=nullptr, uint32_t max=0xFFFFFF, bool types=false) const
 Same as above but write to file or std::cout if file is nullptr.
 
void dot (const std::string &file, uint32_t max=0xFFFFFF, bool types=false) const
 
- Public Member Functions inherited from mim::Setters< Lam >
const Lamset (Loc l) const
 
Lamset (Loc l)
 
const Lamset (Sym s) const
 
Lamset (Sym s)
 
const Lamset (std::string s) const
 
Lamset (std::string s)
 
const Lamset (Loc l, Sym s) const
 
Lamset (Loc l, Sym s)
 
const Lamset (Loc l, std::string s) const
 
Lamset (Loc l, std::string s)
 
const Lamset (Dbg d) const
 
Lamset (Dbg d)
 

Static Public Member Functions

Continuations
static const Lamisa_cn (Ref d)
 
static const Lamisa_basicblock (Ref d)
 
static const Lamisa_returning (Ref d)
 
static Lamisa_mut_cn (Ref d)
 Only for mutables.
 
static Lamisa_mut_basicblock (Ref d)
 Only for mutables.
 
static Lamisa_mut_returning (Ref d)
 Only for mutables.
 

Static Public Attributes

static constexpr auto Node = Node::Lam
 

Private Member Functions

Ref rebuild_ (World &, Ref, Defs) const override
 
Lamstub_ (World &, Ref) override
 

Friends

class World
 

Setters

Lam::Filter is a std::variant<bool, const Def*> that lets you set the Lam::filter() like this:

lam1->app(true, f, arg);
lam2->app(my_filter_def, f, arg);
See also
Setting Ops
using Filter = std::variant<bool, Ref>
 
Lamset (Filter filter, Ref body)
 
Lamset_filter (Filter)
 Set filter first.
 
Lamset_body (Ref body)
 Set body second.
 
Lamapp (Filter filter, Ref callee, Ref arg)
 Set body to an App of callee and arg.
 
Lamapp (Filter filter, Ref callee, Defs args)
 Set body to an App of callee and args.
 
Lambranch (Filter filter, Ref cond, Ref t, Ref f, Ref mem=nullptr)
 Set body to an App of (f, t)#cond mem or (f, t)#cond () if mem is nullptr.
 
Lamtest (Filter filter, Ref val, Ref idx, Ref match, Ref clash, Ref mem)
 
Lamset (Defs ops)
 
Lamunset ()
 

Additional Inherited Members

- Protected Member Functions inherited from mim::Def
 Def (World *, node_t, const Def *type, Defs ops, flags_t flags)
 Constructor for an immutable Def.
 
 Def (node_t n, const Def *type, Defs ops, flags_t flags)
 As above but World retrieved from type.
 
 Def (node_t, const Def *type, size_t num_ops, flags_t flags)
 Constructor for a mutable Def.
 
virtual ~Def ()=default
 
Sym sym (const char *) const
 
Sym sym (std::string_view) const
 
Sym sym (std::string) const
 
- Protected Attributes inherited from mim::Def
Dbg dbg_
 
union { 
 
NormalizeFn normalizer_
 Axiom only: Axioms use this member to store their normalizer.
 
const Axiomaxiom_
 App only: Curried Apps of Axioms use this member to propagate the Axiom.
 
const Varvar_
 Mutable only: Var of a mutable.
 
Worldworld_
 
};  
 
flags_t flags_
 
u8 curry_
 
u8 trip_
 

Detailed Description

A function.

See also
Pi

Definition at line 104 of file lam.h.

Member Typedef Documentation

◆ Filter

using mim::Lam::Filter = std::variant<bool, Ref>

Definition at line 160 of file lam.h.

Member Function Documentation

◆ app() [1/2]

Lam * mim::Lam::app ( Filter filter,
Ref callee,
Defs args )

Set body to an App of callee and args.

Definition at line 30 of file lam.cpp.

References app(), filter(), and mim::Def::world().

◆ app() [2/2]

Lam * mim::Lam::app ( Filter filter,
Ref callee,
Ref arg )

Set body to an App of callee and arg.

Definition at line 29 of file lam.cpp.

References app(), set_body(), set_filter(), and mim::Def::world().

Referenced by app(), app(), branch(), mim::RetWrap::enter(), and test().

◆ body()

◆ branch()

Lam * mim::Lam::branch ( Filter filter,
Ref cond,
Ref t,
Ref f,
Ref mem = nullptr )

Set body to an App of (f, t)#cond mem or (f, t)#cond () if mem is nullptr.

Definition at line 32 of file lam.cpp.

References app(), filter(), and mim::Def::world().

◆ check()

Ref mim::Lam::check ( size_t i,
Ref def )
overridevirtual

◆ codom()

Ref mim::Lam::codom ( ) const
inline

Definition at line 124 of file lam.h.

References mim::Pi::codom(), and type().

Referenced by check().

◆ dom()

Ref mim::Lam::dom ( ) const
inline

Definition at line 123 of file lam.h.

References mim::Pi::dom(), and type().

◆ filter()

Ref mim::Lam::filter ( ) const
inline

◆ isa_basicblock()

static const Lam * mim::Lam::isa_basicblock ( Ref d)
inlinestatic

◆ isa_cn()

static const Lam * mim::Lam::isa_cn ( Ref d)
inlinestatic

Definition at line 133 of file lam.h.

References mim::Pi::isa_cn().

Referenced by isa_mut_cn().

◆ isa_mut_basicblock()

static Lam * mim::Lam::isa_mut_basicblock ( Ref d)
inlinestatic

◆ isa_mut_cn()

static Lam * mim::Lam::isa_mut_cn ( Ref d)
inlinestatic

Only for mutables.

Definition at line 136 of file lam.h.

References isa_cn().

◆ isa_mut_returning()

static Lam * mim::Lam::isa_mut_returning ( Ref d)
inlinestatic

Only for mutables.

Definition at line 138 of file lam.h.

References isa_returning().

◆ isa_returning()

static const Lam * mim::Lam::isa_returning ( Ref d)
inlinestatic

Definition at line 135 of file lam.h.

References mim::Pi::isa_returning().

Referenced by isa_mut_returning(), and mim::plug::mem::CopyProp::rewrite().

◆ rebuild_()

Ref mim::Lam::rebuild_ ( World & w,
Ref t,
Defs o ) const
overrideprivatevirtual

Implements mim::Def.

Definition at line 101 of file def.cpp.

◆ ret_dom()

Ref mim::Lam::ret_dom ( ) const
inline

Definition at line 146 of file lam.h.

References mim::Pi::dom(), and ret_pi().

◆ ret_pi()

const Pi * mim::Lam::ret_pi ( ) const
inline

Definition at line 145 of file lam.h.

References mim::Pi::ret_pi(), and type().

Referenced by ret_dom().

◆ ret_var()

◆ set() [1/2]

Lam * mim::Lam::set ( Defs ops)
inline

Definition at line 171 of file lam.h.

References mim::Def::ops(), and mim::Def::set().

◆ set() [2/2]

◆ set_body()

Lam * mim::Lam::set_body ( Ref body)
inline

Set body second.

Definition at line 163 of file lam.h.

References body(), and mim::Def::set().

Referenced by app(), and set().

◆ set_filter()

Lam * mim::Lam::set_filter ( Filter filter)

Set filter first.

Definition at line 28 of file lam.cpp.

References filter(), mim::Def::set(), and mim::Def::world().

Referenced by app(), and set().

◆ stub()

Lam * mim::Lam::stub ( Ref type)
inline

Definition at line 175 of file lam.h.

References mim::Def::dbg(), set(), stub_(), type(), and mim::Def::world().

◆ stub_()

Lam * mim::Lam::stub_ ( World & w,
Ref t )
overrideprivatevirtual

Reimplemented from mim::Def.

Definition at line 133 of file def.cpp.

Referenced by stub().

◆ test()

Lam * mim::Lam::test ( Filter filter,
Ref val,
Ref idx,
Ref match,
Ref clash,
Ref mem )

Definition at line 36 of file lam.cpp.

References app(), filter(), mim::match(), test(), and mim::Def::world().

Referenced by test().

◆ type()

const Pi * mim::Lam::type ( ) const
inline

◆ unset()

Lam * mim::Lam::unset ( )
inline

Definition at line 172 of file lam.h.

References mim::Def::unset().

Friends And Related Symbol Documentation

◆ World

friend class World
friend

Definition at line 188 of file lam.h.

Member Data Documentation

◆ Node

auto mim::Lam::Node = Node::Lam
staticconstexpr

Definition at line 182 of file lam.h.


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