MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::plug::clos Namespace Reference

The clos Plugin More...

Classes

class  BranchClosElim
 
class  Clos2SJLJ
 
class  ClosConv
 Performs typed closure conversion. More...
 
class  ClosConvPrep
 
class  ClosLit
 Wrapper around a Def that can be used to match closures (see isa_clos_lit). More...
 
class  FreeDefAna
 Transitively compute free Def's on demand. More...
 
class  LowerTypedClos
 This pass lowers typed closures to untyped closures. More...
 
class  LowerTypedClosPrep
 

Enumerations

%clos.BufPtr
enum class  BufPtr : flags_t
 
%clos.alloc_jmpbuf
enum class  alloc_jmpbuf : flags_t
 
%clos.setjmp
enum class  setjmp : flags_t
 
%clos.longjmp
enum class  longjmp : flags_t
 
%clos.clos_conv_prep_pass
enum class  clos_conv_prep_pass : flags_t
 
%clos.branch_clos_pass
enum class  branch_clos_pass : flags_t
 
%clos.lower_typed_clos_prep_pass
enum class  lower_typed_clos_prep_pass : flags_t
 
%clos.clos2sjlj_pass
enum class  clos2sjlj_pass : flags_t
 
%clos.eta_red_bool_pass
enum class  eta_red_bool_pass : flags_t
 
%clos.clos_conv_phase
enum class  clos_conv_phase : flags_t
 
%clos.lower_typed_clos_phase
enum class  lower_typed_clos_phase : flags_t
 

Functions

void register_normalizers (Normalizers &normalizers)
 
Closures
ClosLit isa_clos_lit (Ref def, bool fn_isa_lam=true)
 Tries to match a closure literal.
 
Ref clos_pack (Ref env, Ref fn, Ref ct=nullptr)
 Pack a typed closure. This assumes that fn expects the environment as its Clos_Env_Paramth argument.
 
std::tuple< Ref, Ref, Refclos_unpack (Ref c)
 Deconstruct a closure into (env_type, function, env).
 
Ref clos_apply (Ref closure, Ref args)
 Apply a closure to arguments.
 
Ref apply_closure (Ref closure, Defs args)
 
template<class N >
std::tuple< const Extract *, N * > ca_isa_var (Ref def)
 Checks is def is the variable of a mut of type N.
 
Closure Types
const Sigmaisa_clos_type (Ref def)
 
Sigmaclos_type (const Pi *pi)
 Creates a typed closure type from pi.
 
const Piclos_type_to_pi (Ref ct, Ref new_env_type=nullptr)
 Convert a closure type to a Pi, where the environment type has been removed or replaced by new_env_type (if new_env_type != nullptr)
 

Variables

static constexpr plugin_t Plugin_Id = 0x10d4140000000000
 

%clos.attr

enum class  attr : flags_t {
  returning = 0x10d4140000000400 ,
  freeBB = 0x10d4140000000401 ,
  fstclassBB = 0x10d4140000000402 ,
  esc = 0x10d4140000000403 ,
  bottom = 0x10d4140000000404
}
 
template<attr o>
Ref normalize_clos (Ref type, Ref callee, Ref arg)
 

Closure Environment

static constexpr size_t Clos_Env_Param = 1_u64
 Describes where the environment is placed in the argument list.
 
size_t shift_env (size_t i)
 
size_t skip_env (size_t i)
 
Ref ctype (World &w, Defs doms, Ref env_type=nullptr)
 
Ref clos_insert_env (size_t i, Ref env, std::function< Ref(size_t)> f)
 
Ref clos_insert_env (size_t i, Ref env, Ref a)
 
Ref clos_insert_env (Ref env, Ref tup_or_sig)
 
Ref clos_remove_env (size_t i, std::function< Ref(size_t)> f)
 
Ref clos_remove_env (size_t i, Ref def)
 
Ref clos_remove_env (Ref tup_or_sig)
 
Ref clos_sub_env (Ref tup_or_sig, Ref new_env)
 

Detailed Description

Enumeration Type Documentation

◆ alloc_jmpbuf

Definition at line 21 of file autogen.h.

◆ attr

enum class mim::plug::clos::attr : flags_t
strong
Enumerator
returning 
freeBB 
fstclassBB 
esc 
bottom 

Definition at line 42 of file autogen.h.

◆ branch_clos_pass

Definition at line 64 of file autogen.h.

◆ BufPtr

enum class mim::plug::clos::BufPtr : flags_t
strong

Definition at line 14 of file autogen.h.

◆ clos2sjlj_pass

Definition at line 78 of file autogen.h.

◆ clos_conv_phase

Definition at line 92 of file autogen.h.

◆ clos_conv_prep_pass

Definition at line 57 of file autogen.h.

◆ eta_red_bool_pass

Definition at line 85 of file autogen.h.

◆ longjmp

enum class mim::plug::clos::longjmp : flags_t
strong

Definition at line 35 of file autogen.h.

◆ lower_typed_clos_phase

Definition at line 99 of file autogen.h.

◆ lower_typed_clos_prep_pass

Definition at line 71 of file autogen.h.

◆ setjmp

enum class mim::plug::clos::setjmp : flags_t
strong

Definition at line 28 of file autogen.h.

Function Documentation

◆ apply_closure()

Ref mim::plug::clos::apply_closure ( Ref closure,
Defs args )
inline

Definition at line 72 of file clos.h.

References clos_apply(), and mim::Def::world().

◆ ca_isa_var()

template<class N >
std::tuple< const Extract *, N * > mim::plug::clos::ca_isa_var ( Ref def)

Checks is def is the variable of a mut of type N.

Definition at line 79 of file clos.h.

References mim::Var::mut().

◆ clos_apply()

Ref mim::plug::clos::clos_apply ( Ref closure,
Ref args )

Apply a closure to arguments.

Definition at line 100 of file clos.cpp.

References clos_unpack(), and mim::Def::world().

Referenced by apply_closure(), and mim::plug::clos::Clos2SJLJ::enter().

◆ clos_insert_env() [1/3]

Ref mim::plug::clos::clos_insert_env ( Ref env,
Ref tup_or_sig )
inline

Definition at line 123 of file clos.h.

References mim::Def::num_projs(), and mim::Def::world().

◆ clos_insert_env() [2/3]

Ref mim::plug::clos::clos_insert_env ( size_t i,
Ref env,
Ref a )
inline

Definition at line 119 of file clos.h.

References clos_insert_env().

◆ clos_insert_env() [3/3]

Ref mim::plug::clos::clos_insert_env ( size_t i,
Ref env,
std::function< Ref(size_t)> f )

Definition at line 139 of file clos.cpp.

References Clos_Env_Param, and shift_env().

Referenced by clos_insert_env().

◆ clos_pack()

Ref mim::plug::clos::clos_pack ( Ref env,
Ref fn,
Ref ct = nullptr )

Pack a typed closure. This assumes that fn expects the environment as its Clos_Env_Paramth argument.

Definition at line 78 of file clos.cpp.

References Clos_Env_Param, clos_remove_env(), clos_type(), isa_clos_type(), mim::Def::type(), and mim::Def::world().

Referenced by mim::plug::clos::Clos2SJLJ::enter(), mim::plug::clos::Clos2SJLJ::rewrite(), and mim::plug::clos::LowerTypedClosPrep::rewrite().

◆ clos_remove_env() [1/3]

Ref mim::plug::clos::clos_remove_env ( Ref tup_or_sig)
inline

Definition at line 133 of file clos.h.

References mim::Def::num_projs(), and mim::Def::world().

◆ clos_remove_env() [2/3]

Ref mim::plug::clos::clos_remove_env ( size_t i,
Ref def )
inline

Definition at line 130 of file clos.h.

References clos_remove_env(), and mim::Def::proj().

◆ clos_remove_env() [3/3]

Ref mim::plug::clos::clos_remove_env ( size_t i,
std::function< Ref(size_t)> f )

◆ clos_sub_env()

Ref mim::plug::clos::clos_sub_env ( Ref tup_or_sig,
Ref new_env )
inline

Definition at line 139 of file clos.h.

References Clos_Env_Param, and mim::Def::refine().

Referenced by clos_type_to_pi().

◆ clos_type()

Sigma * mim::plug::clos::clos_type ( const Pi * pi)

Creates a typed closure type from pi.

Definition at line 121 of file clos.cpp.

References mim::Def::as_mut(), ctype(), and mim::Def::world().

Referenced by clos_pack(), and mim::plug::clos::Clos2SJLJ::enter().

◆ clos_type_to_pi()

const Pi * mim::plug::clos::clos_type_to_pi ( Ref ct,
Ref new_env_type = nullptr )

Convert a closure type to a Pi, where the environment type has been removed or replaced by new_env_type (if new_env_type != nullptr)

Definition at line 127 of file clos.cpp.

References clos_remove_env(), clos_sub_env(), isa_clos_type(), mim::Def::op(), and mim::Def::world().

◆ clos_unpack()

std::tuple< Ref, Ref, Ref > mim::plug::clos::clos_unpack ( Ref c)

Deconstruct a closure into (env_type, function, env).

Important: use this or ClosLit to destruct closures, since typechecking dependent pairs is currently broken.

Definition at line 88 of file clos.cpp.

References isa_clos_type().

Referenced by clos_apply(), mim::plug::clos::ClosLit::env(), and mim::plug::clos::ClosLit::fnc().

◆ ctype()

Ref mim::plug::clos::ctype ( World & w,
Defs doms,
Ref env_type = nullptr )

Definition at line 145 of file clos.cpp.

References ctype().

Referenced by clos_type(), and ctype().

◆ isa_clos_lit()

ClosLit mim::plug::clos::isa_clos_lit ( Ref def,
bool fn_isa_lam = true )

◆ isa_clos_type()

const Sigma * mim::plug::clos::isa_clos_type ( Ref def)

Returns def if def is a closure and nullptr otherwise

Definition at line 111 of file clos.cpp.

References Clos_Env_Param, mim::Pi::isa_cn(), mim::Def::isa_mut(), mim::Def::num_ops(), mim::Def::op(), mim::Def::var(), and mim::Def::world().

Referenced by clos_pack(), clos_type_to_pi(), and clos_unpack().

◆ normalize_clos()

template<attr o>
Ref mim::plug::clos::normalize_clos ( Ref type,
Ref callee,
Ref arg )

Definition at line 5 of file normalizers.cpp.

References bottom, and mim::Def::world().

◆ register_normalizers()

void mim::plug::clos::register_normalizers ( Normalizers & normalizers)

Referenced by mim_get_plugin().

◆ shift_env()

size_t mim::plug::clos::shift_env ( size_t i)
inline

Definition at line 110 of file clos.h.

References Clos_Env_Param.

Referenced by clos_insert_env().

◆ skip_env()

size_t mim::plug::clos::skip_env ( size_t i)
inline

Definition at line 113 of file clos.h.

References Clos_Env_Param.

Referenced by clos_remove_env().

Variable Documentation

◆ Clos_Env_Param

size_t mim::plug::clos::Clos_Env_Param = 1_u64
staticconstexpr

Describes where the environment is placed in the argument list.

tup_or_sig should generally be a Tuple, Sigma or Var.

Definition at line 107 of file clos.h.

Referenced by clos_insert_env(), clos_pack(), clos_sub_env(), mim::plug::clos::ClosLit::env_var(), isa_clos_type(), shift_env(), and skip_env().

◆ Plugin_Id

plugin_t mim::plug::clos::Plugin_Id = 0x10d4140000000000
staticconstexpr

Definition at line 10 of file autogen.h.