MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
split_apply.cpp
Go to the documentation of this file.
2
3#include <mim/driver.h>
4
5namespace mim::plug::gpu::phase {
6
7// run extendable pipelines as a phase inspired by optimize.cpp
8static void run_stage(World& world, flags_t annex) {
9 const Def* stages = world.annex(annex);
10 auto body = stages->as<Lam>()->body();
11 auto callee = App::uncurry_callee(body);
12
13 auto create_phase = world.driver().phase(callee->flags());
14 if (!create_phase) fe::throwf("no phase registered for stage `{}`; is its plugin loaded?", callee);
15
16 auto stage = (*create_phase)(world);
17 auto phase = stage.get()->as<Phase>();
18 if (auto app = body->isa<App>()) phase->apply(app);
19 phase->run();
20}
21
23 split_phase.run();
24 swap(old_world(), split_phase.old_world());
25 swap(new_world(), split_phase.new_world());
26
29}
30
31} // namespace mim::plug::gpu::phase
const Def * uncurry_callee() const
Definition lam.h:326
Base class for all Defs.
Definition def.h:273
auto phase(flags_t flags)
Definition driver.h:191
A function.
Definition lam.h:113
A Phase performs one self-contained task over the whole World.
Definition phase.h:25
World & new_world()
Create new Defs into this.
Definition phase.h:452
World & old_world()
Get old Defs from here.
Definition phase.h:451
friend void swap(Rewriter &rw1, Rewriter &rw2) noexcept
Definition rewrite.h:89
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:40
Driver & driver()
Definition world.h:103
const Def * annex(Sym sym)
Lookup annex by Sym.
Definition world.h:294
void start() final
RWBase::start() and then swaps the two worlds.
static void run_stage(World &world, flags_t annex)
u64 flags_t
Definition types.h:39
static consteval flags_t base()
Definition plugin.h:250