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#include <mim/plug/mem/mem.h>
5
7
8namespace mim::plug::clos {
9
10class Clos2SJLJ : public RWPass<Clos2SJLJ, Lam> {
11public:
13 : RWPass(man, "closure2sjlj")
14 , lam2tag_()
15 , dom2throw_()
16 , lam2lpad_()
17 , ignore_() {}
18
19 void enter() override;
20 Ref rewrite(Ref) override;
21
22private:
23 Ref void_ptr() { return world().annex<clos::BufPtr>(); }
24 Ref jb_type() { return void_ptr(); }
25 Ref rb_type() { return world().call<mem::Ptr0>(void_ptr()); }
26 Ref tag_type() { return world().type_i32(); }
27
28 Lam* get_throw(Ref res_type);
29 Lam* get_lpad(Lam* lam, Ref rb);
30
31 void get_exn_closures();
32 void get_exn_closures(Ref def, DefSet& visited);
33
34 // clang-format off
36 DefMap<Lam*> dom2throw_;
37 DefMap<Lam*> lam2lpad_;
38 LamSet ignore_;
39 // clang-format on
40
41 Ref cur_rbuf_ = nullptr;
42 Ref cur_jbuf_ = nullptr;
43};
44
45} // namespace mim::plug::clos
An optimizer that combines several optimizations in an optimal way.
Definition pass.h:107
World & world()
Definition pass.h:296
PassMan & man()
Definition pass.h:30
Inherit from this class using CRTP, if your Pass does not need state and a fixed-point iteration.
Definition pass.h:220
Helper class to retrieve Infer::arg if present.
Definition def.h:86
const Def * annex(Id id)
Lookup annex by Axiom::id.
Definition world.h:185
const Def * call(Id id, Args &&... args)
Definition world.h:518
Ref type_i32()
Definition world.h:485
Ref rewrite(Ref) override
Clos2SJLJ(PassMan &man)
Definition clos2sjlj.h:12
void enter() override
Invoked just before Pass::rewriteing PassMan::curr_mut's body.
@ Lam
Definition def.h:40
The clos Plugin
Definition clos.h:7
GIDSet< Lam * > LamSet
Definition lam.h:200
GIDMap< const Def *, To > DefMap
Definition def.h:58
GIDMap< Lam *, To > LamMap
Definition lam.h:199
GIDSet< const Def * > DefSet
Definition def.h:59