12 constexpr const Child& child()
const {
return *
static_cast<const Child*
>(
this); }
13 constexpr Child& child() {
return *
static_cast<Child*
>(
this); }
16 Value emit_(
const Def* def) {
19 return child().emit_bb(bb, def);
37 assert(child().is_valid(res));
44 if (
auto i =
locals_.find(def); i !=
locals_.end())
return i->second;
46 auto val = emit_(def);
54 child().emit_imported(
entry_);
62 if (
auto lam = mut->isa<
Lam>())
lam2bb_.emplace(lam, BB());
68 auto fct = child().prepare(
scope);
73 for (
auto mut : muts) {
74 if (
auto lam = mut->isa<
Lam>(); lam && lam !=
scope.
exit()) {
76 child().emit_epilogue(lam);
80 child().finalize(
scope);
82 assert_unused(
lam2bb_.size() == old_size &&
"really make sure we didn't triger a rehash");
bool is_set() const
Yields true if empty or the last op is set.
T * isa_mut() const
If this is *mut*able, it will cast constness away and perform a dynamic_cast to T.
T * as_mut() const
Asserts that this is a mutable, casts constness away and performs a static_cast to T.
Value emit_unsafe(const Def *def)
As above but returning !child().is_valid(value) is permitted.
std::ostream & ostream() const
Emitter(World &world, std::string_view name, std::ostream &ostream)
Value emit(const Def *def)
Recursively emits code.
void visit(const Scope &scope) override
Ref ret_var()
Yields the Lam::var of the Lam::ret_pi.
static const Lam * isa_basicblock(Ref d)
std::string_view name() const
static Schedule schedule(const Scope &)
Transitively visits all reachable Scopes in World that do not have free variables.
const Scope & scope() const
A Scope represents a region of Defs that are live from the view of an entry's Var.
Keeps track of indentation level.
The World represents the whole program and manages creation of Thorin nodes (Defs).
GIDMap< Lam *, To > LamMap
GIDMap< const Def *, To > DefMap