21 return w.mut_con({w.call<
M>(0), dom});
27 if (def->
type()->isa<
Arr>())
return {};
30 for (
auto proj : def->
projs())
42 auto& world = def->
world();
44 if (
auto sigma = def->isa<
Sigma>()) {
46 for (
auto op : sigma->
ops())
47 if (
auto new_op =
strip_mem_ty(op); new_op != world.sigma()) new_ops.push_back(new_op);
49 return world.sigma(new_ops);
60 auto& world = def->
world();
64 for (
auto op :
tuple->ops())
65 if (
auto new_op =
strip_mem(op); new_op != world.tuple()) new_ops.push_back(new_op);
67 return world.tuple(new_ops);
70 }
else if (
auto extract = def->isa<
Extract>()) {
72 if (extract->num_projs() == 1)
return extract;
75 for (
auto op : extract->
projs())
76 if (
auto new_op =
strip_mem(op); new_op != world.tuple()) new_ops.push_back(new_op);
78 return world.tuple(new_ops);
102 return w.app(w.app(w.annex<
lea>(), {pointee->arity(), Ts, addr_space}), {ptr, index});
116 World& w = type->world();
117 return w.app(w.app(w.annex<
alloc>(), {type, w.lit_nat_0()}),
mem);
124 World& w = type->world();
125 return w.app(w.app(w.annex<
slot>(), {type, w.lit_nat_0()}), {mem, w.lit_nat(w.curr_gid())});
132 World& w = type->world();
134 return w.app(w.app(w.annex<
malloc>(), {type, w.lit_nat_0()}), {mem, size});
141 World& w = type->world();
143 return w.app(w.app(w.annex<
mslot>(), {type, w.lit_nat_0()}), {mem, size, id});
A (possibly paramterized) Array.
static auto isa(const Def *def)
static auto as(const Def *def)
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::arity(), if it is 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 * mem_def(const Def *def)
Returns the (first) element of type mem.M a 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, nat_t a=0)
Yields con[mem.M 0].
const Def * strip_mem(const Def *def)
Recursively removes all occurrences of mem from a tuple.
Vector< const Def * > DefVec
const Def * tuple_of_types(const Def *t)