23 virtual void pop() { old2news_.pop_back(); }
27 const Def*
map(
const Def* old_def,
const Def* new_def) {
return old2news_.back()[old_def] = new_def; }
32 for (
const auto& old2new : old2news_ | std::views::reverse)
33 if (
auto i = old2new.find(old_def); i != old2new.end())
return i->second;
55 std::deque<Def2Def> old2news_;
70 vars_.emplace_back(var);
75 vars_.emplace_back(
Vars());
85 if (
auto new_def =
lookup(old_def))
return new_def;
92 if (
auto imm = old_def->
isa_imm()) {
94 if (imm->local_vars().empty() && imm->local_muts().empty())
return false;
97 for (
const auto& vars : vars_ | std::views::reverse)
98 if (vars.has_intersection(old_def->
free_vars()))
return true;
104 if (
auto var = mut->has_var()) {
105 auto& vars = vars_.back();
A (possibly paramterized) Array.
const T * isa_imm() const
Vars free_vars() const
Compute a global solution by transitively following mutables as well.
This node is a hole in the IR that is inferred by its context later on.
A (possibly paramterized) Tuple.
virtual const Def * rewrite_hole(Hole *)
const Def * lookup(const Def *old_def)
Lookup old_def by searching in reverse through the stack of maps.
virtual const Def * rewrite_mut(Def *)
virtual const Def * rewrite_pack(const Pack *pack)
const Def * map(const Def *old_def, const Def *new_def)
Map old_def to new_def and returns new_def.
virtual const Def * dispatch(const Def *)
virtual const Def * rewrite_imm(const Def *)
virtual const Def * rewrite_seq(const Seq *)
virtual const Def * rewrite(const Def *)
virtual const Def * rewrite_extract(const Extract *)
virtual const Def * rewrite_arr(const Arr *arr)
Base class for Arr and Pack.
void add(const Var *var, const Def *arg)
const Def * rewrite(const Def *old_def) final
const Def * rewrite_mut(Def *mut) final
VarRewriter(World &world)
bool descend(const Def *old_def)
VarRewriter(const Var *var, const Def *arg)
This is a thin wrapper for absl::InlinedVector<T, N, A> which is a drop-in replacement for std::vecto...
The World represents the whole program and manages creation of MimIR nodes (Defs).
DefMap< const Def * > Def2Def
Sets< const Var >::Set Vars