MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::plug::mach::Subst Class Reference

Rewrites a value of a block under reconstruction: memory becomes m; map and lams replace values and blocks. More...

#include <mim/plug/mach/subst.h>

Inheritance diagram for mim::plug::mach::Subst:
[legend]

Public Member Functions

 Subst (const Target &target, World &world, const Def2Def &map, const Def *m, const LamMap< Lam * > *lams=nullptr)
const Def * rewrite (const Def *def) final
const Def * rewrite_jump (const App *term)
 Rewrites term per argument, so an instruction passed as the whole argument gets the new memory.
Public Member Functions inherited from mim::Rewriter
template<class D = Def>
D * curr_mut () const
 Rewriter (World &world)
virtual ~Rewriter ()
void reset ()
World & world ()
void push (Vars old_vars={}, Vars new_vars={})
void pop ()
Pop scoped (Vars old_vars={}, Vars new_vars={})
 push()es a scope that lives as long as the returned Pop.
void bind_old (const Var *var)
 Adds the old var - if any - to the innermost scope.
void bind_new (const Var *var)
 Adds the new var - if any - to the innermost scope.
void bind (const Var *old_var, const Var *new_var)
const Def * map (const Def *old_def, const Def *new_def)
const Def * map (const Def *old_def, Defs new_defs)
const Def * map (Defs old_defs, const Def *new_def)
const Def * map (Defs old_defs, Defs new_defs)
virtual const Def * lookup (const Def *old_def)
 Lookup old_def by searching in reverse through the stack of maps.
virtual const Def * rewrite_imm (const Def *)
virtual const Def * rewrite_mut (Def *)
virtual const Def * rewrite_stub (Def *, Def *)
const Def * rewrite_stub (Def *old_mut, Def *new_mut, fe::View< size_t > new2old)
 Like above, but new_mut may have a different number of ops than old_mut: new_mut->op(i) is rewritten from old_mut->op(new2old[i]).
virtual DefVec rewrite (Defs)
virtual const Def * rewrite_imm_Lit (const Lit *)
virtual const Def * rewrite_imm_Axm (const Axm *)
virtual const Def * rewrite_imm_Var (const Var *)
virtual const Def * rewrite_imm_Proxy (const Proxy *)
virtual const Def * rewrite_imm_Type (const Type *)
virtual const Def * rewrite_imm_Level (const Level *)
virtual const Def * rewrite_imm_LMax (const LMax *)
virtual const Def * rewrite_imm_LSucc (const LSucc *)
virtual const Def * rewrite_imm_Pi (const Pi *)
virtual const Def * rewrite_imm_Lam (const Lam *)
virtual const Def * rewrite_imm_App (const App *)
virtual const Def * rewrite_imm_Sigma (const Sigma *)
virtual const Def * rewrite_imm_Tuple (const Tuple *)
virtual const Def * rewrite_imm_Extract (const Extract *)
virtual const Def * rewrite_imm_Insert (const Insert *)
virtual const Def * rewrite_imm_Arr (const Arr *)
virtual const Def * rewrite_imm_Pack (const Pack *)
virtual const Def * rewrite_imm_Variant (const Variant *)
virtual const Def * rewrite_imm_Inj (const Inj *)
virtual const Def * rewrite_imm_Match (const Match *)
virtual const Def * rewrite_imm_Top (const Top *)
virtual const Def * rewrite_imm_Bot (const Bot *)
virtual const Def * rewrite_imm_Rho (const Rho *)
virtual const Def * rewrite_imm_Rule (const Rule *)
virtual const Def * rewrite_imm_Fire (const Fire *)
virtual const Def * rewrite_imm_Single (const Single *)
virtual const Def * rewrite_imm_Wrap (const Wrap *)
virtual const Def * rewrite_imm_Nat (const Nat *)
virtual const Def * rewrite_imm_Idx (const Idx *)
virtual const Def * rewrite_imm_Nom (const Nom *)
virtual const Def * rewrite_imm_Name (const Name *)
virtual const Def * rewrite_imm_Struc (const Struc *)
virtual const Def * rewrite_mut_Hole (Hole *)
virtual const Def * rewrite_mut_Pi (Pi *)
virtual const Def * rewrite_mut_Lam (Lam *)
virtual const Def * rewrite_mut_Sigma (Sigma *)
virtual const Def * rewrite_mut_Arr (Arr *)
virtual const Def * rewrite_mut_Pack (Pack *)
virtual const Def * rewrite_mut_Variant (Variant *)
virtual const Def * rewrite_mut_Rho (Rho *)
virtual const Def * rewrite_mut_Rule (Rule *)
virtual const Def * rewrite_imm_Seq (const Seq *seq)
virtual const Def * rewrite_mut_Seq (Seq *seq)

Additional Inherited Members

Protected Member Functions inherited from mim::Rewriter
Def2Def & old2new ()
 The map of the innermost push() scope.
bool has_intersection (const Def *old_def)
 Does old_def depend on the old Vars of any scope?
auto enter (Def *new_mut)
 Updates curr_mut() to new_mut and restores it at the end of the scope.
const Def * seal (Def *old_mut, Def *new_mut)
 The tail of rewrite_stub: immutabilizes new_mut in hindsight, as rewriting may have made it vacuous.
Protected Attributes inherited from mim::Rewriter
fe::Vector< Scope > scopes_

Detailed Description

Rewrites a value of a block under reconstruction: memory becomes m; map and lams replace values and blocks.

mach.spilling and mach.constrain rebuild a block in place, which neither Rewriter nor VarRewriter can do:

  • The keys are no Vars: map holds the current version of each value, instructions and projections alike. After reloads, splits, and SSA reconstruction, a value has several definitions.
  • Every mem.M becomes m, the block's current chain end.
  • It never builds an instruction itself, since the chain places them one by one; reaching an unmapped one bails. Closed Defs and mutables pass through as they are.
  • The substitution changes after every instruction, as map and m move on. A memo shared across instructions would be wrong, so each instruction gets a Subst of its own.

Definition at line 19 of file subst.h.

Constructor & Destructor Documentation

◆ Subst()

mim::plug::mach::Subst::Subst ( const Target & target,
World & world,
const Def2Def & map,
const Def * m,
const LamMap< Lam * > * lams = nullptr )
inline

Member Function Documentation

◆ rewrite()

const Def * mim::plug::mach::Subst::rewrite ( const Def * def)
finalvirtual

◆ rewrite_jump()

const Def * mim::plug::mach::Subst::rewrite_jump ( const App * term)
inline

Rewrites term per argument, so an instruction passed as the whole argument gets the new memory.

Definition at line 31 of file subst.h.

References mim::World::app(), mim::App::arg(), mim::App::callee(), mim::App::num_args(), rewrite(), and mim::Rewriter::world().


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