Thorin 1.9.0
The Higher ORder INtermediate representation
|
Base class for all Defs. More...
#include <thorin/def.h>
Public Member Functions | |
Getters | |
World & | world () const |
flags_t | flags () const |
u32 | gid () const |
hash_t | hash () const |
node_t | node () const |
std::string_view | node_name () const |
type | |
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) . | |
arity | |
Ref | arity () const |
std::optional< nat_t > | isa_lit_arity () const |
nat_t | as_lit_arity () const |
ops | |
template<size_t N = std::dynamic_extent> | |
auto | ops () const |
const Def * | op (size_t i) const |
size_t | num_ops () const |
Setting Ops (Mutables Only) | |
You can set and change the Def::ops of a mutable after construction. However, you have to obey the following rules:
Thorin assumes that a mutable is final, when its last operand is set. Then, Def::check() will be invoked. | |
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. | |
extended_ops | |
Includes Def::type() (if not Def::ops() is only included, if Def::is_set. | |
Defs | extended_ops () const |
const Def * | extended_op (size_t i) const |
size_t | num_extended_ops () const |
partial_ops | |
Includes Def::type() and then the other Def::ops() in this order. Also works with partially set Defs and doesn't assert. Unset operands are | |
Defs | partial_ops () const |
const Def * | partial_op (size_t i) const |
size_t | num_partial_ops () const |
uses | |
const Uses & | uses () const |
size_t | num_uses () const |
dep | |
| |
unsigned | dep () const |
bool | has_dep (Dep d) const |
bool | has_dep (unsigned u) const |
bool | dep_const () const |
proj | |
Splits this Def via Extracts or directly accessing the Def::ops in the case of Sigmas or Arrays. std::array<const Def*, 2> ab = def->projs<2>();
auto [a, b] = def->projs<2>();
Array<const Def*> projs1 = def->projs(); // "projs1" has def->num_projs() many elements
Array<const Def*> projs2 = def->projs(n);// "projs2" has n elements - asserts if incorrect
// same as above but applies Lit::as<nat_t>(def) to each element
| |
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 |
var | |
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. | |
Free Vars and Muts | |
| |
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 () |
external | |
bool | is_external () const |
void | make_external () |
void | make_internal () |
void | transfer_external (Def *to) |
Casts | |
| |
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 Getters | |
Dbg | dbg () const |
Loc | loc () const |
Sym | sym () const |
std::string | unique_name () const |
name + "_" + Def::gid | |
Dbg Setters | |
Every subclass | |
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) |
debug_prefix/suffix | |
Prepends/Appends a prefix/suffix to Def::name - but only in | |
const Def * | debug_prefix (std::string) const |
const Def * | debug_suffix (std::string) const |
Rebuild | |
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) |
Type Checking | |
virtual void | check () |
dump | |
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 |
dot | |
Dumps DOT to If | |
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 |
Protected Member Functions | |
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 |
Wrappers for World::sym | |
These are here to have Def::setters inline without including | |
Sym | sym (const char *) const |
Sym | sym (std::string_view) const |
Sym | sym (std::string) const |
Protected Attributes | ||
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_ | |
Private Member Functions | |
virtual Def * | stub_ (World &, Ref) |
virtual Ref | rebuild_ (World &w, Ref type, Defs ops) const =0 |
Friends | |
class | World |
void | swap (World &, World &) noexcept |
Base class for all Defs.
The data layout (see World::alloc and Def::partial_ops) looks like this:
Constructor for an immutable Def.
Definition at line 16 of file def.cpp.
References extended_ops(), flags_, gid(), local_muts(), local_vars(), thorin::World::merge(), thorin::murmur3(), thorin::murmur3_finalize(), thorin::murmur3_rest(), thorin::World::next_gid(), node(), num_ops(), op(), ops(), type(), thorin::Node::Univ, var(), thorin::World::vars(), and world().
Constructor for a mutable Def.
Definition at line 60 of file def.cpp.
References dep_const(), gid(), thorin::murmur3(), thorin::World::next_gid(), num_ops(), thorin::Use::Type, type(), and world().
|
protectedvirtualdefault |
Ref thorin::Def::arity | ( | ) | const |
Definition at line 483 of file def.cpp.
References thorin::World::lit_nat(), thorin::World::lit_nat_1(), type(), and world().
Referenced by thorin::plug::autodiff::AutoDiffEval::augment_pack(), thorin::World::extract(), thorin::World::insert(), thorin::tuple2str(), and thorin::unflatten().
|
inline |
|
inline |
Definition at line 257 of file def.h.
References isa_lit_arity().
Referenced by thorin::World::extract(), thorin::plug::regex::normalize_conj(), thorin::plug::regex::normalize_disj(), and projs().
|
inline |
Asserts that this
is a mutable, casts const
ness away and performs a static_cast
to T
.
Definition at line 455 of file def.h.
Referenced by thorin::BetaRed::analyze(), thorin::EtaExp::analyze(), thorin::plug::mem::CopyProp::analyze(), thorin::plug::mem::SSAConstr::analyze(), thorin::plug::clos::clos_type(), thorin::plug::autodiff::AutoDiffEval::derive_(), thorin::ast::ExtractExpr::emit_(), thorin::ast::TuplePtrn::emit_body(), thorin::ll::Emitter::emit_epilogue(), thorin::Var::mut(), thorin::ll::Emitter::prepare(), thorin::RWPhase::start(), thorin::Cleanup::start(), and thorin::Emitter< Value, Type, BB, Child >::visit().
|
inlinevirtual |
Reimplemented in thorin::Pi, thorin::Lam, thorin::Sigma, and thorin::Arr.
Definition at line 515 of file def.h.
Referenced by set().
|
inline |
Definition at line 466 of file def.h.
Referenced by thorin::Infer::stub(), thorin::Pi::stub(), thorin::Lam::stub(), thorin::TBound< Up >::stub(), thorin::TExt< Up >::stub(), thorin::Sigma::stub(), thorin::Arr::stub(), and thorin::Pack::stub().
const Def * thorin::Def::debug_prefix | ( | std::string | prefix | ) | const |
const Def * thorin::Def::debug_suffix | ( | std::string | suffix | ) | const |
|
inline |
|
inline |
Definition at line 336 of file def.h.
References has_dep(), thorin::Mut, and thorin::Var.
Referenced by Def(), thorin::Scheduler::early(), thorin::Scheduler::late(), thorin::plug::core::normalize_pe(), and unset_type().
void thorin::Def::dot | ( | const char * | file = nullptr , |
uint32_t | max = 0xFFFFFF , |
||
bool | types = false |
||
) | const |
|
inline |
void thorin::Def::dot | ( | std::ostream & | os, |
uint32_t | max = 0xFFFFFF , |
||
bool | types = false |
||
) | const |
void thorin::Def::dump | ( | int | max | ) | const |
|
inline |
Definition at line 310 of file def.h.
References extended_ops().
Defs thorin::Def::extended_ops | ( | ) | const |
Definition at line 443 of file def.cpp.
References is_set(), and type().
Referenced by Def(), thorin::Scheduler::early(), extended_op(), num_extended_ops(), and thorin::PassMan::run().
|
inline |
Definition at line 235 of file def.h.
References flags_.
Referenced by thorin::Axiom::base(), thorin::Pi::is_implicit(), thorin::optimize(), thorin::Axiom::plugin(), thorin::Axiom::sub(), and thorin::Axiom::tag().
Vars thorin::Def::free_vars | ( | ) |
Definition at line 336 of file def.cpp.
References free_vars(), is_set(), and isa_mut().
Vars thorin::Def::free_vars | ( | ) | const |
Definition at line 328 of file def.cpp.
References isa_mut(), local_muts(), local_vars(), thorin::World::merge(), vars(), and world().
Referenced by free_vars(), thorin::Pi::immutabilize(), thorin::Sigma::immutabilize(), thorin::Arr::immutabilize(), thorin::Pack::immutabilize(), is_closed(), is_open(), and thorin::VarRewriter::rewrite_mut().
|
inline |
Definition at line 236 of file def.h.
Referenced by thorin::commute(), Def(), Def(), thorin::PipelineBuilder::def2pass(), thorin::plug::refly::normalize_gid(), thorin::UseHash::operator()(), thorin::register_pass_with_arg(), and unique_name().
|
inline |
Definition at line 334 of file def.h.
References has_dep().
Referenced by dep_const(), has_dep(), and thorin::Infer::should_eliminate().
|
inline |
|
inline |
Only returns not nullptr
, if Var of this mutable has ever been created.
Definition at line 405 of file def.h.
Referenced by has_var(), thorin::Pi::immutabilize(), thorin::Sigma::immutabilize(), thorin::Arr::immutabilize(), thorin::Pack::immutabilize(), and thorin::VarRewriter::rewrite_mut().
|
inline |
|
inlinevirtual |
Tries to make an immutable from a mutable.
This usually works if the mutable isn't recursive and its var isn't used.
Reimplemented in thorin::Pi, thorin::Sigma, thorin::Arr, and thorin::Pack.
bool thorin::Def::is_closed | ( | ) | const |
Has no free_vars()?
Definition at line 397 of file def.cpp.
References thorin::PooledSet< T >::empty(), free_vars(), is_external(), local_muts(), and local_vars().
Referenced by thorin::World::make_external(), and thorin::World::verify().
|
inline |
Definition at line 431 of file def.h.
Referenced by is_closed(), thorin::isa_workable(), thorin::World::make_external(), and thorin::World::make_internal().
bool thorin::Def::is_open | ( | ) | const |
Has free_vars()?
Definition at line 405 of file def.cpp.
References thorin::PooledSet< T >::empty(), free_vars(), local_muts(), and local_vars().
bool thorin::Def::is_set | ( | ) | const |
Yields true
if empty or the last op is set.
Definition at line 311 of file def.cpp.
References num_ops(), op(), and ops().
Referenced by thorin::EtaExp::analyze(), thorin::World::app(), extended_ops(), free_vars(), thorin::isa_workable(), thorin::EtaExp::rewrite(), thorin::EtaRed::rewrite(), thorin::Rewriter::rewrite_mut(), thorin::PassMan::run(), thorin::Scheduler::Scheduler(), and thorin::Emitter< Value, Type, BB, Child >::visit().
bool thorin::Def::is_term | ( | ) | const |
Yields true
if this:T
and T:(.Type 0)
.
Definition at line 472 of file def.cpp.
References thorin::Lit::isa(), and type().
Referenced by thorin::flatten().
|
inline |
Definition at line 441 of file def.h.
Referenced by thorin::World::app(), thorin::merge_sigma(), thorin::merge_tuple(), thorin::plug::core::normalize_trait(), and thorin::Infer::should_eliminate().
|
inline |
std::optional< nat_t > thorin::Def::isa_lit_arity | ( | ) | const |
Definition at line 490 of file def.cpp.
References thorin::Lit::isa(), num_ops(), and type().
Referenced by as_lit_arity(), thorin::flatten(), thorin::World::insert(), num_projs(), and num_tprojs().
|
inline |
If this
is *mut*able, it will cast const
ness away and perform a dynamic_cast
to T
.
Definition at line 447 of file def.h.
Referenced by thorin::EtaRed::analyze(), thorin::BetaRed::analyze(), thorin::EtaExp::analyze(), thorin::plug::mem::SSAConstr::analyze(), thorin::World::app(), thorin::plug::autodiff::AutoDiffEval::augment_(), thorin::Scheduler::early(), thorin::World::extract(), thorin::Infer::find(), thorin::Bound::find(), free_vars(), free_vars(), has_var(), thorin::isa_apped_mut_lam(), thorin::plug::clos::isa_clos_type(), thorin::Scheduler::late(), local_muts(), reduce(), thorin::Rewriter::rewrite(), thorin::EtaExp::rewrite(), thorin::EtaRed::rewrite(), thorin::Scalerize::rewrite(), thorin::plug::affine::LowerFor::rewrite(), thorin::plug::mem::SSAConstr::rewrite(), thorin::plug::clos::ClosConvPrep::rewrite_arg(), thorin::Scheduler::Scheduler(), thorin::World::tuple(), thorin::plug::mem::AddMem::visit(), and thorin::Emitter< Value, Type, BB, Child >::visit().
|
inline |
Definition at line 467 of file def.h.
Referenced by thorin::World::app(), thorin::Pi::check(), thorin::Lam::check(), thorin::Arr::check(), thorin::World::extract(), thorin::World::insert(), thorin::World::lit(), thorin::World::type(), and thorin::World::uinc().
Muts thorin::Def::local_muts | ( | ) | const |
Definition at line 323 of file def.cpp.
References isa_mut(), thorin::World::muts(), and world().
Referenced by Def(), free_vars(), is_closed(), is_open(), thorin::VarRewriter::rewrite_imm(), and thorin::ClosedMutPhase< M >::start().
|
inline |
Definition at line 421 of file def.h.
Referenced by Def(), free_vars(), is_closed(), is_open(), and thorin::VarRewriter::rewrite_imm().
void thorin::Def::make_external | ( | ) |
Definition at line 510 of file def.cpp.
References thorin::World::make_external(), and world().
Referenced by transfer_external().
void thorin::Def::make_internal | ( | ) |
Definition at line 511 of file def.cpp.
References thorin::World::make_internal(), and world().
Referenced by thorin::plug::compile::InternalCleanup::enter(), thorin::optimize(), and transfer_external().
|
inline |
Definition at line 238 of file def.h.
Referenced by Def(), thorin::Pi::isa_cn(), and node_name().
std::string_view thorin::Def::node_name | ( | ) | const |
Definition at line 433 of file def.cpp.
References CODE, node(), and THORIN_NODE.
Referenced by thorin::plug::autodiff::AutoDiffEval::augment_(), thorin::plug::autodiff::autodiff_type_fun(), and thorin::plug::autodiff::zero_def().
|
inline |
Definition at line 311 of file def.h.
References extended_ops().
|
inline |
Definition at line 268 of file def.h.
Referenced by thorin::EtaExp::analyze(), thorin::plug::mem::SSAConstr::analyze(), thorin::plug::core::convert(), Def(), Def(), thorin::World::ext(), thorin::World::extract(), thorin::Scope::is_free(), is_set(), thorin::plug::clos::isa_clos_type(), isa_lit_arity(), reset(), thorin::plug::mem::SSAConstr::rewrite(), thorin::rewrite(), thorin::EtaExp::rewrite(), thorin::EtaRed::rewrite(), thorin::plug::mem::SSAConstr::rewrite(), thorin::Rewriter::rewrite_imm(), thorin::Rewriter::rewrite_mut(), thorin::PassMan::run(), thorin::Scheduler::Scheduler(), set(), set(), and unset().
|
inline |
Definition at line 321 of file def.h.
References partial_ops().
|
inline |
Yields Def::as_lit_arity(), if it is in fact a Lit, or 1
otherwise.
Definition at line 356 of file def.h.
References isa_lit_arity().
Referenced by thorin::plug::clos::clos_insert_env(), thorin::plug::clos::clos_remove_env(), thorin::plug::mem::mem_def(), proj(), projs(), and thorin::plug::mem::replace_mem().
nat_t thorin::Def::num_tprojs | ( | ) | const |
As above but yields 1, if Flags::scalerize_threshold is exceeded.
Definition at line 515 of file def.cpp.
References thorin::World::flags(), isa_lit_arity(), thorin::Flags::scalerize_threshold, and world().
|
inline |
Definition at line 401 of file def.h.
Referenced by thorin::ll::Emitter::emit_epilogue().
|
inline |
|
inline |
Definition at line 401 of file def.h.
Referenced by thorin::ll::Emitter::emit_epilogue(), and thorin::Lam::ret_var().
|
inline |
Definition at line 267 of file def.h.
References ops().
Referenced by thorin::BetaRed::analyze(), thorin::EtaExp::analyze(), thorin::plug::mem::CopyProp::analyze(), thorin::plug::mem::SSAConstr::analyze(), thorin::EtaExp::analyze(), thorin::plug::mem::SSAConstr::analyze(), thorin::App::arg(), thorin::Lam::body(), thorin::Arr::body(), thorin::Pack::body(), thorin::App::callee(), thorin::Test::clash(), thorin::plug::clos::clos_type_to_pi(), thorin::Pi::codom(), Def(), thorin::Pi::dom(), thorin::World::extract(), thorin::Lam::filter(), thorin::Infer::find(), thorin::Bound::get(), thorin::Sigma::immutabilize(), thorin::Extract::index(), thorin::Insert::index(), thorin::Singleton::inhabitant(), is_set(), thorin::plug::clos::isa_clos_type(), thorin::Test::match(), thorin::plug::mem::normalize_load(), thorin::Infer::op(), thorin::Test::probe(), proj(), thorin::plug::mem::SSAConstr::rewrite(), thorin::rewrite(), thorin::EtaExp::rewrite(), thorin::EtaRed::rewrite(), thorin::plug::mem::SSAConstr::rewrite(), thorin::rewrite(), thorin::Rewriter::rewrite_imm(), thorin::Rewriter::rewrite_mut(), thorin::PassMan::run(), thorin::Scheduler::Scheduler(), set(), thorin::Arr::shape(), thorin::Extract::tuple(), thorin::Insert::tuple(), unset(), thorin::Vel::value(), thorin::Pick::value(), thorin::Test::value(), and thorin::Insert::value().
|
inline |
Definition at line 266 of file def.h.
Referenced by thorin::plug::mem::CopyProp::analyze(), thorin::BetaRed::analyze(), thorin::World::arr(), thorin::Sigma::check(), thorin::plug::core::convert(), Def(), thorin::World::extract(), thorin::Bound::find(), thorin::Sigma::immutabilize(), thorin::Sigma::infer(), is_set(), thorin::plug::core::normalize_trait(), op(), thorin::World::pack(), reduce(), refine(), reset(), thorin::EtaExp::rewrite(), set(), thorin::Lam::set(), and thorin::Sigma::set().
|
inline |
Definition at line 320 of file def.h.
References partial_ops().
|
inline |
Definition at line 319 of file def.h.
Referenced by num_partial_ops(), and partial_op().
Similar to World::extract while assuming an arity of a
, but also works on Sigmas and Arrays.
Definition at line 520 of file def.cpp.
References thorin::Lit::isa(), op(), thorin::Extract::tuple(), type(), uses(), and world().
Referenced by thorin::plug::clos::clos_remove_env(), thorin::ll::Emitter::emit_bb(), thorin::ast::TuplePtrn::emit_value_(), thorin::flatten(), thorin::World::insert(), projs(), projs(), thorin::plug::clos::ClosConvPrep::rewrite_arg(), and tproj().
As above but takes Def::num_projs as arity.
Definition at line 362 of file def.h.
References num_projs(), and proj().
Referenced by proj().
|
inline |
|
inline |
Splits this Def via Def::projections into an Array (if A == -1_n
) or std::array
(otherwise).
Applies f
to each element.
Definition at line 367 of file def.h.
References as_lit_arity(), num_projs(), proj(), and projs().
Referenced by thorin::plug::autodiff::AutoDiffEval::augment_tuple(), thorin::ll::Emitter::emit_bb(), thorin::plug::clos::Clos2SJLJ::enter(), thorin::plug::regex::flatten_in_arg(), thorin::plug::matrix::get_max_index(), thorin::plug::mem::mem_def(), thorin::plug::core::normalize_abs(), thorin::plug::autodiff::normalize_add(), thorin::plug::math::normalize_arith(), thorin::plug::core::normalize_bit2(), thorin::plug::math::normalize_cmp(), thorin::plug::compile::normalize_combine_pass_list(), thorin::plug::refly::normalize_dbg(), thorin::plug::core::normalize_div(), thorin::plug::core::normalize_extrema(), thorin::plug::math::normalize_extrema(), thorin::plug::core::normalize_icmp(), thorin::plug::mem::normalize_lea(), thorin::plug::mem::normalize_load(), thorin::plug::core::normalize_nat(), thorin::plug::core::normalize_ncmp(), thorin::plug::math::normalize_pow(), thorin::plug::regex::normalize_range(), thorin::plug::matrix::normalize_read(), thorin::plug::refly::normalize_refine(), thorin::plug::matrix::normalize_shape(), thorin::plug::core::normalize_shr(), thorin::plug::mem::normalize_store(), thorin::plug::autodiff::normalize_sum(), thorin::plug::core::normalize_wrap(), thorin::plug::core::normalize_zip(), thorin::plug::mem::SSAConstr::rewrite(), thorin::plug::matrix::LowerMatrixMediumLevel::rewrite_(), thorin::plug::matrix::LowerMatrixLowLevel::rewrite_imm(), thorin_get_plugin(), thorin::tuple2str(), and thorin::unflatten().
|
inline |
|
inline |
Def::rebuilds this Def while using new_op
as substitute for its i'th
Def::op.
Definition at line 496 of file def.h.
Referenced by refine(), thorin::EtaExp::rewrite(), and thorin::Rewriter::rewrite_imm().
Implemented in thorin::Var, thorin::Univ, thorin::UMax, thorin::UInc, thorin::Type, thorin::Lit, thorin::Nat, thorin::Idx, thorin::Proxy, thorin::Global, thorin::TBound< Up >, and thorin::TExt< Up >.
Definition at line 213 of file def.cpp.
References thorin::rewrite(), and world().
Rewrites Def::ops by substituting this
mutable's Var with arg
.
Definition at line 208 of file def.cpp.
References isa_mut(), and ops().
Referenced by thorin::World::app(), thorin::World::extract(), and thorin::plug::compile::handle_optimization_part().
Definition at line 220 of file def.cpp.
References ops(), rebuild(), and type().
Referenced by thorin::plug::clos::clos_sub_env(), thorin::EtaRed::rewrite(), thorin::plug::mem::SSAConstr::rewrite(), thorin::plug::clos::ClosConvPrep::rewrite_arg(), and thorin::plug::clos::ClosConvPrep::rewrite_callee().
Successively reset from left to right.
Definition at line 289 of file def.h.
References set(), and unset().
Referenced by thorin::RetWrap::enter(), thorin::Infer::find(), thorin::Infer::reset(), reset(), and thorin::PassMan::run().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Successively set from left to right.
Definition at line 248 of file def.cpp.
References check(), num_ops(), op(), and update().
Referenced by thorin::plug::autodiff::AutoDiffEval::augment_extract(), thorin::plug::autodiff::AutoDiffEval::augment_tuple(), thorin::plug::autodiff::AutoDiffEval::derive_(), thorin::ast::TuplePtrn::emit_body(), thorin::ast::Ptrn::emit_value(), thorin::plug::direct::op_cps2ds_dep(), reset(), thorin::plug::affine::LowerFor::rewrite(), thorin::plug::mem::SSAConstr::rewrite(), thorin::plug::clos::ClosConvPrep::rewrite_arg(), thorin::plug::clos::ClosConvPrep::rewrite_callee(), thorin::Pack::set(), thorin::Infer::set(), set(), thorin::Lam::set(), thorin::Sigma::set(), thorin::Sigma::set(), thorin::Lam::set_body(), thorin::Arr::set_body(), thorin::Pi::set_codom(), thorin::Pi::set_dom(), thorin::Pi::set_dom(), thorin::Lam::set_filter(), thorin::Arr::set_shape(), thorin::TBound< Up >::stub(), thorin::TExt< Up >::stub(), thorin::Arr::stub(), and stub().
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 290 of file def.cpp.
References thorin::Use::Type, type(), and unset_type().
Referenced by thorin::Pi::check(), thorin::Sigma::check(), thorin::Arr::check(), and update().
std::ostream & thorin::Def::stream | ( | std::ostream & | os, |
int | max | ||
) | const |
Definition at line 492 of file def.h.
References set().
Referenced by thorin::TailRecElim::analyze(), thorin::LamSpec::rewrite(), and thorin::Rewriter::rewrite_mut().
Reimplemented in thorin::Infer, thorin::Global, thorin::Pi, thorin::Lam, thorin::TBound< Up >, thorin::TExt< Up >, thorin::Sigma, thorin::Arr, and thorin::Pack.
|
inline |
Definition at line 468 of file def.h.
Referenced by thorin::plug::autodiff::AutoDiffEval::augment_lam(), debug_prefix(), debug_suffix(), thorin::plug::compile::InternalCleanup::enter(), thorin::World::make_external(), thorin::World::make_internal(), thorin::Scope::sym(), thorin_get_plugin(), and unique_name().
|
protected |
Definition at line 413 of file def.cpp.
References thorin::World::sym(), and world().
|
protected |
Definition at line 415 of file def.cpp.
References thorin::World::sym(), and world().
|
protected |
Definition at line 414 of file def.cpp.
References thorin::World::sym(), and world().
As above but takes Def::num_tprojs.
Definition at line 363 of file def.h.
References num_tprojs(), and proj().
|
inline |
|
inline |
Definition at line 379 of file def.h.
References num_tprojs(), and projs().
|
inline |
Definition at line 434 of file def.h.
References make_external(), and make_internal().
|
inline |
Yields the raw type of this Def, i.e. maybe nullptr
.
Definition at line 246 of file def.h.
Referenced by thorin::World::app(), arity(), thorin::Check::assignable(), thorin::plug::autodiff::AutoDiffEval::augment_(), 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::App::callee_type(), thorin::Pi::check(), thorin::Sigma::check(), thorin::Arr::check(), thorin::plug::clos::clos_pack(), thorin::plug::matrix::counting_for(), Def(), Def(), thorin::plug::autodiff::AutoDiffEval::derive_(), thorin::ll::Emitter::emit_bb(), thorin::plug::clos::ClosLit::env_type(), thorin::plug::clos::ClosConvPrep::eta_wrap(), extended_ops(), thorin::World::extract(), thorin::Bound::find(), thorin::flatten(), thorin::plug::clos::ClosLit::fnc_type(), thorin::Bound::get(), thorin::plug::compile::handle_optimization_part(), thorin::World::iapp(), thorin::World::iinfer(), thorin::World::insert(), is_term(), thorin::is_unit(), isa_lit_arity(), thorin::plug::mem::mem_def(), thorin::merge_tuple(), thorin::plug::core::normalize_bitcast(), thorin::plug::core::normalize_conv(), thorin::plug::math::normalize_conv(), thorin::plug::core::normalize_shr(), thorin::plug::core::op(), thorin::plug::direct::op_cps2ds_dep(), thorin::plug::mem::op_lea(), thorin::plug::mem::op_lea_unsafe(), thorin::plug::matrix::op_read(), thorin::optimize(), thorin::World::pack(), proj(), refine(), thorin::plug::mem::replace_mem(), thorin::EtaExp::rewrite(), thorin::plug::matrix::LowerMatrixHighLevelMapRed::rewrite_(), thorin::plug::clos::ClosConvPrep::rewrite_callee(), thorin::Rewriter::rewrite_imm(), thorin::plug::matrix::LowerMatrixLowLevel::rewrite_imm(), thorin::Rewriter::rewrite_mut(), thorin::PassMan::run(), thorin::Scheduler::Scheduler(), set_type(), thorin::Pack::shape(), thorin::plug::mem::strip_mem(), thorin::Infer::stub(), thorin::Pi::stub(), thorin::TBound< Up >::stub(), thorin::TExt< Up >::stub(), thorin::Sigma::stub(), thorin::Arr::stub(), thorin::Pack::stub(), thorin::World::test(), thorin::World::tuple(), thorin::plug::clos::ClosLit::type(), thorin::Global::type(), thorin::Lam::type(), thorin::World::type(), thorin::World::uinc(), update(), and world().
const Def * thorin::Def::unfold_type | ( | ) | const |
Yields the type of this Def and builds a new .Type (UInc n)
if necessary.
Definition at line 423 of file def.cpp.
References thorin::World::type(), and world().
Referenced by thorin::World::arr(), thorin::Arr::check(), and thorin::Pi::infer().
std::string thorin::Def::unique_name | ( | ) | const |
Def * thorin::Def::unset | ( | ) |
Unsets all Def::ops; works even, if not set at all or partially.
Definition at line 266 of file def.cpp.
References num_ops(), op(), and unset().
Referenced by reset(), thorin::Infer::unset(), unset(), thorin::Pi::unset(), thorin::Lam::unset(), thorin::Sigma::unset(), thorin::Arr::unset(), and thorin::Pack::unset().
void thorin::Def::unset_type | ( | ) |
Definition at line 300 of file def.cpp.
References dep_const(), and thorin::Use::Type.
Referenced by set_type().
|
inline |
Resolves Infers of this Def's type.
Definition at line 297 of file def.h.
References thorin::Ref::refer(), set_type(), and type().
Referenced by thorin::Infer::find(), and set().
|
inline |
Definition at line 326 of file def.h.
Referenced by num_uses(), and proj().
Ref thorin::Def::var | ( | ) |
Not necessarily a Var: E.g., if the return type is []
, this will yield ()
.
Definition at line 456 of file def.cpp.
References world().
Referenced by Def(), thorin::Pi::immutabilize(), thorin::Arr::immutabilize(), thorin::Pack::immutabilize(), and thorin::Lam::ret_var().
Definition at line 401 of file def.h.
Referenced by thorin::World::app(), thorin::plug::autodiff::AutoDiffEval::augment_app(), thorin::plug::autodiff::AutoDiffEval::augment_lam(), thorin::plug::autodiff::AutoDiffEval::derive_(), thorin::ast::TuplePtrn::emit_body(), thorin::ll::Emitter::emit_epilogue(), thorin::ast::PiExpr::Dom::emit_type(), thorin::plug::clos::ClosLit::env_var(), thorin::plug::clos::ClosConvPrep::eta_wrap(), thorin::World::extract(), thorin::Scope::is_free(), thorin::plug::clos::isa_clos_type(), thorin::plug::mem::mem_var(), thorin::plug::direct::op_cps2ds_dep(), thorin::rewrite(), thorin::rewrite(), and thorin::rewrite().
|
inline |
Definition at line 401 of file def.h.
Referenced by free_vars().
|
inline |
Definition at line 401 of file def.h.
Referenced by thorin::RetWrap::enter(), and thorin::plug::affine::LowerFor::rewrite().
|
inline |
World & thorin::Def::world | ( | ) | const |
Definition at line 417 of file def.cpp.
References type(), and world().
Referenced by thorin::Check::alpha(), thorin::Lam::app(), thorin::Lam::app(), thorin::plug::clos::apply_closure(), arity(), thorin::Check::assignable(), thorin::plug::autodiff::AutoDiffEval::augment_(), thorin::plug::autodiff::AutoDiffEval::augment_app(), thorin::plug::autodiff::AutoDiffEval::augment_extract(), thorin::plug::autodiff::AutoDiffEval::augment_lam(), thorin::plug::autodiff::AutoDiffEval::augment_pack(), thorin::plug::autodiff::AutoDiffEval::augment_tuple(), thorin::plug::autodiff::autodiff_type_fun(), thorin::plug::autodiff::autodiff_type_fun_pi(), thorin::Lam::branch(), thorin::Lam::check(), thorin::Sigma::check(), thorin::plug::clos::clos_apply(), thorin::plug::clos::clos_insert_env(), thorin::plug::clos::clos_pack(), thorin::plug::clos::clos_remove_env(), thorin::plug::clos::clos_type(), thorin::plug::clos::clos_type_to_pi(), thorin::plug::core::convert(), thorin::plug::matrix::counting_for(), debug_prefix(), debug_suffix(), Def(), Def(), thorin::PipelineBuilder::def2pass(), thorin::plug::autodiff::AutoDiffEval::derive_(), thorin::Infer::eliminate(), thorin::flatten(), free_vars(), thorin::plug::autodiff::id_pullback(), thorin::Pi::immutabilize(), thorin::Sigma::immutabilize(), thorin::Arr::immutabilize(), thorin::Pack::immutabilize(), thorin::Pi::infer(), thorin::is_unit(), thorin::plug::clos::isa_clos_type(), local_muts(), make_external(), make_internal(), thorin::merge_sigma(), thorin::merge_tuple(), thorin::plug::mem::mut_con(), thorin::plug::core::normalize_abs(), thorin::plug::math::normalize_abs(), thorin::plug::autodiff::normalize_ad(), thorin::plug::autodiff::normalize_AD(), thorin::plug::autodiff::normalize_add(), thorin::plug::math::normalize_arith(), thorin::plug::core::normalize_bit1(), thorin::plug::core::normalize_bit2(), thorin::plug::core::normalize_bitcast(), thorin::plug::clos::normalize_clos(), thorin::plug::math::normalize_cmp(), thorin::plug::compile::normalize_combine_pass_list(), thorin::plug::compile::normalize_combined_phase(), thorin::plug::regex::normalize_conj(), thorin::plug::demo::normalize_const(), thorin::plug::core::normalize_conv(), thorin::plug::math::normalize_conv(), thorin::plug::refly::normalize_dbg(), thorin::plug::regex::normalize_disj(), thorin::plug::core::normalize_div(), thorin::plug::math::normalize_er(), thorin::plug::math::normalize_exp(), thorin::plug::core::normalize_extrema(), thorin::plug::math::normalize_extrema(), thorin::plug::math::normalize_gamma(), thorin::plug::refly::normalize_gid(), thorin::plug::core::normalize_icmp(), thorin::plug::core::normalize_idx(), thorin::plug::matrix::normalize_insert(), thorin::plug::mem::normalize_lea(), thorin::plug::mem::normalize_load(), thorin::plug::matrix::normalize_map_reduce(), thorin::plug::core::normalize_nat(), thorin::plug::core::normalize_ncmp(), thorin::plug::regex::normalize_not(), thorin::plug::compile::normalize_pass_phase(), thorin::plug::core::normalize_pe(), thorin::plug::math::normalize_pow(), thorin::plug::matrix::normalize_prod(), thorin::plug::regex::normalize_quant(), thorin::plug::regex::normalize_range(), thorin::plug::matrix::normalize_read(), thorin::plug::refly::normalize_refine(), thorin::plug::mem::normalize_remem(), thorin::plug::math::normalize_round(), thorin::plug::math::normalize_rt(), thorin::plug::matrix::normalize_shape(), thorin::plug::core::normalize_shr(), thorin::plug::compile::normalize_single_pass_phase(), thorin::plug::mem::normalize_store(), thorin::plug::autodiff::normalize_sum(), thorin::plug::core::normalize_trait(), thorin::plug::matrix::normalize_transpose(), thorin::plug::math::normalize_tri(), thorin::plug::core::normalize_wrap(), thorin::plug::autodiff::normalize_zero(), thorin::plug::core::normalize_zip(), num_tprojs(), thorin::plug::core::op(), thorin::plug::core::op(), thorin::plug::mem::op_alloc(), thorin::plug::mem::op_lea(), thorin::plug::mem::op_lea_unsafe(), thorin::plug::mem::op_lea_unsafe(), thorin::plug::mem::op_malloc(), thorin::plug::mem::op_mslot(), thorin::plug::matrix::op_read(), thorin::plug::mem::op_slot(), thorin::plug::autodiff::op_sum(), thorin::operator<<(), proj(), thorin::plug::autodiff::pullback_type(), reduce(), thorin::plug::direct::DS2CPS::rewrite(), thorin::plug::regex::LowerRegex::rewrite(), thorin::plug::matrix::LowerMatrixMediumLevel::rewrite_(), thorin::PassMan::run(), thorin::Pi::set_dom(), thorin::Lam::set_filter(), thorin::Pack::shape(), stream(), thorin::plug::mem::strip_mem(), thorin::plug::mem::strip_mem_ty(), thorin::Infer::stub(), thorin::Pi::stub(), thorin::Lam::stub(), thorin::TBound< Up >::stub(), thorin::TExt< Up >::stub(), thorin::Sigma::stub(), thorin::Arr::stub(), thorin::Pack::stub(), sym(), sym(), sym(), thorin::Lam::test(), unfold_type(), var(), world(), thorin::plug::autodiff::zero_def(), and thorin::plug::autodiff::zero_pullback().
void thorin::Def::write | ( | int | max | ) | const |
void thorin::Def::write | ( | int | max, |
const char * | file | ||
) | const |
union { ... } thorin::Def |
|
protected |
Definition at line 576 of file def.h.
Referenced by thorin::Axiom::curry(), and thorin::App::curry().
|
mutableprotected |
Definition at line 568 of file def.h.
Referenced by debug_prefix(), and debug_suffix().
|
protected |
Definition at line 575 of file def.h.
Referenced by Def(), flags(), thorin::Pi::make_explicit(), and thorin::Pi::make_implicit().
|
protected |
Definition at line 577 of file def.h.
Referenced by thorin::Axiom::trip(), and thorin::App::trip().