MimIR
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:
28 using RWPhase::RWPhase;
29
30 const Def* rewrite_imm_App(const App*) final;
31};
32
33} // namespace mim::plug::affine::phase
Base class for all Defs.
Definition def.h:289
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:334
Lowers the for axm to actual control flow in CPS.
Definition lower_for.h:26
const Def * rewrite_imm_App(const App *) final
Definition lower_for.cpp:24
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:334