MimIR 0.1
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/pass.h>
5
6#include <mim/pass/beta_red.h>
7#include <mim/pass/eta_exp.h>
8
9#include "mim/plug/mem/mem.h"
14
15using namespace mim;
16using namespace mim::plug;
17
18void reg_stages(Flags2Stages& stages) {
19 MIM_REPL(stages, mem::remem_repl, {
20 if (auto remem = Axm::isa<mem::remem>(def)) return remem->arg();
21 return {};
22 });
23
25 if (auto alloc = Axm::isa<mem::alloc>(def)) {
26 auto [pointee, addr_space] = alloc->decurry()->args<2>();
27 return mem::op_malloc(pointee, alloc->arg());
28 } else if (auto slot = Axm::isa<mem::slot>(def)) {
29 auto [Ta, mi] = slot->uncurry_args<2>();
30 auto [pointee, addr_space] = Ta->projs<2>();
31 auto [mem, id] = mi->projs<2>();
32 return mem::op_mslot(pointee, mem, id);
33 }
34 if (auto remem = Axm::isa<mem::remem>(def)) return remem->arg();
35 return {};
36 });
37
38 // clang-format off
43 // clang-format on
44}
45
46extern "C" MIM_EXPORT Plugin mim_get_plugin() { return {"mem", mem::register_normalizers, reg_stages, nullptr}; }
void reg_stages(Flags2Stages &stages)
Definition affine.cpp:11
static auto isa(const Def *def)
Definition axm.h:107
static void hook(Flags2Stages &stages)
Definition pass.h:57
#define MIM_EXPORT
Definition config.h:16
void reg_stages(Flags2Stages &stages)
Definition mem.cpp:18
The mem Plugin
Definition mem.h:11
void register_normalizers(Normalizers &normalizers)
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
Definition ast.h:14
absl::flat_hash_map< flags_t, std::function< std::unique_ptr< Stage >(World &)> > Flags2Stages
Maps an an axiom of a Stage to a function that creates one.
Definition plugin.h:22
mim::Plugin mim_get_plugin()
#define MIM_REPL(__stages, __annex,...)
Definition phase.h:141
Basic info and registration function pointer to be returned from a specific plugin.
Definition plugin.h:30