MimIR
0.4-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/mem.h
"
7
#include "
mim/plug/mem/phase/add_mem.h
"
8
#include "
mim/plug/mem/phase/seo.h
"
9
10
using namespace
mim
;
11
using namespace
mim::plug
;
12
13
void
reg_phases
(
Flags2Phases
& phases) {
14
MIM_REPL
(phases,
mem::remem_repl
, {
15
if
(
auto
remem =
Axm::isa<mem::remem>
(def))
return
remem->arg();
16
return
{};
17
});
18
19
MIM_REPL
(phases,
mem::alloc2malloc_repl
, {
20
if
(
auto
alloc =
Axm::isa<mem::alloc>
(def)) {
21
auto
[pointee, addr_space] = alloc->decurry()->args<2>();
22
return
mem::op_malloc
(pointee, addr_space, alloc->arg());
23
}
else
if
(
auto
slot =
Axm::isa<mem::slot>
(def)) {
24
auto
[Ta, mr] = slot->uncurry_args<2>();
25
auto
[pointee, addr_space] = Ta->projs<2>();
26
auto
[
mem
, ret] = mr->projs<2>();
27
return
mem::op_mslot
(pointee, addr_space,
mem
, ret);
28
}
29
if
(
auto
remem =
Axm::isa<mem::remem>
(def))
return
remem->arg();
30
return
{};
31
});
32
33
// clang-format off
34
Phase::hook<mem::add_mem, mem::phase::AddMem>
(phases);
35
Phase::hook<mem::seo, mem::phase::SEO >
(phases);
36
// clang-format on
37
}
38
39
extern
"C"
MIM_EXPORT
Plugin
mim_get_plugin
() {
40
return
{
"mem"
,
MIM_VERSION
,
mem::register_normalizers
,
reg_phases
, {}, {}, {}, {}};
41
}
add_mem.h
reg_phases
void reg_phases(Flags2Phases &phases)
Definition
affine.cpp:12
mim::Axm::isa
static auto isa(const Def *def)
Definition
axm.h:112
mim::Phase::hook
static void hook(Flags2Phases &phases)
Definition
phase.h:70
config.h
MIM_EXPORT
#define MIM_EXPORT
Definition
config.h:21
mem.h
mim::plug::mem
The mem Plugin
Definition
mem.h:11
mim::plug::mem::register_normalizers
void register_normalizers(Normalizers &normalizers)
mim::plug::mem::alloc2malloc_repl
alloc2malloc_repl
Definition
autogen.h:130
mim::plug::mem::op_mslot
const Def * op_mslot(const Def *type, const Def *as, const Def *mem, const Def *ret)
Definition
mem.h:172
mim::plug::mem::remem_repl
remem_repl
Definition
autogen.h:123
mim::plug::mem::op_malloc
const Def * op_malloc(const Def *type, const Def *as, const Def *mem)
Definition
mem.h:160
mim::plug
Definition
lower_for.h:5
mim
Definition
ast.h:16
mim::Flags2Phases
absl::flat_hash_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
mim::mim_get_plugin
mim::Plugin mim_get_plugin()
phase.h
MIM_REPL
#define MIM_REPL(__phases, __annex,...)
Definition
phase.h:547
MIM_VERSION
#define MIM_VERSION
Definition
plugin.h:149
seo.h
mim::Plugin
Basic info and registration function pointer to be returned from a specific plugin.
Definition
plugin.h:154
src
mim
plug
mem
mem.cpp
Generated by
1.18.0