MimIR
0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
ds2cps.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
mim/def.h
>
4
5
#include <
mim/pass/pass.h
>
6
7
namespace
mim::plug::direct
{
8
9
/// Converts direct style function to cps functions.
10
/// To do so, for each (non-type-level) ds function a corresponding cps function is created:
11
/// ```
12
/// f: [a: A] -> B
13
/// f_cps: Cn [a: A, Cn B]
14
/// ```
15
/// Only the type signature of the function is changed and the body is wrapped in the newly added return continuation.
16
/// (Technical detail: the arguments are substituted to fit the new function)
17
///
18
/// In a second distinct but connected step, the call sites are converted:
19
/// For a direct style call `f args`, the call to the cps function `cps2ds_dep ... f_cps args` is introduced.
20
/// The underlying substitution is `f` -> `cps2ds_dep ... f_cps`.
21
class
DS2CPS
:
public
RWPass
<DS2CPS, Lam> {
22
public
:
23
DS2CPS
(
PassMan
&
man
)
24
:
RWPass
(
man
,
"ds2cps"
) {}
25
26
const
Def
*
rewrite
(
const
Def
*)
override
;
27
28
private
:
29
Def2Def
rewritten_;
30
31
const
Def
* rewrite_lam(
Lam
* lam);
32
};
33
34
}
// namespace mim::plug::direct
mim::Def
Base class for all Defs.
Definition
def.h:198
mim::Lam
A function.
Definition
lam.h:105
mim::Pass::man
PassMan & man()
Definition
pass.h:30
mim::Pass::PassMan
friend class PassMan
Definition
pass.h:101
mim::RWPass< DS2CPS, Lam >::RWPass
RWPass(PassMan &man, std::string_view name)
Definition
pass.h:222
mim::plug::direct::DS2CPS::rewrite
const Def * rewrite(const Def *) override
Definition
ds2cps.cpp:11
mim::plug::direct::DS2CPS::DS2CPS
DS2CPS(PassMan &man)
Definition
ds2cps.h:23
def.h
mim::plug::direct
The direct style Plugin
Definition
direct.h:7
mim::Def2Def
DefMap< const Def * > Def2Def
Definition
def.h:48
pass.h
include
mim
plug
direct
pass
ds2cps.h
Generated by
1.13.2