MimIR 0.1
MimIR is my Intermediate Representation
|
Base class for all Defs. More...
#include <mim/def.h>
Public Member Functions | |
Getters | |
World & | world () const noexcept |
constexpr flags_t | flags () const noexcept |
constexpr u32 | gid () const noexcept |
Global id - unique number for this Def. | |
constexpr u32 | tid () const noexcept |
Trie id - only used in Trie. | |
constexpr u32 | mark () const noexcept |
Used internally by free_vars(). | |
constexpr size_t | hash () const noexcept |
constexpr Node | node () const noexcept |
std::string_view | node_name () const |
Judgement | |
u32 | judge () const noexcept |
bool | is_form () const noexcept |
bool | is_intro () const noexcept |
bool | is_elim () const noexcept |
bool | is_meta () const noexcept |
type | |
const Def * | type () const noexcept |
Yields the "raw" type of this Def (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 |
virtual const Def * | arity () const |
ops | |
template<size_t N = std::dynamic_extent> | |
constexpr auto | ops () const noexcept |
const Def * | op (size_t i) const noexcept |
constexpr size_t | num_ops () const noexcept |
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: If Def::is_set() is ...
MimIR assumes that a mutable is final, when its last operand is set. Then, Def::check() will be invoked. | |
bool | is_set () const |
Yields true if empty or the last op is set. | |
Def * | set (size_t i, const Def *) |
Successively set from left to right. | |
Def * | set (Defs ops) |
Set ops all at once (no Def::unset necessary beforehand). | |
Def * | unset () |
Unsets all Def::ops; works even, if not set at all or only partially set. | |
Def * | set_type (const Def *) |
Update type. | |
deps | |
All dependencies of a Def and includes:
| |
Defs | deps () const noexcept |
const Def * | dep (size_t i) const noexcept |
size_t | num_deps () const noexcept |
has_dep | |
Checks whether one Def::deps() contains specific elements defined in Dep. This works up to the next mutable. For example, consider the Tuple const Var * has_var() Only returns not nullptr, if Var of this mutable has ever been created. Definition def.h:433 | |
bool | has_dep () const |
bool | has_dep (Dep d) const |
bool | has_dep (unsigned u) 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>();
Vector<const Def*> projs1 = def->projs(); // "projs1" has def->num_projs() many elements
Vector<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
Vector(I, I, A=A()) -> Vector< typename std::iterator_traits< I >::value_type, Default_Inlined_Size< typename std::iterator_traits< I >::value_type >, A > | |
nat_t | num_projs () const |
Yields Def::arity(), if it is a Lit, or 1 otherwise. | |
nat_t | num_tprojs () const |
As above but yields 1, if Flags::scalarize_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 = 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 |
var | |
nat_t | num_vars () noexcept |
nat_t | num_tvars () noexcept |
const Def * | var (nat_t a, nat_t i) noexcept |
const Def * | var (nat_t i) noexcept |
const Def * | tvar (nat_t i) noexcept |
template<nat_t A = std::dynamic_extent, class F> | |
auto | vars (F f) noexcept |
template<class F> | |
auto | tvars (F f) noexcept |
template<nat_t A = std::dynamic_extent> | |
auto | vars () noexcept |
auto | tvars () noexcept |
template<class F> | |
auto | vars (nat_t a, F f) noexcept |
auto | vars (nat_t a) noexcept |
const Def * | 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 |
Mutables reachable by following immutable deps(); mut->local_muts() is by definition the set { mut } . | |
Vars | local_vars () const |
Vars reachable by following immutable deps(). | |
Vars | free_vars () const |
Compute a global solution by transitively following mutables as well. | |
Vars | free_vars () |
Muts | users () |
Set of mutables where this mutable is locally referenced. | |
bool | is_open () const |
Has free_vars()? | |
bool | is_closed () const |
Has no free_vars()? | |
external | |
bool | is_external () const noexcept |
void | make_external () |
void | make_internal () |
void | transfer_external (Def *to) |
Casts | |
| |
bool | is_mutable () const noexcept |
template<class T = Def> | |
const T * | isa_imm () const |
template<class T = Def> | |
const T * | as_imm () const |
template<class T = Def, bool invert = false> | |
T * | isa_mut () const |
If this is mutable, 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 | |
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, const Def *type) |
Def * | stub (const Def *type) |
const Def * | rebuild (World &w, const Def *type, Defs ops) const |
Def::rebuilds this Def while using new_op as substitute for its i'th Def::op. | |
const Def * | rebuild (const Def *type, Defs ops) const |
virtual const Def * | immutabilize () |
Tries to make an immutable from a mutable. | |
bool | is_immutabilizable () |
const Def * | refine (size_t i, const Def *new_op) const |
template<size_t N = std::dynamic_extent> | |
constexpr auto | reduce (const Def *arg) const |
virtual constexpr size_t | reduction_offset () const noexcept |
First Def::op that needs to be dealt with during reduction; e.g. | |
Type Checking | |
virtual const Def * | check (size_t i, const Def *def) |
Checks whether the i th operand can be set to def . | |
virtual const Def * | check () |
After all Def::ops have ben Def::set, this method will be invoked to check the type of this mutable. | |
const Def * | zonk () const |
If Holes have been filled, reconstruct the program without them. | |
const Def * | zonk_mut () const |
If *mutable, zonks all ops and tries to immutabilize it; otherwise just zonk. | |
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 |
Static Public Member Functions | |
static DefVec | zonk (Defs defs) |
zonks all defs and retuns a new DefVec. | |
Protected Member Functions | |
C'tors and D'tors | |
Def (World *, Node, const Def *type, Defs ops, flags_t flags) | |
Constructor for an immutable Def. | |
Def (Node, const Def *type, Defs ops, flags_t flags) | |
As above but World retrieved from type . | |
Def (Node, 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_ | |
Axm only: Axms use this member to store their normalizer. | ||
const Axm * | axm_ | |
App only: Curried Apps of Axms use this member to propagate the Axm. | ||
const Var * | var_ | |
Mutable only: Var of a mutable. | ||
World * | world_ | |
}; | ||
flags_t | flags_ | |
u8 | curry_ = 0 | |
u8 | trip_ = 0 | |
Private Member Functions | |
virtual Def * | stub_ (World &, const Def *) |
virtual const Def * | rebuild_ (World &w, const Def *type, Defs ops) const =0 |
Friends | |
template<class D, size_t N> | |
class | Sets |
class | World |
void | swap (World &, World &) noexcept |
std::ostream & | operator<< (std::ostream &os, const Def *def) |
This will stream def as an operand. | |
Syntactic Comparison | |
enum class | Cmp { L , G , E , U } |
static Cmp | cmp (const Def *a, const Def *b) |
static bool | less (const Def *a, const Def *b) |
static bool | greater (const Def *a, const Def *b) |
Base class for all Defs.
These are the most important subclasses:
Type Formation | Term Introduction | Term Elimination |
---|---|---|
Pi | Lam | App |
Sigma / Arr | Tuple / Pack | Extract |
Insert | Insert | |
Uniq | Wrap | Unwrap |
Join | Inj | Match |
Meet | Merge | Split |
Reform | Rule | |
Nat | Lit | |
Idx | Lit |
In addition there is:
The data layout (see World::alloc and Def::deps) looks like this:
|
strong |
|
protectedvirtualdefault |
References World.
|
virtual |
Reimplemented in mim::Arr, mim::Pack, and mim::Sigma.
Definition at line 546 of file def.cpp.
References mim::World::lit_nat_1(), type(), and world().
Referenced by mim::Pack::arity(), mim::Sigma::arity(), mim::World::extract(), mim::flatten(), mim::plug::regex::normalize_conj(), mim::plug::regex::normalize_disj(), num_projs(), num_tprojs(), mim::Rewriter::rewrite_imm_Seq(), mim::Rewriter::rewrite_mut_Seq(), mim::Seq::set(), mim::tuple2str(), and mim::unflatten().
|
inline |
|
inline |
Asserts that this
is a mutable, casts const
ness away and performs a static_cast
to T
.
Definition at line 491 of file def.h.
Referenced by as_imm(), mim::plug::clos::clos_type(), mim::plug::autodiff::AutoDiffEval::derive_(), mim::ast::TuplePtrn::emit_body(), mim::Var::mut(), mim::Var::rebuild_(), and mim::Rewriter::rewrite_mut_Seq().
|
inlinevirtual |
After all Def::ops have ben Def::set, this method will be invoked to check the type of this mutable.
The method returns a possibly updated version of its type (e.g. where Holes have been resolved). If different from Def::type, it will update its Def::type to a Def::zonked version of that.
Reimplemented in mim::Arr, mim::Pi, mim::Reform, mim::Rule, and mim::Sigma.
Definition at line 580 of file def.h.
References type().
|
inline |
Definition at line 502 of file def.h.
References dbg_.
Referenced by rebuild(), mim::Axm::rebuild_(), mim::Inj::rebuild_(), mim::TBound< Up >::rebuild_(), mim::TExt< Up >::rebuild_(), mim::Rewriter::rewrite(), mim::Arr::stub(), stub(), mim::Global::stub(), mim::Hole::stub(), mim::Lam::stub(), mim::Pack::stub(), mim::Pi::stub(), mim::Rule::stub(), and mim::Sigma::stub().
const Def * mim::Def::debug_prefix | ( | std::string | prefix | ) | const |
const Def * mim::Def::debug_suffix | ( | std::string | suffix | ) | const |
|
inlinenoexcept |
|
noexcept |
Definition at line 464 of file def.cpp.
References is_set(), and type().
Referenced by dep(), mim::Scheduler::early(), mim::plug::clos::free_defs(), is_immutabilizable(), num_deps(), mim::post_order(), mim::PassMan::run(), mim::ClosedMutPhase< M >::start(), and zonk_mut().
void mim::Def::dot | ( | const char * | file = nullptr, |
uint32_t | max = 0xFFFFFF, | ||
bool | types = false ) const |
|
inline |
void mim::Def::dot | ( | std::ostream & | os, |
uint32_t | max = 0xFFFFFF, | ||
bool | types = false ) const |
|
inlineconstexprnoexcept |
Definition at line 269 of file def.h.
References flags(), and flags_.
Referenced by mim::Axm::base(), cmp(), Def(), Def(), Def(), flags(), mim::Axm::IsA< Id, D >::id(), mim::Pi::is_implicit(), mim::Global::is_mutable(), mim::UInc::offset(), mim::Proxy::pass(), mim::Axm::plugin(), mim::Axm::sub(), mim::Axm::tag(), and mim::Proxy::tag().
Vars mim::Def::free_vars | ( | ) |
Definition at line 347 of file def.cpp.
References free_vars(), and world().
Vars mim::Def::free_vars | ( | ) | const |
Compute a global solution by transitively following mutables as well.
Definition at line 334 of file def.cpp.
References isa_mut(), local_muts(), local_vars(), vars(), mim::World::vars(), and world().
Referenced by cmp(), mim::Nest::contains(), free_vars(), mim::plug::clos::ClosConvPrep::from_outer_scope(), is_closed(), mim::Rule::is_in_rule(), and is_open().
|
inlineconstexprnoexcept |
Global id - unique number for this Def.
Definition at line 270 of file def.h.
Referenced by mim::plug::regex::compare_re(), Def(), mim::World::match(), mim::plug::refly::normalize_gid(), mim::UseHash::operator()(), set(), set(), and unique_name().
Definition at line 543 of file def.cpp.
Referenced by mim::plug::core::normalize_bit2(), mim::plug::core::normalize_nat(), and mim::plug::core::normalize_ncmp().
|
inline |
|
inline |
Only returns not nullptr
, if Var of this mutable has ever been created.
Definition at line 433 of file def.h.
References has_var().
Referenced by mim::Lam::eta_reduce(), has_var(), has_var(), is_immutabilizable(), and mim::Rewriter::rewrite_mut_Seq().
|
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 mim::Arr, mim::Pack, mim::Pi, mim::Rule, and mim::Sigma.
Definition at line 553 of file def.h.
Referenced by mim::Rewriter::rewrite_stub().
bool mim::Def::is_closed | ( | ) | const |
Has no free_vars()?
Definition at line 415 of file def.cpp.
References mim::Sets< D, N >::Set::empty(), free_vars(), is_external(), local_muts(), and local_vars().
Referenced by mim::Scheduler::early(), mim::plug::clos::free_defs(), mim::Scheduler::late(), mim::World::make_external(), mim::plug::vec::normalize_diff(), and mim::plug::core::normalize_pe().
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 464 of file def.h.
Referenced by is_closed(), mim::isa_workable(), mim::World::make_external(), and mim::World::make_internal().
|
inlinenoexcept |
bool mim::Def::is_immutabilizable | ( | ) |
Definition at line 177 of file def.cpp.
References deps(), has_var(), is_set(), and op().
Referenced by mim::Arr::immutabilize(), mim::Pack::immutabilize(), mim::Pi::immutabilize(), and mim::Sigma::immutabilize().
|
inlinenoexcept |
Definition at line 284 of file def.h.
References mim::Intro, and judge().
Referenced by mim::flatten(), mim::Rewriter::rewrite_imm_Seq(), and mim::Rewriter::rewrite_mut_Seq().
|
inlinenoexcept |
bool mim::Def::is_open | ( | ) | const |
Has free_vars()?
Definition at line 423 of file def.cpp.
References mim::Sets< D, N >::Set::empty(), free_vars(), and local_vars().
bool mim::Def::is_set | ( | ) | const |
Yields true
if empty or the last op is set.
Definition at line 298 of file def.cpp.
References num_ops(), op(), and ops().
Referenced by mim::EtaExp::analyze(), cmp(), deps(), is_immutabilizable(), mim::Hole::isa_set(), mim::isa_workable(), mim::EtaExp::rewrite(), mim::EtaRed::rewrite(), mim::BetaRedPhase::rewrite_imm_App(), mim::Rewriter::rewrite_mut_Seq(), mim::Rewriter::rewrite_stub(), mim::Hole::tuplefy(), and zonk_mut().
bool mim::Def::is_term | ( | ) | const |
Definition at line 480 of file def.cpp.
References mim::Lit::isa(), and type().
Referenced by mim::Rewriter::rewrite_mut_Seq().
|
inline |
Definition at line 476 of file def.h.
References isa_mut().
Referenced by mim::World::app(), cmp(), mim::merge_sigma(), mim::merge_tuple(), and rebuild().
|
inline |
If this
is mutable, it will cast const
ness away and perform a dynamic_cast
to T
.
Definition at line 482 of file def.h.
Referenced by mim::BetaRed::analyze(), mim::EtaExp::analyze(), mim::EtaRed::analyze(), mim::plug::mem::SSAConstr::analyze(), mim::World::app(), mim::Sigma::arity(), mim::plug::autodiff::AutoDiffEval::augment_(), cmp(), mim::Scheduler::early(), mim::Bound::find(), mim::Hole::find(), free_vars(), has_var(), mim::plug::clos::isa_clos_type(), isa_imm(), mim::Hole::isa_unset(), mim::Scheduler::late(), local_muts(), proj(), mim::EtaExp::rewrite(), mim::EtaRed::rewrite(), mim::plug::affine::LowerFor::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::Rewriter::rewrite(), mim::Scalarize::rewrite(), mim::plug::clos::ClosConvPrep::rewrite_arg(), mim::BetaRedPhase::rewrite_imm_App(), mim::Scheduler::Scheduler(), mim::Hole::tuplefy(), and zonk_mut().
|
noexcept |
|
inline |
Definition at line 503 of file def.h.
References dbg_.
Referenced by mim::World::app(), mim::Arr::check(), mim::Lam::check(), mim::Pi::check(), mim::Reform::check(), mim::Rule::check(), mim::World::extract(), mim::World::insert(), mim::plug::refly::normalize_equiv(), mim::World::seq(), mim::World::type(), mim::World::uinc(), and mim::World::umax().
Muts mim::Def::local_muts | ( | ) | const |
Mutables reachable by following immutable deps(); mut->local_muts()
is by definition the set { mut }
.
Definition at line 329 of file def.cpp.
References isa_mut().
Referenced by free_vars(), is_closed(), mim::post_order(), and mim::ClosedMutPhase< M >::start().
Vars mim::Def::local_vars | ( | ) | const |
Vars reachable by following immutable deps().
var->local_vars()
is by definition the set { var }
. Definition at line 345 of file def.cpp.
Referenced by free_vars(), is_closed(), and is_open().
void mim::Def::make_external | ( | ) |
Definition at line 563 of file def.cpp.
References mim::World::make_external(), and world().
Referenced by transfer_external().
void mim::Def::make_internal | ( | ) |
Definition at line 564 of file def.cpp.
References mim::World::make_internal(), and world().
Referenced by mim::optimize(), mim::PrefixCleanup::rewrite_external(), and transfer_external().
|
inlineconstexprnoexcept |
Used internally by free_vars().
|
inlineconstexprnoexcept |
Definition at line 274 of file def.h.
Referenced by mim::Bound::Bound(), cmp(), Def(), Def(), mim::Ext::Ext(), mim::Pi::isa_cn(), judge(), node_name(), mim::Rewriter::rewrite_imm(), mim::Rewriter::rewrite_mut(), and mim::Seq::set().
std::string_view mim::Def::node_name | ( | ) | const |
Definition at line 454 of file def.cpp.
References mim::CODE, MIM_NODE, and node().
Referenced by mim::plug::autodiff::AutoDiffEval::augment_(), mim::plug::autodiff::autodiff_type_fun(), and mim::plug::autodiff::zero_def().
|
inlinenoexcept |
|
inlineconstexprnoexcept |
Definition at line 309 of file def.h.
Referenced by mim::EtaExp::analyze(), mim::plug::mem::SSAConstr::analyze(), mim::Sigma::arity(), cmp(), mim::plug::core::convert(), Def(), is_set(), mim::plug::mem::normalize_load(), refine(), mim::EtaExp::rewrite(), mim::EtaRed::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::Rewriter::rewrite_stub(), set(), set(), mim::Sigma::stub_(), and unset().
nat_t mim::Def::num_projs | ( | ) | const |
Yields Def::arity(), if it is a Lit, or 1
otherwise.
Definition at line 574 of file def.cpp.
References arity(), and mim::Lit::isa().
Referenced by mim::plug::clos::clos_insert_env(), mim::plug::clos::clos_remove_env(), mim::plug::mem::mem_def(), proj(), projs(), and mim::plug::mem::replace_mem().
nat_t mim::Def::num_tprojs | ( | ) | const |
As above but yields 1, if Flags::scalarize_threshold is exceeded.
Definition at line 576 of file def.cpp.
References arity(), mim::World::flags(), mim::Lit::isa(), mim::Flags::scalarize_threshold, and world().
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 429 of file def.h.
Referenced by mim::ll::Emitter::emit_epilogue(), and mim::Lam::ret_var().
|
inlinenoexcept |
Definition at line 308 of file def.h.
References ops().
Referenced by mim::EtaExp::analyze(), mim::plug::mem::SSAConstr::analyze(), mim::App::arg(), mim::Arr::arity(), mim::Sigma::arity(), mim::Lam::body(), mim::App::callee(), mim::plug::clos::clos_type_to_pi(), cmp(), mim::Pi::codom(), mim::Pi::dom(), mim::Lam::filter(), mim::Hole::find(), mim::Bound::get(), mim::Rule::guard(), mim::Extract::index(), mim::Insert::index(), mim::Global::init(), is_immutabilizable(), is_set(), mim::plug::clos::isa_clos_type(), mim::Hole::isa_set(), mim::Type::level(), mim::Rule::lhs(), mim::Reform::meta_type(), mim::Var::mut(), mim::plug::mem::normalize_load(), mim::Hole::op(), mim::UInc::op(), mim::Uniq::op(), proj(), mim::TBound< false >::rebuild_(), refine(), mim::EtaExp::rewrite(), mim::EtaRed::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::Rewriter::rewrite_stub(), mim::Rule::rhs(), mim::Match::scrutinee(), set(), mim::Extract::tuple(), mim::Insert::tuple(), mim::Inj::value(), mim::Insert::value(), mim::Split::value(), and zonk_mut().
|
inlineconstexprnoexcept |
Definition at line 305 of file def.h.
Referenced by mim::BetaRed::analyze(), mim::Match::arms(), mim::Seq::body(), mim::Bound::Bound(), mim::Sigma::check(), mim::plug::core::convert(), Def(), Def(), mim::World::extract(), mim::Bound::find(), mim::Sigma::immutabilize(), mim::Sigma::infer(), mim::Tuple::infer(), is_set(), op(), rebuild(), rebuild(), rebuild_(), mim::TBound< false >::rebuild_(), mim::EtaExp::rewrite(), set(), mim::Lam::set(), mim::Reform::set(), mim::Sigma::set(), and mim::plug::mem::strip_mem_ty().
Similar to World::extract while assuming an arity of a
, but also works on Sigmas and Arrays.
Definition at line 581 of file def.cpp.
References isa_mut(), op(), type(), World, and world().
Referenced by mim::plug::clos::clos_remove_env(), mim::ll::Emitter::emit_bb(), mim::flatten(), projs(), projs(), mim::plug::clos::ClosConvPrep::rewrite_arg(), tproj(), mim::tuple2str(), and mim::Hole::tuplefy().
As above but takes Def::num_projs as arity.
Definition at line 384 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 == std::dynamic_extent
) or std::array
(otherwise).
Applies f
to each element.
Definition at line 390 of file def.h.
References num_projs(), proj(), and projs().
Referenced by mim::plug::autodiff::AutoDiffEval::augment_tuple(), mim::ll::Emitter::emit_bb(), mim::plug::clos::Clos2SJLJ::enter(), mim::plug::regex::flatten_in_arg(), mim::plug::mem::mem_def(), mim::plug::core::normalize_abs(), mim::plug::autodiff::normalize_add(), mim::plug::math::normalize_arith(), mim::plug::core::normalize_bit2(), mim::plug::tuple::normalize_cat(), mim::plug::vec::normalize_cat(), mim::plug::refly::normalize_check(), mim::plug::math::normalize_cmp(), mim::plug::ord::normalize_contains(), mim::plug::tuple::normalize_contains(), mim::plug::refly::normalize_dbg(), mim::plug::vec::normalize_diff(), mim::plug::core::normalize_div(), mim::plug::refly::normalize_equiv(), mim::plug::core::normalize_extrema(), mim::plug::math::normalize_extrema(), mim::plug::vec::normalize_fold(), mim::plug::ord::normalize_get(), mim::plug::core::normalize_icmp(), mim::plug::ord::normalize_insert(), mim::plug::mem::normalize_lea(), mim::plug::mem::normalize_load(), mim::plug::core::normalize_nat(), mim::plug::core::normalize_ncmp(), mim::plug::math::normalize_pow(), mim::plug::regex::normalize_range(), mim::plug::matrix::normalize_read(), mim::plug::refly::normalize_refine(), mim::plug::matrix::normalize_shape(), mim::plug::core::normalize_shr(), mim::plug::mem::normalize_store(), mim::plug::autodiff::normalize_sum(), mim::plug::core::normalize_wrap(), mim::plug::tuple::normalize_zip(), reg_stages(), mim::plug::matrix::LowerMatrixLowLevel::rewrite_imm_App(), mim::plug::mem::strip_mem(), and mim::unflatten().
|
inline |
|
inline |
Definition at line 408 of file def.h.
References proj(), and mim::Vector().
Def::rebuilds this Def while using new_op
as substitute for its i'th
Def::op.
Definition at line 545 of file def.h.
References dbg(), isa_imm(), ops(), rebuild_(), set(), type(), and World.
Referenced by refine(), and mim::EtaExp::rewrite().
|
privatepure virtual |
Implemented in mim::App, mim::Arr, mim::Axm, mim::Extract, mim::Global, mim::Hole, mim::Idx, mim::Inj, mim::Insert, mim::Lam, mim::Lit, mim::Match, mim::Merge, mim::Nat, mim::Pack, mim::Pi, mim::Proxy, mim::Reform, mim::Rule, mim::Sigma, mim::Split, mim::TBound< Up >, mim::TBound< false >, mim::TBound< false >, mim::TBound< true >, mim::TBound< true >, mim::TExt< Up >, mim::TExt< false >, mim::TExt< false >, mim::TExt< true >, mim::TExt< true >, mim::Tuple, mim::Type, mim::UInc, mim::UMax, mim::Uniq, mim::Univ, and mim::Var.
References ops(), type(), and World.
Referenced by rebuild().
|
inlineconstexpr |
Definition at line 560 of file def.h.
Referenced by mim::plug::clos::Clos2SJLJ::enter(), mim::RetWrap::enter(), mim::Arr::reduce(), mim::Pack::reduce(), mim::Pi::reduce(), mim::Rule::reduce(), and mim::Lam::reduce_body().
|
inlineconstexprvirtualnoexcept |
First Def::op that needs to be dealt with during reduction; e.g.
for a Pi we don't reduce the Pi::dom.
Reimplemented in mim::Arr, mim::Bound, mim::Lam, mim::Pack, mim::Pi, mim::Rule, and mim::Sigma.
Definition at line 232 of file def.cpp.
References num_ops(), op(), rebuild(), and type().
Referenced by mim::plug::clos::clos_sub_env(), mim::EtaRed::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::plug::clos::ClosConvPrep::rewrite_arg(), and mim::plug::clos::ClosConvPrep::rewrite_callee().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Successively set from left to right.
Definition at line 266 of file def.cpp.
References check(), gid(), num_ops(), op(), type(), world(), and zonk().
Referenced by mim::plug::autodiff::AutoDiffEval::augment_extract(), mim::plug::autodiff::AutoDiffEval::augment_tuple(), mim::plug::autodiff::AutoDiffEval::derive_(), mim::ast::MatchExpr::Arm::emit(), mim::ast::AliasPtrn::emit_value(), rebuild(), mim::LamSpec::rewrite(), mim::plug::affine::LowerFor::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::VarRewriter::rewrite(), mim::plug::clos::ClosConvPrep::rewrite_arg(), mim::plug::clos::ClosConvPrep::rewrite_callee(), mim::Rewriter::rewrite_stub(), set(), set(), set(), set(), set(), set(), set(), set(), mim::Global::set(), mim::Hole::set(), mim::Lam::set(), mim::Lam::set(), mim::Pack::set(), mim::Pi::set(), mim::Reform::set(), mim::Reform::set(), mim::Seq::set(), mim::Sigma::set(), mim::Sigma::set(), mim::Arr::set_arity(), mim::Arr::set_body(), mim::Lam::set_body(), mim::Pi::set_codom(), mim::Pi::set_dom(), mim::Pi::set_dom(), mim::Lam::set_filter(), mim::Rule::set_guard(), mim::Rule::set_lhs(), mim::Rule::set_rhs(), and stub().
|
inline |
|
inline |
|
inline |
|
inline |
std::ostream & mim::Def::stream | ( | std::ostream & | os, |
int | max ) const |
Definition at line 541 of file def.h.
References dbg(), set(), stub_(), type(), and World.
Referenced by mim::LamSpec::rewrite(), and mim::Seq::stub().
|
inline |
Definition at line 504 of file def.h.
References dbg_.
Referenced by mim::plug::autodiff::AutoDiffEval::augment_lam(), debug_prefix(), debug_suffix(), mim::World::make_external(), mim::World::make_internal(), mim::PrefixCleanup::rewrite_external(), set(), set(), set(), set(), transfer_external(), and unique_name().
|
protected |
Definition at line 432 of file def.cpp.
References mim::World::sym(), and world().
|
protected |
Definition at line 434 of file def.cpp.
References mim::World::sym(), and world().
|
protected |
Definition at line 433 of file def.cpp.
References mim::World::sym(), and world().
|
inlineconstexprnoexcept |
As above but takes Def::num_tprojs.
Definition at line 385 of file def.h.
References num_tprojs(), and proj().
|
inline |
|
inline |
Definition at line 403 of file def.h.
References num_tprojs(), and projs().
void mim::Def::transfer_external | ( | Def * | to | ) |
Definition at line 566 of file def.cpp.
References make_external(), make_internal(), and sym().
Referenced by mim::EtaExpPhase::rewrite_external(), mim::EtaRedPhase::rewrite_external(), mim::PrefixCleanup::rewrite_external(), and mim::RWPhase::rewrite_external().
|
inlinenoexcept |
Yields the "raw" type of this Def (maybe nullptr
).
Definition at line 295 of file def.h.
Referenced by mim::World::app(), arity(), mim::Pack::arity(), mim::Checker::assignable(), mim::plug::autodiff::AutoDiffEval::augment_(), mim::plug::autodiff::AutoDiffEval::augment_app(), mim::plug::autodiff::AutoDiffEval::augment_extract(), mim::plug::autodiff::AutoDiffEval::augment_lam(), mim::plug::autodiff::AutoDiffEval::augment_pack(), mim::plug::autodiff::AutoDiffEval::augment_tuple(), mim::Bound::Bound(), mim::App::callee_type(), mim::Arr::check(), check(), mim::Lam::check(), mim::Pi::check(), mim::Reform::check(), mim::Rule::check(), mim::Sigma::check(), mim::plug::clos::clos_pack(), cmp(), mim::plug::matrix::counting_for(), Def(), Def(), Def(), deps(), mim::plug::autodiff::AutoDiffEval::derive_(), mim::ll::Emitter::emit_bb(), mim::plug::clos::ClosLit::env_type(), mim::plug::clos::ClosConvPrep::eta_wrap(), mim::Ext::Ext(), mim::World::extract(), mim::Bound::find(), mim::flatten(), mim::plug::clos::ClosLit::fnc_type(), mim::Bound::get(), mim::World::implicit_app(), mim::Axm::infer_curry_and_trip(), mim::World::insert(), is_term(), mim::is_unit(), mim::plug::clos::ClosLit::isa_clos_lit, mim::World::match(), mim::plug::mem::mem_def(), mim::merge_tuple(), mim::plug::core::normalize_bitcast(), mim::plug::core::normalize_conv(), mim::plug::math::normalize_conv(), mim::plug::core::normalize_shr(), mim::plug::refly::normalize_type(), mim::plug::core::op(), mim::plug::direct::op_cps2ds_dep(), mim::plug::mem::op_lea(), mim::plug::mem::op_lea_unsafe(), mim::optimize(), mim::Pi::Pi(), mim::Pi::Pi(), proj(), rebuild(), rebuild(), mim::Axm::rebuild_(), rebuild_(), mim::TBound< false >::rebuild_(), refine(), mim::Reform::Reform(), mim::plug::mem::replace_mem(), mim::EtaExp::rewrite(), mim::plug::matrix::LowerMatrixHighLevelMapRed::rewrite_(), mim::plug::clos::ClosConvPrep::rewrite_callee(), mim::plug::matrix::LowerMatrixLowLevel::rewrite_imm_App(), mim::EtaExpPhase::rewrite_imm_Var(), mim::EtaRedPhase::rewrite_imm_Var(), mim::Rewriter::rewrite_mut_Seq(), mim::Scheduler::Scheduler(), mim::World::seq(), set(), set_type(), mim::plug::mem::strip_mem(), mim::Arr::stub(), stub(), stub(), mim::Hole::stub(), mim::Pack::stub(), mim::Pi::stub(), mim::Seq::stub(), mim::Sigma::stub(), mim::Hole::tuplefy(), mim::Global::type(), mim::Lam::type(), mim::Rule::type(), mim::World::type(), mim::World::uinc(), mim::World::umax(), mim::World::uniq(), and world().
const Def * mim::Def::unfold_type | ( | ) | const |
Yields the type of this Def and builds a new Type (UInc n)
if necessary.
Definition at line 443 of file def.cpp.
References world().
Referenced by mim::Arr::check(), mim::World::seq(), mim::World::umax(), and mim::World::uniq().
std::string mim::Def::unique_name | ( | ) | const |
name + "_" + Def::gid
Definition at line 572 of file def.cpp.
Referenced by mim::Nest::Node::name(), and mim::ll::Emitter::prepare().
Def * mim::Def::unset | ( | ) |
Unsets all Def::ops; works even, if not set at all or only partially set.
Definition at line 289 of file def.cpp.
References num_ops().
Referenced by mim::Arr::unset(), mim::Hole::unset(), mim::Lam::unset(), mim::Pack::unset(), mim::Pi::unset(), mim::Reform::unset(), mim::Rule::unset(), mim::Seq::unset(), and mim::Sigma::unset().
|
inline |
const Def * mim::Def::var | ( | ) |
Not necessarily a Var: E.g., if the return type is []
, this will yield ()
.
Definition at line 310 of file def.cpp.
References world().
Referenced by mim::Lam::ret_var().
Definition at line 429 of file def.h.
Referenced by mim::plug::autodiff::AutoDiffEval::augment_app(), mim::plug::autodiff::AutoDiffEval::augment_lam(), Def(), mim::plug::autodiff::AutoDiffEval::derive_(), mim::ast::TuplePtrn::emit_body(), mim::plug::clos::ClosLit::env_var(), mim::Lam::eta_reduce(), mim::plug::clos::ClosConvPrep::eta_wrap(), mim::Rule::is_in_rule(), mim::plug::clos::isa_clos_type(), mim::plug::mem::mem_var(), num_tvars(), mim::Rule::replace(), mim::plug::matrix::LowerMatrixMediumLevel::rewrite_(), and mim::Hole::tuplefy().
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 429 of file def.h.
Referenced by mim::plug::clos::Clos2SJLJ::enter(), mim::RetWrap::enter(), free_vars(), mim::ll::Emitter::prepare(), and mim::plug::affine::LowerFor::rewrite().
|
inlinenoexcept |
|
noexcept |
Definition at line 436 of file def.cpp.
Referenced by mim::Checker::alpha(), mim::Lam::app(), mim::Lam::app(), apply(), mim::plug::clos::apply_closure(), arity(), mim::Pack::arity(), mim::Sigma::arity(), mim::plug::autodiff::autodiff_type_fun(), mim::plug::autodiff::autodiff_type_fun_pi(), mim::Lam::branch(), mim::Lam::check(), mim::Rule::check(), mim::Sigma::check(), mim::plug::clos::clos_apply(), mim::plug::clos::clos_insert_env(), mim::plug::clos::clos_pack(), mim::plug::clos::clos_remove_env(), mim::plug::clos::clos_type(), mim::plug::clos::clos_type_to_pi(), mim::plug::core::convert(), mim::plug::matrix::counting_for(), debug_prefix(), debug_suffix(), Def(), Def(), mim::flatten(), free_vars(), free_vars(), mim::plug::autodiff::id_pullback(), mim::Arr::immutabilize(), mim::Pack::immutabilize(), mim::Pi::immutabilize(), mim::Rule::immutabilize(), mim::Sigma::immutabilize(), mim::Tuple::infer(), mim::is_unit(), mim::plug::clos::isa_clos_type(), make_external(), make_internal(), mim::merge_sigma(), mim::merge_tuple(), mim::plug::mem::mut_con(), mim::plug::core::normalize_bitcast(), mim::plug::ord::normalize_contains(), mim::plug::core::normalize_conv(), mim::plug::math::normalize_conv(), mim::plug::core::normalize_div(), mim::plug::refly::normalize_gid(), mim::plug::core::normalize_idx_unsafe(), mim::plug::compile::normalize_is_loaded(), num_tprojs(), mim::plug::core::op(), mim::plug::direct::op_cps2ds_dep(), mim::plug::mem::op_lea(), mim::plug::mem::op_lea_unsafe(), mim::plug::mem::op_lea_unsafe(), mim::plug::autodiff::op_sum(), operator<<, proj(), mim::plug::autodiff::pullback_type(), rebuild(), mim::Axm::rebuild_(), reg_stages(), mim::Rule::replace(), set(), set(), mim::Lam::set(), mim::Pi::set_dom(), mim::Lam::set_filter(), stream(), mim::plug::mem::strip_mem(), mim::plug::mem::strip_mem_ty(), mim::Arr::stub(), stub(), mim::Global::stub(), mim::Hole::stub(), mim::Lam::stub(), mim::Pack::stub(), mim::Pi::stub(), mim::Rule::stub(), mim::Sigma::stub(), sym(), sym(), sym(), mim::tuple2str(), mim::Hole::tuplefy(), unfold_type(), var(), mim::plug::autodiff::zero_def(), mim::plug::autodiff::zero_pullback(), zonk(), and zonk_mut().
void mim::Def::write | ( | int | max | ) | const |
void mim::Def::write | ( | int | max, |
const char * | file ) const |
const Def * mim::Def::zonk | ( | ) | const |
If Holes have been filled, reconstruct the program without them.
Only gues up to but excluding other mutables.
Definition at line 61 of file check.cpp.
References world().
Referenced by mim::World::app(), mim::World::extract(), mim::World::inj(), mim::World::insert(), mim::World::match(), mim::World::merge(), mim::World::merge(), mim::World::raw_app(), mim::World::seq(), set(), mim::World::sigma(), mim::World::split(), mim::World::tuple(), mim::World::tuple(), mim::World::type(), mim::World::uinc(), mim::World::umax(), mim::World::uniq(), and zonk_mut().
const Def * mim::Def::zonk_mut | ( | ) | const |
|
friend |
|
friend |
|
friend |
union { ... } mim::Def |
|
protected |
Definition at line 661 of file def.h.
Referenced by mim::App::curry(), and mim::Axm::curry().
|
mutableprotected |
|
protected |
Definition at line 660 of file def.h.
Referenced by Def(), Def(), flags(), mim::Lit::get(), mim::Pi::make_explicit(), and mim::Pi::make_implicit().
|
protected |
Definition at line 662 of file def.h.
Referenced by mim::App::trip(), and mim::Axm::trip().