MimIR
0.5-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
mem.cpp
Go to the documentation of this file.
1
#include "
mim/plug/mem/mem.h
"
2
3
#include <
mim/config.h
>
4
#include <
mim/phase.h
>
5
6
#include "
mim/plug/mem/phase/add_mem.h
"
7
#include "
mim/plug/mem/phase/free_locals.h
"
8
#include "
mim/plug/mem/phase/heap2stack.h
"
9
#include "
mim/plug/mem/phase/seo.h
"
10
11
using namespace
mim
;
12
using namespace
mim::plug
;
13
14
static
void
reg_phases
(
Flags2Phases
& phases) {
15
MIM_REPL
(phases,
mem::alloc2malloc_repl
, {
16
if
(
auto
alloc =
Axm::isa<mem::alloc>
(def)) {
17
auto
[pointee, addr_space] = alloc->decurry()->args<2>();
18
return
mem::op_malloc
(pointee, addr_space, alloc->arg());
19
}
else
if
(
auto
slot =
Axm::isa<mem::slot>
(def)) {
20
auto
[Ta, mr] = slot->uncurry_args<2>();
21
auto
[pointee, addr_space] = Ta->projs<2>();
22
auto
[
mem
, ret] = mr->projs<2>();
23
return
mem::op_mslot
(pointee, addr_space,
mem
, ret);
24
}
25
return
{};
26
});
27
28
// clang-format off
29
Phase::hook<mem::add_mem, mem::phase::AddMem >
(phases);
30
Phase::hook<mem::free_locals, mem::phase::FreeLocals>
(phases);
31
Phase::hook<mem::heap2stack, mem::phase::Heap2Stack>
(phases);
32
Phase::hook<mem::seo, mem::phase::SEO >
(phases);
33
// clang-format on
34
}
35
36
MIM_PLUGIN_ENTRY
(
mem
) {
37
plugin.register_normalizers =
mem::register_normalizers
;
38
plugin.register_phases =
reg_phases
;
39
}
add_mem.h
mim::Axm::isa
static auto isa(const Def *def)
Definition
axm.h:112
mim::Phase::hook
static void hook(Flags2Phases &phases)
Definition
phase.h:51
config.h
free_locals.h
heap2stack.h
reg_phases
static void reg_phases(Flags2Phases &phases)
Definition
mem.cpp:14
mem.h
mim::plug::mem
The mem Plugin
Definition
escape_analysis.h:9
mim::plug::mem::register_normalizers
void register_normalizers(Normalizers &normalizers)
mim::plug::mem::alloc2malloc_repl
alloc2malloc_repl
Definition
autogen.h:155
mim::plug::mem::op_mslot
const Def * op_mslot(const Def *type, const Def *as, const Def *mem, const Def *ret)
Definition
mem.h:148
mim::plug::mem::op_malloc
const Def * op_malloc(const Def *type, const Def *as, const Def *mem)
Definition
mem.h:137
mim::plug
Definition
affine.h:10
mim
Definition
ast.h:16
mim::Flags2Phases
ankerl::unordered_dense::map< flags_t, std::function< std::unique_ptr< Phase >(World &)> > Flags2Phases
Maps an axiom of a Phase to a function that creates one.
Definition
plugin.h:30
phase.h
MIM_REPL
#define MIM_REPL(__phases, __annex,...)
Definition
phase.h:457
MIM_PLUGIN_ENTRY
#define MIM_PLUGIN_ENTRY(p)
Defines a Plugin's entry point; the body fills in the plugin handed to it, as in MIM_PLUGIN_ENTRY(dem...
Definition
plugin.h:196
seo.h
src
mim
plug
mem
mem.cpp
Generated by
1.18.0