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/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:
23 : RWPass(man, "scalarize")
24 , eta_exp_(eta_exp) {}
25
26 Ref rewrite(Ref) override;
27
28private:
29 bool should_expand(Lam* lam);
30 Lam* make_scalar(Ref def);
31
32 EtaExp* eta_exp_;
33 Lam2Lam tup2sca_;
34};
35
36} // namespace mim
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:103
An optimizer that combines several optimizations in an optimal way.
Definition pass.h:107
PassMan & man()
Definition pass.h:30
Inherit from this class using CRTP, if your Pass does not need state and a fixed-point iteration.
Definition pass.h:220
Helper class to retrieve Infer::arg if present.
Definition def.h:86
Perform Scalarization (= Argument simplification).
Definition scalarize.h:20
Ref rewrite(Ref) override
Definition scalarize.cpp:56
Scalarize(PassMan &man, EtaExp *eta_exp)
Definition scalarize.h:22
Definition cfg.h:11
LamMap< Lam * > Lam2Lam
Definition lam.h:201