/builds/2mk6rsew/0/parcoach/parcoach/src/aSSA/MSSAMuChi.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef MSSAMUCHI_H |
2 | | #define MSSAMUCHI_H |
3 | | |
4 | | #include "parcoach/MemoryRegion.h" |
5 | | |
6 | | #include "llvm/IR/Instructions.h" |
7 | | |
8 | | #include <set> |
9 | | #include <vector> |
10 | | |
11 | | class MSSAVar; |
12 | | |
13 | | class MSSADef { |
14 | | public: |
15 | | enum TYPE { |
16 | | PHI, |
17 | | CALL, |
18 | | STORE, |
19 | | SYNC, |
20 | | CHI, |
21 | | ENTRY, |
22 | | |
23 | | // External functions |
24 | | EXTVARARG, |
25 | | EXTARG, |
26 | | EXTRET, |
27 | | EXTCALL, |
28 | | EXTRETCALL |
29 | | }; |
30 | | |
31 | | MSSADef(MemRegEntry *region, TYPE type) |
32 | 217k | : region(region), var(nullptr), type(type) {} |
33 | | |
34 | 217k | virtual ~MSSADef() {} |
35 | 80 | virtual std::string getName() const { return region->getName().str(); } |
36 | | |
37 | | MemRegEntry *region; |
38 | | std::unique_ptr<MSSAVar> var; |
39 | | TYPE type; |
40 | | }; |
41 | | |
42 | | class MSSAVar { |
43 | | public: |
44 | | MSSAVar(MSSADef *def, unsigned version, llvm::BasicBlock const *bb) |
45 | 217k | : def(def), version(version), bb(bb) {} |
46 | 217k | virtual ~MSSAVar() {} |
47 | | |
48 | | MSSADef *def; |
49 | | unsigned version; |
50 | | llvm::BasicBlock const *bb; |
51 | 116 | std::string getName() const { |
52 | 116 | return def->getName() + std::to_string(version); |
53 | 116 | } |
54 | | }; |
55 | | |
56 | | class MSSAPhi : public MSSADef { |
57 | | public: |
58 | 8.11k | MSSAPhi(MemRegEntry *region) : MSSADef(region, PHI) {} |
59 | | |
60 | | std::map<int, MSSAVar *> opsVar; |
61 | | std::set<llvm::Value const *> preds; |
62 | | |
63 | 0 | static inline bool classof(MSSADef const *m) { return m->type == PHI; } |
64 | | }; |
65 | | |
66 | | class MSSAChi : public MSSADef { |
67 | | public: |
68 | | MSSAChi(MemRegEntry *region, TYPE type) |
69 | 209k | : MSSADef(region, type), opVar(NULL) {} |
70 | | |
71 | | MSSAVar *opVar; |
72 | | |
73 | 0 | static inline bool classof(MSSADef const *m) { return m->type == CHI; } |
74 | | }; |
75 | | |
76 | | class MSSAExtVarArgChi : public MSSAChi { |
77 | | public: |
78 | | MSSAExtVarArgChi(llvm::Function const *func) |
79 | 10.2k | : MSSAChi(NULL, EXTVARARG), func(func) {} |
80 | | |
81 | | llvm::Function const *func; |
82 | | |
83 | 16 | virtual std::string getName() const { return "VarArg"; } |
84 | | |
85 | 0 | static inline bool classof(MSSADef const *m) { return m->type == EXTVARARG; } |
86 | | }; |
87 | | |
88 | | class MSSAExtArgChi : public MSSAChi { |
89 | | public: |
90 | | MSSAExtArgChi(llvm::Function const *func, unsigned argNo) |
91 | 110k | : MSSAChi(NULL, EXTARG), func(func), argNo(argNo) {} |
92 | | |
93 | | llvm::Function const *func; |
94 | | unsigned argNo; |
95 | | |
96 | 20 | virtual std::string getName() const { |
97 | 20 | return "arg" + std::to_string(argNo) + "_"; |
98 | 20 | } |
99 | | |
100 | 0 | static inline bool classof(MSSADef const *m) { return m->type == EXTARG; } |
101 | | }; |
102 | | |
103 | | class MSSAExtRetChi : public MSSAChi { |
104 | | public: |
105 | | MSSAExtRetChi(llvm::Function const *func) |
106 | 2.60k | : MSSAChi(NULL, EXTRET), func(func) {} |
107 | | |
108 | | llvm::Function const *func; |
109 | | |
110 | 0 | virtual std::string getName() const { return "retval"; } |
111 | | |
112 | 0 | static inline bool classof(MSSADef const *m) { return m->type == EXTRET; } |
113 | | }; |
114 | | |
115 | | class MSSAEntryChi : public MSSAChi { |
116 | | public: |
117 | | MSSAEntryChi(MemRegEntry *region, llvm::Function const *func) |
118 | 40.3k | : MSSAChi(region, ENTRY), func(func) {} |
119 | | llvm::Function const *func; |
120 | | |
121 | 0 | static inline bool classof(MSSADef const *m) { return m->type == ENTRY; } |
122 | | }; |
123 | | |
124 | | class MSSAStoreChi : public MSSAChi { |
125 | | public: |
126 | | MSSAStoreChi(MemRegEntry *region, llvm::StoreInst const *inst) |
127 | 26.4k | : MSSAChi(region, STORE), inst(inst) {} |
128 | | llvm::StoreInst const *inst; |
129 | | |
130 | 2 | static inline bool classof(MSSADef const *m) { return m->type == STORE; } |
131 | | }; |
132 | | |
133 | | class MSSASyncChi : public MSSAChi { |
134 | | public: |
135 | | MSSASyncChi(MemRegEntry *region, llvm::Instruction const *inst) |
136 | 1 | : MSSAChi(region, SYNC), inst(inst) {} |
137 | | llvm::Instruction const *inst; |
138 | | |
139 | 0 | static inline bool classof(MSSADef const *m) { return m->type == SYNC; } |
140 | | }; |
141 | | |
142 | | class MSSACallChi : public MSSAChi { |
143 | | public: |
144 | | MSSACallChi(MemRegEntry *region, llvm::Function const *called, |
145 | | llvm::Instruction const *inst) |
146 | 31 | : MSSAChi(region, CALL), called(called), inst(inst) {} |
147 | | llvm::Function const *called; |
148 | | llvm::Instruction const *inst; |
149 | | |
150 | 2 | static inline bool classof(MSSADef const *m) { return m->type == CALL; } |
151 | | }; |
152 | | |
153 | | class MSSAExtCallChi : public MSSAChi { |
154 | | public: |
155 | | MSSAExtCallChi(MemRegEntry *region, llvm::Function const *called, |
156 | | unsigned argNo, llvm::Instruction const *inst) |
157 | 16.9k | : MSSAChi(region, EXTCALL), called(called), argNo(argNo), inst(inst) {} |
158 | | llvm::Function const *called; |
159 | | unsigned argNo; |
160 | | llvm::Instruction const *inst; |
161 | | |
162 | 17.0k | static inline bool classof(MSSADef const *m) { return m->type == EXTCALL; } |
163 | | }; |
164 | | |
165 | | class MSSAExtRetCallChi : public MSSAChi { |
166 | | public: |
167 | | MSSAExtRetCallChi(MemRegEntry *region, llvm::Function const *called) |
168 | 2.54k | : MSSAChi(region, EXTRETCALL), called(called) {} |
169 | | llvm::Function const *called; |
170 | | |
171 | 0 | static inline bool classof(MSSADef const *m) { return m->type == EXTRETCALL; } |
172 | | }; |
173 | | |
174 | | class MSSAMu { |
175 | | public: |
176 | | enum TYPE { LOAD, CALL, RET, EXTCALL }; |
177 | | |
178 | | MSSAMu(MemRegEntry *region, TYPE type) |
179 | 139k | : region(region), var(nullptr), type(type) {} |
180 | 139k | virtual ~MSSAMu() {} |
181 | | MemRegEntry *region; |
182 | | MSSAVar *var; |
183 | | TYPE type; |
184 | | }; |
185 | | |
186 | | class MSSALoadMu : public MSSAMu { |
187 | | public: |
188 | | MSSALoadMu(MemRegEntry *region, llvm::LoadInst const *inst) |
189 | 43.9k | : MSSAMu(region, LOAD), inst(inst) {} |
190 | | llvm::LoadInst const *inst; |
191 | | |
192 | 0 | static inline bool classof(MSSAMu const *m) { return m->type == LOAD; } |
193 | | }; |
194 | | |
195 | | class MSSACallMu : public MSSAMu { |
196 | | public: |
197 | | MSSACallMu(MemRegEntry *region, llvm::Function const *called) |
198 | 215 | : MSSAMu(region, CALL), called(called) {} |
199 | | llvm::Function const *called; |
200 | | |
201 | 0 | static inline bool classof(MSSAMu const *m) { return m->type == CALL; } |
202 | | }; |
203 | | |
204 | | class MSSAExtCallMu : public MSSAMu { |
205 | | public: |
206 | | MSSAExtCallMu(MemRegEntry *region, llvm::Function const *called, |
207 | | unsigned argNo) |
208 | 54.7k | : MSSAMu(region, EXTCALL), called(called), argNo(argNo) {} |
209 | | llvm::Function const *called; |
210 | | |
211 | | unsigned argNo; |
212 | | |
213 | 54.9k | static inline bool classof(MSSAMu const *m) { return m->type == EXTCALL; } |
214 | | }; |
215 | | |
216 | | class MSSARetMu : public MSSAMu { |
217 | | public: |
218 | | MSSARetMu(MemRegEntry *region, llvm::Function const *func) |
219 | 40.3k | : MSSAMu(region, RET), func(func) {} |
220 | | |
221 | | llvm::Function const *func; |
222 | | |
223 | 0 | static inline bool classof(MSSAMu const *m) { return m->type == RET; } |
224 | | }; |
225 | | |
226 | | #endif /* MSSAMUCHI */ |