21 return w.mut_con({w.annex<
M>(), dom});
27 if (def->
type()->isa<
Arr>())
return {};
30 for (
auto proj : def->
projs())
44 auto& w =
mem->world();
45 return w.tuple(
DefVec(arg->
num_projs(), [&](
auto i) { return replace_mem(mem, arg->proj(i)); }));
55 auto& world = def->
world();
57 if (
auto sigma = def->isa<
Sigma>()) {
59 for (
auto op : sigma->
ops())
60 if (
auto new_op =
strip_mem_ty(op); new_op != world.sigma()) new_ops.push_back(new_op);
62 return world.sigma(new_ops);
73 auto& world = def->
world();
75 if (
auto tuple = def->isa<
Tuple>()) {
77 for (
auto op : tuple->
ops())
78 if (
auto new_op =
strip_mem(op); new_op != world.tuple()) new_ops.push_back(new_op);
80 return world.tuple(new_ops);
83 }
else if (
auto extract = def->isa<
Extract>()) {
85 if (extract->num_projs() == 1)
return extract;
88 for (
auto op : extract->
projs())
89 if (
auto new_op =
strip_mem(op); new_op != world.tuple()) new_ops.push_back(new_op);
91 return world.tuple(new_ops);
115 return w.app(w.app(w.annex<
lea>(), {pointee->arity(), Ts, addr_space}), {ptr, index});
130 return w.app(w.annex<
remem>(),
mem);
138 return w.app(w.app(w.annex<
alloc>(), {type, w.lit_nat_0()}),
mem);
146 return w.app(w.app(w.annex<
slot>(), {type, w.lit_nat_0()}), {mem, w.lit_nat(w.curr_gid())});
155 return w.app(w.app(w.annex<
malloc>(), {type, w.lit_nat_0()}), {mem, size});
164 return w.app(w.app(w.annex<
mslot>(), {type, w.lit_nat_0()}), {mem, size, id});
A (possibly paramterized) Array.
World & world() const noexcept
constexpr auto ops() const noexcept
const Def * var(nat_t a, nat_t i) noexcept
auto projs(F f) const
Splits this Def via Def::projections into an Array (if A == std::dynamic_extent) or std::array (other...
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
nat_t num_projs() const
Yields Def::as_lit_arity(), if it is in fact a Lit, or 1 otherwise.
Data constructor for a Sigma.
The World represents the whole program and manages creation of MimIR nodes (Defs).
const Def * op_slot(const Def *type, const Def *mem)
const Def * mem_var(Lam *lam)
Returns the memory argument of a function if it has one.
const Def * replace_mem(const Def *mem, const Def *arg)
Swaps the memory occurrences in the given def with the given memory.
const Def * mem_def(const Def *def)
Returns the (first) element of type mem::M from the given tuple.
const Def * op_mslot(const Def *type, const Def *mem, const Def *id)
const Def * op_malloc(const Def *type, const Def *mem)
const Def * strip_mem_ty(const Def *def)
Removes recusively all occurences of mem from a type (sigma).
const Def * op_lea(const Def *ptr, const Def *index)
const Def * op_alloc(const Def *type, const Def *mem)
const Def * op_lea_unsafe(const Def *ptr, const Def *i)
Lam * mut_con(World &w)
Yields con[mem.M].
const Def * strip_mem(const Def *def)
Recursively removes all occurrences of mem from a tuple.
const Def * op_remem(const Def *mem)
Vector< const Def * > DefVec
const Def * tuple_of_types(const Def *t)
auto match(const Def *def)
auto force(const Def *def)