Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
scalarize.h
Go to the documentation of this file.
1#pragma once
2
3#include "thorin/pass/pass.h"
4
5namespace thorin {
6
7class EtaExp;
8
9/// Perform Scalarization (= Argument simplification), i.e.:
10/// ```
11/// f := λ (x_1:[T_1, T_2], .., x_n:T_n).E`
12/// ```
13/// will be transformed to
14/// ```
15/// f' := λ (y_1:T_1, y_2:T2, .. y_n:T_n).E[x_1 \ (y_1, y2); ..; x_n \ y_n]
16/// ```
17/// if `f` appears in callee position only (see @p EtaExp).
18/// It will not flatten mutable @p Sigma%s or @p Arr%ays.
19class Scalerize : public RWPass<Scalerize, Lam> {
20public:
22 : RWPass(man, "scalerize")
23 , eta_exp_(eta_exp) {}
24
25 Ref rewrite(Ref) override;
26
27private:
28 bool should_expand(Lam* lam);
29 Lam* make_scalar(Ref def);
30
31 EtaExp* eta_exp_;
32 Lam2Lam tup2sca_;
33};
34
35} // namespace thorin
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:97
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:85
Perform Scalarization (= Argument simplification), i.e.:
Definition scalarize.h:19
Ref rewrite(Ref) override
Definition scalarize.cpp:56
Scalerize(PassMan &man, EtaExp *eta_exp)
Definition scalarize.h:21
Definition cfg.h:11
LamMap< Lam * > Lam2Lam
Definition lam.h:191