MimIR
MimIR is my Intermediate Representation
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
10
11using namespace mim;
12using namespace mim::plug;
13
14static void reg_phases(Flags2Phases& phases) {
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
33 // clang-format on
34}
35
37 plugin.register_normalizers = mem::register_normalizers;
38 plugin.register_phases = reg_phases;
39}
static auto isa(const Def *def)
Definition axm.h:112
static void hook(Flags2Phases &phases)
Definition phase.h:51
static void reg_phases(Flags2Phases &phases)
Definition mem.cpp:14
The mem Plugin
void register_normalizers(Normalizers &normalizers)
const Def * op_mslot(const Def *type, const Def *as, const Def *mem, const Def *ret)
Definition mem.h:148
const Def * op_malloc(const Def *type, const Def *as, const Def *mem)
Definition mem.h:137
Definition ast.h:16
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
#define MIM_REPL(__phases, __annex,...)
Definition phase.h:457
#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