Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
add_mem.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace thorin::plug::mem {
7
8/// This phase adds mems to all lambdas and continuations.
9/// It's primarily to be used as preparation for other phases
10/// that rely on all continuations having a mem.
11class AddMem : public ScopePhase {
12public:
14 : ScopePhase(world, "add_mem", true) {
15 dirty_ = true;
16 }
17
18 void visit(const Scope&) override;
19
20private:
21 const Def* add_mem_to_lams(Lam*, const Def*);
22 const Def* rewrite_type(const Def*);
23 const Def* rewrite_pi(const Pi*);
24 /// Return the most recent memory for the given lambda.
25 const Def* mem_for_lam(Lam*) const;
26
27 Scheduler sched_;
28 // Stores the most recent memory for a lambda.
29 Def2Def val2mem_;
30 // Memoization & Association for rewritten defs.
31 Def2Def mem_rewritten_;
32};
33
34} // namespace thorin::plug::mem
Base class for all Defs.
Definition def.h:220
A function.
Definition lam.h:97
World & world()
Definition phase.h:26
bool dirty_
Definition phase.h:47
A dependent function type.
Definition lam.h:11
Transitively visits all reachable Scopes in World that do not have free variables.
Definition phase.h:150
A Scope represents a region of Defs that are live from the view of an entry's Var.
Definition scope.h:22
The World represents the whole program and manages creation of Thorin nodes (Defs).
Definition world.h:33
This phase adds mems to all lambdas and continuations.
Definition add_mem.h:11
void visit(const Scope &) override
Definition add_mem.cpp:66
AddMem(World &world)
Definition add_mem.h:13
The mem Plugin
Definition mem.h:11
DefMap< const Def * > Def2Def
Definition def.h:59