MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
scalarize.h
Go to the documentation of this file.
1#pragma once
2
3#include "mim/pass.h"
4
5namespace mim {
6
7class EtaExp;
8
9/// Perform Scalarization (= Argument simplification).
10/// This means that, i.e.,
11/// ```
12/// f := λ (x_1:[T_1, T_2], .., x_n:T_n).E
13/// ```
14/// will be transformed to
15/// ```
16/// f' := λ (y_1:T_1, y_2:T2, .. y_n:T_n).E[x_1 \ (y_1, y2); ..; x_n \ y_n]
17/// ```
18/// if `f` appears in callee position only (see @p EtaExp).
19/// It will not flatten mutable @p Sigma%s or @p Arr%ays.
20class Scalarize : public RWPass<Scalarize, Lam> {
21public:
24
25 void init(PassMan*) final;
26
27 const Def* rewrite(const Def*) override;
28
29private:
30 bool should_expand(Lam* lam);
31 Lam* make_scalar(const Def* def);
32
33 EtaExp* eta_exp_;
34 Lam2Lam tup2sca_;
35};
36
37} // namespace mim
Base class for all Defs.
Definition def.h:251
Performs η-expansion: f -> λx.f x, if f is a Lam with more than one user and does not appear in calle...
Definition eta_exp.h:13
A function.
Definition lam.h:111
An optimizer that combines several optimizations in an optimal way.
Definition pass.h:172
RWPass(World &world, std::string name)
Definition pass.h:295
void init(PassMan *) final
Definition scalarize.cpp:9
Scalarize(World &world, flags_t annex)
Definition scalarize.h:22
const Def * rewrite(const Def *) override
Definition scalarize.cpp:60
World & world()
Definition pass.h:64
flags_t annex() const
Definition pass.h:68
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:36
Definition ast.h:14
u64 flags_t
Definition types.h:45
LamMap< Lam * > Lam2Lam
Definition lam.h:222