MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
clos2sjlj.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/pass.h>
4
5#include <mim/plug/mem/mem.h>
6
8
9namespace mim::plug::clos {
10
11class Clos2SJLJ : public RWPass<Clos2SJLJ, Lam> {
12public:
15
16 void enter() override;
17 const Def* rewrite(const Def*) override;
18
19private:
20 const Def* void_ptr() { return world().annex<clos::BufPtr>(); }
21 const Def* jb_type() { return void_ptr(); }
22 const Def* rb_type() { return world().call<mem::Ptr0>(void_ptr()); }
23 const Def* tag_type() { return world().type_i32(); }
24
25 Lam* get_throw(const Def* res_type);
26 Lam* get_lpad(Lam* lam, const Def* rb);
27
28 void get_exn_closures();
29 void get_exn_closures(const Def* def, DefSet& visited);
30
31 // clang-format off
33 DefMap<Lam*> dom2throw_;
34 DefMap<Lam*> lam2lpad_;
35 LamSet ignore_;
36 // clang-format on
37
38 const Def* cur_rbuf_ = nullptr;
39 const Def* cur_jbuf_ = nullptr;
40};
41
42} // namespace mim::plug::clos
Base class for all Defs.
Definition def.h:251
RWPass(World &world, std::string name)
Definition pass.h:295
World & world()
Definition pass.h:64
flags_t annex() const
Definition pass.h:68
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:32
const Def * annex(Id id)
Lookup annex by Axm::id.
Definition world.h:182
const Def * call(Id id, Args &&... args)
Complete curried call of annexes obeying implicits.
Definition world.h:543
const Def * type_i32()
Definition world.h:515
const Def * rewrite(const Def *) override
Clos2SJLJ(World &world, flags_t annex)
Definition clos2sjlj.h:13
void enter() override
Invoked just before Pass::rewriteing PassMan::curr_mut's body.
The clos Plugin
Definition clos.h:7
GIDSet< Lam * > LamSet
Definition lam.h:221
u64 flags_t
Definition types.h:45
GIDMap< const Def *, To > DefMap
Definition def.h:73
GIDMap< Lam *, To > LamMap
Definition lam.h:220
GIDSet< const Def * > DefSet
Definition def.h:74
@ Lam
Definition def.h:114