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/def.h
>
4
5
#include <
mim/pass/pass.h
>
6
7
namespace
mim::plug::affine
{
8
9
/// Lowers the for axiom to actual control flow in CPS.
10
/// It basically mimics this implementation:
11
/// ```
12
/// con %affine.For_impl
13
/// (m: Nat , n: Nat , Ts: «n; *»)
14
/// (begin: Idx m, end: Idx m, step: Idx m, init: «i: n; Ts#i»,
15
/// body: Cn [iter: Idx m, acc: «i: n; Ts#i», yield: Cn «i: n; Ts#i»],
16
/// exit: Cn «i: n; Ts#i»
17
/// ) =
18
/// con head(iter: Idx m, acc: «i: n; Ts#i») =
19
/// con new_body() = body (iter, acc, cn acc: «i: n; Ts#i» =
20
/// let iter2 = %core.wrap.add %core.mode.nsuw (iter, step);
21
/// head (iter2, acc));
22
/// con new_exit() = exit (acc);
23
/// (new_exit, new_body)#(%core.icmp.ul (iter, end)) ();
24
/// head(begin, init);
25
/// ```
26
/// However, we merge `init`/`acc` into the signature, as it may contain a `mem`.
27
/// In this case we have to equip `new_body`/`new_exit` with a `mem` as well.
28
/// @todo We probably want to have phases which fix such things so we don't have to do this in C++.
29
class
LowerFor
:
public
RWPass
<LowerFor, Lam> {
30
public
:
31
LowerFor
(
PassMan
&
man
)
32
:
RWPass
(
man
,
"lower_affine_for"
) {}
33
34
const
Def
*
rewrite
(
const
Def
*)
override
;
35
36
private
:
37
Def2Def
rewritten_;
38
};
39
40
}
// namespace mim::plug::affine
mim::Def
Base class for all Defs.
Definition
def.h:198
mim::Pass::man
PassMan & man()
Definition
pass.h:30
mim::Pass::PassMan
friend class PassMan
Definition
pass.h:101
mim::RWPass< LowerFor, Lam >::RWPass
RWPass(PassMan &man, std::string_view name)
Definition
pass.h:222
mim::plug::affine::LowerFor::rewrite
const Def * rewrite(const Def *) override
Definition
lower_for.cpp:32
mim::plug::affine::LowerFor::LowerFor
LowerFor(PassMan &man)
Definition
lower_for.h:31
def.h
mim::plug::affine
The affine Plugin
Definition
affine.h:7
mim::Def2Def
DefMap< const Def * > Def2Def
Definition
def.h:48
pass.h
include
mim
plug
affine
pass
lower_for.h
Generated by
1.13.2