MimIR
0.5-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
static_arg_opt.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <fe/bitset.h>
4
5
#include "
mim/phase.h
"
6
7
namespace
mim
{
8
9
/// Static Argument Transformation.
10
/// A recursive Lam whose self-calls merely forward some of its params is split into a wrapper `wrap`
11
/// (same signature) and a `loop` that drops those params;
12
/// self-calls forwarding all of them become jumps to `loop`, all others go through `wrap`.
13
/// Tail recursion elimination is the special case where the dropped param is the ret var.
14
/// @see [Compilation by Transformation in Non-Strict Functional Languages,
15
/// ยง7](https://theses.gla.ac.uk/74568/1/10992188.pdf)
16
class
StaticArgOpt
:
public
RWPhase
{
17
public
:
18
using
RWPhase::RWPhase
;
19
20
private
:
21
bool
analyze
()
final
;
22
void
analyze
(
const
Def
*);
23
void
visit(
const
App
*,
Lam
*);
24
25
const
Def
*
rewrite_imm_App
(
const
App
*)
final
;
26
const
Def
*
rewrite_mut_Lam
(
Lam
*)
final
;
27
28
/// Which of @p lam's doms does the loop keep - those the selected self-calls do *not* forward unchanged?
29
/// A Sieve that keeps *all* of them means: leave @p lam alone.
30
Sieve
sieve(
Lam
* lam);
31
32
DefSet
analyzed_;
33
LamMap<fe::Vector<fe::Bitset>
> lam2sites_;
34
LamMap<Sieve>
lam2sieve_;
35
Lam2Lam
old2loop_;
36
};
37
38
}
// namespace mim
mim::App
Definition
lam.h:215
mim::Def
Base class for all Defs.
Definition
def.h:289
mim::Lam
A function.
Definition
lam.h:91
mim::RWPhase::RWPhase
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition
phase.h:334
mim::Sieve
Filters the components of an aggregate and keeps track of where the survivors end up.
Definition
tuple.h:116
mim::StaticArgOpt
Static Argument Transformation.
Definition
static_arg_opt.h:16
mim::StaticArgOpt::RWPhase
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition
phase.h:334
mim::StaticArgOpt::rewrite_mut_Lam
const Def * rewrite_mut_Lam(Lam *) final
Definition
static_arg_opt.cpp:63
mim::StaticArgOpt::analyze
bool analyze() final
Runs the optional pre-analysis on old_world(), typically to a fixed point, before rewriting begins.
Definition
static_arg_opt.cpp:5
mim::StaticArgOpt::rewrite_imm_App
const Def * rewrite_imm_App(const App *) final
Definition
static_arg_opt.cpp:90
mim
Definition
ast.h:16
mim::Lam2Lam
LamMap< Lam * > Lam2Lam
Definition
lam.h:212
mim::LamMap
GIDMap< Lam *, To > LamMap
Definition
lam.h:210
mim::DefSet
GIDSet< const Def * > DefSet
Definition
def.h:94
phase.h
include
mim
phase
static_arg_opt.h
Generated by
1.18.0