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/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:
16 : RWPass(man, "cps2ds") {}
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:220
A function.
Definition lam.h:96
An optimizer that combines several optimizations in an optimal way.
Definition pass.h:107
PassMan & man()
Definition pass.h:30
Inherit from this class using CRTP, if your Pass does not need state and a fixed-point iteration.
Definition pass.h:220
This is the second part of ds2cps.
Definition cps2ds.h:13
void enter() override
Invoked just before Pass::rewriteing PassMan::curr_mut's body.
Definition cps2ds.cpp:13
CPS2DS(PassMan &man)
Definition cps2ds.h:15
The direct style Plugin
Definition direct.h:7
DefMap< const Def * > Def2Def
Definition def.h:59
GIDSet< const Def * > DefSet
Definition def.h:58