MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
clos_conv_prep.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/phase.h>
4
6
8
9/// Wraps operands with `%clos.attr` markers (returning, free_bb, fstclass_bb, ...) and eta-expands
10/// branches and continuations so that ClosConv sees a canonical program.
11class ClosConvPrep : public RWPhase {
12public:
15
16private:
17 /// Fills lam2fscope_: assigns each basicblock Lam to its enclosing returning Lam.
18 bool analyze() final;
19 const Def* rewrite_imm_App(const App*) final;
20
21 const Def* rewrite_arg(const App* app, const Def* old_op);
22 const Def* rewrite_callee_op(const Def* old_op);
23
24 Lam* scope(Lam* lam) { return lam2fscope_[lam]; }
25
26 bool from_outer_scope(Lam* lam) {
27 auto mut = curr_mut() ? curr_mut()->isa_mut<Lam>() : nullptr;
28 return mut && scope(lam) && scope(lam) != scope(mut);
29 }
30
31 const Def* eta_wrap(const Def* old_op, attr a);
32
33 DefMap<Lam*> old2wrapper_;
34 Lam2Lam lam2fscope_;
35 bool analyzed_ = false;
36};
37
38} // namespace mim::plug::clos::phase
Base class for all Defs.
Definition def.h:261
A function.
Definition lam.h:110
flags_t annex() const
Definition phase.h:81
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:316
World & world()=delete
Hides both and forbids direct access.
D * curr_mut() const
Definition rewrite.h:89
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:36
ClosConvPrep(World &world, flags_t annex)
const Def * rewrite_imm_App(const App *) final
bool analyze() final
Fills lam2fscope_: assigns each basicblock Lam to its enclosing returning Lam.
u64 flags_t
Definition types.h:39
GIDMap< const Def *, To > DefMap
Definition def.h:75
LamMap< Lam * > Lam2Lam
Definition lam.h:221