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/pass.h>
4
5#include <mim/plug/mem/mem.h>
6
8
9namespace mim::plug::clos {
10
11class Clos2SJLJ : public RWPass<Clos2SJLJ, Lam> {
12public:
14 : RWPass(man, "closure2sjlj")
15 , lam2tag_()
16 , dom2throw_()
17 , lam2lpad_()
18 , ignore_() {}
19
20 void enter() override;
21 const Def* rewrite(const Def*) override;
22
23private:
24 const Def* void_ptr() { return world().annex<clos::BufPtr>(); }
25 const Def* jb_type() { return void_ptr(); }
26 const Def* rb_type() { return world().call<mem::Ptr0>(void_ptr()); }
27 const Def* tag_type() { return world().type_i32(); }
28
29 Lam* get_throw(const Def* res_type);
30 Lam* get_lpad(Lam* lam, const Def* rb);
31
32 void get_exn_closures();
33 void get_exn_closures(const Def* def, DefSet& visited);
34
35 // clang-format off
37 DefMap<Lam*> dom2throw_;
38 DefMap<Lam*> lam2lpad_;
39 LamSet ignore_;
40 // clang-format on
41
42 const Def* cur_rbuf_ = nullptr;
43 const Def* cur_jbuf_ = nullptr;
44};
45
46} // namespace mim::plug::clos
Base class for all Defs.
Definition def.h:198
World & world()
Definition pass.h:296
PassMan & man()
Definition pass.h:30
friend class PassMan
Definition pass.h:101
RWPass(PassMan &man, std::string_view name)
Definition pass.h:222
const Def * annex(Id id)
Lookup annex by Axiom::id.
Definition world.h:171
const Def * call(Id id, Args &&... args)
Complete curried call of annexes obeying implicits.
Definition world.h:506
const Def * type_i32()
Definition world.h:481
const Def * rewrite(const Def *) override
Clos2SJLJ(PassMan &man)
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:198
GIDMap< const Def *, To > DefMap
Definition def.h:46
GIDMap< Lam *, To > LamMap
Definition lam.h:197
GIDSet< const Def * > DefSet
Definition def.h:47
@ Lam
Definition def.h:85