10 auto compilation_functions = {
11 world.
sym(
"_compile"),
12 world.
sym(
"_default_compile"),
16 const Def* compilation =
nullptr;
17 for (
auto compilation_function : compilation_functions) {
18 if (
auto compilation_ = world.
externals()[compilation_function]) {
19 if (!compilation) compilation = compilation_;
26 if (
auto lam = def->isa<
Lam>(); lam && lam->num_doms() == 0) {
27 if (lam->codom()->sym().view() ==
"%compile.Phase") {
28 if (!compilation) compilation = lam;
35 world.ILOG(
"no compilation function found - skipping optimization");
37 world.DLOG(
"compilation using {} : {}", compilation, compilation->
type());
39 auto body = compilation->as<
Lam>()->body();
42 world.DLOG(
"Building pipeline");
43 if (
auto f = world.
driver().
stage(callee->flags())) {
44 auto stage = (*f)(world);
45 auto phase = stage.get()->as<
Phase>();
46 if (
auto app = body->isa<
App>()) phase->
apply(app);
49 world.ELOG(
"axm not found in passes");
const Def * uncurry_callee() const
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
auto stage(flags_t flags)
Unlike a Pass, a Phase performs one self-contained task and does not interleave with other phases.
virtual void apply(const App *)
Invoked if your Stage has additional args.
Vector< Def * > mutate() const
Returns a copy of muts() in a Vector; this allows you to modify the Externals while iterating.
The World represents the whole program and manages creation of MimIR nodes (Defs).
const Driver & driver() const
Sym sym(std::string_view)
const Externals & externals() const
void optimize(World &)
Runs _compile or _default_compile, if available (in this order).