13 enum Lattice :
u8 {
Bot, Single, Eta };
15 static Lattice join(Lattice l1, Lattice l2) {
16 if (l1 == Bot)
return l2;
17 if (l2 == Bot)
return l1;
21 void join(
const Def* def, Lattice l) {
22 if (
auto [i, ins] = def2lattice_.emplace(def, l); !ins) i->second = join(i->second, l);
25 Lattice lattice(
const Def* def) {
26 if (
auto i = def2lattice_.find(def); i != def2lattice_.end())
return i->second;
32 void visit(const Def*, Lattice = Eta);
34 const Def*
rewrite(const Def*) final;
36 const Def* rewrite_no_eta(const Def* old_def) {
return Rewriter::rewrite(old_def); }
39 DefMap<Lattice> def2lattice_;
40 DefMap<const Def*> def2eta_;
RWPhase(World &world, std::string name)
World & world()=delete
Hides both and forbids direct access.
const Def * rewrite_mut_Lam(Lam *) final
bool analyze() final
You can do an optional fixed-point loop on the RWPhase::old_world before rewriting.
const Def * rewrite(const Def *) final
RetWrap(World &world, flags_t annex)
virtual const Def * rewrite(const Def *)
The World represents the whole program and manages creation of MimIR nodes (Defs).
GIDMap< const Var *, To > VarMap
GIDSet< const Def * > DefSet