MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
split_apply.cpp
Go to the documentation of this file.
1
3
4#include <mim/driver.h>
5
6namespace mim::plug::gpu::phase {
7
8// run extendable pipelines as a phase inspired by optimize.cpp
9static void run_stage(World& world, flags_t annex) {
10 const Def* stages = world.annex(annex);
11 auto body = stages->as<Lam>()->body();
12 auto callee = App::uncurry_callee(body);
13
14 auto create_phase = world.driver().phase(callee->flags());
15 if (!create_phase) fe::throwf("Could not get phase");
16
17 auto stage = (*create_phase)(world);
18 auto phase = stage.get()->as<Phase>();
19 if (auto app = body->isa<App>()) phase->apply(app);
20 phase->run();
21}
22
24 split_phase.run();
25 swap(old_world(), split_phase.old_world());
26 swap(new_world(), split_phase.new_world());
27
30}
31
32} // namespace mim::plug::gpu::phase
const Def * uncurry_callee() const
Definition lam.h:327
Base class for all Defs.
Definition def.h:261
auto phase(flags_t flags)
Definition driver.h:123
A function.
Definition lam.h:110
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:368
World & old_world()
Get old Defs from here.
Definition phase.h:367
friend void swap(Rewriter &rw1, Rewriter &rw2) noexcept
Definition rewrite.h:82
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:36
const Driver & driver() const
Definition world.h:93
const Def * annex(Sym sym)
Lookup annex by Sym.
Definition world.h:280
void start() final
Actual entry.
static void run_stage(World &world, flags_t annex)
u64 flags_t
Definition types.h:39
static consteval flags_t base()
Definition plugin.h:150