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 |
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 |
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:
MimIR 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 |
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 = -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 | |
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(), mim::World::merge(), mim::murmur3(), mim::murmur3_finalize(), mim::murmur3_rest(), mim::World::next_gid(), node(), num_ops(), op(), ops(), type(), mim::Node::Univ, var(), mim::World::vars(), and world().
Constructor for a mutable Def.
Definition at line 60 of file def.cpp.
References dep_const(), gid(), mim::murmur3(), mim::World::next_gid(), num_ops(), mim::Use::Type, type(), and world().
|
protectedvirtualdefault |
Ref mim::Def::arity | ( | ) | const |
Definition at line 481 of file def.cpp.
References mim::World::lit_nat(), mim::World::lit_nat_1(), type(), and world().
Referenced by mim::plug::autodiff::AutoDiffEval::augment_pack(), mim::World::extract(), mim::World::insert(), mim::tuple2str(), and mim::unflatten().
|
inline |
|
inline |
Definition at line 259 of file def.h.
References isa_lit_arity().
Referenced by mim::World::extract(), mim::plug::regex::normalize_conj(), mim::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 mim::BetaRed::analyze(), mim::EtaExp::analyze(), mim::plug::mem::CopyProp::analyze(), mim::plug::mem::SSAConstr::analyze(), as_imm(), mim::plug::clos::clos_type(), mim::plug::autodiff::AutoDiffEval::derive_(), mim::ast::TuplePtrn::emit_body(), mim::Var::mut(), mim::ll::Emitter::prepare(), mim::Cleanup::start(), and mim::Emitter< Value, Type, BB, Child >::visit().
|
inlinevirtual |
|
inline |
Definition at line 466 of file def.h.
References dbg_.
Referenced by rebuild(), mim::Arr::stub(), stub(), mim::Global::stub(), mim::Infer::stub(), mim::Lam::stub(), mim::Pack::stub(), mim::Pi::stub(), mim::Sigma::stub(), mim::TBound< Up >::stub(), and mim::TExt< Up >::stub().
const Def * mim::Def::debug_prefix | ( | std::string | prefix | ) | const |
const Def * mim::Def::debug_suffix | ( | std::string | suffix | ) | const |
|
inline |
|
inline |
Definition at line 338 of file def.h.
References has_dep(), mim::Mut, and mim::Var.
Referenced by Def(), mim::Scheduler::early(), mim::Scheduler::late(), mim::plug::core::normalize_pe(), mim::Rewriter::rewrite_imm(), and unset_type().
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 |
|
inline |
Definition at line 312 of file def.h.
References extended_ops().
Defs mim::Def::extended_ops | ( | ) | const |
Definition at line 441 of file def.cpp.
References is_set(), and type().
Referenced by Def(), mim::Scheduler::early(), extended_op(), num_extended_ops(), mim::PassMan::run(), and mim::ClosedMutPhase< M >::start().
|
inline |
Definition at line 238 of file def.h.
References flags_.
Referenced by mim::Axiom::base(), mim::Pi::is_implicit(), mim::Global::is_mutable(), mim::UInc::offset(), mim::optimize(), mim::Proxy::pass(), mim::Axiom::plugin(), mim::Axiom::sub(), mim::Axiom::tag(), and mim::Proxy::tag().
Vars mim::Def::free_vars | ( | ) |
Definition at line 334 of file def.cpp.
References free_vars(), is_set(), and isa_mut().
Vars mim::Def::free_vars | ( | ) | const |
Definition at line 326 of file def.cpp.
References isa_mut(), local_muts(), local_vars(), mim::World::merge(), vars(), and world().
Referenced by free_vars(), mim::Arr::immutabilize(), mim::Pack::immutabilize(), mim::Pi::immutabilize(), mim::Sigma::immutabilize(), is_closed(), is_open(), and mim::VarRewriter::rewrite_mut().
|
inline |
Definition at line 239 of file def.h.
Referenced by mim::commute(), Def(), Def(), mim::PipelineBuilder::def2pass(), mim::plug::refly::normalize_gid(), mim::UseHash::operator()(), mim::register_pass_with_arg(), and unique_name().
|
inline |
Definition at line 336 of file def.h.
References has_dep().
Referenced by dep_const(), has_dep(), and mim::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(), mim::Arr::immutabilize(), mim::Pack::immutabilize(), mim::Pi::immutabilize(), mim::Sigma::immutabilize(), and mim::VarRewriter::rewrite_mut().
|
inline |
|
inlinevirtual |
bool mim::Def::is_closed | ( | ) | const |
Has no free_vars()?
Definition at line 395 of file def.cpp.
References mim::PooledSet< T >::empty(), free_vars(), is_external(), local_muts(), and local_vars().
Referenced by mim::World::make_external(), and mim::World::verify().
|
inline |
Definition at line 431 of file def.h.
Referenced by is_closed(), mim::isa_workable(), mim::World::make_external(), and mim::World::make_internal().
bool mim::Def::is_open | ( | ) | const |
Has free_vars()?
Definition at line 403 of file def.cpp.
References mim::PooledSet< T >::empty(), free_vars(), local_muts(), and local_vars().
bool mim::Def::is_set | ( | ) | const |
Yields true
if empty or the last op is set.
Definition at line 309 of file def.cpp.
References num_ops(), op(), and ops().
Referenced by mim::EtaExp::analyze(), mim::World::app(), extended_ops(), free_vars(), mim::isa_workable(), mim::EtaExp::rewrite(), mim::EtaRed::rewrite(), mim::Rewriter::rewrite_mut(), mim::PassMan::run(), and mim::Emitter< Value, Type, BB, Child >::visit().
bool mim::Def::is_term | ( | ) | const |
Yields true
if this:T
and T:(Type 0)
.
Definition at line 470 of file def.cpp.
References mim::Lit::isa(), and type().
Referenced by mim::flatten().
|
inline |
Definition at line 441 of file def.h.
References isa_mut().
Referenced by mim::World::app(), mim::merge_sigma(), mim::merge_tuple(), mim::plug::core::normalize_trait(), rebuild(), and mim::Infer::should_eliminate().
|
inline |
std::optional< nat_t > mim::Def::isa_lit_arity | ( | ) | const |
Definition at line 488 of file def.cpp.
References mim::Lit::isa(), num_ops(), and type().
Referenced by as_lit_arity(), mim::flatten(), mim::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 mim::BetaRed::analyze(), mim::EtaExp::analyze(), mim::EtaRed::analyze(), mim::plug::mem::SSAConstr::analyze(), mim::World::app(), mim::plug::autodiff::AutoDiffEval::augment_(), mim::Scheduler::early(), mim::World::extract(), mim::Bound::find(), mim::Infer::find(), free_vars(), free_vars(), has_var(), mim::plug::clos::isa_clos_type(), isa_imm(), isa_imm(), mim::Scheduler::late(), local_muts(), proj(), mim::Arr::reduce(), reduce(), mim::Pack::reduce(), 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::Scheduler::Scheduler(), mim::World::tuple(), mim::Emitter< Value, Type, BB, Child >::visit(), and mim::plug::mem::AddMem::visit().
|
inline |
Definition at line 467 of file def.h.
References dbg_, and mim::Dbg::loc().
Referenced by mim::World::app(), mim::Arr::check(), mim::Lam::check(), mim::Pi::check(), mim::World::extract(), mim::World::insert(), mim::World::lit(), mim::World::type(), and mim::World::uinc().
Muts mim::Def::local_muts | ( | ) | const |
Definition at line 321 of file def.cpp.
References isa_mut(), mim::World::muts(), and world().
Referenced by Def(), free_vars(), is_closed(), is_open(), mim::VarRewriter::rewrite_imm(), and mim::ClosedMutPhase< M >::start().
|
inline |
Definition at line 421 of file def.h.
Referenced by Def(), free_vars(), is_closed(), is_open(), and mim::VarRewriter::rewrite_imm().
void mim::Def::make_external | ( | ) |
Definition at line 508 of file def.cpp.
References mim::World::make_external(), and world().
Referenced by transfer_external().
void mim::Def::make_internal | ( | ) |
Definition at line 509 of file def.cpp.
References mim::World::make_internal(), and world().
Referenced by mim::plug::compile::InternalCleanup::enter(), mim::optimize(), and transfer_external().
|
inline |
Definition at line 241 of file def.h.
Referenced by Def(), mim::Pi::isa_cn(), and node_name().
std::string_view mim::Def::node_name | ( | ) | const |
Definition at line 431 of file def.cpp.
References CODE, MIM_NODE, and node().
Referenced by mim::plug::autodiff::AutoDiffEval::augment_(), and mim::plug::autodiff::autodiff_type_fun().
|
inline |
Definition at line 313 of file def.h.
References extended_ops().
|
inline |
Definition at line 270 of file def.h.
Referenced by mim::EtaExp::analyze(), mim::plug::mem::SSAConstr::analyze(), mim::plug::core::convert(), Def(), Def(), mim::World::ext(), mim::World::extract(), mim::Scope::is_free(), is_set(), mim::plug::clos::isa_clos_type(), isa_lit_arity(), mim::plug::mem::normalize_load(), reset(), mim::EtaExp::rewrite(), mim::EtaRed::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::rewrite(), mim::Rewriter::rewrite_imm(), mim::Rewriter::rewrite_mut(), mim::PassMan::run(), set(), set(), and unset().
|
inline |
Definition at line 323 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 357 of file def.h.
References isa_lit_arity().
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 513 of file def.cpp.
References mim::World::flags(), isa_lit_arity(), mim::Flags::scalarize_threshold, and world().
|
inline |
Definition at line 401 of file def.h.
Referenced by mim::ll::Emitter::emit_epilogue(), and mim::Lam::ret_var().
|
inline |
Definition at line 269 of file def.h.
References ops().
Referenced by mim::BetaRed::analyze(), mim::EtaExp::analyze(), mim::EtaExp::analyze(), mim::plug::mem::CopyProp::analyze(), mim::plug::mem::SSAConstr::analyze(), mim::plug::mem::SSAConstr::analyze(), mim::App::arg(), mim::Arr::body(), mim::Lam::body(), mim::Pack::body(), mim::App::callee(), mim::Test::clash(), mim::plug::clos::clos_type_to_pi(), mim::Pi::codom(), Def(), mim::Pi::dom(), mim::World::extract(), mim::Lam::filter(), mim::Infer::find(), mim::Bound::get(), mim::Sigma::immutabilize(), mim::Extract::index(), mim::Insert::index(), mim::Singleton::inhabitant(), mim::Global::init(), is_set(), mim::plug::clos::isa_clos_type(), mim::Type::level(), mim::Test::match(), mim::Var::mut(), mim::plug::mem::normalize_load(), mim::Infer::op(), mim::UInc::op(), mim::Test::probe(), proj(), mim::EtaExp::rewrite(), mim::EtaRed::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::rewrite(), mim::rewrite(), mim::Rewriter::rewrite_imm(), mim::Rewriter::rewrite_mut(), mim::PassMan::run(), set(), mim::Arr::shape(), mim::Extract::tuple(), mim::Insert::tuple(), unset(), mim::Insert::value(), mim::Pick::value(), mim::Test::value(), and mim::Vel::value().
|
inline |
Definition at line 268 of file def.h.
Referenced by mim::BetaRed::analyze(), mim::plug::mem::CopyProp::analyze(), mim::World::arr(), mim::CFA::CFA(), mim::Sigma::check(), mim::plug::core::convert(), Def(), mim::World::extract(), mim::Bound::find(), mim::Sigma::immutabilize(), mim::Sigma::infer(), is_set(), mim::plug::core::normalize_trait(), op(), mim::World::pack(), rebuild(), rebuild(), reduce(), refine(), reset(), mim::EtaExp::rewrite(), set(), mim::Lam::set(), mim::Sigma::set(), mim::plug::mem::strip_mem(), and mim::plug::mem::strip_mem_ty().
|
inline |
Definition at line 322 of file def.h.
References partial_ops().
|
inline |
Definition at line 321 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 518 of file def.cpp.
References mim::Lit::isa(), isa_mut(), op(), mim::Extract::tuple(), type(), uses(), and world().
Referenced by mim::plug::clos::clos_remove_env(), mim::ll::Emitter::emit_bb(), mim::ast::TuplePtrn::emit_value_(), mim::flatten(), mim::World::insert(), projs(), projs(), mim::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 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_get_plugin(), mim::plug::core::normalize_abs(), mim::plug::autodiff::normalize_add(), mim::plug::math::normalize_arith(), mim::plug::core::normalize_bit2(), mim::plug::math::normalize_cmp(), mim::plug::compile::normalize_combine_pass_list(), mim::plug::refly::normalize_dbg(), mim::plug::core::normalize_div(), mim::plug::core::normalize_extrema(), mim::plug::math::normalize_extrema(), mim::plug::core::normalize_icmp(), 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::core::normalize_zip(), mim::plug::matrix::LowerMatrixMediumLevel::rewrite_(), mim::plug::matrix::LowerMatrixLowLevel::rewrite_imm(), mim::plug::mem::strip_mem(), mim::tuple2str(), and mim::unflatten().
|
inline |
|
inline |
Definition at line 381 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 509 of file def.h.
References dbg(), isa_imm(), ops(), rebuild_(), set(), and type().
Referenced by refine(), mim::EtaExp::rewrite(), and mim::Rewriter::rewrite_imm().
Implemented in mim::Ac, mim::App, mim::Arr, mim::Axiom, mim::Extract, mim::Global, mim::Idx, mim::Infer, mim::Insert, mim::Lam, mim::Lit, mim::Nat, mim::Pack, mim::Pi, mim::Pick, mim::Proxy, mim::Sigma, mim::Singleton, mim::TBound< Up >, mim::Test, mim::TExt< Up >, mim::Tuple, mim::Type, mim::UInc, mim::UMax, mim::Univ, mim::Var, and mim::Vel.
Referenced by rebuild().
Definition at line 211 of file def.cpp.
References mim::rewrite(), and world().
Rewrites Def::ops by substituting this
mutable's Var with arg
.
Definition at line 206 of file def.cpp.
References isa_mut(), and ops().
Referenced by mim::World::app(), mim::World::extract(), and mim::plug::compile::handle_optimization_part().
Definition at line 218 of file def.cpp.
References ops(), 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().
Successively reset from left to right.
Definition at line 291 of file def.h.
References set(), and unset().
Referenced by mim::plug::clos::Clos2SJLJ::enter(), mim::RetWrap::enter(), mim::Infer::find(), reset(), mim::Infer::reset(), and mim::PassMan::run().
|
inline |
Definition at line 477 of file def.h.
References dbg_, mim::Dbg::loc(), and mim::Dbg::set().
|
inline |
Definition at line 476 of file def.h.
References dbg_, mim::Dbg::loc(), and mim::Dbg::set().
|
inline |
|
inline |
|
inline |
|
inline |
Successively set from left to right.
Definition at line 246 of file def.cpp.
References check(), num_ops(), op(), and update().
Referenced by mim::plug::autodiff::AutoDiffEval::augment_extract(), mim::plug::autodiff::AutoDiffEval::augment_tuple(), mim::plug::autodiff::AutoDiffEval::derive_(), mim::ast::TuplePtrn::emit_body(), mim::ast::Ptrn::emit_value(), mim::plug::direct::op_cps2ds_dep(), rebuild(), reset(), mim::LamSpec::rewrite(), mim::plug::affine::LowerFor::rewrite(), mim::plug::mem::SSAConstr::rewrite(), mim::plug::clos::ClosConvPrep::rewrite_arg(), mim::plug::clos::ClosConvPrep::rewrite_callee(), set(), mim::Global::set(), mim::Infer::set(), mim::Lam::set(), mim::Pack::set(), mim::Sigma::set(), mim::Sigma::set(), 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::Arr::set_shape(), mim::Arr::stub(), and stub().
|
inline |
|
inline |
|
inline |
Definition at line 479 of file def.h.
References dbg_, mim::Dbg::set(), and mim::Dbg::sym().
|
inline |
Definition at line 478 of file def.h.
References dbg_, mim::Dbg::set(), and mim::Dbg::sym().
Definition at line 288 of file def.cpp.
References mim::Use::Type, type(), and unset_type().
Referenced by mim::Arr::check(), mim::Pi::check(), mim::Sigma::check(), and update().
std::ostream & mim::Def::stream | ( | std::ostream & | os, |
int | max ) const |
Definition at line 505 of file def.h.
References dbg(), set(), stub_(), and type().
Referenced by mim::LamSpec::rewrite(), and mim::Rewriter::rewrite_mut().
Reimplemented in mim::Arr, mim::Global, mim::Infer, mim::Lam, mim::Pack, mim::Pi, mim::Sigma, mim::TBound< Up >, and mim::TExt< Up >.
Definition at line 562 of file def.h.
Referenced by stub().
|
inline |
Definition at line 468 of file def.h.
References dbg_, and mim::Dbg::sym().
Referenced by mim::plug::autodiff::AutoDiffEval::augment_lam(), debug_prefix(), debug_suffix(), mim::plug::compile::InternalCleanup::enter(), mim::World::make_external(), mim::World::make_internal(), mim_get_plugin(), set(), set(), set(), set(), mim::Scope::sym(), and unique_name().
|
protected |
Definition at line 411 of file def.cpp.
References mim::World::sym(), and world().
|
protected |
Definition at line 413 of file def.cpp.
References mim::World::sym(), and world().
|
protected |
Definition at line 412 of file def.cpp.
References mim::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 248 of file def.h.
Referenced by mim::World::app(), arity(), mim::plug::autodiff::AutoDiffEval::augment_(), mim::plug::autodiff::AutoDiffEval::augment_app(), mim::plug::autodiff::AutoDiffEval::augment_extract(), mim::plug::autodiff::AutoDiffEval::augment_pack(), mim::plug::autodiff::AutoDiffEval::augment_tuple(), mim::App::callee_type(), mim::Arr::check(), mim::Pi::check(), mim::Sigma::check(), mim::plug::clos::clos_pack(), mim::plug::matrix::counting_for(), Def(), Def(), mim::plug::autodiff::AutoDiffEval::derive_(), mim::ll::Emitter::emit_bb(), mim::plug::clos::ClosLit::env_type(), mim::plug::clos::ClosConvPrep::eta_wrap(), extended_ops(), mim::World::extract(), mim::Bound::find(), mim::flatten(), mim::plug::clos::ClosLit::fnc_type(), mim::Bound::get(), mim::plug::compile::handle_optimization_part(), mim::World::iapp(), mim::World::iinfer(), mim::World::insert(), is_term(), mim::is_unit(), isa_lit_arity(), 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::core::op(), mim::plug::mem::op_lea(), mim::plug::mem::op_lea_unsafe(), mim::plug::matrix::op_read(), mim::optimize(), mim::World::pack(), proj(), rebuild(), rebuild(), refine(), 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(), mim::Rewriter::rewrite_imm(), mim::Rewriter::rewrite_mut(), mim::PassMan::run(), mim::Scheduler::Scheduler(), set_type(), mim::Pack::shape(), mim::plug::mem::strip_mem(), mim::Arr::stub(), stub(), stub(), mim::Infer::stub(), mim::Pack::stub(), mim::Pi::stub(), mim::Sigma::stub(), mim::TBound< Up >::stub(), mim::TExt< Up >::stub(), mim::World::test(), mim::World::tuple(), mim::Global::type(), mim::Lam::type(), mim::plug::clos::ClosLit::type(), mim::World::type(), mim::World::uinc(), update(), 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 421 of file def.cpp.
References mim::World::type(), and world().
Referenced by mim::World::arr(), mim::Arr::check(), and mim::Pi::infer().
std::string mim::Def::unique_name | ( | ) | const |
Def * mim::Def::unset | ( | ) |
Unsets all Def::ops; works even, if not set at all or partially.
Definition at line 264 of file def.cpp.
References num_ops(), op(), and unset().
Referenced by reset(), mim::Arr::unset(), unset(), mim::Infer::unset(), mim::Lam::unset(), mim::Pack::unset(), mim::Pi::unset(), and mim::Sigma::unset().
void mim::Def::unset_type | ( | ) |
Definition at line 298 of file def.cpp.
References dep_const(), and mim::Use::Type.
Referenced by set_type().
|
inline |
Resolves Infers of this Def's type.
Definition at line 299 of file def.h.
References mim::Ref::refer(), set_type(), and type().
Referenced by mim::Infer::find(), and set().
|
inline |
Definition at line 328 of file def.h.
Referenced by num_uses(), and proj().
Ref mim::Def::var | ( | ) |
Not necessarily a Var: E.g., if the return type is []
, this will yield ()
.
Definition at line 454 of file def.cpp.
References world().
Referenced by Def(), mim::Arr::immutabilize(), mim::Pack::immutabilize(), mim::Pi::immutabilize(), and mim::Lam::ret_var().
Definition at line 401 of file def.h.
Referenced by mim::World::app(), mim::plug::autodiff::AutoDiffEval::augment_app(), mim::plug::autodiff::AutoDiffEval::augment_lam(), mim::plug::autodiff::AutoDiffEval::derive_(), mim::ast::TuplePtrn::emit_body(), mim::ast::PiExpr::Dom::emit_type(), mim::plug::clos::ClosLit::env_var(), mim::plug::clos::ClosConvPrep::eta_wrap(), mim::World::extract(), mim::Scope::is_free(), mim::plug::clos::isa_clos_type(), mim::plug::mem::mem_var(), mim::rewrite(), mim::rewrite(), and mim::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 mim::plug::clos::Clos2SJLJ::enter(), mim::RetWrap::enter(), and mim::plug::affine::LowerFor::rewrite().
|
inline |
World & mim::Def::world | ( | ) | const |
Definition at line 415 of file def.cpp.
References type(), and world().
Referenced by mim::Check::alpha(), mim::Lam::app(), mim::Lam::app(), mim::plug::clos::apply_closure(), arity(), mim::Check::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::plug::autodiff::autodiff_type_fun(), mim::plug::autodiff::autodiff_type_fun_pi(), mim::Lam::branch(), mim::Lam::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::PipelineBuilder::def2pass(), mim::plug::autodiff::AutoDiffEval::derive_(), mim::Infer::eliminate(), mim::flatten(), free_vars(), mim::plug::autodiff::id_pullback(), mim::Arr::immutabilize(), mim::Pack::immutabilize(), mim::Pi::immutabilize(), mim::Sigma::immutabilize(), mim::Pi::infer(), mim::is_unit(), mim::plug::clos::isa_clos_type(), local_muts(), make_external(), make_internal(), mim::merge_sigma(), mim::merge_tuple(), mim::plug::mem::mut_con(), mim::plug::core::normalize_abs(), mim::plug::math::normalize_abs(), mim::plug::autodiff::normalize_AD(), mim::plug::autodiff::normalize_ad(), mim::plug::autodiff::normalize_add(), mim::plug::math::normalize_arith(), mim::plug::core::normalize_bit1(), mim::plug::core::normalize_bit2(), mim::plug::core::normalize_bitcast(), mim::plug::clos::normalize_clos(), mim::plug::math::normalize_cmp(), mim::plug::compile::normalize_combine_pass_list(), mim::plug::compile::normalize_combined_phase(), mim::plug::regex::normalize_conj(), mim::plug::demo::normalize_const(), mim::plug::core::normalize_conv(), mim::plug::math::normalize_conv(), mim::plug::refly::normalize_dbg(), mim::plug::regex::normalize_disj(), mim::plug::core::normalize_div(), mim::plug::math::normalize_er(), mim::plug::math::normalize_exp(), mim::plug::core::normalize_extrema(), mim::plug::math::normalize_extrema(), mim::plug::math::normalize_gamma(), mim::plug::refly::normalize_gid(), mim::plug::core::normalize_icmp(), mim::plug::core::normalize_idx(), mim::plug::matrix::normalize_insert(), mim::plug::mem::normalize_lea(), mim::plug::mem::normalize_load(), mim::plug::matrix::normalize_map_reduce(), mim::plug::core::normalize_nat(), mim::plug::core::normalize_ncmp(), mim::plug::regex::normalize_not(), mim::plug::compile::normalize_pass_phase(), mim::plug::core::normalize_pe(), mim::plug::math::normalize_pow(), mim::plug::matrix::normalize_prod(), mim::plug::regex::normalize_quant(), mim::plug::regex::normalize_range(), mim::plug::matrix::normalize_read(), mim::plug::refly::normalize_refine(), mim::plug::mem::normalize_remem(), mim::plug::math::normalize_round(), mim::plug::math::normalize_rt(), mim::plug::matrix::normalize_shape(), mim::plug::core::normalize_shr(), mim::plug::compile::normalize_single_pass_phase(), mim::plug::mem::normalize_store(), mim::plug::autodiff::normalize_sum(), mim::plug::core::normalize_trait(), mim::plug::matrix::normalize_transpose(), mim::plug::math::normalize_tri(), mim::plug::core::normalize_wrap(), mim::plug::autodiff::normalize_zero(), mim::plug::core::normalize_zip(), num_tprojs(), mim::plug::core::op(), mim::plug::core::op(), mim::plug::mem::op_alloc(), mim::plug::mem::op_lea(), mim::plug::mem::op_lea_unsafe(), mim::plug::mem::op_lea_unsafe(), mim::plug::mem::op_malloc(), mim::plug::mem::op_mslot(), mim::plug::matrix::op_read(), mim::plug::mem::op_slot(), mim::plug::autodiff::op_sum(), mim::operator<<(), proj(), mim::plug::autodiff::pullback_type(), rebuild(), reduce(), mim::plug::direct::DS2CPS::rewrite(), mim::plug::regex::LowerRegex::rewrite(), mim::plug::matrix::LowerMatrixMediumLevel::rewrite_(), mim::PassMan::run(), mim::Pi::set_dom(), mim::Lam::set_filter(), mim::Pack::shape(), mim::plug::mem::strip_mem(), mim::plug::mem::strip_mem_ty(), mim::Arr::stub(), stub(), mim::Global::stub(), mim::Infer::stub(), mim::Lam::stub(), mim::Pack::stub(), mim::Pi::stub(), mim::Sigma::stub(), mim::TBound< Up >::stub(), mim::TExt< Up >::stub(), sym(), sym(), sym(), mim::Lam::test(), unfold_type(), var(), world(), mim::plug::autodiff::zero_def(), and mim::plug::autodiff::zero_pullback().
union { ... } mim::Def |
|
protected |
Definition at line 589 of file def.h.
Referenced by mim::App::curry(), and mim::Axiom::curry().
|
mutableprotected |
|
protected |
Definition at line 588 of file def.h.
Referenced by Def(), flags(), mim::Lit::get(), mim::Pi::make_explicit(), and mim::Pi::make_implicit().
|
protected |
Definition at line 590 of file def.h.
Referenced by mim::App::trip(), and mim::Axiom::trip().