MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
eta_red.h
Go to the documentation of this file.
1#pragma once
2
3#include "mim/pass/pass.h"
4
5namespace mim {
6
7/// Performs η-reduction.
8/// Rewrites `λx.e x` to `e`, whenever `x` does (optimistically) not appear free in `e`.
9class EtaRed : public FPPass<EtaRed, Def> {
10public:
11 EtaRed(PassMan& man, bool callee_only = false)
12 : FPPass(man, "eta_red")
13 , callee_only_(callee_only) {}
14
15 enum Lattice {
16 Bot, ///< Never seen.
17 Reduce, ///< η-reduction performed.
18 Irreducible, ///< η-reduction not possible as we stumbled upon a Var.
19 };
20
22 void mark_irreducible(Lam* lam) { irreducible_.emplace(lam); }
23
24private:
25 const bool callee_only_;
26 Ref rewrite(Ref) override;
27 undo_t analyze(const Var*) override;
28
29 LamSet irreducible_;
30};
31
32} // namespace mim
Performs η-reduction.
Definition eta_red.h:9
EtaRed(PassMan &man, bool callee_only=false)
Definition eta_red.h:11
LamMap< Lattice > Data
Definition eta_red.h:21
@ Irreducible
η-reduction not possible as we stumbled upon a Var.
Definition eta_red.h:18
@ Reduce
η-reduction performed.
Definition eta_red.h:17
@ Bot
Never seen.
Definition eta_red.h:16
void mark_irreducible(Lam *lam)
Definition eta_red.h:22
Ref rewrite(Ref) override
Definition eta_red.cpp:21
undo_t analyze(const Var *) override
Definition eta_red.cpp:37
Inherit from this class using CRTP, if you do need a Pass with a state and a fixed-point.
Definition pass.h:242
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
Helper class to retrieve Infer::arg if present.
Definition def.h:86
Definition cfg.h:11
GIDSet< Lam * > LamSet
Definition lam.h:200
GIDMap< Lam *, To > LamMap
Definition lam.h:199
size_t undo_t
Definition pass.h:14