Base class for all Defs. More...
#include <mim/def.h>
Public Member Functions | |
| bool | has_hole () const noexcept |
| Is this a Hole or does it reach one through Def::deps() up to (and excluding) the next mutable? | |
Getters | |
| World & | world () const noexcept |
| Driver & | driver () const noexcept |
| constexpr flags_t | flags () const noexcept |
| constexpr u32 | gid () const noexcept |
| Global id - unique number for this Def. | |
| constexpr u32 | mark () const noexcept |
| Used internally by free_vars(). | |
| constexpr size_t | hash () const noexcept |
| constexpr Node | node () const noexcept |
| constexpr MutNode | mut_node () const noexcept |
| node() of a Def whose Node may be mutable, whether this one is or not; see MutNode. | |
| std::string_view | node_name () const |
Diagnostics | |
| fe::Error & | error () const noexcept |
| Loc | err_loc () const |
| Returns a blame Loc from World::get_loc, this Def, or its nearest located dependency, in that order. | |
| template<class... Args> | |
| fe::Error & | blame (fe::cite_string< Args... > s, Args &&... args) const |
| Reports an error that blames this; chain Error::n for Notes and Error::bail to throw. | |
| void | bail_expected (fe::Cite what) const |
Blames this for not being what and bails; where Def::expect and friends funnel their diagnostic. | |
Judgement | |
| Judge | judge () const noexcept |
| Def must never become polymorphic: a vptr costs 8 bytes on every node in the World and would shift Def::type_. | |
| 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 (LSucc n) if necessary. | |
| template<class T> | |
| const T * | isa_type () const |
Is Def::unfold_type a T? Yields nullptr for Level, which has no type at all. | |
| bool | is_term () const |
| Is this Def a term, i.e. is its type() a Type? | |
| const Def * | arity () const |
| Number of elements available to Extract / Insert (may be dynamic). | |
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 |
| 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 |
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>();
fe::Vector<const Def*> projs1 = def->projs(); // "projs1" has def->num_projs() many elements
fe::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
| |
| 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 an Arr/Pack exceeds Flags::scalarize_threshold. | |
| 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 * | tproj (nat_t i) const |
| As above but takes Def::num_tprojs. | |
| template<nat_t A = std::dynamic_extent> | |
| auto | projs (Projector auto f) const |
| Splits this Def via Def::projections into an Array (if A == std::dynamic_extent) or std::array (otherwise). | |
| auto | tprojs (Projector auto f) const |
| auto | projs (nat_t a, Projector auto 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 * | tvar (nat_t i) noexcept |
| template<nat_t A = std::dynamic_extent> | |
| auto | vars (Projector auto f) noexcept |
| auto | tvars (Projector auto f) noexcept |
| template<nat_t A = std::dynamic_extent> | |
| auto | vars () noexcept |
| auto | tvars () noexcept |
| auto | vars (nat_t a, Projector auto 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 Def * | var_type () |
| If this is a binder, compute the type of its Variable. | |
| 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. | |
| template<class D = Def> | |
| std::pair< D *, const Var * > | isa_binder () const |
| Is this a mutable that introduces a Var? | |
Free Vars and Muts | |
MimIR splits the free-variable analysis into a local and a global layer:
| |
| 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 |
| Global set of free Vars: extends local_vars() by transitively following mutables as well. | |
| Vars | free_vars () |
| As above but drives (and caches) the fixed-point iteration for mutables. | |
| Muts | users () |
| Set of mutables where this mutable is locally referenced. | |
| bool | is_open () const |
| Same as has_free_vars(). | |
| bool | is_closed () const |
| Same as !has_free_vars(). | |
| bool | is_ground () const |
| Immutable that contains neither mutables nor Vars. | |
| Def * | outermost_binder () const |
| Transitively walks up free_vars() till the outermoust binder has been found. | |
| bool | nests (Def *mut) |
Does this nest mut? | |
| bool | nests (const Def *def) |
Does this nest def? | |
| bool | in_scope (Def *mut) const |
Is every free Var of this bound by mut or by a mutable that nests mut? | |
free_vars predicates | |
free_vars() of an immutable is not cached: it merges free_vars() of every local_muts() entry on every call, and each merge allocates, hashes, and probes the pool. Since free_vars() is a union, any predicate over it distributes over that union - so these answer the question without ever materializing the merged set. Prefer them over free_vars().contains(...) / .empty() / has_intersection(...). | |
| bool | has_free_var (const Var *) const |
| Same as free_vars().contains(var). | |
| bool | has_free_vars () const |
| Same as !free_vars().empty(). | |
| bool | has_free_vars_in (Vars) const |
| Same as vars.has_intersection(free_vars()). | |
external | |
| bool | is_external () const noexcept |
| void | externalize () |
| void | internalize () |
| void | transfer_external (Def *to) |
| bool | is_annex () const noexcept |
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 constness away and perform a dynamic_cast to T. | |
| template<class T = Def, bool invert = false> | |
| T * | as_mut () const |
Asserts that this is a mutable, casts constness away and performs a static_cast to T. | |
| template<class T, class... Args> | |
| T * | expect (fe::cite_string< Args... > fmt, Args &&... args) |
| Like Def::as but - instead of merely asserting in Debug builds - bails via Def::bail_expected when the cast fails; hides fe::RuntimeCast::expect, as a Def can blame itself with a Loc. | |
| template<class T, class... Args> | |
| const T * | expect (fe::cite_string< Args... > fmt, Args &&... args) const |
| const version. | |
| template<class T = Def, class... Args> | |
| T * | expect_mut (fe::cite_string< Args... > fmt, Args &&... args) const |
| The mutable counterpart of Def::expect. | |
Dbg Getters | |
| Dbg | dbg () const |
| Looks up Def::dbg_ in Driver::dbg. | |
| DbgKey | dbg_key () const |
| Cheap handle for other->set(this->dbg_key()). | |
| 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) |
| template<bool Ow = false> | |
| const Def * | set (DbgKey key) const |
Adopts the Dbg behind key - just copies the interned index, so nothing is re-interned. | |
| template<bool Ow = false> | |
| Def * | set (DbgKey key) |
debug_prefix/suffix | |
Prepends/Appends a prefix/suffix to Def::name - but only in Debug build. | |
| const Def * | debug_prefix (std::string) const |
| const Def * | debug_suffix (std::string) const |
Rebuild | |
| const Def * | immutabilize () |
| bool | is_immutabilizable () |
| template<size_t N = std::dynamic_extent> | |
| constexpr auto | reduce (const Def *arg) const |
| size_t | reduction_offset () const noexcept |
| First Def::op that needs to be dealt with during reduction; e.g. | |
Type Checking | |
| const Def * | check (size_t i, const Def *def) |
| Checks whether the ith operand can be set to def. | |
| const Def * | check () |
| After all Def::ops have been Def::set, this method will be invoked to check the type of this mutable. | |
| bool | needs_zonk () const |
| Yields true, if Def::local_muts() contain a Hole that is set. | |
| const Def * | zonk () const |
| If Holes have been filled, reconstruct the program without them. | |
| const Def * | zonk_mut () const |
| If mutable, zonk()s all ops and tries to immutabilize it; otherwise just zonk. | |
dot | |
Streams dot to | |
| void | dot (std::ostream &os, DotConfig cfg={}) const |
| void | dot (const char *file=nullptr, DotConfig cfg={}) const |
Same as above but write to file or std::cout if file is nullptr. | |
| void | dot (const std::string &file, DotConfig cfg={}) const |
Static Public Member Functions | |
| static DefVec | zonk (Defs defs) |
zonks all defs and returns a new DefVec. | |
Concatenation | |
| static DefVec | cat (Defs a, Defs b) |
| static DefVec | cat (const Def *a, Defs bs) |
| static DefVec | cat (Defs as, const Def *b) |
Protected Member Functions | |
| void | collect_locals () |
| Fills in an immutable's local Vars and Muts once it is in the sea. | |
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. | |
| Def (Node, Def *binder) | |
Constructor for a Var; stores its binder. | |
Wrappers for World::sym | |
These are here to have Def::setters inline without including mim/world.h. | |
| Sym | sym (const char *) const |
| Sym | sym (std::string_view) const |
| Sym | sym (std::string) const |
| void | set_dbg (Dbg) const |
Interns dbg via Driver::dbg and stores the key in Def::dbg_. | |
| void | set_dbg_ (Dbg, bool ow) const |
| Backs Def::set(Dbg). | |
| void | set_dbg_key_ (DbgKey, bool ow) const |
| Backs Def::set(DbgKey). | |
Protected Attributes | |
| union mim::Def:: { ... } | |
| flags_t | flags_ |
| u8 | curry_ = 0 |
| u8 | trip_ = 0 |
Friends | |
| struct | DefKey |
| class | World |
| void | swap (World &, World &) noexcept |
| std::ostream & | operator<< (std::ostream &os, const Def *def) |
| Def::Dump::Expr: one Def, one line, no analysis - and the backend of std::formatter for every Def pointer. | |
dump | |
The output uses Mim syntax and - decls aside - reads back again. | |
| enum class | Dump { Expr , Scope , All } |
| void | dump () const |
| Dump::Expr - one line, no analysis. | |
| void | dump (Dump) const |
| void | write (Dump) const |
| void | write (Dump, const char *file) const |
| std::ostream & | stream (std::ostream &, Dump) const |
Syntactic Comparison | |
Establishes an arbitrary but deterministic total order on Defs that is stable across runs. | |
| 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 | |
| Single | Wrap | |
| Nom | Name | Struc |
| Join | Inj | Match |
| Variant | Inj | Match |
| Reform | Rule | |
| Nat | Lit | |
| Idx | Lit |
In addition there is:
The data layout (see World::alloc and Def::deps) looks like this:
|
strong |
|
strong |
How much of a Def's context a dump reproduces. Only Dump::Expr asks no analysis, so that is the one to reach for while a Nest would choke.
| Enumerator | |
|---|---|
| Expr | Only this Def; whatever does not inline is referenced by its name. |
| Scope | Plus its operands as lets and the mutables that live in its scope. |
| All | Plus everything else that is reachable. |
Constructor for an immutable Def.
Definition at line 29 of file def.cpp.
References flags(), flags_, gid(), has_hole(), mim::Level, mim::Proxy::Muts_Bit, node(), op(), ops(), mim::Proxy, type(), mim::Proxy::Vars_Bit, World, and world().
|
protected |
| const Def * mim::Def::arity | ( | ) | const |
Number of elements available to Extract / Insert (may be dynamic).
Definition at line 612 of file def.cpp.
References arity(), mim::Arr, isa_mut(), mim::World::lit_nat(), mim::World::lit_nat_1(), node(), num_ops(), op(), mim::Pack, mim::Shape::Shape(), mim::Sigma, type(), and world().
Referenced by arity(), mim::plug::autodiff::phase::Eval::augment_pack(), mim::Prod::cat(), mim::Prod::cat(), mim::plug::regex::normalize_conj(), mim::plug::regex::normalize_disj(), mim::plug::tensor::normalize_fastest_axis(), num_projs(), num_tprojs(), mim::Switch::Switch(), and mim::tuple2str().
|
inline |
|
inline |
Asserts that this is a mutable, casts constness away and performs a static_cast to T.
Definition at line 597 of file def.h.
Referenced by as_imm(), mim::plug::clos::clos_type(), mim::plug::autodiff::phase::Eval::derive_(), mim::ast::TuplePtrn::emit_body(), mim::ast::VariantExpr::emit_body_(), mim::plug::tensor::is_copy_comb(), mim::plug::tensor::is_identity_post(), mim::Driver::move_to_library(), mim::LamSpec::rewrite_imm_App(), mim::plug::affine::phase::LowerIndex::rewrite_imm_App(), and mim::plug::mem::phase::SEO::rewrite_imm_App().
| void mim::Def::bail_expected | ( | fe::Cite | what | ) | const |
Blames this for not being what and bails; where Def::expect and friends funnel their diagnostic.
Definition at line 413 of file def.cpp.
References err_loc(), error(), and loc().
Referenced by mim::Axm::expect(), expect(), mim::Lit::expect(), and expect_mut().
|
inline |
Reports an error that blames this; chain Error::n for Notes and Error::bail to throw.
Definition at line 333 of file def.h.
References blame(), err_loc(), and error().
Referenced by mim::World::app(), blame(), check(), mim::plug::tensor::phase::check_gather_shape_constraints(), mim::plug::tensor::phase::check_scatter_shape_constraints(), mim::plug::ll::Emitter::emit_phi(), mim::World::inj(), mim::World::inj(), mim::World::lmax(), mim::World::match(), mim::World::name(), mim::plug::refly::normalize_alpha(), mim::plug::regex::normalize_not(), mim::plug::refly::normalize_struc(), mim::plug::affine::phase::LowerIndex::rewrite_imm_App(), mim::World::struc(), mim::World::type(), and mim::plug::ll::Emitter::visit().
Definition at line 138 of file tuple.cpp.
Referenced by cat(), mim::plug::mem::phase::AddMem::rewrite_imm_App(), and mim::plug::mem::phase::AddMem::rewrite_imm_Pi().
| const Def * mim::Def::check | ( | ) |
After all Def::ops have been 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.
Definition at line 524 of file check.cpp.
References mim::Check::alpha(), mim::Arr, mim::Check::coerce(), mim::Hole, mim::Pi::infer(), mim::Sigma::infer(), mim::Variant::infer(), mim::Lam, mut_node(), ops(), mim::Pack, mim::Pi, mim::Rule, mim::Sigma, type(), mim::type_of(), mim::Variant, and world().
| const Def * mim::Def::check | ( | size_t | i, |
| const Def * | def ) |
Checks whether the ith operand can be set to def.
The method returns a possibly updated version of def (e.g. where Holes have been resolved). This is the actual def that will be set as the ith operand.
Definition at line 507 of file check.cpp.
References blame(), mim::Check::coerce(), mim::type_of(), and world().
|
staticnodiscard |
|
protected |
Fills in an immutable's local Vars and Muts once it is in the sea.
Definition at line 65 of file def.cpp.
References flags_, mim::World::muts(), mim::Proxy::Muts_Bit, node(), op(), ops(), mim::Proxy, type(), vars(), mim::World::vars(), mim::Proxy::Vars_Bit, and world().
| Dbg mim::Def::dbg | ( | ) | const |
Looks up Def::dbg_ in Driver::dbg.
Definition at line 448 of file def.cpp.
References mim::World::driver(), and world().
Referenced by debug_prefix(), debug_suffix(), mim::ast::emit_ctor(), loc(), set(), set(), set(), set(), set_dbg_(), set_dbg_key_(), and sym().
|
inline |
Cheap handle for other->set(this->dbg_key()).
Definition at line 631 of file def.h.
Referenced by mim::plug::mem::phase::mk_phi(), mim::Rewriter::rewrite(), mim::VarRewriter::rewrite(), mim::plug::mem::phase::AddMem::rewrite_mut_Lam(), and mim::StaticArgOpt::rewrite_mut_Lam().
| 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 486 of file def.cpp.
References set().
Referenced by dep(), mim::Scheduler::early(), err_loc(), mim::plug::nvptx::HostEmitter::find_kernels(), is_immutabilizable(), num_deps(), mim::Analysis::pin_imm(), mim::post_order(), and zonk_mut().
| void mim::Def::dot | ( | const char * | file = nullptr, |
| DotConfig | cfg = {} ) const |
|
inline |
| void mim::Def::dot | ( | std::ostream & | os, |
| DotConfig | cfg = {} ) const |
Definition at line 261 of file dot.cpp.
References mim::DotConfig::max.
|
noexcept |
Definition at line 410 of file def.cpp.
References mim::World::driver(), and world().
Referenced by error(), and set_dbg_key_().
| void mim::Def::dump | ( | ) | const |
| void mim::Def::dump | ( | Dump | mode | ) | const |
| Loc mim::Def::err_loc | ( | ) | const |
Returns a blame Loc from World::get_loc, this Def, or its nearest located dependency, in that order.
Definition at line 420 of file def.cpp.
References dep(), deps(), loc(), and world().
Referenced by bail_expected(), and blame().
|
noexcept |
Definition at line 411 of file def.cpp.
References driver().
Referenced by bail_expected(), and blame().
|
inline |
Like Def::as but - instead of merely asserting in Debug builds - bails via Def::bail_expected when the cast fails; hides fe::RuntimeCast::expect, as a Def can blame itself with a Loc.
fmt / args describe what was expected; a plain string works, as does a fe::cite_string plus arguments.
Definition at line 609 of file def.h.
References bail_expected().
Referenced by expect().
|
inline |
|
inline |
The mutable counterpart of Def::expect.
Definition at line 622 of file def.h.
References bail_expected(), and isa_mut().
| void mim::Def::externalize | ( | ) |
Definition at line 625 of file def.cpp.
References mim::World::Externals::externalize(), mim::World::externals(), and world().
Referenced by mim::plug::gpu::phase::SplitOffKernels::start(), and transfer_external().
|
inlineconstexprnoexcept |
Definition at line 311 of file def.h.
References flags_.
Referenced by mim::Axm::base(), cmp(), Def(), Def(), Def(), mim::Axm::IsA< mem::M, mim::App >::id(), mim::Inj::index(), mim::Pi::is_implicit(), mim::Nom::key(), mim::LSucc::offset(), mim::Axm::plugin(), stream(), mim::Axm::sub(), and mim::Axm::tag().
| Vars mim::Def::free_vars | ( | ) |
As above but drives (and caches) the fixed-point iteration for mutables.
Definition at line 289 of file def.cpp.
References free_vars(), and world().
| Vars mim::Def::free_vars | ( | ) | const |
Global set of free Vars: extends local_vars() by transitively following mutables as well.
Definition at line 254 of file def.cpp.
References isa_mut(), local_muts(), local_vars(), vars(), mim::World::vars(), and world().
Referenced by cmp(), mim::Prod::Def(), free_vars(), in_scope(), mim::Rule::is_in_rule(), nests(), and outermost_binder().
|
inlineconstexprnoexcept |
Global id - unique number for this Def.
Definition at line 312 of file def.h.
Referenced by mim::plug::regex::compare_re(), Def(), Def(), mim::plug::refly::normalize_gid(), mim::UseHash::operator()(), and unique_name().
|
staticnodiscard |
Definition at line 555 of file def.cpp.
Referenced by mim::plug::core::normalize_bit2(), mim::plug::core::normalize_nat(), and mim::plug::core::normalize_ncmp().
| bool mim::Def::has_free_var | ( | const Var * | var | ) | const |
Same as free_vars().contains(var).
Definition at line 277 of file def.cpp.
References mim::any_free_vars(), and var().
Referenced by mim::World::fuse(), is_immutabilizable(), and mim::is_trivial().
| bool mim::Def::has_free_vars | ( | ) | const |
Same as !free_vars().empty().
Definition at line 281 of file def.cpp.
References mim::any_free_vars().
Referenced by is_closed(), and is_open().
| bool mim::Def::has_free_vars_in | ( | Vars | vars | ) | const |
Same as vars.has_intersection(free_vars()).
Definition at line 285 of file def.cpp.
References mim::any_free_vars(), and vars().
Referenced by mim::Nest::contains(), mim::Rewriter::has_intersection(), and mim::Rewriter::map().
|
inlinenoexcept |
Is this a Hole or does it reach one through Def::deps() up to (and excluding) the next mutable?
E.g., (?, lam (x: Nat) = ?) has a Hole, while (0, lam (x: Nat) = ?) doesn't.
Definition at line 425 of file def.h.
Referenced by Def(), and needs_zonk().
|
inline |
Only returns not nullptr, if Var of this mutable has ever been created.
Definition at line 496 of file def.h.
References has_var().
Referenced by mim::World::app(), mim::eta_callee(), mim::World::fuse(), has_var(), mim::Lam::is_dependent(), is_immutabilizable(), mim::is_trivial(), isa_binder(), mim::Rewriter::map(), nests(), nests(), mim::World::peel(), mim::plug::affine::phase::LowerFor::rewrite_imm_App(), mim::plug::affine::phase::LowerIndex::rewrite_imm_App(), mim::VarRewriter::rewrite_mut(), mim::Rewriter::rewrite_mut_Seq(), and mim::RWPhase::rewrite_stub().
|
inline |
| const Def * mim::Def::immutabilize | ( | ) |
Tries to make an immutable from a mutable. This usually works if the mutable isn't recursive and its var isn't used.
Definition at line 567 of file def.cpp.
References mim::Arr, mim::Hole, is_immutabilizable(), mim::Lit::isa(), mim::Lam, mut_node(), node(), ops(), mim::Pack, mim::Pi, mim::Rule, mim::Sigma, mim::Variant, and world().
Referenced by mim::ast::TuplePtrn::emit_body(), mim::Zonker::rewire_mut(), and mim::Rewriter::seal().
| bool mim::Def::in_scope | ( | Def * | mut | ) | const |
Is every free Var of this bound by mut or by a mutable that nests mut?
I.e., may mut use this?
Definition at line 399 of file def.cpp.
References mim::Var::binder(), free_vars(), and nests().
| void mim::Def::internalize | ( | ) |
Definition at line 626 of file def.cpp.
References mim::World::externals(), mim::World::Externals::internalize(), and world().
Referenced by mim::optimize(), and transfer_external().
|
inlinenoexcept |
Definition at line 573 of file def.h.
Referenced by mim::plug::cps::convertible(), and mim::Lam::is_rewritable().
| bool mim::Def::is_closed | ( | ) | const |
Same as !has_free_vars().
Definition at line 357 of file def.cpp.
References has_free_vars(), and is_external().
Referenced by mim::Scheduler::early(), mim::World::Externals::externalize(), mim::World::inj(), mim::Scheduler::late(), mim::plug::vec::normalize_diff(), and mim::plug::core::normalize_pe().
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 569 of file def.h.
Referenced by mim::plug::cps::convertible(), mim::World::Externals::externalize(), mim::World::Externals::internalize(), is_closed(), mim::Lam::is_rewritable(), mim::RWPhase::rewrite_external(), and mim::plug::gpu::phase::RemoveDoubleSyncs::rewrite_imm_App().
|
inlinenoexcept |
|
inline |
Immutable that contains neither mutables nor Vars.
Definition at line 538 of file def.h.
References local_muts(), and local_vars().
| bool mim::Def::is_immutabilizable | ( | ) |
Definition at line 131 of file def.cpp.
References deps(), has_free_var(), has_var(), is_set(), local_muts(), and op().
Referenced by immutabilize(), and mim::Rewriter::seal().
|
inlinenoexcept |
Definition at line 347 of file def.h.
References mim::Intro, and judge().
Referenced by mim::Rewriter::rewrite_imm_Seq(), mim::SingleErasure::rewrite_imm_Seq(), mim::Rewriter::rewrite_mut_Seq(), mim::SingleErasure::rewrite_mut_Seq(), and mim::World::seq().
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
Same as has_free_vars().
Definition at line 534 of file def.h.
References has_free_vars().
Referenced by mim::plug::vec::normalize_zip().
|
inline |
Yields true if empty or the last op is set.
Definition at line 396 of file def.h.
References num_ops(), op(), and ops().
Referenced by mim::World::app(), cmp(), mim::plug::cps::convertible(), mim::eta_callee(), mim::plug::tensor::is_identity_map(), is_immutabilizable(), mim::Lam::is_rewritable(), mim::Hole::isa_set(), mim::BetaRed::rewrite_imm_App(), mim::DispatchNormalize::rewrite_mut_Lam(), mim::plug::clos::phase::Clos2SJLJ::rewrite_mut_Lam(), mim::plug::cps::Conv::rewrite_mut_Lam(), mim::plug::mem::phase::AddMem::rewrite_mut_Lam(), mim::plug::tensor::phase::LowerToMem::rewrite_mut_Lam(), mim::Rewriter::rewrite_mut_Seq(), mim::SingleErasure::rewrite_mut_Seq(), mim::Rewriter::rewrite_stub(), mim::Rewriter::rewrite_stub(), mim::RWPhase::rewrite_stub(), mim::Scheduler::Scheduler(), mim::Hole::tuplefy(), and zonk_mut().
| bool mim::Def::is_term | ( | ) | const |
|
inline |
Is this a mutable that introduces a Var?
Definition at line 503 of file def.h.
References has_var(), isa_mut(), and var().
Referenced by mim::is_value_telescope(), and mim::Hole::tuplefy().
|
inline |
Definition at line 582 of file def.h.
References isa_mut().
Referenced by mim::World::app(), mim::Prod::cat(), mim::isa_flex_rank(), mim::plug::mem::phase::AddMem::rewrite(), mim::World::seq(), and mim::World::tuple().
|
inline |
If this is mutable, it will cast constness away and perform a dynamic_cast to T.
Definition at line 588 of file def.h.
Referenced by mim::plug::clos::phase::LowerTypedClosPrep::analyze(), mim::any_free_vars(), mim::World::app(), arity(), mim::plug::autodiff::phase::Eval::augment_(), expect_mut(), mim::Hole::find(), mim::plug::clos::ClosLit::fnc_as_lam(), mim::Lam::forwardee(), free_vars(), mim::plug::ll::Emitter::id(), isa_binder(), mim::plug::clos::isa_clos_type(), isa_imm(), mim::Lam::isa_rewritable(), mim::plug::nvptx::HostEmitter::isa_targetspecific_intrinsic(), mim::Hole::isa_unset(), mim::Scheduler::late(), local_muts(), mim::Zonker::lookup(), nests(), outermost_binder(), mim::Analysis::pin_imm(), proj(), mim::Analysis::rewrite(), mim::plug::clos::phase::LowerTypedClos::rewrite(), mim::plug::mem::phase::AddMem::rewrite(), mim::Rewriter::rewrite(), mim::VarRewriter::rewrite(), mim::Zonker::rewrite(), mim::ADCE::rewrite_imm_App(), mim::BetaRed::rewrite_imm_App(), mim::plug::affine::phase::LowerFor::rewrite_imm_App(), mim::plug::mem::phase::SEO::rewrite_imm_App(), mim::plug::tensor::phase::LowerToMem::rewrite_imm_App(), mim::SCCP::rewrite_imm_App(), mim::StaticArgOpt::rewrite_imm_App(), mim::plug::mem::phase::SEO::rewrite_imm_Var(), mim::Scheduler::Scheduler(), zonk(), and zonk_mut().
|
inline |
Is Def::unfold_type a T? Yields nullptr for Level, which has no type at all.
Definition at line 363 of file def.h.
References isa_type(), and unfold_type().
Referenced by mim::Match::accepts(), mim::World::app(), mim::ast::InfixExpr::emit_(), mim::ast::MatchExpr::emit_(), isa_type(), mim::World::lmax(), mim::World::match(), mim::World::struc(), mim::World::type(), and mim::ast::unwrap_field().
|
inlinenoexcept |
Def must never become polymorphic: a vptr costs 8 bytes on every node in the World and would shift Def::type_.
Def dispatches on its own Def::node() tag instead - see the dispatch section in def.cpp.
Definition at line 843 of file def.h.
References CODE, MIM_NODE, and mim::Num_Nodes.
Referenced by is_elim(), is_form(), is_intro(), and is_meta().
|
staticnodiscard |
|
inline |
Definition at line 632 of file def.h.
References dbg().
Referenced by mim::World::app(), bail_expected(), mim::ast::check_nom_scope(), and err_loc().
|
inline |
Mutables reachable by following immutable deps(); mut->local_muts() is by definition the set { mut }.
Definition at line 520 of file def.h.
References isa_mut().
Referenced by mim::any_free_vars(), free_vars(), is_ground(), is_immutabilizable(), needs_zonk(), and mim::VarRewriter::rewrite().
|
inline |
Vars reachable by following immutable deps().
Definition at line 527 of file def.h.
Referenced by mim::any_free_vars(), free_vars(), is_ground(), and mim::VarRewriter::rewrite().
|
inlineconstexprnoexcept |
Used internally by free_vars().
|
inlineconstexprnoexcept |
node() of a Def whose Node may be mutable, whether this one is or not; see MutNode.
Definition at line 317 of file def.h.
References mim::is_mut_node().
Referenced by check(), immutabilize(), reduction_offset(), and var_type().
| bool mim::Def::needs_zonk | ( | ) | const |
Yields true, if Def::local_muts() contain a Hole that is set.
Rewriting (Def::zonking) will resolve the Hole to its operand.
Definition at line 11 of file check.cpp.
References has_hole(), mim::Hole::isa_set(), and local_muts().
Referenced by mim::Zonker::rewrite(), and zonk().
| bool mim::Def::nests | ( | const Def * | def | ) |
| bool mim::Def::nests | ( | Def * | mut | ) |
Does this nest mut?
The relation is strict: f->nests(f) is false.
Definition at line 382 of file def.cpp.
References has_var(), and nests().
Referenced by mim::plug::mem::phase::FreeLocals::analyze(), in_scope(), nests(), and nests().
|
inlineconstexprnoexcept |
Definition at line 315 of file def.h.
Referenced by arity(), cmp(), collect_locals(), Def(), Def(), Def(), mim::Ext::Ext(), mim::World::fuse(), immutabilize(), mim::is_flex(), mim::Pi::isa_cn(), node_name(), reduction_offset(), mim::plug::clos::phase::LowerTypedClos::rewrite_imm(), mim::Rewriter::rewrite_imm(), and mim::Rewriter::rewrite_mut().
| std::string_view mim::Def::node_name | ( | ) | const |
|
inlinenoexcept |
|
inlineconstexprnoexcept |
Definition at line 378 of file def.h.
Referenced by arity(), cmp(), Def(), mim::ast::emit_ctor(), mim::plug::mem::has_leading_mem(), mim::World::inj(), is_set(), mim::World::match(), mim::plug::mem::normalize_load(), mim::plug::ll::Emitter::prepare(), mim::Zonker::rewire_mut(), mim::Rewriter::rewrite_stub(), mim::Rewriter::rewrite_stub(), mim::Scheduler::Scheduler(), set(), set(), unset(), and mim::ast::Emitter::variant_str().
|
inline |
Yields Def::arity(), if it is a Lit, or 1 otherwise.
Definition at line 1140 of file def.h.
References arity(), and mim::Lit::isa().
Referenced by mim::plug::btensor::app_cps(), mim::plug::clos::clos_insert_env(), mim::plug::clos::clos_remove_env(), mim::plug::clos::clos_remove_env(), mim::plug::clos::clos_sub_env(), mim::Var::isa_tproj(), mim::plug::mem::mem_def(), projs(), and mim::plug::clos::phase::ClosConvPrep::rewrite_imm_App().
| nat_t mim::Def::num_tprojs | ( | ) | const |
As above but yields 1, if an Arr/Pack exceeds Flags::scalarize_threshold.
Definition at line 642 of file def.cpp.
References arity(), mim::World::flags(), mim::is_seq_arity(), mim::Lit::isa(), mim::Flags::scalarize_threshold, and world().
Referenced by mim::Var::isa_tproj(), mim::plug::mem::phase::sloxy_path(), tproj(), and tprojs().
|
inlinenoexcept |
Definition at line 492 of file def.h.
References MIM_PROJ, var(), and var_type().
Referenced by mim::plug::ll::Emitter::emit_phi_args().
|
inlinenoexcept |
Definition at line 492 of file def.h.
Referenced by mim::Lam::ret_var(), mim::plug::affine::phase::LowerIndex::rewrite_imm_App(), and mim::plug::mem::phase::AddMem::rewrite_mut_Lam().
|
inlinenoexcept |
Definition at line 377 of file def.h.
References ops().
Referenced by mim::Match::accepts(), mim::App::arg(), arity(), mim::Lam::body(), mim::Seq::body(), mim::App::callee(), mim::plug::clos::clos_type_to_pi(), cmp(), mim::Pi::codom(), collect_locals(), Def(), mim::Pi::dom(), mim::Reform::dom(), mim::ast::MatchExpr::emit_(), mim::ast::emit_ctor(), mim::Lam::filter(), mim::Hole::find(), mim::Rule::guard(), mim::Extract::index(), mim::Insert::index(), mim::Tuple::infer(), mim::World::inj(), mim::World::inj(), is_immutabilizable(), is_set(), mim::plug::clos::isa_clos_type(), mim::Hole::isa_set(), mim::Type::level(), mim::Rule::lhs(), mim::World::match(), mim::plug::mem::normalize_load(), mim::plug::option::normalize_unwrap_unsafe(), mim::Hole::op(), mim::LSucc::op(), mim::Name::op(), mim::Nom::op(), mim::Single::op(), mim::Struc::op(), mim::Wrap::op(), proj(), mim::Rewriter::rewrite_stub(), mim::Rewriter::rewrite_stub(), mim::Rule::rhs(), mim::Scheduler::Scheduler(), mim::Match::scrutinee(), set(), mim::Seq::shape(), mim::Extract::tuple(), mim::Insert::tuple(), mim::World::unwrap(), mim::Inj::value(), mim::Insert::value(), mim::ast::Emitter::variant_str(), and zonk_mut().
|
inlineconstexprnoexcept |
Definition at line 374 of file def.h.
Referenced by mim::Match::arms(), check(), collect_locals(), Def(), Def(), mim::World::ext(), mim::has_inferred_type(), immutabilize(), mim::Sigma::infer(), mim::Tuple::infer(), mim::Variant::infer(), mim::World::inj(), is_set(), mim::World::join(), op(), mim::Zonker::rewire_mut(), mim::SingleErasure::rewrite_imm_Sigma(), mim::RWPhase::rewrite_imm_Tuple(), set(), mim::Lam::set(), mim::Reform::set(), mim::Sigma::set(), and mim::Variant::set().
| Def * mim::Def::outermost_binder | ( | ) | const |
Transitively walks up free_vars() till the outermoust binder has been found.
Definition at line 363 of file def.cpp.
References free_vars(), and isa_mut().
Similar to World::extract while assuming an arity of a, but also works on Sigmas and Arrays.
Definition at line 647 of file def.cpp.
References mim::World::extract(), isa_mut(), op(), type(), and world().
Referenced by mim::plug::btensor::build_pointwise(), mim::Prod::cat_projs(), mim::plug::tensor::phase::check_gather_shape_constraints(), mim::plug::tensor::phase::check_scatter_shape_constraints(), mim::plug::clos::clos_sub_env(), mim::World::component(), mim::plug::btensor::concat_extents(), mim::ast::Ptrn::emit_proj(), mim::Shape::front(), mim::plug::tensor::is_copy_comb(), mim::plug::tensor::is_identity_post(), mim::plug::nvptx::HostEmitter::isa_targetspecific_intrinsic(), mim::Var::isa_tproj(), mim::plug::tensor::lit_projs(), mim::plug::tensor::normalize_pad(), mim::plug::buffer::normalize_shape(), mim::plug::vec::normalize_zip(), mim::plug::btensor::pad_coords(), projs(), projs(), mim::plug::affine::phase::LowerIndex::rewrite_imm_App(), mim::plug::tensor::phase::Lower::rewrite_imm_App(), mim::plug::tensor::phase::LowerToMem::rewrite_imm_Extract(), mim::plug::tensor::phase::LowerToMem::rewrite_imm_Insert(), mim::Switch::target(), tproj(), mim::tuple2str(), and mim::Hole::tuplefy().
|
inline |
|
inline |
|
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 457 of file def.h.
References num_projs(), proj(), and projs().
Referenced by mim::plug::autodiff::phase::Eval::augment_tuple(), mim::plug::btensor::build_pointwise(), mim::plug::mem::mem_def(), mim::plug::core::normalize_abs(), mim::plug::autodiff::normalize_add(), mim::plug::refly::normalize_alpha(), mim::plug::math::normalize_arith(), mim::plug::core::normalize_bit2(), mim::plug::tensor::normalize_broadcast(), mim::plug::buffer::normalize_Buf(), 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::core::normalize_extrema(), mim::plug::math::normalize_extrema(), mim::plug::tensor::normalize_fastest_axis(), mim::plug::vec::normalize_fold(), mim::plug::ord::normalize_get(), mim::plug::core::normalize_icmp(), mim::plug::tensor::normalize_if_static(), mim::plug::ord::normalize_init(), mim::plug::ord::normalize_insert(), mim::plug::mem::normalize_lea(), mim::plug::mem::normalize_load(), mim::plug::btensor::normalize_map_reduce(), mim::plug::core::normalize_nat(), mim::plug::core::normalize_ncmp(), mim::plug::math::normalize_pow(), mim::plug::regex::normalize_range(), mim::plug::buffer::normalize_read(), mim::plug::core::normalize_shr(), mim::plug::mem::normalize_store(), mim::plug::refly::normalize_struc(), mim::plug::autodiff::normalize_sum(), mim::plug::core::normalize_wrap(), mim::plug::tuple::normalize_zip(), mim::plug::btensor::MapRedPost::of(), projs(), projs(), projs(), mim::plug::clos::phase::LowerTypedClos::rewrite(), mim::plug::affine::phase::LowerIndex::rewrite_imm_App(), mim::plug::buffer::LowerPtr::rewrite_imm_App(), mim::plug::tensor::phase::LowerToMem::rewrite_imm_Insert(), and tprojs().
|
inlineconstexpr |
Definition at line 681 of file def.h.
Referenced by mim::ast::RetExpr::emit_(), mim::Lam::reduce(), mim::Pi::reduce(), mim::Rule::reduce(), mim::Seq::reduce(), and mim::RWPhase::rewrite_stub().
|
noexcept |
First Def::op that needs to be dealt with during reduction; e.g.
for a Pi we don't reduce the Pi::dom.
Definition at line 597 of file def.cpp.
References mim::Arr, mim::Hole, mim::is_mut_node(), mim::Lam, mut_node(), node(), mim::Pack, mim::Pi, mim::Rule, mim::Sigma, and mim::Variant.
Referenced by mim::World::reduce(), and mim::World::reduce().
|
inline |
Definition at line 652 of file def.h.
References set_dbg_().
|
inline |
Definition at line 651 of file def.h.
References set_dbg_().
|
inline |
Definition at line 656 of file def.h.
References set_dbg_key_().
|
inline |
| Def * mim::Def::set | ( | Defs | ops | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| Def * mim::Def::set | ( | size_t | i, |
| const Def * | def ) |
Successively set from left to right.
Definition at line 188 of file def.cpp.
References check(), num_ops(), and op().
Referenced by mim::Lam::app(), mim::ast::assign(), debug_prefix(), debug_suffix(), deps(), mim::plug::autodiff::phase::Eval::derive_(), mim::ast::IdDecl::emit(), mim::ast::MatchExpr::Arm::emit(), mim::ast::AliasPtrn::emit_value(), mim::ast::IdPtrn::emit_value(), mim::Zonker::rewire_mut(), mim::VarRewriter::rewrite(), mim::DispatchNormalize::rewrite_mut_Lam(), mim::plug::mem::phase::AddMem::rewrite_mut_Lam(), mim::Rewriter::rewrite_stub(), mim::Rewriter::rewrite_stub(), set(), set(), set(), set(), set(), set(), mim::Hole::set(), mim::Lam::set(), mim::Lam::set(), mim::Pi::set(), mim::Reform::set(), mim::Reform::set(), mim::Rule::set(), mim::Seq::set(), mim::Sigma::set(), mim::Sigma::set(), mim::Variant::set(), mim::Variant::set(), mim::Arr::set_body(), mim::Lam::set_body(), mim::Pack::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(), mim::Arr::set_shape(), and mim::Pack::set_shape().
|
inline |
|
inline |
|
inline |
|
inline |
|
protected |
Interns dbg via Driver::dbg and stores the key in Def::dbg_.
Definition at line 449 of file def.cpp.
References mim::World::driver(), and world().
Referenced by debug_prefix(), debug_suffix(), set(), set(), set(), set(), and set_dbg_().
|
protected |
Backs Def::set(Dbg).
Definition at line 453 of file def.cpp.
References dbg(), and set_dbg().
Referenced by set(), set(), and set_dbg_key_().
|
protected |
Backs Def::set(DbgKey).
Definition at line 462 of file def.cpp.
References dbg(), driver(), set_dbg_(), and world().
| Def * mim::Def::set_type | ( | const Def * | type | ) |
| std::ostream & mim::Def::stream | ( | std::ostream & | os, |
| Dump | mode ) const |
|
inline |
Definition at line 633 of file def.h.
References dbg().
Referenced by mim::plug::autodiff::phase::Eval::augment_lam(), debug_prefix(), debug_suffix(), mim::World::Externals::externalize(), mim::World::Externals::internalize(), set(), set(), set(), set(), transfer_external(), unique_name(), and mim::ast::Emitter::variant_str().
|
protected |
Definition at line 444 of file def.cpp.
References mim::World::sym(), and world().
|
protected |
Definition at line 446 of file def.cpp.
References mim::World::sym(), and world().
|
protected |
Definition at line 445 of file def.cpp.
References mim::World::sym(), and world().
|
inline |
As above but takes Def::num_tprojs.
Definition at line 452 of file def.h.
References num_tprojs(), and proj().
|
inline |
| void mim::Def::transfer_external | ( | Def * | to | ) |
Definition at line 628 of file def.cpp.
References externalize(), internalize(), and sym().
|
inlinenoexcept |
Definition at line 492 of file def.h.
Referenced by mim::StaticArgOpt::rewrite_imm_App().
|
inlinenoexcept |
Yields the "raw" type of this Def (maybe nullptr).
Definition at line 1119 of file def.h.
References var(), and var_type().
Referenced by arity(), mim::plug::autodiff::phase::Eval::augment_(), mim::plug::autodiff::phase::Eval::augment_app(), mim::plug::autodiff::phase::Eval::augment_extract(), mim::plug::autodiff::phase::Eval::augment_pack(), mim::plug::autodiff::phase::Eval::augment_tuple(), mim::App::callee_type(), mim::Match::cases(), check(), mim::plug::clos::clos_pack(), cmp(), mim::Check::coerce(), mim::RWPhase::coerce(), collect_locals(), mim::plug::tensor::phase::compose_map(), mim::plug::affine::counting_for(), Def(), Def(), Def(), mim::plug::btensor::ds_splice(), mim::ast::TuplePtrn::emit_value(), mim::plug::clos::ClosLit::env_type(), mim::Idx::expect_bitwidth(), mim::Ext::Ext(), mim::plug::clos::ClosLit::fnc_type(), mim::has_inferred_type(), mim::Axm::infer_curry_and_trip(), mim::is_polymorphic_arg(), mim::is_seq_arity(), mim::Analysis::is_singleton(), is_term(), mim::is_unit(), mim::plug::clos::ClosLit::isa_clos_lit, mim::plug::mem::isa_mem(), mim::plug::nvptx::HostEmitter::isa_targetspecific_intrinsic(), mim::plug::mem::mem_def(), mim::Name::nom(), mim::plug::core::normalize_bitcast(), mim::plug::core::normalize_conv(), mim::plug::math::normalize_conv(), mim::plug::core::normalize_idx2nat(), mim::plug::tensor::normalize_repeat(), mim::plug::tensor::normalize_reshape(), mim::plug::tensor::normalize_shape(), mim::plug::refly::normalize_type(), mim::plug::core::op(), mim::plug::buffer::op_copy(), mim::plug::cps::op_cps2ds_dep(), mim::plug::mem::op_lea(), mim::optimize(), mim::Pi::Pi(), mim::Pi::Pi(), mim::plug::mem::pointee(), mim::plug::nvptx::DeviceEmitter::prepare(), proj(), mim::plug::autodiff::phase::Eval::pullback(), mim::plug::tensor::phase::read_through(), mim::Reform::Reform(), mim::Zonker::rewire_mut(), mim::plug::clos::phase::LowerTypedClos::rewrite(), mim::plug::mem::phase::AddMem::rewrite(), mim::plug::tensor::phase::LowerToMem::rewrite(), mim::plug::clos::phase::LowerTypedClos::rewrite_imm(), mim::plug::mem::EscapeAnalysis::rewrite_imm(), mim::plug::affine::phase::LowerFor::rewrite_imm_App(), mim::plug::mem::phase::AddMem::rewrite_imm_App(), mim::plug::tensor::phase::LowerToMem::rewrite_imm_App(), mim::Scalarize::rewrite_imm_App(), mim::plug::tensor::phase::LowerToMem::rewrite_imm_Extract(), mim::SingleErasure::rewrite_imm_Extract(), mim::SingleErasure::rewrite_imm_Inj(), mim::SingleErasure::rewrite_imm_Seq(), mim::RWPhase::rewrite_imm_Tuple(), mim::SingleErasure::rewrite_imm_Tuple(), mim::Rewriter::rewrite_mut_Seq(), mim::SingleErasure::rewrite_mut_Seq(), mim::SingleErasure::rewrite_mut_Sigma(), mim::Scheduler::Scheduler(), set_type(), mim::Switch::Switch(), mim::Hole::tuplefy(), mim::Lam::type(), mim::plug::clos::ClosLit::type(), mim::Rule::type(), and unfold_type().
| const Def * mim::Def::unfold_type | ( | ) | const |
Yields the type of this Def and builds a new Type (LSucc n) if necessary.
Definition at line 469 of file def.cpp.
References type(), and world().
Referenced by mim::Match::cases(), mim::Shape::extent(), mim::World::implicit_holes(), mim::Reform::infer(), mim::World::inj(), isa_type(), mim::World::peel(), mim::SingleErasure::rewrite_imm_Match(), mim::World::seq(), and mim::type_of().
| std::string mim::Def::unique_name | ( | ) | const |
name + "_" + Def::gid
Definition at line 634 of file def.cpp.
Referenced by mim::plug::ll::Emitter::emit_slot(), mim::plug::nvptx::DeviceEmitter::emit_slot(), mim::plug::ll::Emitter::id(), mim::Nest::Node::name(), and mim::plug::gpu::phase::SplitOffKernels::rewrite_mut_Lam().
| Def * mim::Def::unset | ( | ) |
Unsets all Def::ops; works even, if not set at all or only partially set.
Definition at line 205 of file def.cpp.
References num_ops().
Referenced by mim::Zonker::rewire_mut(), mim::Arr::unset(), mim::Hole::unset(), mim::Lam::unset(), mim::Pack::unset(), mim::Pi::unset(), mim::Reform::unset(), mim::Rule::unset(), mim::Seq::unset(), mim::Sigma::unset(), and mim::Variant::unset().
|
inline |
Set of mutables where this mutable is locally referenced.
Definition at line 533 of file def.h.
Referenced by mim::Rewriter::seal().
| const Def * mim::Def::var | ( | ) |
Not necessarily a Var: E.g., if the return type is [], this will yield ().
Definition at line 218 of file def.cpp.
References mim::World::var(), and world().
Definition at line 492 of file def.h.
Referenced by mim::plug::autodiff::phase::Eval::augment_app(), mim::plug::autodiff::phase::Eval::augment_lam(), mim::plug::btensor::build_pointwise(), mim::plug::tensor::phase::compose_map(), mim::plug::autodiff::phase::Eval::derive_(), mim::ast::TuplePtrn::emit_body(), mim::plug::ll::Emitter::emit_phi_args(), mim::ast::emit_var(), has_free_var(), isa_binder(), mim::plug::clos::isa_clos_type(), mim::Var::isa_tproj(), mim::plug::mem::mem_var(), mim::plug::mem::phase::mk_phi(), num_tvars(), mim::plug::tensor::phase::reads_injectively(), mim::Rule::replace(), mim::Lam::ret_var(), mim::plug::affine::phase::LowerFor::rewrite_imm_App(), mim::plug::affine::phase::LowerIndex::rewrite_imm_App(), mim::plug::mem::phase::AddMem::rewrite_mut_Lam(), mim::RetWrap::rewrite_mut_Lam(), mim::StaticArgOpt::rewrite_mut_Lam(), mim::RWPhase::rewrite_stub(), mim::Hole::tuplefy(), and type().
| const Def * mim::Def::var_type | ( | ) |
If this is a binder, compute the type of its Variable.
Definition at line 239 of file def.cpp.
References mim::Arr, mim::Hole, mim::Lam, mut_node(), mim::Pack, mim::Pi, mim::Rule, mim::Sigma, mim::World::type_indices(), mim::Variant, and world().
Referenced by num_tvars(), type(), mim::Var::type(), and mim::World::var().
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 492 of file def.h.
Referenced by collect_locals(), free_vars(), has_free_vars_in(), mim::plug::affine::phase::LowerFor::rewrite_imm_App(), and mim::RetWrap::rewrite_mut_Lam().
|
inlinenoexcept |
Definition at line 1105 of file def.h.
References mim::Level, mim::Type, mim::Var, and World.
Referenced by mim::Check::alpha(), mim::Lam::app(), mim::Lam::app(), mim::plug::btensor::app_cps(), mim::plug::clos::apply_closure(), arity(), mim::plug::autodiff::autodiff_type_fun(), mim::plug::autodiff::autodiff_type_fun_pi(), mim::Rewriter::bind_new(), mim::Rewriter::bind_old(), mim::Lam::branch(), check(), check(), mim::plug::btensor::clamp(), 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_sub_env(), mim::plug::clos::clos_type(), mim::plug::clos::clos_type_to_pi(), collect_locals(), mim::plug::btensor::concat_select(), mim::plug::affine::counting_for(), mim::plug::affine::counting_nest(), mim::Phase::create(), dbg(), Def(), driver(), mim::drop_self(), mim::plug::btensor::ds_splice(), mim::Seq::elem(), err_loc(), mim::eta_callee(), externalize(), free_vars(), free_vars(), mim::has_inferred_type(), mim::plug::autodiff::id_pullback(), immutabilize(), mim::Pi::infer(), internalize(), mim::Analysis::is_singleton(), mim::is_unit(), mim::plug::clos::isa_clos_type(), mim::Rewriter::map(), mim::plug::mem::mut_con(), mim::plug::compile::normalize_aggr(), mim::plug::core::normalize_bitcast(), mim::plug::buffer::normalize_Buf(), mim::plug::compile::normalize_cond(), mim::plug::ord::normalize_contains(), mim::plug::core::normalize_conv(), mim::plug::math::normalize_conv(), mim::plug::core::normalize_div(), mim::plug::tensor::normalize_fastest_axis(), mim::plug::ord::normalize_get(), mim::plug::refly::normalize_gid(), mim::plug::compile::normalize_is_loaded(), mim::plug::tensor::normalize_vec_width(), num_tprojs(), mim::plug::core::op(), mim::plug::cps::op_cps2ds_dep(), mim::plug::mem::op_lea(), mim::plug::autodiff::op_sum(), operator<<, mim::plug::btensor::pad_coords(), proj(), mim::plug::autodiff::pullback_type(), mim::Lam::reduce(), mim::Rule::replace(), mim::plug::clos::phase::Clos2SJLJ::rewrite(), mim::Lam::set(), set_dbg(), set_dbg_key_(), mim::Pi::set_dom(), mim::Lam::set_filter(), stream(), mim::plug::mem::strip_mem_ty(), sym(), sym(), sym(), mim::tuple2str(), mim::Hole::tuplefy(), unfold_type(), var(), var_type(), mim::ast::Emitter::variant_str(), mim::plug::autodiff::zero_def(), mim::plug::autodiff::zero_pullback(), zonk(), and zonk_mut().
| void mim::Def::write | ( | Dump | mode | ) | const |
| void mim::Def::write | ( | Dump | mode, |
| const char * | file ) const |
| const Def * mim::Def::zonk | ( | ) | const |
If Holes have been filled, reconstruct the program without them.
Only goes up to but excluding other mutables.
Definition at line 20 of file check.cpp.
References isa_mut(), needs_zonk(), mim::Zonker::rewrite(), world(), zonk_mut(), and mim::World::zonker().
Referenced by mim::World::app(), mim::ast::TuplePtrn::emit_value(), mim::eval0(), mim::World::extract(), mim::World::fuse(), mim::World::inj(), mim::World::inj(), mim::World::insert(), mim::World::lmax(), mim::World::match(), mim::World::name(), mim::World::raw_app(), mim::Rewriter::rewrite_mut_Seq(), mim::World::seq(), mim::World::sigma(), mim::World::struc(), mim::World::tuple(), mim::World::type(), mim::World::variant(), zonk(), and zonk_mut().
| const Def * mim::Def::zonk_mut | ( | ) | const |
If mutable, zonk()s all ops and tries to immutabilize it; otherwise just zonk.
Definition at line 26 of file check.cpp.
References deps(), is_set(), isa_mut(), op(), mim::Zonker::rewire_mut(), world(), zonk(), and mim::World::zonker().
Referenced by mim::World::fuse(), mim::known_rank(), mim::World::type_indices(), and zonk().
|
friend |
|
friend |
Def::Dump::Expr: one Def, one line, no analysis - and the backend of std::formatter for every Def pointer.
Definition at line 1440 of file dump.cpp.
References mim::World::freeze(), operator<<, and world().
Referenced by operator<<, and swap.
References operator<<, and World.
|
friend |
| union { ... } mim::Def |
|
protected |
Definition at line 804 of file def.h.
Referenced by mim::App::curry(), and mim::Axm::curry().
|
protected |
Definition at line 803 of file def.h.
Referenced by collect_locals(), Def(), Def(), Def(), flags(), mim::Lit::get(), mim::Proxy::tag(), mim::Proxy::tracks_muts(), and mim::Proxy::tracks_vars().
|
protected |
Definition at line 805 of file def.h.
Referenced by mim::App::trip(), and mim::Axm::trip().