llir-opt
0.0.1
Low-Level Post-Link Optimiser for OCaml and C
passes
inliner
trampoline_graph.h
1
// This file if part of the llir-opt project.
2
// Licensing information can be found in the LICENSE file.
3
// (C) 2018 Nandor Licker. All rights reserved.
4
5
#pragma once
6
7
#include <unordered_map>
8
#include <set>
9
#include <stack>
10
11
class
Func
;
12
class
Prog
;
13
class
Value
;
14
15
19
class
TrampolineGraph
final {
20
public
:
22
TrampolineGraph
(
const
Prog
*prog);
23
25
bool
NeedsTrampoline
(
ConstRef<Value>
callee);
26
27
private
:
28
30
void
BuildGraph(
const
Prog
*prog);
31
33
void
Visit(
const
Func
*func);
34
35
private
:
37
struct
Node
{
38
std::set<const Func *> Out;
39
unsigned
Index = 0;
40
unsigned
LowLink = 0;
41
bool
OnStack =
false
;
42
bool
Trampoline =
false
;
43
};
45
std::unordered_map<const Func *, Node> graph_;
46
48
unsigned
index_ = 1;
50
std::stack<const Func *> stack_;
51
};
Func
Definition:
func.h:30
ConstRef
Definition:
ref.h:83
TrampolineGraph
Definition:
trampoline_graph.h:19
Value
Definition:
value.h:22
TrampolineGraph::NeedsTrampoline
bool NeedsTrampoline(ConstRef< Value > callee)
Checks whether a call to a specific callee needs a trampoline.
Definition:
trampoline_graph.cpp:45
Prog
Definition:
prog.h:33
Node::Node
Node(Kind kind)
Creates a new node.
Definition:
node.cpp:12
TrampolineGraph::TrampolineGraph
TrampolineGraph(const Prog *prog)
Construct a trampoline graph for a program.
Definition:
trampoline_graph.cpp:32
Generated by
1.8.17