Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
thorin::EtaExp Class Reference

Performs η-expansion: f -> λx.f x, if f is a Lam with more than one user and does not appear in callee position. More...

#include <thorin/pass/eta_exp.h>

Inheritance diagram for thorin::EtaExp:
[legend]

Public Member Functions

 EtaExp (PassMan &man, EtaRed *eta_red)
 
interface for other passes
const Proxyproxy (Lam *lam)
 
void new2old (Lam *new_lam, Lam *old_lam)
 
Lamnew2old (Lam *new_lam)
 
- Public Member Functions inherited from thorin::FPPass< EtaExp, Lam >
 FPPass (PassMan &man, std::string_view name)
 
bool fixed_point () const override
 
- Public Member Functions inherited from thorin::RWPass< P, M >
 RWPass (PassMan &man, std::string_view name)
 
bool inspect () const override
 Should the PassMan even consider this pass?
 
Mcurr_mut () const
 
- Public Member Functions inherited from thorin::Pass
 Pass (PassMan &, std::string_view name)
 
virtual ~Pass ()=default
 
Worldworld ()
 
PassManman ()
 
const PassManman () const
 
std::string_view name () const
 
size_t index () const
 
virtual Ref rewrite (const Var *var)
 
virtual Ref rewrite (const Proxy *proxy)
 
virtual undo_t analyze (const Var *)
 
virtual void enter ()
 Invoked just before Pass::rewriteing PassMan::curr_mut's body.
 
virtual void prepare ()
 Invoked once before entering the main rewrite loop.
 
const Proxyproxy (Ref type, Defs ops, u32 tag=0)
 
const Proxyisa_proxy (Ref def, u32 tag=0)
 Check whether given def is a Proxy whose Proxy::pass matches this Pass's IPass::index.
 
const Proxyas_proxy (Ref def, u32 tag=0)
 

Private Member Functions

PassMan hooks
Ref rewrite (Ref) override
 
undo_t analyze (const Proxy *) override
 
undo_t analyze (Ref) override
 

Lattice

EtaExp uses the following lattice:

expand_ <-- η-expand non-callee as the Lam occurs more than once.
/ \ Don't η-reduce the expansion again.
Callee Non_Callee_1 <-- Pos: Either multiple callees, **or** exactly one non-callee are okay.
\ /
Bot <-- Never seen.
A function.
Definition lam.h:97
  • EtaExp::expand_ trackes if a Lam is the top element.
  • If it's not within EtaExp::expand_, it's either Pos or Bot. But there is no need to differentiate this any further.
  • EtaExp::Pos tracks the particular element at that level and is memorized statefully.
enum  Pos : bool {
  Callee ,
  Non_Callee_1
}
 
using Data = std::tuple< Def2Def, LamMap< Pos > >
 
auto & old2new ()
 
auto & pos ()
 
static std::string_view pos2str (Pos pos)
 

Additional Inherited Members

- Public Types inherited from thorin::FPPass< EtaExp, Lam >
using Super = RWPass< EtaExp, Lam >
 
using Data = std::tuple<>
 Default.
 
- Protected Member Functions inherited from thorin::FPPass< EtaExp, Lam >
const auto & states () const
 
auto & states ()
 
auto & data ()
 
auto & data ()
 
auto & data (const K &key)
 Use this for your convenience if P::Data is a map.
 
auto & data (const K &key)
 Use this for your convenience if P::Data<I> is a map.
 
undo_t curr_undo () const
 Current undo point.
 
undo_t undo_visit (Def *mut) const
 Retrieves the point to backtrack to just before mut was seen the very first time.
 
undo_t undo_enter (Def *mut) const
 Retrieves the point to backtrack to just before rewriting mut's body.
 

Detailed Description

Performs η-expansion: f -> λx.f x, if f is a Lam with more than one user and does not appear in callee position.

This rule is a generalization of critical edge elimination. It gives other Passes such as SSAConstr the opportunity to change f's signature (e.g. adding or removingp Vars).

Definition at line 13 of file eta_exp.h.

Member Typedef Documentation

◆ Data

using thorin::EtaExp::Data = std::tuple<Def2Def, LamMap<Pos> >

Definition at line 43 of file eta_exp.h.

Member Enumeration Documentation

◆ Pos

enum thorin::EtaExp::Pos : bool
Enumerator
Callee 
Non_Callee_1 

Definition at line 40 of file eta_exp.h.

Constructor & Destructor Documentation

◆ EtaExp()

thorin::EtaExp::EtaExp ( PassMan man,
EtaRed eta_red 
)
inline

Definition at line 15 of file eta_exp.h.

Member Function Documentation

◆ analyze() [1/2]

undo_t thorin::EtaExp::analyze ( const Proxy proxy)
overrideprivatevirtual

◆ analyze() [2/2]

◆ new2old() [1/2]

Lam * thorin::EtaExp::new2old ( Lam new_lam)

Definition at line 9 of file eta_exp.cpp.

References thorin::lookup(), and new2old().

◆ new2old() [2/2]

void thorin::EtaExp::new2old ( Lam new_lam,
Lam old_lam 
)
inline

◆ old2new()

auto & thorin::EtaExp::old2new ( )
inline

Definition at line 44 of file eta_exp.h.

Referenced by rewrite().

◆ pos()

auto & thorin::EtaExp::pos ( )
inline

Definition at line 45 of file eta_exp.h.

Referenced by analyze(), and pos2str().

◆ pos2str()

static std::string_view thorin::EtaExp::pos2str ( Pos  pos)
inlinestatic

Definition at line 41 of file eta_exp.h.

References Callee, and pos().

Referenced by analyze().

◆ proxy()

const Proxy * thorin::EtaExp::proxy ( Lam lam)
inline

Definition at line 21 of file eta_exp.h.

References thorin::Pass::proxy(), and thorin::Lam::type().

Referenced by analyze(), and thorin::plug::mem::SSAConstr::rewrite().

◆ rewrite()

Ref thorin::EtaExp::rewrite ( Ref  def)
overrideprivatevirtual

The documentation for this class was generated from the following files: