MimIR
0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
alloc2malloc.cpp
Go to the documentation of this file.
1
#include "
mim/plug/mem/pass/alloc2malloc.h
"
2
3
#include "
mim/plug/mem/mem.h
"
4
5
namespace
mim::plug::mem
{
6
7
const
Def
*
Alloc2Malloc::rewrite
(
const
Def
* def) {
8
if
(
auto
alloc
=
Axm::isa<mem::alloc>
(def)) {
9
auto
[pointee, addr_space] =
alloc
->decurry()->args<2>();
10
return
op_malloc
(pointee,
alloc
->arg());
11
}
else
if
(
auto
slot
=
Axm::isa<mem::slot>
(def)) {
12
auto
[Ta, mi] =
slot
->uncurry_args<2>();
13
auto
[pointee, addr_space] = Ta->projs<2>();
14
auto
[
mem
, id] = mi->projs<2>();
15
return
op_mslot
(pointee,
mem
,
id
);
16
}
17
18
return
def;
19
}
20
21
}
// namespace mim::plug::mem
alloc2malloc.h
mim::Axm::isa
static auto isa(const Def *def)
Definition
axm.h:107
mim::Def
Base class for all Defs.
Definition
def.h:251
mim::plug::mem::Alloc2Malloc::rewrite
const Def * rewrite(const Def *) override
Definition
alloc2malloc.cpp:7
mem.h
mim::plug::mem
The mem Plugin
Definition
mem.h:11
mim::plug::mem::op_mslot
const Def * op_mslot(const Def *type, const Def *mem, const Def *id)
Definition
mem.h:161
mim::plug::mem::op_malloc
const Def * op_malloc(const Def *type, const Def *mem)
Definition
mem.h:152
mim::plug::mem::slot
slot
Definition
autogen.h:66
mim::plug::mem::alloc
alloc
Definition
autogen.h:59
src
mim
plug
mem
pass
alloc2malloc.cpp
Generated by
1.13.2