|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef jit_mips_LIR_mips_h |
|
8 #define jit_mips_LIR_mips_h |
|
9 |
|
10 namespace js { |
|
11 namespace jit { |
|
12 |
|
13 class LBox : public LInstructionHelper<2, 1, 0> |
|
14 { |
|
15 MIRType type_; |
|
16 |
|
17 public: |
|
18 LIR_HEADER(Box); |
|
19 |
|
20 LBox(const LAllocation &in_payload, MIRType type) |
|
21 : type_(type) |
|
22 { |
|
23 setOperand(0, in_payload); |
|
24 } |
|
25 |
|
26 MIRType type() const { |
|
27 return type_; |
|
28 } |
|
29 const char *extraName() const { |
|
30 return StringFromMIRType(type_); |
|
31 } |
|
32 }; |
|
33 |
|
34 class LBoxFloatingPoint : public LInstructionHelper<2, 1, 1> |
|
35 { |
|
36 MIRType type_; |
|
37 |
|
38 public: |
|
39 LIR_HEADER(BoxFloatingPoint); |
|
40 |
|
41 LBoxFloatingPoint(const LAllocation &in, const LDefinition &temp, MIRType type) |
|
42 : type_(type) |
|
43 { |
|
44 setOperand(0, in); |
|
45 setTemp(0, temp); |
|
46 } |
|
47 |
|
48 MIRType type() const { |
|
49 return type_; |
|
50 } |
|
51 const char *extraName() const { |
|
52 return StringFromMIRType(type_); |
|
53 } |
|
54 }; |
|
55 |
|
56 class LUnbox : public LInstructionHelper<1, 2, 0> |
|
57 { |
|
58 public: |
|
59 LIR_HEADER(Unbox); |
|
60 |
|
61 MUnbox *mir() const { |
|
62 return mir_->toUnbox(); |
|
63 } |
|
64 const LAllocation *payload() { |
|
65 return getOperand(0); |
|
66 } |
|
67 const LAllocation *type() { |
|
68 return getOperand(1); |
|
69 } |
|
70 const char *extraName() const { |
|
71 return StringFromMIRType(mir()->type()); |
|
72 } |
|
73 }; |
|
74 |
|
75 class LUnboxFloatingPoint : public LInstructionHelper<1, 2, 0> |
|
76 { |
|
77 MIRType type_; |
|
78 |
|
79 public: |
|
80 LIR_HEADER(UnboxFloatingPoint); |
|
81 |
|
82 static const size_t Input = 0; |
|
83 |
|
84 LUnboxFloatingPoint(MIRType type) |
|
85 : type_(type) |
|
86 { } |
|
87 |
|
88 MUnbox *mir() const { |
|
89 return mir_->toUnbox(); |
|
90 } |
|
91 |
|
92 MIRType type() const { |
|
93 return type_; |
|
94 } |
|
95 const char *extraName() const { |
|
96 return StringFromMIRType(type_); |
|
97 } |
|
98 }; |
|
99 |
|
100 // Convert a 32-bit unsigned integer to a double. |
|
101 class LAsmJSUInt32ToDouble : public LInstructionHelper<1, 1, 0> |
|
102 { |
|
103 public: |
|
104 LIR_HEADER(AsmJSUInt32ToDouble) |
|
105 |
|
106 LAsmJSUInt32ToDouble(const LAllocation &input) { |
|
107 setOperand(0, input); |
|
108 } |
|
109 }; |
|
110 |
|
111 // Convert a 32-bit unsigned integer to a float32. |
|
112 class LAsmJSUInt32ToFloat32 : public LInstructionHelper<1, 1, 0> |
|
113 { |
|
114 public: |
|
115 LIR_HEADER(AsmJSUInt32ToFloat32) |
|
116 |
|
117 LAsmJSUInt32ToFloat32(const LAllocation &input) { |
|
118 setOperand(0, input); |
|
119 } |
|
120 }; |
|
121 |
|
122 |
|
123 class LDivI : public LBinaryMath<1> |
|
124 { |
|
125 public: |
|
126 LIR_HEADER(DivI); |
|
127 |
|
128 LDivI(const LAllocation &lhs, const LAllocation &rhs, |
|
129 const LDefinition &temp) { |
|
130 setOperand(0, lhs); |
|
131 setOperand(1, rhs); |
|
132 setTemp(0, temp); |
|
133 } |
|
134 |
|
135 MDiv *mir() const { |
|
136 return mir_->toDiv(); |
|
137 } |
|
138 }; |
|
139 |
|
140 class LDivPowTwoI : public LInstructionHelper<1, 1, 1> |
|
141 { |
|
142 const int32_t shift_; |
|
143 |
|
144 public: |
|
145 LIR_HEADER(DivPowTwoI) |
|
146 |
|
147 LDivPowTwoI(const LAllocation &lhs, int32_t shift, const LDefinition &temp) |
|
148 : shift_(shift) |
|
149 { |
|
150 setOperand(0, lhs); |
|
151 setTemp(0, temp); |
|
152 } |
|
153 |
|
154 const LAllocation *numerator() { |
|
155 return getOperand(0); |
|
156 } |
|
157 |
|
158 int32_t shift() { |
|
159 return shift_; |
|
160 } |
|
161 |
|
162 MDiv *mir() const { |
|
163 return mir_->toDiv(); |
|
164 } |
|
165 }; |
|
166 |
|
167 class LModI : public LBinaryMath<1> |
|
168 { |
|
169 public: |
|
170 LIR_HEADER(ModI); |
|
171 |
|
172 LModI(const LAllocation &lhs, const LAllocation &rhs, |
|
173 const LDefinition &callTemp) |
|
174 { |
|
175 setOperand(0, lhs); |
|
176 setOperand(1, rhs); |
|
177 setTemp(0, callTemp); |
|
178 } |
|
179 |
|
180 const LDefinition *callTemp() { |
|
181 return getTemp(0); |
|
182 } |
|
183 |
|
184 MMod *mir() const { |
|
185 return mir_->toMod(); |
|
186 } |
|
187 }; |
|
188 |
|
189 class LModPowTwoI : public LInstructionHelper<1, 1, 0> |
|
190 { |
|
191 const int32_t shift_; |
|
192 |
|
193 public: |
|
194 LIR_HEADER(ModPowTwoI); |
|
195 int32_t shift() |
|
196 { |
|
197 return shift_; |
|
198 } |
|
199 |
|
200 LModPowTwoI(const LAllocation &lhs, int32_t shift) |
|
201 : shift_(shift) |
|
202 { |
|
203 setOperand(0, lhs); |
|
204 } |
|
205 |
|
206 MMod *mir() const { |
|
207 return mir_->toMod(); |
|
208 } |
|
209 }; |
|
210 |
|
211 class LModMaskI : public LInstructionHelper<1, 1, 1> |
|
212 { |
|
213 const int32_t shift_; |
|
214 |
|
215 public: |
|
216 LIR_HEADER(ModMaskI); |
|
217 |
|
218 LModMaskI(const LAllocation &lhs, const LDefinition &temp1, int32_t shift) |
|
219 : shift_(shift) |
|
220 { |
|
221 setOperand(0, lhs); |
|
222 setTemp(0, temp1); |
|
223 } |
|
224 |
|
225 int32_t shift() const { |
|
226 return shift_; |
|
227 } |
|
228 |
|
229 MMod *mir() const { |
|
230 return mir_->toMod(); |
|
231 } |
|
232 }; |
|
233 |
|
234 class LPowHalfD : public LInstructionHelper<1, 1, 0> |
|
235 { |
|
236 public: |
|
237 LIR_HEADER(PowHalfD); |
|
238 LPowHalfD(const LAllocation &input) { |
|
239 setOperand(0, input); |
|
240 } |
|
241 |
|
242 const LAllocation *input() { |
|
243 return getOperand(0); |
|
244 } |
|
245 const LDefinition *output() { |
|
246 return getDef(0); |
|
247 } |
|
248 }; |
|
249 |
|
250 // Takes a tableswitch with an integer to decide |
|
251 class LTableSwitch : public LInstructionHelper<0, 1, 2> |
|
252 { |
|
253 public: |
|
254 LIR_HEADER(TableSwitch); |
|
255 |
|
256 LTableSwitch(const LAllocation &in, const LDefinition &inputCopy, |
|
257 const LDefinition &jumpTablePointer, MTableSwitch *ins) { |
|
258 setOperand(0, in); |
|
259 setTemp(0, inputCopy); |
|
260 setTemp(1, jumpTablePointer); |
|
261 setMir(ins); |
|
262 } |
|
263 |
|
264 MTableSwitch *mir() const { |
|
265 return mir_->toTableSwitch(); |
|
266 } |
|
267 |
|
268 const LAllocation *index() { |
|
269 return getOperand(0); |
|
270 } |
|
271 const LDefinition *tempInt() { |
|
272 return getTemp(0); |
|
273 } |
|
274 // This is added to share the same CodeGenerator prefixes. |
|
275 const LDefinition *tempPointer() { |
|
276 return getTemp(1); |
|
277 } |
|
278 }; |
|
279 |
|
280 // Takes a tableswitch with an integer to decide |
|
281 class LTableSwitchV : public LInstructionHelper<0, BOX_PIECES, 3> |
|
282 { |
|
283 public: |
|
284 LIR_HEADER(TableSwitchV); |
|
285 |
|
286 LTableSwitchV(const LDefinition &inputCopy, const LDefinition &floatCopy, |
|
287 const LDefinition &jumpTablePointer, MTableSwitch *ins) |
|
288 { |
|
289 setTemp(0, inputCopy); |
|
290 setTemp(1, floatCopy); |
|
291 setTemp(2, jumpTablePointer); |
|
292 setMir(ins); |
|
293 } |
|
294 |
|
295 MTableSwitch *mir() const { |
|
296 return mir_->toTableSwitch(); |
|
297 } |
|
298 |
|
299 static const size_t InputValue = 0; |
|
300 |
|
301 const LDefinition *tempInt() { |
|
302 return getTemp(0); |
|
303 } |
|
304 const LDefinition *tempFloat() { |
|
305 return getTemp(1); |
|
306 } |
|
307 const LDefinition *tempPointer() { |
|
308 return getTemp(2); |
|
309 } |
|
310 }; |
|
311 |
|
312 class LGuardShape : public LInstructionHelper<0, 1, 1> |
|
313 { |
|
314 public: |
|
315 LIR_HEADER(GuardShape); |
|
316 |
|
317 LGuardShape(const LAllocation &in, const LDefinition &temp) { |
|
318 setOperand(0, in); |
|
319 setTemp(0, temp); |
|
320 } |
|
321 const MGuardShape *mir() const { |
|
322 return mir_->toGuardShape(); |
|
323 } |
|
324 const LDefinition *tempInt() { |
|
325 return getTemp(0); |
|
326 } |
|
327 }; |
|
328 |
|
329 class LGuardObjectType : public LInstructionHelper<0, 1, 1> |
|
330 { |
|
331 public: |
|
332 LIR_HEADER(GuardObjectType); |
|
333 |
|
334 LGuardObjectType(const LAllocation &in, const LDefinition &temp) { |
|
335 setOperand(0, in); |
|
336 setTemp(0, temp); |
|
337 } |
|
338 const MGuardObjectType *mir() const { |
|
339 return mir_->toGuardObjectType(); |
|
340 } |
|
341 const LDefinition *tempInt() { |
|
342 return getTemp(0); |
|
343 } |
|
344 }; |
|
345 |
|
346 class LInterruptCheck : public LInstructionHelper<0, 0, 0> |
|
347 { |
|
348 public: |
|
349 LIR_HEADER(InterruptCheck); |
|
350 }; |
|
351 |
|
352 class LMulI : public LBinaryMath<0> |
|
353 { |
|
354 public: |
|
355 LIR_HEADER(MulI); |
|
356 |
|
357 MMul *mir() { |
|
358 return mir_->toMul(); |
|
359 } |
|
360 }; |
|
361 |
|
362 class LUDiv : public LBinaryMath<0> |
|
363 { |
|
364 public: |
|
365 LIR_HEADER(UDiv); |
|
366 |
|
367 MDiv *mir() { |
|
368 return mir_->toDiv(); |
|
369 } |
|
370 }; |
|
371 |
|
372 class LUMod : public LBinaryMath<0> |
|
373 { |
|
374 public: |
|
375 LIR_HEADER(UMod); |
|
376 |
|
377 MMod *mir() { |
|
378 return mir_->toMod(); |
|
379 } |
|
380 }; |
|
381 |
|
382 class LAsmJSLoadFuncPtr : public LInstructionHelper<1, 1, 1> |
|
383 { |
|
384 public: |
|
385 LIR_HEADER(AsmJSLoadFuncPtr); |
|
386 LAsmJSLoadFuncPtr(const LAllocation &index, const LDefinition &temp) { |
|
387 setOperand(0, index); |
|
388 setTemp(0, temp); |
|
389 } |
|
390 const MAsmJSLoadFuncPtr *mir() const { |
|
391 return mir_->toAsmJSLoadFuncPtr(); |
|
392 } |
|
393 const LAllocation *index() { |
|
394 return getOperand(0); |
|
395 } |
|
396 const LDefinition *temp() { |
|
397 return getTemp(0); |
|
398 } |
|
399 }; |
|
400 |
|
401 } // namespace jit |
|
402 } // namespace js |
|
403 |
|
404 #endif /* jit_mips_LIR_mips_h */ |