11 auto n = dispatch.num_args();
12 auto sieve =
Sieve(n, [&](
size_t i) {
return isa_mem(dispatch.arg(n, i)); });
15 auto body = sink(dispatch, sieve);
16 return {filter, body};
28 auto dom =
DefVec(m, [&](
size_t j) {
return mems[j]->type(); });
29 auto ops = [&](
Lam* lam) {
30 return DefVec(n, [&](
size_t i) {
37 auto target = dispatch.target(t);
38 if (auto lam = target->isa_mut<Lam>(); lam && lam->is_set()) {
39 if (auto stub = lookup(lam)) return stub;
40 auto stub = w.mut_con(dom)->set(lam->dbg());
43 for (size_t i = 0; i != n; ++i)
44 map(lam->var(n, i), vs[i]);
45 if (n > 1) map(lam->var(), w.tuple(vs));
46 return stub->set(rewrite_filter_body(lam, stub));
48 auto wrapper = w.mut_con(dom)->set(target->dbg());
49 return wrapper->app(
false,
rewrite(target), w.tuple(ops(wrapper)));
52 profile_count(
"sink-args");
54 return w.app(
w.extract(
w.tuple(targets), rewrite(dispatch.
index())),
w.tuple(mems));
Matches (target_0, target_1, ...)#index arg.
const Def * filter() const
const fe::Vector< std::string > & args()
Command-line arguments passed to this Phase's plugin via -X <plugin>:<arg>.
World & new_world()
Create new Defs into this.
virtual std::array< const Def *, 2 > rewrite_filter_body(Lam *old_lam, Lam *)
The rewritten filter and body of old_lam for its stub new_lam, before the body is coerce()d.
virtual const Def * rewrite(const Def *)
Filters the components of an aggregate and keeps track of where the survivors end up.
DefVec gather(Defs ops) const
The surviving components of ops - one per candidate, concat'ed ones included.
size_t num_new() const
Number of survivors.
size_t num_old() const
Number of old components.
static constexpr size_t Gone
size_t num_targets() const
const Def * index() const
std::array< const Def *, 2 > rewrite_filter_body(Lam *, Lam *) final
The rewritten filter and body of old_lam for its stub new_lam, before the body is coerce()d.
const App * isa_mem(const Def *def)
If def is a core.M-typed value, yields its memory type core.M a; otherwise nullptr.
fe::Vector< const Def * > DefVec