MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
cps2ds.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include <mim/def.h>
6#include <mim/pass.h>
7
8namespace mim::plug::direct {
9
10/// This is the second part of ds2cps.
11/// We replace all ds call sites of cps (or ds converted) functions with the cps calls.
12/// `b = f args` becomes `f (args,cont)` with a newly introduced continuation `cont: Cn b`.
13class CPS2DS : public RWPass<CPS2DS, Lam> {
14public:
17
18 void enter() override;
19
20private:
21 Def2Def rewritten_;
22 DefSet rewritten_lams;
23 std::vector<Lam*> lam_stack;
24 Lam* curr_lam_ = nullptr;
25
26 void rewrite_lam(Lam* lam);
27 const Def* rewrite_body(const Def*);
28 const Def* rewrite_body_(const Def*);
29};
30
31} // namespace mim::plug::direct
Base class for all Defs.
Definition def.h:251
A function.
Definition lam.h:111
RWPass(World &world, std::string name)
Definition pass.h:295
World & world()
Definition pass.h:64
flags_t annex() const
Definition pass.h:68
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:36
void enter() override
Invoked just before Pass::rewriteing PassMan::curr_mut's body.
Definition cps2ds.cpp:13
CPS2DS(World &world, flags_t annex)
Definition cps2ds.h:15
The direct style Plugin
Definition direct.h:7
DefMap< const Def * > Def2Def
Definition def.h:75
u64 flags_t
Definition types.h:45
GIDSet< const Def * > DefSet
Definition def.h:74