MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
alloc2malloc.cpp
Go to the documentation of this file.
2
3#include "mim/plug/mem/mem.h"
4
5namespace mim::plug::mem {
6
7const Def* Alloc2Malloc::rewrite(const Def* def) {
8 if (auto alloc = match<mem::alloc>(def)) {
9 auto [pointee, addr_space] = alloc->decurry()->args<2>();
10 return op_malloc(pointee, alloc->arg());
11 } else if (auto slot = match<mem::slot>(def)) {
12 auto [pointee, addr_space] = slot->decurry()->args<2>();
13 auto [mem, id] = slot->args<2>();
14 return op_mslot(pointee, mem, id);
15 }
16
17 return def;
18}
19
20} // namespace mim::plug::mem
Base class for all Defs.
Definition def.h:198
const Def * rewrite(const Def *) override
The mem Plugin
Definition mem.h:11
const Def * op_mslot(const Def *type, const Def *mem, const Def *id)
Definition mem.h:161
const Def * op_malloc(const Def *type, const Def *mem)
Definition mem.h:152
auto match(const Def *def)
Definition axiom.h:112