Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
thorin::Def Class Referenceabstract

Base class for all Defs. More...

#include <thorin/def.h>

Inheritance diagram for thorin::Def:
[legend]

Public Member Functions

Getters
Worldworld () const
 
flags_t flags () const
 
u32 gid () const
 
hash_t hash () const
 
node_t node () const
 
std::string_view node_name () const
 
type
const Deftype () const
 Yields the raw type of this Def, i.e. maybe nullptr.
 
const Defunfold_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_tisa_lit_arity () const
 
nat_t as_lit_arity () const
 
ops
template<size_t N = std::dynamic_extent>
auto ops () const
 
const Defop (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:

  1. If Def::is_set() is ...
    1. ... false, set the operands from
      • left (i == 0) to
      • right (i == num_ops() - 1).
    2. ... true, reset the operands from left to right as in 1a.
  2. In addition, you can invoke Def::unset() at any time to start over with 1a:
    mut->unset()->set({a, b, c}); // This will always work, but should be your last resort.

Thorin assumes that a mutable is final, when its last operand is set. Then, Def::check() will be invoked.

Defset (size_t i, const Def *def)
 Successively set from left to right.
 
Defreset (size_t i, const Def *def)
 Successively reset from left to right.
 
Defset (Defs ops)
 Def::set ops all at once.
 
Defreset (Defs ops)
 Def::reset ops all at once.
 
Defunset ()
 Unsets all Def::ops; works even, if not set at all or partially.
 
Defset_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 nullptr) and then the other Def::ops() in this order.

Def::ops() is only included, if Def::is_set.

Defs extended_ops () const
 
const Defextended_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 nullptr.

Defs partial_ops () const
 
const Defpartial_op (size_t i) const
 
size_t num_partial_ops () const
 
uses
const Usesuses () const
 
size_t num_uses () const
 
dep
See also
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>();
std::array<u64, 2> xy = def->projs<2>([](auto def) { return Lit::as(def); });
auto [a, b] = def->projs<2>();
auto [x, y] = def->projs<2>([](auto def) { return Lit::as(def); });
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
Array<const Lit*> lits1 = def->projs( [](auto def) { return Lit::as(def); });
Array<const Lit*> lits2 = def->projs(n, [](auto def) { return Lit::as(def); });
static T as(Ref def)
Definition def.h:731
nat_t num_projs () const
 Yields Def::as_lit_arity(), if it is in fact a Lit, or 1 otherwise.
 
nat_t num_tprojs () const
 As above but yields 1, if Flags::scalerize_threshold is exceeded.
 
const Defproj (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 Defproj (nat_t i) const
 As above but takes Def::num_projs as arity.
 
const Deftproj (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

Retrieve Var for mutables.

See also
proj
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 Varhas_var ()
 Only returns not nullptr, if Var of this mutable has ever been created.
 
const Varhas_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 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.
 
Dbg Getters
Dbg dbg () const
 
Loc loc () const
 
Sym sym () const
 
std::string unique_name () const
 name + "_" + Def::gid
 
Dbg Setters

Every subclass S of Def has the same setters that return S*/const S* but will not show up in Doxygen.

template<bool Ow = false>
const Defset (Loc l) const
 
template<bool Ow = false>
Defset (Loc l)
 
template<bool Ow = false>
const Defset (Sym s) const
 
template<bool Ow = false>
Defset (Sym s)
 
template<bool Ow = false>
const Defset (std::string s) const
 
template<bool Ow = false>
Defset (std::string s)
 
template<bool Ow = false>
const Defset (Loc l, Sym s) const
 
template<bool Ow = false>
Defset (Loc l, Sym s)
 
template<bool Ow = false>
const Defset (Loc l, std::string s) const
 
template<bool Ow = false>
Defset (Loc l, std::string s)
 
template<bool Ow = false>
const Defset (Dbg d) const
 
template<bool Ow = false>
Defset (Dbg d)
 
debug_prefix/suffix

Prepends/Appends a prefix/suffix to Def::name - but only in Debug build.

const Defdebug_prefix (std::string) const
 
const Defdebug_suffix (std::string) const
 
Rebuild
Defstub (World &w, Ref type)
 
Defstub (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 Defimmutabilize ()
 Tries to make an immutable from a mutable.
 
const Defrefine (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 os while obeying maximum recursion depth of max.

If types is true, Def::type() dependencies will be followed as well.

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 thorin/world.h.

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 Axiomaxiom_
 App only: Curried Apps of Axioms use this member to propagate the Axiom.
 
const Varvar_
 Mutable only: Var of a mutable.
 
Worldworld_
 
};  
 
flags_t flags_
 
u8 curry_
 
u8 trip_
 

Private Member Functions

virtual Defstub_ (World &, Ref)
 
virtual Ref rebuild_ (World &w, Ref type, Defs ops) const =0
 

Detailed Description

Base class for all Defs.

The data layout (see World::alloc and Def::partial_ops) looks like this:

Def| type | op(0) ... op(num_ops-1) |
|-----------ops-----------|
|----------partial_ops-----------|
|--------------------------------| if type() != nullptr && is_set()
|-------------------------| if type() == nullptr && is_set()
|------| if type() != nullptr && !is_set()
|| if type() == nullptr && !is_set()
Base class for all Defs.
Definition def.h:222
auto ops() const
Definition def.h:268
Defs extended_ops() const
Definition def.cpp:447
bool is_set() const
Yields true if empty or the last op is set.
Definition def.cpp:315
const Def * op(size_t i) const
Definition def.h:269
size_t num_ops() const
Definition def.h:270
const Def * type() const
Yields the raw type of this Def, i.e. maybe nullptr.
Definition def.h:248
Defs partial_ops() const
Definition def.h:321
Attention
This means that any subclass of Def must not introduce additional members.
See also
Immutables vs. Mutables

Definition at line 222 of file def.h.

Constructor & Destructor Documentation

◆ Def() [1/3]

thorin::Def::Def ( World w,
node_t  node,
const Def type,
Defs  ops,
flags_t  flags 
)
protected

◆ Def() [2/3]

thorin::Def::Def ( node_t  n,
const Def type,
Defs  ops,
flags_t  flags 
)
protected

As above but World retrieved from type.

Definition at line 63 of file def.cpp.

◆ Def() [3/3]

thorin::Def::Def ( node_t  node,
const Def type,
size_t  num_ops,
flags_t  flags 
)
protected

Constructor for a mutable Def.

Definition at line 66 of file def.cpp.

References dep_const(), gid(), thorin::murmur3(), thorin::World::next_gid(), num_ops(), thorin::Use::Type, type(), and world().

◆ ~Def()

virtual thorin::Def::~Def ( )
protectedvirtualdefault

Member Function Documentation

◆ arity()

◆ as_imm()

template<class T = Def>
const T * thorin::Def::as_imm ( ) const
inline

Definition at line 444 of file def.h.

◆ as_lit_arity()

nat_t thorin::Def::as_lit_arity ( ) const
inline

◆ as_mut()

◆ check()

virtual void thorin::Def::check ( )
inlinevirtual

Reimplemented in thorin::Pi, thorin::Lam, thorin::Sigma, and thorin::Arr.

Definition at line 517 of file def.h.

Referenced by set().

◆ dbg()

◆ debug_prefix()

const Def * thorin::Def::debug_prefix ( std::string  prefix) const

Definition at line 454 of file def.cpp.

References dbg_, sym(), thorin::Dbg::sym, thorin::World::sym(), and world().

◆ debug_suffix()

const Def * thorin::Def::debug_suffix ( std::string  suffix) const

Definition at line 459 of file def.cpp.

References dbg_, sym(), thorin::Dbg::sym, thorin::World::sym(), and world().

◆ dep()

unsigned thorin::Def::dep ( ) const
inline

Definition at line 335 of file def.h.

Referenced by has_dep().

◆ dep_const()

bool thorin::Def::dep_const ( ) const
inline

◆ dot() [1/3]

void thorin::Def::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.

Definition at line 126 of file dot.cpp.

References dot().

◆ dot() [2/3]

void thorin::Def::dot ( const std::string &  file,
uint32_t  max = 0xFFFFFF,
bool  types = false 
) const
inline

Definition at line 536 of file def.h.

◆ dot() [3/3]

void thorin::Def::dot ( std::ostream &  os,
uint32_t  max = 0xFFFFFF,
bool  types = false 
) const

Definition at line 124 of file dot.cpp.

Referenced by dot().

◆ dump() [1/2]

void thorin::Def::dump ( ) const

Definition at line 419 of file dump.cpp.

◆ dump() [2/2]

void thorin::Def::dump ( int  max) const

Definition at line 420 of file dump.cpp.

References stream().

◆ extended_op()

const Def * thorin::Def::extended_op ( size_t  i) const
inline

Definition at line 312 of file def.h.

References extended_ops().

◆ extended_ops()

Defs thorin::Def::extended_ops ( ) const

Definition at line 447 of file def.cpp.

References is_set(), and type().

Referenced by Def(), thorin::Scheduler::early(), extended_op(), num_extended_ops(), and thorin::PassMan::run().

◆ flags()

flags_t thorin::Def::flags ( ) const
inline

◆ free_vars() [1/2]

Vars thorin::Def::free_vars ( )

Definition at line 340 of file def.cpp.

References free_vars(), is_set(), and isa_mut().

◆ free_vars() [2/2]

◆ fv_consumers()

Muts thorin::Def::fv_consumers ( )
inline

Definition at line 428 of file def.h.

◆ gid()

◆ has_dep() [1/2]

bool thorin::Def::has_dep ( Dep  d) const
inline

Definition at line 336 of file def.h.

References has_dep().

Referenced by dep_const(), has_dep(), and thorin::Infer::should_eliminate().

◆ has_dep() [2/2]

bool thorin::Def::has_dep ( unsigned  u) const
inline

Definition at line 337 of file def.h.

References dep().

◆ has_var() [1/2]

const Var * thorin::Def::has_var ( )
inline

Only returns not nullptr, if Var of this mutable has ever been created.

Definition at line 407 of file def.h.

Referenced by has_var(), thorin::Pi::immutabilize(), thorin::Sigma::immutabilize(), thorin::Arr::immutabilize(), thorin::Pack::immutabilize(), and thorin::VarRewriter::rewrite_mut().

◆ has_var() [2/2]

const Var * thorin::Def::has_var ( ) const
inline

As above if this is a mutable.

Definition at line 409 of file def.h.

References has_var(), and isa_mut().

◆ hash()

hash_t thorin::Def::hash ( ) const
inline

Definition at line 239 of file def.h.

◆ immutabilize()

virtual const Def * thorin::Def::immutabilize ( )
inlinevirtual

Tries to make an immutable from a mutable.

This usually works if the mutable isn't recursive and its var isn't used.

Reimplemented in thorin::Pi, thorin::Sigma, thorin::Arr, and thorin::Pack.

Definition at line 506 of file def.h.

◆ is_closed()

bool thorin::Def::is_closed ( ) const

◆ is_external()

bool thorin::Def::is_external ( ) const
inline

◆ is_open()

bool thorin::Def::is_open ( ) const

Has free_vars()?

Definition at line 409 of file def.cpp.

References thorin::PooledSet< T >::empty(), free_vars(), local_muts(), and local_vars().

◆ is_set()

◆ is_term()

bool thorin::Def::is_term ( ) const

Yields true if this:T and T:(.Type 0).

Definition at line 483 of file def.cpp.

References thorin::Lit::isa(), and type().

Referenced by thorin::flatten().

◆ isa_imm() [1/2]

template<class T = Def>
const T * thorin::Def::isa_imm ( ) const
inline

◆ isa_imm() [2/2]

template<class T = Def, class R >
const T * thorin::Def::isa_imm ( R(T::*)() const  f) const
inline

Definition at line 445 of file def.h.

◆ isa_lit_arity()

std::optional< nat_t > thorin::Def::isa_lit_arity ( ) const

Definition at line 501 of file def.cpp.

References thorin::Lit::isa(), num_ops(), and type().

Referenced by as_lit_arity(), thorin::flatten(), thorin::World::insert(), num_projs(), and num_tprojs().

◆ isa_mut()

◆ loc()

Loc thorin::Def::loc ( ) const
inline

Definition at line 469 of file def.h.

Referenced by thorin::error().

◆ local_muts()

Muts thorin::Def::local_muts ( ) const

◆ local_vars()

Vars thorin::Def::local_vars ( ) const
inline

Definition at line 423 of file def.h.

Referenced by Def(), free_vars(), is_closed(), is_open(), and thorin::VarRewriter::rewrite_imm().

◆ make_external()

void thorin::Def::make_external ( )

Definition at line 521 of file def.cpp.

References thorin::World::make_external(), and world().

Referenced by transfer_external().

◆ make_internal()

void thorin::Def::make_internal ( )

◆ node()

node_t thorin::Def::node ( ) const
inline

Definition at line 240 of file def.h.

Referenced by Def(), thorin::Pi::isa_cn(), and node_name().

◆ node_name()

std::string_view thorin::Def::node_name ( ) const

◆ num_extended_ops()

size_t thorin::Def::num_extended_ops ( ) const
inline

Definition at line 313 of file def.h.

References extended_ops().

◆ num_ops()

◆ num_partial_ops()

size_t thorin::Def::num_partial_ops ( ) const
inline

Definition at line 323 of file def.h.

References partial_ops().

◆ num_projs()

nat_t thorin::Def::num_projs ( ) const
inline

◆ num_tprojs()

nat_t thorin::Def::num_tprojs ( ) const

As above but yields 1, if Flags::scalerize_threshold is exceeded.

Definition at line 526 of file def.cpp.

References thorin::World::flags(), isa_lit_arity(), thorin::Flags::scalerize_threshold, and world().

Referenced by tproj(), and tprojs().

◆ num_tvars()

nat_t thorin::Def::num_tvars ( )
inline

Definition at line 403 of file def.h.

Referenced by thorin::ll::Emitter::emit_epilogue().

◆ num_uses()

size_t thorin::Def::num_uses ( ) const
inline

Definition at line 329 of file def.h.

References uses().

◆ num_vars()

nat_t thorin::Def::num_vars ( )
inline

Definition at line 403 of file def.h.

Referenced by thorin::ll::Emitter::emit_epilogue(), and thorin::Lam::ret_var().

◆ op()

◆ ops()

◆ partial_op()

const Def * thorin::Def::partial_op ( size_t  i) const
inline

Definition at line 322 of file def.h.

References partial_ops().

◆ partial_ops()

Defs thorin::Def::partial_ops ( ) const
inline

Definition at line 321 of file def.h.

Referenced by num_partial_ops(), and partial_op().

◆ proj() [1/2]

const Def * thorin::Def::proj ( nat_t  a,
nat_t  i 
) const

◆ proj() [2/2]

const Def * thorin::Def::proj ( nat_t  i) const
inline

As above but takes Def::num_projs as arity.

Definition at line 364 of file def.h.

References num_projs(), and proj().

Referenced by proj().

◆ projs() [1/4]

template<nat_t A = -1_n>
auto thorin::Def::projs ( ) const
inline

Definition at line 387 of file def.h.

Referenced by projs(), projs(), and tprojs().

◆ projs() [2/4]

template<nat_t A = -1_n, class F >
auto thorin::Def::projs ( f) const
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 369 of file def.h.

References as_lit_arity(), num_projs(), proj(), and projs().

Referenced by thorin::plug::autodiff::AutoDiffEval::augment_tuple(), thorin::ll::Emitter::emit_bb(), thorin::plug::clos::Clos2SJLJ::enter(), thorin::plug::regex::flatten_in_arg(), thorin::plug::matrix::get_max_index(), thorin::plug::mem::mem_def(), thorin::plug::core::normalize_abs(), thorin::plug::autodiff::normalize_add(), thorin::plug::math::normalize_arith(), thorin::plug::core::normalize_bit2(), thorin::plug::math::normalize_cmp(), thorin::plug::compile::normalize_combine_pass_list(), thorin::plug::refly::normalize_dbg(), thorin::plug::core::normalize_div(), thorin::plug::core::normalize_extrema(), thorin::plug::math::normalize_extrema(), thorin::plug::core::normalize_icmp(), thorin::plug::mem::normalize_lea(), thorin::plug::mem::normalize_load(), thorin::plug::core::normalize_nat(), thorin::plug::core::normalize_ncmp(), thorin::plug::math::normalize_pow(), thorin::plug::regex::normalize_range(), thorin::plug::matrix::normalize_read(), thorin::plug::refly::normalize_refine(), thorin::plug::matrix::normalize_shape(), thorin::plug::core::normalize_shr(), thorin::plug::mem::normalize_store(), thorin::plug::autodiff::normalize_sum(), thorin::plug::core::normalize_wrap(), thorin::plug::core::normalize_zip(), thorin::plug::mem::SSAConstr::rewrite(), thorin::plug::matrix::LowerMatrixMediumLevel::rewrite_(), thorin::plug::matrix::LowerMatrixLowLevel::rewrite_imm(), thorin_get_plugin(), thorin::tuple2str(), and thorin::unflatten().

◆ projs() [3/4]

auto thorin::Def::projs ( nat_t  a) const
inline

Definition at line 393 of file def.h.

References projs().

◆ projs() [4/4]

template<class F >
auto thorin::Def::projs ( nat_t  a,
f 
) const
inline

Definition at line 383 of file def.h.

References proj().

◆ rebuild() [1/2]

Ref thorin::Def::rebuild ( Ref  type,
Defs  ops 
) const
inline

Definition at line 502 of file def.h.

References rebuild().

Referenced by rebuild().

◆ rebuild() [2/2]

Ref thorin::Def::rebuild ( World w,
Ref  type,
Defs  ops 
) const
inline

Def::rebuilds this Def while using new_op as substitute for its i'th Def::op.

Definition at line 498 of file def.h.

Referenced by refine(), thorin::EtaExp::rewrite(), and thorin::Rewriter::rewrite_imm().

◆ rebuild_()

virtual Ref thorin::Def::rebuild_ ( World w,
Ref  type,
Defs  ops 
) const
privatepure virtual

◆ reduce() [1/2]

DefVec thorin::Def::reduce ( const Def arg)

Definition at line 219 of file def.cpp.

References thorin::rewrite(), and world().

◆ reduce() [2/2]

DefVec thorin::Def::reduce ( const Def arg) const

Rewrites Def::ops by substituting this mutable's Var with arg.

Definition at line 214 of file def.cpp.

References isa_mut(), and ops().

Referenced by thorin::World::app(), thorin::World::extract(), and thorin::plug::compile::handle_optimization_part().

◆ refine()

◆ reset() [1/2]

Def * thorin::Def::reset ( Defs  ops)

Def::reset ops all at once.

Definition at line 251 of file def.cpp.

References num_ops(), ops(), and reset().

◆ reset() [2/2]

Def * thorin::Def::reset ( size_t  i,
const Def def 
)
inline

Successively reset from left to right.

Definition at line 291 of file def.h.

References set(), and unset().

Referenced by thorin::RetWrap::enter(), thorin::Infer::find(), thorin::Infer::reset(), reset(), and thorin::PassMan::run().

◆ set() [1/14]

template<bool Ow = false>
Def * thorin::Def::set ( Dbg  d)
inline

Definition at line 477 of file def.h.

◆ set() [2/14]

template<bool Ow = false>
const Def * thorin::Def::set ( Dbg  d) const
inline

Definition at line 477 of file def.h.

◆ set() [3/14]

Def * thorin::Def::set ( Defs  ops)

Def::set ops all at once.

Definition at line 250 of file def.cpp.

References num_ops(), ops(), and set().

◆ set() [4/14]

template<bool Ow = false>
Def * thorin::Def::set ( Loc  l)
inline

Definition at line 477 of file def.h.

◆ set() [5/14]

template<bool Ow = false>
const Def * thorin::Def::set ( Loc  l) const
inline

Definition at line 477 of file def.h.

◆ set() [6/14]

template<bool Ow = false>
Def * thorin::Def::set ( Loc  l,
std::string  s 
)
inline

Definition at line 477 of file def.h.

◆ set() [7/14]

template<bool Ow = false>
const Def * thorin::Def::set ( Loc  l,
std::string  s 
) const
inline

Definition at line 477 of file def.h.

◆ set() [8/14]

template<bool Ow = false>
Def * thorin::Def::set ( Loc  l,
Sym  s 
)
inline

Definition at line 477 of file def.h.

◆ set() [9/14]

template<bool Ow = false>
const Def * thorin::Def::set ( Loc  l,
Sym  s 
) const
inline

Definition at line 477 of file def.h.

◆ set() [10/14]

◆ set() [11/14]

template<bool Ow = false>
Def * thorin::Def::set ( std::string  s)
inline

Definition at line 477 of file def.h.

◆ set() [12/14]

template<bool Ow = false>
const Def * thorin::Def::set ( std::string  s) const
inline

Definition at line 477 of file def.h.

◆ set() [13/14]

template<bool Ow = false>
Def * thorin::Def::set ( Sym  s)
inline

Definition at line 477 of file def.h.

◆ set() [14/14]

template<bool Ow = false>
const Def * thorin::Def::set ( Sym  s) const
inline

Definition at line 477 of file def.h.

◆ set_type()

Def * thorin::Def::set_type ( const Def type)

Definition at line 296 of file def.cpp.

References thorin::Use::Type, type(), and unset_type().

Referenced by update().

◆ stream()

std::ostream & thorin::Def::stream ( std::ostream &  os,
int  max 
) const

Definition at line 400 of file dump.cpp.

References world().

Referenced by dump(), and write().

◆ stub() [1/2]

Def * thorin::Def::stub ( Ref  type)
inline

Definition at line 495 of file def.h.

References stub().

Referenced by stub().

◆ stub() [2/2]

Def * thorin::Def::stub ( World w,
Ref  type 
)
inline

Definition at line 494 of file def.h.

References set().

Referenced by thorin::TailRecElim::analyze(), thorin::LamSpec::rewrite(), and thorin::Rewriter::rewrite_mut().

◆ stub_()

virtual Def * thorin::Def::stub_ ( World ,
Ref   
)
inlineprivatevirtual

◆ sym() [1/4]

◆ sym() [2/4]

Sym thorin::Def::sym ( const char *  s) const
protected

Definition at line 417 of file def.cpp.

References thorin::World::sym(), and world().

◆ sym() [3/4]

Sym thorin::Def::sym ( std::string  s) const
protected

Definition at line 419 of file def.cpp.

References thorin::World::sym(), and world().

◆ sym() [4/4]

Sym thorin::Def::sym ( std::string_view  s) const
protected

Definition at line 418 of file def.cpp.

References thorin::World::sym(), and world().

◆ tproj()

const Def * thorin::Def::tproj ( nat_t  i) const
inline

As above but takes Def::num_tprojs.

Definition at line 365 of file def.h.

References num_tprojs(), and proj().

◆ tprojs() [1/2]

auto thorin::Def::tprojs ( ) const
inline

Definition at line 390 of file def.h.

References tprojs().

Referenced by tprojs().

◆ tprojs() [2/2]

template<class F >
auto thorin::Def::tprojs ( f) const
inline

Definition at line 381 of file def.h.

References num_tprojs(), and projs().

◆ transfer_external()

void thorin::Def::transfer_external ( Def to)
inline

Definition at line 436 of file def.h.

References make_external(), and make_internal().

◆ tvar()

Ref thorin::Def::tvar ( nat_t  i)
inline

Definition at line 403 of file def.h.

◆ tvars() [1/2]

auto thorin::Def::tvars ( )
inline

Definition at line 403 of file def.h.

◆ tvars() [2/2]

template<class F >
auto thorin::Def::tvars ( f)
inline

Definition at line 403 of file def.h.

◆ type()

const Def * thorin::Def::type ( ) const
inline

Yields the raw type of this Def, i.e. maybe nullptr.

See also
Def::unfold_type.

Definition at line 248 of file def.h.

Referenced by thorin::World::app(), arity(), thorin::Check::assignable(), thorin::plug::autodiff::AutoDiffEval::augment_(), thorin::plug::autodiff::AutoDiffEval::augment_app(), thorin::plug::autodiff::AutoDiffEval::augment_extract(), thorin::plug::autodiff::AutoDiffEval::augment_pack(), thorin::plug::autodiff::AutoDiffEval::augment_tuple(), thorin::App::callee_type(), thorin::Pi::check(), thorin::Arr::check(), thorin::plug::clos::clos_pack(), thorin::plug::matrix::counting_for(), Def(), Def(), thorin::plug::autodiff::AutoDiffEval::derive_(), thorin::ll::Emitter::emit_bb(), thorin::plug::clos::ClosLit::env_type(), thorin::plug::clos::ClosConvPrep::eta_wrap(), extended_ops(), thorin::World::extract(), thorin::Bound::find(), thorin::flatten(), thorin::plug::clos::ClosLit::fnc_type(), thorin::Bound::get(), thorin::plug::compile::handle_optimization_part(), thorin::World::iapp(), thorin::World::iinfer(), thorin::World::insert(), is_term(), thorin::is_unit(), isa_lit_arity(), thorin::plug::mem::mem_def(), thorin::merge_tuple(), thorin::plug::core::normalize_bitcast(), thorin::plug::core::normalize_conv(), thorin::plug::math::normalize_conv(), thorin::plug::core::normalize_shr(), thorin::plug::core::op(), thorin::plug::direct::op_cps2ds_dep(), thorin::plug::mem::op_lea(), thorin::plug::mem::op_lea_unsafe(), thorin::plug::matrix::op_read(), thorin::optimize(), thorin::World::pack(), proj(), refine(), thorin::plug::mem::replace_mem(), thorin::EtaExp::rewrite(), thorin::plug::matrix::LowerMatrixHighLevelMapRed::rewrite_(), thorin::plug::clos::ClosConvPrep::rewrite_callee(), thorin::Rewriter::rewrite_imm(), thorin::plug::matrix::LowerMatrixLowLevel::rewrite_imm(), thorin::Rewriter::rewrite_mut(), thorin::PassMan::run(), thorin::Scheduler::Scheduler(), set_type(), thorin::Pack::shape(), thorin::plug::mem::strip_mem(), thorin::Infer::stub(), thorin::Pi::stub(), thorin::TBound< Up >::stub(), thorin::TExt< Up >::stub(), thorin::Sigma::stub(), thorin::Arr::stub(), thorin::Pack::stub(), thorin::World::test(), thorin::World::tuple(), thorin::plug::clos::ClosLit::type(), thorin::Global::type(), thorin::Lam::type(), thorin::World::type(), thorin::World::uinc(), update(), and world().

◆ unfold_type()

const Def * thorin::Def::unfold_type ( ) const

Yields the type of this Def and builds a new .Type (UInc n) if necessary.

Definition at line 427 of file def.cpp.

References thorin::World::type(), and world().

Referenced by thorin::World::arr(), thorin::Arr::check(), and thorin::Pi::infer().

◆ unique_name()

std::string thorin::Def::unique_name ( ) const

name + "_" + Def::gid

Definition at line 524 of file def.cpp.

References gid(), and sym().

Referenced by thorin::ll::Emitter::emit_epilogue().

◆ unset()

Def * thorin::Def::unset ( )

Unsets all Def::ops; works even, if not set at all or partially.

Definition at line 272 of file def.cpp.

References num_ops(), op(), and unset().

Referenced by reset(), thorin::Infer::unset(), unset(), thorin::Pi::unset(), thorin::Lam::unset(), thorin::Sigma::unset(), thorin::Arr::unset(), and thorin::Pack::unset().

◆ unset_type()

void thorin::Def::unset_type ( )

Definition at line 306 of file def.cpp.

References thorin::Use::Type.

Referenced by set_type().

◆ update()

void thorin::Def::update ( )
inline

Resolves Infers of this Def's type.

Definition at line 299 of file def.h.

References thorin::Ref::refer(), set_type(), and type().

Referenced by thorin::Infer::find(), and set().

◆ uses()

const Uses & thorin::Def::uses ( ) const
inline

Definition at line 328 of file def.h.

Referenced by num_uses(), and proj().

◆ var() [1/3]

Ref thorin::Def::var ( )

Not necessarily a Var: E.g., if the return type is [], this will yield ().

Definition at line 467 of file def.cpp.

References world().

Referenced by Def(), thorin::Pi::immutabilize(), thorin::Arr::immutabilize(), thorin::Pack::immutabilize(), and thorin::Lam::ret_var().

◆ var() [2/3]

◆ var() [3/3]

Ref thorin::Def::var ( nat_t  i)
inline

Definition at line 403 of file def.h.

◆ vars() [1/4]

template<nat_t A = std::dynamic_extent>
auto thorin::Def::vars ( )
inline

Definition at line 403 of file def.h.

Referenced by free_vars().

◆ vars() [2/4]

template<nat_t A = std::dynamic_extent, class F >
auto thorin::Def::vars ( f)
inline

Definition at line 403 of file def.h.

Referenced by thorin::RetWrap::enter(), and thorin::plug::affine::LowerFor::rewrite().

◆ vars() [3/4]

auto thorin::Def::vars ( nat_t  a)
inline

Definition at line 403 of file def.h.

◆ vars() [4/4]

template<class F >
auto thorin::Def::vars ( nat_t  a,
f 
)
inline

Definition at line 403 of file def.h.

◆ world()

World & thorin::Def::world ( ) const

Definition at line 421 of file def.cpp.

References type(), and world().

Referenced by thorin::Check::alpha(), thorin::Lam::app(), thorin::Lam::app(), thorin::plug::clos::apply_closure(), arity(), thorin::Check::assignable(), thorin::plug::autodiff::AutoDiffEval::augment_(), thorin::plug::autodiff::AutoDiffEval::augment_app(), thorin::plug::autodiff::AutoDiffEval::augment_extract(), thorin::plug::autodiff::AutoDiffEval::augment_lam(), thorin::plug::autodiff::AutoDiffEval::augment_pack(), thorin::plug::autodiff::AutoDiffEval::augment_tuple(), thorin::plug::autodiff::autodiff_type_fun(), thorin::plug::autodiff::autodiff_type_fun_pi(), thorin::Lam::branch(), thorin::Lam::check(), thorin::plug::clos::clos_apply(), thorin::plug::clos::clos_insert_env(), thorin::plug::clos::clos_pack(), thorin::plug::clos::clos_remove_env(), thorin::plug::clos::clos_type(), thorin::plug::clos::clos_type_to_pi(), thorin::plug::core::convert(), thorin::plug::matrix::counting_for(), debug_prefix(), debug_suffix(), Def(), Def(), thorin::PipelineBuilder::def2pass(), thorin::plug::autodiff::AutoDiffEval::derive_(), thorin::Infer::eliminate(), thorin::flatten(), free_vars(), thorin::plug::autodiff::id_pullback(), thorin::Pi::immutabilize(), thorin::Sigma::immutabilize(), thorin::Arr::immutabilize(), thorin::Pack::immutabilize(), thorin::Pi::infer(), thorin::is_unit(), thorin::plug::clos::isa_clos_type(), local_muts(), make_external(), make_internal(), thorin::merge_sigma(), thorin::merge_tuple(), thorin::plug::mem::mut_con(), thorin::plug::core::normalize_abs(), thorin::plug::math::normalize_abs(), thorin::plug::autodiff::normalize_ad(), thorin::plug::autodiff::normalize_AD(), thorin::plug::autodiff::normalize_add(), thorin::plug::math::normalize_arith(), thorin::plug::core::normalize_bit1(), thorin::plug::core::normalize_bit2(), thorin::plug::core::normalize_bitcast(), thorin::plug::clos::normalize_clos(), thorin::plug::math::normalize_cmp(), thorin::plug::compile::normalize_combine_pass_list(), thorin::plug::compile::normalize_combined_phase(), thorin::plug::regex::normalize_conj(), thorin::plug::demo::normalize_const(), thorin::plug::core::normalize_conv(), thorin::plug::math::normalize_conv(), thorin::plug::refly::normalize_dbg(), thorin::plug::regex::normalize_disj(), thorin::plug::core::normalize_div(), thorin::plug::math::normalize_er(), thorin::plug::math::normalize_exp(), thorin::plug::core::normalize_extrema(), thorin::plug::math::normalize_extrema(), thorin::plug::math::normalize_gamma(), thorin::plug::refly::normalize_gid(), thorin::plug::core::normalize_icmp(), thorin::plug::core::normalize_idx(), thorin::plug::matrix::normalize_insert(), thorin::plug::mem::normalize_lea(), thorin::plug::mem::normalize_load(), thorin::plug::matrix::normalize_map_reduce(), thorin::plug::core::normalize_nat(), thorin::plug::core::normalize_ncmp(), thorin::plug::regex::normalize_not(), thorin::plug::compile::normalize_pass_phase(), thorin::plug::core::normalize_pe(), thorin::plug::math::normalize_pow(), thorin::plug::matrix::normalize_prod(), thorin::plug::regex::normalize_quant(), thorin::plug::regex::normalize_range(), thorin::plug::matrix::normalize_read(), thorin::plug::refly::normalize_refine(), thorin::plug::mem::normalize_remem(), thorin::plug::math::normalize_round(), thorin::plug::math::normalize_rt(), thorin::plug::matrix::normalize_shape(), thorin::plug::core::normalize_shr(), thorin::plug::compile::normalize_single_pass_phase(), thorin::plug::mem::normalize_store(), thorin::plug::autodiff::normalize_sum(), thorin::plug::core::normalize_trait(), thorin::plug::matrix::normalize_transpose(), thorin::plug::math::normalize_tri(), thorin::plug::core::normalize_wrap(), thorin::plug::autodiff::normalize_zero(), thorin::plug::core::normalize_zip(), num_tprojs(), thorin::plug::core::op(), thorin::plug::core::op(), thorin::plug::mem::op_alloc(), thorin::plug::mem::op_lea(), thorin::plug::mem::op_lea_unsafe(), thorin::plug::mem::op_lea_unsafe(), thorin::plug::mem::op_malloc(), thorin::plug::mem::op_mslot(), thorin::plug::matrix::op_read(), thorin::plug::mem::op_slot(), thorin::plug::autodiff::op_sum(), thorin::operator<<(), proj(), thorin::plug::autodiff::pullback_type(), reduce(), thorin::plug::direct::DS2CPS::rewrite(), thorin::plug::regex::LowerRegex::rewrite(), thorin::plug::matrix::LowerMatrixMediumLevel::rewrite_(), thorin::PassMan::run(), thorin::Pi::set_dom(), thorin::Lam::set_filter(), thorin::Pack::shape(), stream(), thorin::plug::mem::strip_mem(), thorin::plug::mem::strip_mem_ty(), thorin::Infer::stub(), thorin::Pi::stub(), thorin::Lam::stub(), thorin::TBound< Up >::stub(), thorin::TExt< Up >::stub(), thorin::Sigma::stub(), thorin::Arr::stub(), thorin::Pack::stub(), sym(), sym(), sym(), thorin::Lam::test(), unfold_type(), var(), world(), thorin::plug::autodiff::zero_def(), and thorin::plug::autodiff::zero_pullback().

◆ write() [1/2]

void thorin::Def::write ( int  max) const

Definition at line 427 of file dump.cpp.

References write().

Referenced by write().

◆ write() [2/2]

void thorin::Def::write ( int  max,
const char *  file 
) const

Definition at line 422 of file dump.cpp.

References stream().

Member Data Documentation

◆ [union]

union { ... } thorin::Def

◆ curry_

u8 thorin::Def::curry_
protected

Definition at line 578 of file def.h.

Referenced by thorin::Axiom::curry(), and thorin::App::curry().

◆ dbg_

Dbg thorin::Def::dbg_
mutableprotected

Definition at line 570 of file def.h.

Referenced by debug_prefix(), and debug_suffix().

◆ flags_

flags_t thorin::Def::flags_
protected

Definition at line 577 of file def.h.

Referenced by Def(), flags(), thorin::Pi::make_explicit(), and thorin::Pi::make_implicit().

◆ trip_

u8 thorin::Def::trip_
protected

Definition at line 579 of file def.h.

Referenced by thorin::Axiom::trip(), and thorin::App::trip().


The documentation for this class was generated from the following files: