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
7#include <mim/pass/pass.h>
8
9namespace mim::plug::direct {
10
11/// This is the second part of ds2cps.
12/// We replace all ds call sites of cps (or ds converted) functions with the cps calls.
13/// `b = f args` becomes `f (args,cont)` with a newly introduced continuation `cont: Cn b`.
14class CPS2DS : public RWPass<CPS2DS, Lam> {
15public:
17 : RWPass(man, "cps2ds") {}
18
19 void enter() override;
20
21private:
22 Def2Def rewritten_;
23 DefSet rewritten_lams;
24 std::vector<Lam*> lam_stack;
25 Lam* curr_lam_ = nullptr;
26
27 void rewrite_lam(Lam* lam);
28 const Def* rewrite_body(const Def*);
29 const Def* rewrite_body_(const Def*);
30};
31
32} // namespace mim::plug::direct
Base class for all Defs.
Definition def.h:223
A function.
Definition lam.h:103
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:14
void enter() override
Invoked just before Pass::rewriteing PassMan::curr_mut's body.
Definition cps2ds.cpp:13
CPS2DS(PassMan &man)
Definition cps2ds.h:16
The direct style Plugin
Definition direct.h:7
DefMap< const Def * > Def2Def
Definition def.h:60
GIDSet< const Def * > DefSet
Definition def.h:59