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
5#include <mim/pass/beta_red.h>
6#include <mim/pass/eta_exp.h>
7#include <mim/pass/pass.h>
9
17
18using namespace mim;
19using namespace mim::plug;
20
22 return {"mem", [](Normalizers& normalizers) { mem::register_normalizers(normalizers); },
23 [](Passes& passes) {
27
28 // TODO: generalize register_pass_with_arg
30 = [&](World& world, PipelineBuilder& builder, const Def* app) {
31 auto [br, ee, bb] = app->as<App>()->args<3>();
32 // TODO: let get_pass do the casts
33 auto br_pass = (BetaRed*)builder.pass(br);
34 auto ee_pass = (EtaExp*)builder.pass(ee);
35 auto bb_only = bb->as<Lit>()->get<u64>();
36 world.DLOG("registering copy_prop with br = {}, ee = {}, bb_only = {}", br, ee, bb_only);
37 builder.add_pass<mem::CopyProp>(app, br_pass, ee_pass, bb_only);
38 };
40 = [&](World&, PipelineBuilder& builder, const Def* app) {
41 auto mode_ax = app->as<App>()->arg()->as<Axiom>();
42 auto mode = mode_ax->flags() == flags_t(Annex::Base<mem::reshape_arg>) ? mem::Reshape::Arg
44 builder.add_pass<mem::Reshape>(app, mode);
45 };
47 },
48 nullptr};
49}
Optimistically performs β-reduction (aka inlining).
Definition beta_red.h:9
Base class for all Defs.
Definition def.h:223
Performs η-expansion: f -> λx.f x, if f is a Lam with more than one user and does not appear in calle...
Definition eta_exp.h:13
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:33
This FPPass is similar to sparse conditional constant propagation (SCCP).
Definition copy_prop.h:16
The general idea of this pass/phase is to change the shape of signatures of functions.
Definition reshape.h:23
#define MIM_EXPORT
Definition config.h:16
void register_normalizers(Normalizers &normalizers)
Definition cfg.h:11
u64 flags_t
Definition types.h:45
absl::flat_hash_map< flags_t, std::function< void(World &, PipelineBuilder &, const Def *)> > Passes
axiom ↦ (pipeline part) × (axiom application) → () The function should inspect Application to const...
Definition plugin.h:22
void register_pass(Passes &passes, CArgs &&... args)
void register_pass_with_arg(Passes &passes)
MIM_EXPORT mim::Plugin mim_get_plugin()
void register_phase(Passes &passes, CArgs &&... args)
absl::flat_hash_map< flags_t, NormalizeFn > Normalizers
Definition plugin.h:19
static constexpr flags_t Base
Definition plugin.h:118
Basic info and registration function pointer to be returned from a specific plugin.
Definition plugin.h:29