MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::Sieve Class Reference

Filters the components of an aggregate and keeps track of where the survivors end up. More...

#include <mim/tuple.h>

Public Member Functions

Construction
 Sieve (size_t num)
 Sieve (size_t num, std::predicate< size_t > auto pred)
 Keeps those of num candidates that satisfy pred.
 Sieve (Defs ops, std::predicate< const Def * > auto pred)
 Keeps those ops that satisfy pred.
Concat

Candidates the rewrite adds; they have no old counterpart and simply continue the candidate indices.

void cat (size_t num, std::predicate< size_t > auto pred)
size_t num_cat () const
 Number of concat'ed candidates.
size_t cat (size_t i) const
 As Sieve::operator[] but for concat'ed i.
Getters
size_t num_old () const
 Number of old components.
size_t num_new () const
 Number of survivors.
bool all () const
 Is the new aggregate the old one - nothing dropped and nothing concat'ed?
fe::View< size_t > new2old () const
 The old index of the i th survivor; this is what Rewriter::rewrite_stub expects.
size_t operator[] (size_t i) const
 The new index of the candidate i - or Sieve::Gone, if it didn't survive.
DefVec gather (Defs ops) const
 The surviving components of ops - one per candidate, concat'ed ones included.

Static Public Attributes

static constexpr size_t Gone = size_t(-1)

Detailed Description

Filters the components of an aggregate and keeps track of where the survivors end up.

This is what a Phase needs that drops components of a Sigma - or the parameters of a Lam:

Note
Only a Sigma ever needs that last adjustment: an Arr's components all share one type - so it is dropped as a whole - and World::extract_fused splits a fused index at the Arr boundary, which leaves a Sigma's index scalar.

A rewrite that also adds components - mem::SEO threads fresh φs through a Lam - Sieve::cats them as further candidates: they extend the very same index space, so one Sieve still answers the whole new layout.

Definition at line 116 of file tuple.h.

Constructor & Destructor Documentation

◆ Sieve() [1/3]

mim::Sieve::Sieve ( size_t num)
inlineexplicit

Keeps all num components.

Definition at line 123 of file tuple.h.

Referenced by mim::SCCP::rewrite_imm_App(), and Sieve().

◆ Sieve() [2/3]

mim::Sieve::Sieve ( size_t num,
std::predicate< size_t > auto pred )
inline

Keeps those of num candidates that satisfy pred.

Definition at line 128 of file tuple.h.

◆ Sieve() [3/3]

mim::Sieve::Sieve ( Defs ops,
std::predicate< const Def * > auto pred )
inline

Keeps those ops that satisfy pred.

Definition at line 136 of file tuple.h.

References Sieve().

Member Function Documentation

◆ all()

bool mim::Sieve::all ( ) const
inline

Is the new aggregate the old one - nothing dropped and nothing concat'ed?

Definition at line 165 of file tuple.h.

References num_new(), and num_old().

◆ cat() [1/2]

size_t mim::Sieve::cat ( size_t i) const
inline

As Sieve::operator[] but for concat'ed i.

Definition at line 157 of file tuple.h.

References num_old().

◆ cat() [2/2]

void mim::Sieve::cat ( size_t num,
std::predicate< size_t > auto pred )
inline

Concats num candidates behind the old ones and keeps those that satisfy pred.

Note
A concat'ed component has no old op to rewrite from, so this rules out Sieve::new2old.

Definition at line 145 of file tuple.h.

◆ gather()

DefVec mim::Sieve::gather ( Defs ops) const
inline

The surviving components of ops - one per candidate, concat'ed ones included.

Definition at line 177 of file tuple.h.

References num_new().

◆ new2old()

fe::View< size_t > mim::Sieve::new2old ( ) const
inline

The old index of the i th survivor; this is what Rewriter::rewrite_stub expects.

Definition at line 167 of file tuple.h.

◆ num_cat()

size_t mim::Sieve::num_cat ( ) const
inline

Number of concat'ed candidates.

Definition at line 156 of file tuple.h.

◆ num_new()

size_t mim::Sieve::num_new ( ) const
inline

Number of survivors.

Definition at line 163 of file tuple.h.

Referenced by all(), and gather().

◆ num_old()

size_t mim::Sieve::num_old ( ) const
inline

Number of old components.

Definition at line 162 of file tuple.h.

Referenced by all(), and cat().

◆ operator[]()

size_t mim::Sieve::operator[] ( size_t i) const
inline

The new index of the candidate i - or Sieve::Gone, if it didn't survive.

Definition at line 172 of file tuple.h.

References Gone.

Member Data Documentation

◆ Gone

size_t mim::Sieve::Gone = size_t(-1)
staticconstexpr

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