MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
lower_for.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/phase.h>
4
6
7/// Lowers the for axm to actual control flow in CPS.
8/// It basically mimics this implementation:
9/// ```
10/// con %affine.For_impl
11/// {m n: Nat, Ts: «n; *»}
12/// (begin: Idx m, end: Idx m, step: Idx m, init: «i: n; Ts#i»,
13/// body: Cn [iter: Idx m, acc: «i: n; Ts#i», yield: Cn «i: n; Ts#i»],
14/// exit: Cn «i: n; Ts#i»
15/// ) =
16/// con head(iter: Idx m, acc: «i: n; Ts#i») =
17/// con new_body() = body (iter, acc, cn acc: «i: n; Ts#i» =
18/// let iter2 = %core.wrap.add %core.mode.nsuw (iter, step);
19/// head (iter2, acc));
20/// con new_exit() = exit (acc);
21/// (new_exit, new_body)#(%core.icmp.ul (iter, end)) ();
22/// head(begin, init);
23/// ```
24/// However, we merge `init`/`acc` into the signature, as it may contain a `mem`.
25/// In this case we have to equip `new_body`/`new_exit` with a `mem` as well.
26class LowerFor : public RWPhase {
27public:
30
31 const Def* rewrite_imm_App(const App*) final;
32};
33
34} // namespace mim::plug::affine::phase
Base class for all Defs.
Definition def.h:251
RWPhase(World &world, std::string name)
Definition phase.h:71
World & world()=delete
Hides both and forbids direct access.
flags_t annex() const
Definition pass.h:68
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:32
const Def * rewrite_imm_App(const App *) final
Definition lower_for.cpp:34
LowerFor(World &world, flags_t annex)
Definition lower_for.h:28
u64 flags_t
Definition types.h:45