|
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_x64_LIR_x64_h |
|
8 #define jit_x64_LIR_x64_h |
|
9 |
|
10 namespace js { |
|
11 namespace jit { |
|
12 |
|
13 // Given a typed input, returns an untyped box. |
|
14 class LBox : public LInstructionHelper<1, 1, 0> |
|
15 { |
|
16 MIRType type_; |
|
17 |
|
18 public: |
|
19 LIR_HEADER(Box) |
|
20 |
|
21 LBox(MIRType type, const LAllocation &payload) |
|
22 : type_(type) |
|
23 { |
|
24 setOperand(0, payload); |
|
25 } |
|
26 |
|
27 MIRType type() const { |
|
28 return type_; |
|
29 } |
|
30 const char *extraName() const { |
|
31 return StringFromMIRType(type_); |
|
32 } |
|
33 }; |
|
34 |
|
35 // Given an untyped input, guards on whether it's a specific type and returns |
|
36 // the unboxed payload. |
|
37 class LUnboxBase : public LInstructionHelper<1, 1, 0> |
|
38 { |
|
39 public: |
|
40 LUnboxBase(const LAllocation &input) { |
|
41 setOperand(0, input); |
|
42 } |
|
43 |
|
44 static const size_t Input = 0; |
|
45 |
|
46 MUnbox *mir() const { |
|
47 return mir_->toUnbox(); |
|
48 } |
|
49 }; |
|
50 |
|
51 class LUnbox : public LUnboxBase { |
|
52 public: |
|
53 LIR_HEADER(Unbox) |
|
54 |
|
55 LUnbox(const LAllocation &input) |
|
56 : LUnboxBase(input) |
|
57 { } |
|
58 |
|
59 const char *extraName() const { |
|
60 return StringFromMIRType(mir()->type()); |
|
61 } |
|
62 }; |
|
63 |
|
64 class LUnboxFloatingPoint : public LUnboxBase { |
|
65 MIRType type_; |
|
66 |
|
67 public: |
|
68 LIR_HEADER(UnboxFloatingPoint) |
|
69 |
|
70 LUnboxFloatingPoint(const LAllocation &input, MIRType type) |
|
71 : LUnboxBase(input), |
|
72 type_(type) |
|
73 { } |
|
74 |
|
75 MIRType type() const { |
|
76 return type_; |
|
77 } |
|
78 const char *extraName() const { |
|
79 return StringFromMIRType(type_); |
|
80 } |
|
81 }; |
|
82 |
|
83 // Convert a 32-bit unsigned integer to a double. |
|
84 class LAsmJSUInt32ToDouble : public LInstructionHelper<1, 1, 0> |
|
85 { |
|
86 public: |
|
87 LIR_HEADER(AsmJSUInt32ToDouble) |
|
88 |
|
89 LAsmJSUInt32ToDouble(const LAllocation &input) { |
|
90 setOperand(0, input); |
|
91 } |
|
92 }; |
|
93 |
|
94 // Convert a 32-bit unsigned integer to a float32. |
|
95 class LAsmJSUInt32ToFloat32 : public LInstructionHelper<1, 1, 0> |
|
96 { |
|
97 public: |
|
98 LIR_HEADER(AsmJSUInt32ToFloat32) |
|
99 |
|
100 LAsmJSUInt32ToFloat32(const LAllocation &input) { |
|
101 setOperand(0, input); |
|
102 } |
|
103 }; |
|
104 |
|
105 class LAsmJSLoadFuncPtr : public LInstructionHelper<1, 1, 1> |
|
106 { |
|
107 public: |
|
108 LIR_HEADER(AsmJSLoadFuncPtr); |
|
109 LAsmJSLoadFuncPtr(const LAllocation &index, const LDefinition &temp) { |
|
110 setOperand(0, index); |
|
111 setTemp(0, temp); |
|
112 } |
|
113 MAsmJSLoadFuncPtr *mir() const { |
|
114 return mir_->toAsmJSLoadFuncPtr(); |
|
115 } |
|
116 const LAllocation *index() { |
|
117 return getOperand(0); |
|
118 } |
|
119 const LDefinition *temp() { |
|
120 return getTemp(0); |
|
121 } |
|
122 }; |
|
123 |
|
124 } // namespace jit |
|
125 } // namespace js |
|
126 |
|
127 #endif /* jit_x64_LIR_x64_h */ |