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

The mem Plugin More...

Namespaces

namespace  phase

Classes

class  EscapeAnalysis
 Determines which allocations stay within the scope that allocates them. More...

Typedefs

using M = plug::core::M
using Ptr = plug::core::Ptr

Enumerations

<tt>mem.Ptr0</tt>
enum class  Ptr0 : flags_t
<tt>mem.Char</tt>
enum class  Char : flags_t
<tt>mem.Str</tt>
enum class  Str : flags_t
<tt>mem.fresh</tt>
enum class  fresh : flags_t
<tt>mem.alloc</tt>
enum class  alloc : flags_t
<tt>mem.slot</tt>
enum class  slot : flags_t
<tt>mem.malloc</tt>
enum class  malloc : flags_t
<tt>mem.free</tt>
enum class  free : flags_t
<tt>mem.mslot</tt>
enum class  mslot : flags_t
<tt>mem.decay</tt>
enum class  decay : flags_t
<tt>mem.assume</tt>
enum class  assume : flags_t
<tt>mem.cstr</tt>
enum class  cstr : flags_t
<tt>mem.add_mem</tt>
enum class  add_mem : flags_t
<tt>mem.free_locals</tt>
enum class  free_locals : flags_t
<tt>mem.heap2stack</tt>
enum class  heap2stack : flags_t
<tt>mem.seo</tt>
enum class  seo : flags_t
<tt>mem.alloc2malloc_repl</tt>
enum class  alloc2malloc_repl : flags_t

Functions

void register_normalizers (Normalizers &normalizers)
mem.M
Lam * mut_con (World &w, nat_t a=0)
 Yields con[mem.M 0].
Lam * mut_con (const Def *dom)
 Yields con[mem.M 0, dom].
const App * isa_mem (const Def *def)
 If def is a mem.M-typed value, yields its memory type mem.M a; otherwise nullptr.
bool has_leading_mem (const Pi *pi)
 Does pi already thread memory - a leading mem.M, either directly or grouped as the first component of the first parameter (e.g.
const Def * mem_def (const Def *def)
 Returns the (first) element of type mem.M a from the given tuple.
const Def * mem_var (Lam *lam)
 Returns the memory argument of a function if it has one.
bool has_mem_ty (const Def *type)
 Is type mem.M or a Sigma with a mem.M component?
const Def * strip_mem_ty (const Def *def)
 Removes recusively all occurences of mem from a type (sigma).
mem.Ptr
const Def * pointee (const Def *ptr)
mem.lea
const Def * op_lea (const Def *ptr, const Def *index)
const Def * op_lea_tuple (const Def *ptr, const Def *tuple)
 Successively offsets ptr by each component of the index tuple, peeling one array dimension per mem.lea.
mem.alloc
const Def * op_alloc (const Def *type, const Def *as, const Def *mem)
const Def * op_alloc (const Def *type, const Def *mem)
mem.slot
const Def * op_slot (const Def *type, const Def *as, const Def *mem, const Def *ret)
std::tuple< const Def *, Lam *, const Def *, const Def * > split_slot (const App *slotslot)
 Decomposes the continuation-based slot into (mem, ret_lam, ret_mem, ptr), where ret_mem is the continuation's mem and ptr is the continuation's slot var; the slot's lifetime is ret_lam's scope.
mem.malloc
const Def * op_malloc (const Def *type, const Def *as, const Def *mem)
mem.mslot
const Def * op_mslot (const Def *type, const Def *as, const Def *mem, const Def *ret)

Variables

static constexpr plugin_t Plugin_Id = 0x3863800000000000

<tt>mem.load</tt>

enum class  load : flags_t
const Def * normalize_load (const Def *type, const Def *, const Def *arg)

<tt>mem.store</tt>

enum class  store : flags_t
const Def * normalize_store (const Def *, const Def *, const Def *arg)

<tt>mem.lea</tt>

enum class  lea : flags_t
const Def * normalize_lea (const Def *, const Def *, const Def *arg)

Detailed Description

Typedef Documentation

◆ M

Definition at line 14 of file autogen.h.

◆ Ptr

Definition at line 15 of file autogen.h.

Enumeration Type Documentation

◆ add_mem

enum class mim::plug::mem::add_mem : flags_t
strong

Definition at line 127 of file autogen.h.

◆ alloc

enum class mim::plug::mem::alloc : flags_t
strong

Definition at line 63 of file autogen.h.

◆ alloc2malloc_repl

Definition at line 155 of file autogen.h.

◆ assume

enum class mim::plug::mem::assume : flags_t
strong

Definition at line 113 of file autogen.h.

◆ Char

enum class mim::plug::mem::Char : flags_t
strong

Definition at line 26 of file autogen.h.

◆ cstr

enum class mim::plug::mem::cstr : flags_t
strong

Definition at line 120 of file autogen.h.

◆ decay

enum class mim::plug::mem::decay : flags_t
strong

Definition at line 106 of file autogen.h.

◆ free

enum class mim::plug::mem::free : flags_t
strong

Definition at line 84 of file autogen.h.

◆ free_locals

enum class mim::plug::mem::free_locals : flags_t
strong

Definition at line 134 of file autogen.h.

◆ fresh

enum class mim::plug::mem::fresh : flags_t
strong

Definition at line 56 of file autogen.h.

◆ heap2stack

enum class mim::plug::mem::heap2stack : flags_t
strong

Definition at line 141 of file autogen.h.

◆ lea

enum class mim::plug::mem::lea : flags_t
strong

Definition at line 98 of file autogen.h.

◆ load

enum class mim::plug::mem::load : flags_t
strong

Definition at line 40 of file autogen.h.

◆ malloc

enum class mim::plug::mem::malloc : flags_t
strong

Definition at line 77 of file autogen.h.

◆ mslot

enum class mim::plug::mem::mslot : flags_t
strong

Definition at line 91 of file autogen.h.

◆ Ptr0

enum class mim::plug::mem::Ptr0 : flags_t
strong

Definition at line 19 of file autogen.h.

◆ seo

enum class mim::plug::mem::seo : flags_t
strong

Definition at line 148 of file autogen.h.

◆ slot

enum class mim::plug::mem::slot : flags_t
strong

Definition at line 70 of file autogen.h.

◆ store

enum class mim::plug::mem::store : flags_t
strong

Definition at line 48 of file autogen.h.

◆ Str

enum class mim::plug::mem::Str : flags_t
strong

Definition at line 33 of file autogen.h.

Function Documentation

◆ has_leading_mem()

bool mim::plug::mem::has_leading_mem ( const Pi * pi)
inline

Does pi already thread memory - a leading mem.M, either directly or grouped as the first component of the first parameter (e.g.

the Fn [mem.M 0, To, ins] → … shape of a mem-threaded combiner)?

Definition at line 29 of file mem.h.

References mim::Pi::dom(), has_leading_mem(), mim::Axm::isa(), mim::Pi::num_doms(), and mim::Def::num_ops().

Referenced by has_leading_mem(), and mim::plug::mem::phase::AddMem::rewrite_imm_Pi().

◆ has_mem_ty()

bool mim::plug::mem::has_mem_ty ( const Def * type)
inline

Is type mem.M or a Sigma with a mem.M component?

Definition at line 54 of file mem.h.

References has_mem_ty(), and mim::Axm::isa().

Referenced by has_mem_ty().

◆ isa_mem()

const App * mim::plug::mem::isa_mem ( const Def * def)
inline

If def is a mem.M-typed value, yields its memory type mem.M a; otherwise nullptr.

Definition at line 25 of file mem.h.

References mim::Axm::isa(), isa_mem(), and mim::Def::type().

Referenced by isa_mem(), mem_def(), mim::plug::mem::phase::AddMem::rewrite(), and mim::plug::mem::phase::AddMem::rewrite_imm_Tuple().

◆ mem_def()

const Def * mim::plug::mem::mem_def ( const Def * def)
inline

◆ mem_var()

const Def * mim::plug::mem::mem_var ( Lam * lam)
inline

Returns the memory argument of a function if it has one.

Definition at line 51 of file mem.h.

References mem_def(), mem_var(), and mim::Def::var().

Referenced by mem_var(), mim::plug::affine::phase::LowerFor::rewrite_imm_App(), and mim::plug::mem::phase::AddMem::rewrite_mut_Lam().

◆ mut_con() [1/2]

Lam * mim::plug::mem::mut_con ( const Def * dom)
inline

Yields con[mem.M 0, dom].

Definition at line 19 of file mem.h.

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

◆ mut_con() [2/2]

Lam * mim::plug::mem::mut_con ( World & w,
nat_t a = 0 )
inline

Yields con[mem.M 0].

Definition at line 16 of file mem.h.

References mut_con().

Referenced by mut_con(), and mut_con().

◆ normalize_lea()

const Def * mim::plug::mem::normalize_lea ( const Def * ,
const Def * ,
const Def * arg )

Definition at line 7 of file normalizers.cpp.

References mim::Lit::isa(), normalize_lea(), pointee(), and mim::Def::projs().

Referenced by normalize_lea().

◆ normalize_load()

const Def * mim::plug::mem::normalize_load ( const Def * type,
const Def * ,
const Def * arg )

Definition at line 14 of file normalizers.cpp.

References normalize_load(), mim::Def::num_ops(), mim::Def::op(), pointee(), and mim::Def::projs().

Referenced by normalize_load().

◆ normalize_store()

const Def * mim::plug::mem::normalize_store ( const Def * ,
const Def * ,
const Def * arg )

Definition at line 28 of file normalizers.cpp.

References mim::Seq::body(), normalize_store(), and mim::Def::projs().

Referenced by normalize_store().

◆ op_alloc() [1/2]

const Def * mim::plug::mem::op_alloc ( const Def * type,
const Def * as,
const Def * mem )
inline

◆ op_alloc() [2/2]

const Def * mim::plug::mem::op_alloc ( const Def * type,
const Def * mem )
inline

Definition at line 112 of file mem.h.

References op_alloc().

◆ op_lea()

const Def * mim::plug::mem::op_lea ( const Def * ptr,
const Def * index )
inline

Definition at line 89 of file mem.h.

References mim::Axm::as(), op_lea(), pointee(), mim::tuple_of_types(), mim::Def::type(), and mim::Def::world().

Referenced by op_lea(), and op_lea_tuple().

◆ op_lea_tuple()

const Def * mim::plug::mem::op_lea_tuple ( const Def * ptr,
const Def * tuple )
inline

Successively offsets ptr by each component of the index tuple, peeling one array dimension per mem.lea.

Definition at line 97 of file mem.h.

References op_lea(), and op_lea_tuple().

Referenced by op_lea_tuple(), and mim::plug::buffer::LowerPtr::rewrite_imm_App().

◆ op_malloc()

const Def * mim::plug::mem::op_malloc ( const Def * type,
const Def * as,
const Def * mem )
inline

Definition at line 137 of file mem.h.

References op_malloc(), and mim::plug::core::size.

Referenced by op_malloc(), and reg_phases().

◆ op_mslot()

const Def * mim::plug::mem::op_mslot ( const Def * type,
const Def * as,
const Def * mem,
const Def * ret )
inline

Builds the continuation-based mem.mslot (type, as) applied to (mem, size) and the continuation ret. ret is a Cn [mem.M as, mem.Ptr (type, as)] receiving the fresh slot; its scope delimits the slot's lifetime.

Definition at line 148 of file mem.h.

References op_mslot(), and mim::plug::core::size.

Referenced by op_mslot(), and reg_phases().

◆ op_slot()

const Def * mim::plug::mem::op_slot ( const Def * type,
const Def * as,
const Def * mem,
const Def * ret )
inline

Builds the continuation-based mem.slot (type, as) applied to mem and the continuation ret. ret is a Cn [mem.M as, mem.Ptr (type, as)] receiving the fresh slot; its scope delimits the slot's lifetime.

Definition at line 119 of file mem.h.

References op_slot().

Referenced by op_slot(), mim::plug::mem::phase::Heap2Stack::rewrite_imm_App(), and mim::plug::mem::phase::SEO::rewrite_imm_App().

◆ pointee()

◆ register_normalizers()

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

◆ split_slot()

std::tuple< const Def *, Lam *, const Def *, const Def * > mim::plug::mem::split_slot ( const App * slot)
inline

Decomposes the continuation-based slot into (mem, ret_lam, ret_mem, ptr), where ret_mem is the continuation's mem and ptr is the continuation's slot var; the slot's lifetime is ret_lam's scope.

All but mem are nullptr if the continuation is no mutable Lam.

Definition at line 127 of file mem.h.

References split_slot().

Referenced by mim::plug::mem::phase::SEO::rewrite_imm_App(), and split_slot().

◆ strip_mem_ty()

const Def * mim::plug::mem::strip_mem_ty ( const Def * def)
inline

Removes recusively all occurences of mem from a type (sigma).

Definition at line 62 of file mem.h.

References mim::Axm::isa(), strip_mem_ty(), and mim::Def::world().

Referenced by mim::plug::ll::Emitter::convert_ret_pi(), and strip_mem_ty().

Variable Documentation

◆ Plugin_Id

plugin_t mim::plug::mem::Plugin_Id = 0x3863800000000000
staticconstexpr

Definition at line 12 of file autogen.h.