Thorin 1.9.0
The Higher ORder INtermediate representation
|
A function. More...
#include <thorin/lam.h>
Public Member Functions | |
Lam * | stub (Ref type) |
ops & type | |
Ref | filter () const |
Ref | body () const |
const Pi * | type () const |
dom | |
| |
Ref | dom () const |
codom | |
| |
Ref | codom () const |
Return Continuation | |
| |
const Pi * | ret_pi () const |
Ref | ret_dom () const |
Ref | ret_var () |
Yields the Lam::var of the Lam::ret_pi. | |
Type Checking | |
void | check () override |
Public Member Functions inherited from thorin::Def | |
World & | world () const |
flags_t | flags () const |
u32 | gid () const |
hash_t | hash () const |
node_t | node () const |
std::string_view | node_name () const |
const Def * | type () const |
Yields the raw type of this Def, i.e. maybe nullptr . | |
const Def * | 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_t > | isa_lit_arity () const |
nat_t | as_lit_arity () const |
template<size_t N = std::dynamic_extent> | |
auto | ops () const |
const Def * | op (size_t i) const |
size_t | num_ops () const |
Def * | set (size_t i, const Def *def) |
Successively set from left to right. | |
Def * | reset (size_t i, const Def *def) |
Successively reset from left to right. | |
Def * | set (Defs ops) |
Def::set ops all at once. | |
Def * | reset (Defs ops) |
Def::reset ops all at once. | |
Def * | unset () |
Unsets all Def::ops; works even, if not set at all or partially. | |
Def * | set_type (const Def *) |
void | unset_type () |
void | update () |
Resolves Infers of this Def's type. | |
bool | is_set () const |
Yields true if empty or the last op is set. | |
Defs | extended_ops () const |
const Def * | extended_op (size_t i) const |
size_t | num_extended_ops () const |
Defs | partial_ops () const |
const Def * | partial_op (size_t i) const |
size_t | num_partial_ops () const |
const Uses & | uses () 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 |
Yields Def::as_lit_arity(), if it is in fact a Lit, or 1 otherwise. | |
nat_t | num_tprojs () const |
As above but yields 1, if Flags::scalerize_threshold is exceeded. | |
const Def * | 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. | |
const Def * | proj (nat_t i) const |
As above but takes Def::num_projs as arity. | |
const Def * | tproj (nat_t i) const |
As above but takes Def::num_tprojs. | |
template<nat_t A = -1_n, class F > | |
auto | projs (F f) const |
Splits this Def via Def::projections into an Array (if A == -1_n ) 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 = -1_n> | |
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 Var * | has_var () |
Only returns not nullptr , if Var of this mutable has ever been created. | |
const Var * | has_var () const |
As above if this is a mutable. | |
Muts | local_muts () const |
Vars | local_vars () const |
Vars | free_vars () const |
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 const ness 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 const ness 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 Def * | set (Loc l) const |
template<bool Ow = false> | |
Def * | set (Loc l) |
template<bool Ow = false> | |
const Def * | set (Sym s) const |
template<bool Ow = false> | |
Def * | set (Sym s) |
template<bool Ow = false> | |
const Def * | set (std::string s) const |
template<bool Ow = false> | |
Def * | set (std::string s) |
template<bool Ow = false> | |
const Def * | set (Loc l, Sym s) const |
template<bool Ow = false> | |
Def * | set (Loc l, Sym s) |
template<bool Ow = false> | |
const Def * | set (Loc l, std::string s) const |
template<bool Ow = false> | |
Def * | set (Loc l, std::string s) |
template<bool Ow = false> | |
const Def * | set (Dbg d) const |
template<bool Ow = false> | |
Def * | set (Dbg d) |
const Def * | debug_prefix (std::string) const |
const Def * | debug_suffix (std::string) const |
Def * | stub (World &w, Ref type) |
Def * | stub (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 Def * | immutabilize () |
Tries to make an immutable from a mutable. | |
const Def * | refine (size_t i, const Def *new_op) const |
DefVec | reduce (const Def *arg) const |
Rewrites Def::ops by substituting this mutable's Var with arg . | |
DefVec | reduce (const Def *arg) |
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 |
Static Public Member Functions | |
Continuations | |
| |
static const Lam * | isa_cn (Ref d) |
static const Lam * | isa_basicblock (Ref d) |
static const Lam * | isa_returning (Ref d) |
static Lam * | isa_mut_cn (Ref d) |
Only for mutables. | |
static Lam * | isa_mut_basicblock (Ref d) |
Only for mutables. | |
static Lam * | isa_mut_returning (Ref d) |
Only for mutables. | |
Private Member Functions | |
Lam * | stub_ (World &, Ref) override |
Setters | |
Lam::Filter is a lam1->app(true, f, arg);
lam2->app(my_filter_def, f, arg);
| |
using | Filter = std::variant< bool, const Def * > |
Lam * | set (Filter filter, const Def *body) |
Lam * | set_filter (Filter) |
Set filter first. | |
Lam * | set_body (const Def *body) |
Set body second. | |
Lam * | app (Filter filter, const Def *callee, const Def *arg) |
Set body to an App of callee and arg . | |
Lam * | app (Filter filter, const Def *callee, Defs args) |
Set body to an App of callee and args . | |
Lam * | branch (Filter filter, const Def *cond, const Def *t, const Def *f, const Def *mem=nullptr) |
Set body to an App of (f, t)#cond mem or (f, t)#cond () if mem is nullptr . | |
Lam * | test (Filter filter, const Def *val, const Def *idx, const Def *match, const Def *clash, const Def *mem) |
Lam * | set (Defs ops) |
Lam * | unset () |
Additional Inherited Members | ||
Protected Member Functions inherited from thorin::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 thorin::Def | ||
Dbg | dbg_ | |
union { | ||
NormalizeFn | normalizer_ | |
Axiom only: Axioms use this member to store their normalizer. | ||
const Axiom * | axiom_ | |
App only: Curried Apps of Axioms use this member to propagate the Axiom. | ||
const Var * | var_ | |
Mutable only: Var of a mutable. | ||
World * | world_ | |
}; | ||
flags_t | flags_ | |
u8 | curry_ | |
u8 | trip_ | |
using thorin::Lam::Filter = std::variant<bool, const Def*> |
Set body to an App of callee
and arg
.
Definition at line 29 of file lam.cpp.
References app(), set_body(), set_filter(), and thorin::Def::world().
Referenced by app(), app(), branch(), thorin::RetWrap::enter(), and test().
|
inline |
Definition at line 108 of file lam.h.
References thorin::Def::op().
Referenced by thorin::World::app(), thorin::plug::autodiff::AutoDiffEval::augment_lam(), check(), thorin::ll::Emitter::emit_epilogue(), thorin::plug::clos::ClosConvPrep::enter(), set(), and set_body().
Lam * thorin::Lam::branch | ( | Filter | filter, |
const Def * | cond, | ||
const Def * | t, | ||
const Def * | f, | ||
const Def * | 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(), thorin::World::tuple(), and thorin::Def::world().
|
overridevirtual |
Reimplemented from thorin::Def.
Definition at line 235 of file check.cpp.
References thorin::Check::alpha(), thorin::Check::assignable(), body(), codom(), thorin::error(), filter(), type(), and thorin::Def::world().
|
inline |
Definition at line 124 of file lam.h.
References thorin::Pi::codom(), and type().
Referenced by check().
|
inline |
Definition at line 116 of file lam.h.
References thorin::Pi::dom(), and type().
|
inline |
Definition at line 107 of file lam.h.
References thorin::Def::op().
Referenced by app(), thorin::World::app(), thorin::plug::autodiff::AutoDiffEval::augment_lam(), branch(), check(), set(), set_filter(), and test().
Definition at line 133 of file lam.h.
References thorin::Pi::isa_basicblock().
Referenced by thorin::plug::mem::SSAConstr::analyze(), thorin::plug::autodiff::AutoDiffEval::augment_lam(), isa_mut_basicblock(), and thorin::Emitter< Value, Type, BB, Child >::visit().
Only for mutables.
Definition at line 136 of file lam.h.
References isa_basicblock().
Referenced by thorin::ll::Emitter::emit_epilogue(), thorin::plug::clos::ClosConvPrep::enter(), and thorin::plug::clos::ClosConvPrep::rewrite_arg().
Definition at line 134 of file lam.h.
References thorin::Pi::isa_returning().
Referenced by isa_mut_returning(), and thorin::plug::mem::CopyProp::rewrite().
|
inline |
Definition at line 145 of file lam.h.
References thorin::Pi::dom(), and ret_pi().
|
inline |
Definition at line 144 of file lam.h.
References thorin::Pi::ret_pi(), and type().
Referenced by ret_dom().
|
inline |
Yields the Lam::var of the Lam::ret_pi.
Definition at line 147 of file lam.h.
References thorin::Def::num_vars(), thorin::Pi::ret_pi(), type(), and thorin::Def::var().
Referenced by thorin::ll::Emitter::emit_epilogue(), thorin::RetWrap::enter(), thorin::plug::clos::ClosLit::ret_var(), and thorin::Emitter< Value, Type, BB, Child >::visit().
Definition at line 169 of file lam.h.
References thorin::Def::ops(), and thorin::Def::set().
Definition at line 159 of file lam.h.
References body(), filter(), set_body(), and set_filter().
Referenced by thorin::plug::autodiff::AutoDiffEval::augment_app(), thorin::plug::autodiff::AutoDiffEval::augment_extract(), thorin::plug::autodiff::AutoDiffEval::augment_pack(), thorin::plug::autodiff::AutoDiffEval::augment_tuple(), thorin::plug::autodiff::AutoDiffEval::derive_(), thorin::RetWrap::enter(), thorin::plug::clos::Clos2SJLJ::enter(), thorin::plug::affine::LowerFor::rewrite(), thorin::plug::matrix::LowerMatrixMediumLevel::rewrite_(), stub(), and thorin::World::World().
Set filter first.
Definition at line 28 of file lam.cpp.
References filter(), thorin::Def::set(), and thorin::Def::world().
Definition at line 173 of file lam.h.
References thorin::Def::dbg(), set(), stub_(), type(), and thorin::Def::world().
Lam * thorin::Lam::test | ( | Filter | filter, |
const Def * | val, | ||
const Def * | idx, | ||
const Def * | match, | ||
const Def * | clash, | ||
const Def * | mem | ||
) |
Definition at line 36 of file lam.cpp.
References app(), filter(), thorin::match(), test(), and thorin::Def::world().
Referenced by test().
|
inline |
Definition at line 109 of file lam.h.
References thorin::Def::type().
Referenced by thorin::plug::autodiff::AutoDiffEval::augment_lam(), check(), codom(), dom(), thorin::ll::Emitter::emit_imported(), thorin::EtaExp::proxy(), ret_pi(), ret_var(), and stub().
|
inline |
Definition at line 170 of file lam.h.
References thorin::Def::unset().