OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // that this RawMachineAssembler becomes invalid after export. | 67 // that this RawMachineAssembler becomes invalid after export. |
68 Schedule* Export(); | 68 Schedule* Export(); |
69 | 69 |
70 // =========================================================================== | 70 // =========================================================================== |
71 // The following utility methods create new nodes with specific operators and | 71 // The following utility methods create new nodes with specific operators and |
72 // place them into the current basic block. They don't perform control flow, | 72 // place them into the current basic block. They don't perform control flow, |
73 // hence will not switch the current basic block. | 73 // hence will not switch the current basic block. |
74 | 74 |
75 Node* UndefinedConstant() { | 75 Node* UndefinedConstant() { |
76 Handle<HeapObject> undefined = isolate()->factory()->undefined_value(); | 76 Handle<HeapObject> undefined = isolate()->factory()->undefined_value(); |
77 return NewNode(common()->HeapConstant(undefined)); | 77 return AddNode(common()->HeapConstant(undefined)); |
78 } | 78 } |
79 | 79 |
80 // Constants. | 80 // Constants. |
81 Node* PointerConstant(void* value) { | 81 Node* PointerConstant(void* value) { |
82 return IntPtrConstant(reinterpret_cast<intptr_t>(value)); | 82 return IntPtrConstant(reinterpret_cast<intptr_t>(value)); |
83 } | 83 } |
84 Node* IntPtrConstant(intptr_t value) { | 84 Node* IntPtrConstant(intptr_t value) { |
85 // TODO(dcarney): mark generated code as unserializable if value != 0. | 85 // TODO(dcarney): mark generated code as unserializable if value != 0. |
86 return kPointerSize == 8 ? Int64Constant(value) | 86 return kPointerSize == 8 ? Int64Constant(value) |
87 : Int32Constant(static_cast<int>(value)); | 87 : Int32Constant(static_cast<int>(value)); |
88 } | 88 } |
89 Node* Int32Constant(int32_t value) { | 89 Node* Int32Constant(int32_t value) { |
90 return NewNode(common()->Int32Constant(value)); | 90 return AddNode(common()->Int32Constant(value)); |
91 } | 91 } |
92 Node* Int64Constant(int64_t value) { | 92 Node* Int64Constant(int64_t value) { |
93 return NewNode(common()->Int64Constant(value)); | 93 return AddNode(common()->Int64Constant(value)); |
94 } | 94 } |
95 Node* NumberConstant(double value) { | 95 Node* NumberConstant(double value) { |
96 return NewNode(common()->NumberConstant(value)); | 96 return AddNode(common()->NumberConstant(value)); |
97 } | 97 } |
98 Node* Float32Constant(float value) { | 98 Node* Float32Constant(float value) { |
99 return NewNode(common()->Float32Constant(value)); | 99 return AddNode(common()->Float32Constant(value)); |
100 } | 100 } |
101 Node* Float64Constant(double value) { | 101 Node* Float64Constant(double value) { |
102 return NewNode(common()->Float64Constant(value)); | 102 return AddNode(common()->Float64Constant(value)); |
103 } | 103 } |
104 Node* HeapConstant(Handle<HeapObject> object) { | 104 Node* HeapConstant(Handle<HeapObject> object) { |
105 return NewNode(common()->HeapConstant(object)); | 105 return AddNode(common()->HeapConstant(object)); |
106 } | 106 } |
107 Node* ExternalConstant(ExternalReference address) { | 107 Node* ExternalConstant(ExternalReference address) { |
108 return NewNode(common()->ExternalConstant(address)); | 108 return AddNode(common()->ExternalConstant(address)); |
109 } | 109 } |
110 | 110 |
111 Node* Projection(int index, Node* a) { | 111 Node* Projection(int index, Node* a) { |
112 return NewNode(common()->Projection(index), a); | 112 return AddNode(common()->Projection(index), a); |
113 } | 113 } |
114 | 114 |
115 // Memory Operations. | 115 // Memory Operations. |
116 Node* Load(MachineType rep, Node* base) { | 116 Node* Load(MachineType rep, Node* base) { |
117 return Load(rep, base, IntPtrConstant(0)); | 117 return Load(rep, base, IntPtrConstant(0)); |
118 } | 118 } |
119 Node* Load(MachineType rep, Node* base, Node* index) { | 119 Node* Load(MachineType rep, Node* base, Node* index) { |
120 return NewNode(machine()->Load(rep), base, index, graph()->start(), | 120 return AddNode(machine()->Load(rep), base, index, graph()->start(), |
121 graph()->start()); | 121 graph()->start()); |
122 } | 122 } |
123 Node* Store(MachineType rep, Node* base, Node* value) { | 123 Node* Store(MachineType rep, Node* base, Node* value) { |
124 return Store(rep, base, IntPtrConstant(0), value); | 124 return Store(rep, base, IntPtrConstant(0), value); |
125 } | 125 } |
126 Node* Store(MachineType rep, Node* base, Node* index, Node* value) { | 126 Node* Store(MachineType rep, Node* base, Node* index, Node* value) { |
127 return NewNode(machine()->Store(StoreRepresentation(rep, kNoWriteBarrier)), | 127 return AddNode(machine()->Store(StoreRepresentation(rep, kNoWriteBarrier)), |
128 base, index, value, graph()->start(), graph()->start()); | 128 base, index, value, graph()->start(), graph()->start()); |
129 } | 129 } |
130 | 130 |
131 // Arithmetic Operations. | 131 // Arithmetic Operations. |
132 Node* WordAnd(Node* a, Node* b) { | 132 Node* WordAnd(Node* a, Node* b) { |
133 return NewNode(machine()->WordAnd(), a, b); | 133 return AddNode(machine()->WordAnd(), a, b); |
134 } | 134 } |
135 Node* WordOr(Node* a, Node* b) { return NewNode(machine()->WordOr(), a, b); } | 135 Node* WordOr(Node* a, Node* b) { return AddNode(machine()->WordOr(), a, b); } |
136 Node* WordXor(Node* a, Node* b) { | 136 Node* WordXor(Node* a, Node* b) { |
137 return NewNode(machine()->WordXor(), a, b); | 137 return AddNode(machine()->WordXor(), a, b); |
138 } | 138 } |
139 Node* WordShl(Node* a, Node* b) { | 139 Node* WordShl(Node* a, Node* b) { |
140 return NewNode(machine()->WordShl(), a, b); | 140 return AddNode(machine()->WordShl(), a, b); |
141 } | 141 } |
142 Node* WordShr(Node* a, Node* b) { | 142 Node* WordShr(Node* a, Node* b) { |
143 return NewNode(machine()->WordShr(), a, b); | 143 return AddNode(machine()->WordShr(), a, b); |
144 } | 144 } |
145 Node* WordSar(Node* a, Node* b) { | 145 Node* WordSar(Node* a, Node* b) { |
146 return NewNode(machine()->WordSar(), a, b); | 146 return AddNode(machine()->WordSar(), a, b); |
147 } | 147 } |
148 Node* WordRor(Node* a, Node* b) { | 148 Node* WordRor(Node* a, Node* b) { |
149 return NewNode(machine()->WordRor(), a, b); | 149 return AddNode(machine()->WordRor(), a, b); |
150 } | 150 } |
151 Node* WordEqual(Node* a, Node* b) { | 151 Node* WordEqual(Node* a, Node* b) { |
152 return NewNode(machine()->WordEqual(), a, b); | 152 return AddNode(machine()->WordEqual(), a, b); |
153 } | 153 } |
154 Node* WordNotEqual(Node* a, Node* b) { | 154 Node* WordNotEqual(Node* a, Node* b) { |
155 return WordBinaryNot(WordEqual(a, b)); | 155 return WordBinaryNot(WordEqual(a, b)); |
156 } | 156 } |
157 Node* WordNot(Node* a) { | 157 Node* WordNot(Node* a) { |
158 if (machine()->Is32()) { | 158 if (machine()->Is32()) { |
159 return Word32Not(a); | 159 return Word32Not(a); |
160 } else { | 160 } else { |
161 return Word64Not(a); | 161 return Word64Not(a); |
162 } | 162 } |
163 } | 163 } |
164 Node* WordBinaryNot(Node* a) { | 164 Node* WordBinaryNot(Node* a) { |
165 if (machine()->Is32()) { | 165 if (machine()->Is32()) { |
166 return Word32BinaryNot(a); | 166 return Word32BinaryNot(a); |
167 } else { | 167 } else { |
168 return Word64BinaryNot(a); | 168 return Word64BinaryNot(a); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 Node* Word32And(Node* a, Node* b) { | 172 Node* Word32And(Node* a, Node* b) { |
173 return NewNode(machine()->Word32And(), a, b); | 173 return AddNode(machine()->Word32And(), a, b); |
174 } | 174 } |
175 Node* Word32Or(Node* a, Node* b) { | 175 Node* Word32Or(Node* a, Node* b) { |
176 return NewNode(machine()->Word32Or(), a, b); | 176 return AddNode(machine()->Word32Or(), a, b); |
177 } | 177 } |
178 Node* Word32Xor(Node* a, Node* b) { | 178 Node* Word32Xor(Node* a, Node* b) { |
179 return NewNode(machine()->Word32Xor(), a, b); | 179 return AddNode(machine()->Word32Xor(), a, b); |
180 } | 180 } |
181 Node* Word32Shl(Node* a, Node* b) { | 181 Node* Word32Shl(Node* a, Node* b) { |
182 return NewNode(machine()->Word32Shl(), a, b); | 182 return AddNode(machine()->Word32Shl(), a, b); |
183 } | 183 } |
184 Node* Word32Shr(Node* a, Node* b) { | 184 Node* Word32Shr(Node* a, Node* b) { |
185 return NewNode(machine()->Word32Shr(), a, b); | 185 return AddNode(machine()->Word32Shr(), a, b); |
186 } | 186 } |
187 Node* Word32Sar(Node* a, Node* b) { | 187 Node* Word32Sar(Node* a, Node* b) { |
188 return NewNode(machine()->Word32Sar(), a, b); | 188 return AddNode(machine()->Word32Sar(), a, b); |
189 } | 189 } |
190 Node* Word32Ror(Node* a, Node* b) { | 190 Node* Word32Ror(Node* a, Node* b) { |
191 return NewNode(machine()->Word32Ror(), a, b); | 191 return AddNode(machine()->Word32Ror(), a, b); |
192 } | 192 } |
193 Node* Word32Clz(Node* a) { return NewNode(machine()->Word32Clz(), a); } | 193 Node* Word32Clz(Node* a) { return AddNode(machine()->Word32Clz(), a); } |
194 Node* Word32Equal(Node* a, Node* b) { | 194 Node* Word32Equal(Node* a, Node* b) { |
195 return NewNode(machine()->Word32Equal(), a, b); | 195 return AddNode(machine()->Word32Equal(), a, b); |
196 } | 196 } |
197 Node* Word32NotEqual(Node* a, Node* b) { | 197 Node* Word32NotEqual(Node* a, Node* b) { |
198 return Word32BinaryNot(Word32Equal(a, b)); | 198 return Word32BinaryNot(Word32Equal(a, b)); |
199 } | 199 } |
200 Node* Word32Not(Node* a) { return Word32Xor(a, Int32Constant(-1)); } | 200 Node* Word32Not(Node* a) { return Word32Xor(a, Int32Constant(-1)); } |
201 Node* Word32BinaryNot(Node* a) { return Word32Equal(a, Int32Constant(0)); } | 201 Node* Word32BinaryNot(Node* a) { return Word32Equal(a, Int32Constant(0)); } |
202 | 202 |
203 Node* Word64And(Node* a, Node* b) { | 203 Node* Word64And(Node* a, Node* b) { |
204 return NewNode(machine()->Word64And(), a, b); | 204 return AddNode(machine()->Word64And(), a, b); |
205 } | 205 } |
206 Node* Word64Or(Node* a, Node* b) { | 206 Node* Word64Or(Node* a, Node* b) { |
207 return NewNode(machine()->Word64Or(), a, b); | 207 return AddNode(machine()->Word64Or(), a, b); |
208 } | 208 } |
209 Node* Word64Xor(Node* a, Node* b) { | 209 Node* Word64Xor(Node* a, Node* b) { |
210 return NewNode(machine()->Word64Xor(), a, b); | 210 return AddNode(machine()->Word64Xor(), a, b); |
211 } | 211 } |
212 Node* Word64Shl(Node* a, Node* b) { | 212 Node* Word64Shl(Node* a, Node* b) { |
213 return NewNode(machine()->Word64Shl(), a, b); | 213 return AddNode(machine()->Word64Shl(), a, b); |
214 } | 214 } |
215 Node* Word64Shr(Node* a, Node* b) { | 215 Node* Word64Shr(Node* a, Node* b) { |
216 return NewNode(machine()->Word64Shr(), a, b); | 216 return AddNode(machine()->Word64Shr(), a, b); |
217 } | 217 } |
218 Node* Word64Sar(Node* a, Node* b) { | 218 Node* Word64Sar(Node* a, Node* b) { |
219 return NewNode(machine()->Word64Sar(), a, b); | 219 return AddNode(machine()->Word64Sar(), a, b); |
220 } | 220 } |
221 Node* Word64Ror(Node* a, Node* b) { | 221 Node* Word64Ror(Node* a, Node* b) { |
222 return NewNode(machine()->Word64Ror(), a, b); | 222 return AddNode(machine()->Word64Ror(), a, b); |
223 } | 223 } |
224 Node* Word64Equal(Node* a, Node* b) { | 224 Node* Word64Equal(Node* a, Node* b) { |
225 return NewNode(machine()->Word64Equal(), a, b); | 225 return AddNode(machine()->Word64Equal(), a, b); |
226 } | 226 } |
227 Node* Word64NotEqual(Node* a, Node* b) { | 227 Node* Word64NotEqual(Node* a, Node* b) { |
228 return Word64BinaryNot(Word64Equal(a, b)); | 228 return Word64BinaryNot(Word64Equal(a, b)); |
229 } | 229 } |
230 Node* Word64Not(Node* a) { return Word64Xor(a, Int64Constant(-1)); } | 230 Node* Word64Not(Node* a) { return Word64Xor(a, Int64Constant(-1)); } |
231 Node* Word64BinaryNot(Node* a) { return Word64Equal(a, Int64Constant(0)); } | 231 Node* Word64BinaryNot(Node* a) { return Word64Equal(a, Int64Constant(0)); } |
232 | 232 |
233 Node* Int32Add(Node* a, Node* b) { | 233 Node* Int32Add(Node* a, Node* b) { |
234 return NewNode(machine()->Int32Add(), a, b); | 234 return AddNode(machine()->Int32Add(), a, b); |
235 } | 235 } |
236 Node* Int32AddWithOverflow(Node* a, Node* b) { | 236 Node* Int32AddWithOverflow(Node* a, Node* b) { |
237 return NewNode(machine()->Int32AddWithOverflow(), a, b); | 237 return AddNode(machine()->Int32AddWithOverflow(), a, b); |
238 } | 238 } |
239 Node* Int32Sub(Node* a, Node* b) { | 239 Node* Int32Sub(Node* a, Node* b) { |
240 return NewNode(machine()->Int32Sub(), a, b); | 240 return AddNode(machine()->Int32Sub(), a, b); |
241 } | 241 } |
242 Node* Int32SubWithOverflow(Node* a, Node* b) { | 242 Node* Int32SubWithOverflow(Node* a, Node* b) { |
243 return NewNode(machine()->Int32SubWithOverflow(), a, b); | 243 return AddNode(machine()->Int32SubWithOverflow(), a, b); |
244 } | 244 } |
245 Node* Int32Mul(Node* a, Node* b) { | 245 Node* Int32Mul(Node* a, Node* b) { |
246 return NewNode(machine()->Int32Mul(), a, b); | 246 return AddNode(machine()->Int32Mul(), a, b); |
247 } | 247 } |
248 Node* Int32MulHigh(Node* a, Node* b) { | 248 Node* Int32MulHigh(Node* a, Node* b) { |
249 return NewNode(machine()->Int32MulHigh(), a, b); | 249 return AddNode(machine()->Int32MulHigh(), a, b); |
250 } | 250 } |
251 Node* Int32Div(Node* a, Node* b) { | 251 Node* Int32Div(Node* a, Node* b) { |
252 return NewNode(machine()->Int32Div(), a, b, graph()->start()); | 252 return AddNode(machine()->Int32Div(), a, b, graph()->start()); |
253 } | 253 } |
254 Node* Int32Mod(Node* a, Node* b) { | 254 Node* Int32Mod(Node* a, Node* b) { |
255 return NewNode(machine()->Int32Mod(), a, b, graph()->start()); | 255 return AddNode(machine()->Int32Mod(), a, b, graph()->start()); |
256 } | 256 } |
257 Node* Int32LessThan(Node* a, Node* b) { | 257 Node* Int32LessThan(Node* a, Node* b) { |
258 return NewNode(machine()->Int32LessThan(), a, b); | 258 return AddNode(machine()->Int32LessThan(), a, b); |
259 } | 259 } |
260 Node* Int32LessThanOrEqual(Node* a, Node* b) { | 260 Node* Int32LessThanOrEqual(Node* a, Node* b) { |
261 return NewNode(machine()->Int32LessThanOrEqual(), a, b); | 261 return AddNode(machine()->Int32LessThanOrEqual(), a, b); |
262 } | 262 } |
263 Node* Uint32Div(Node* a, Node* b) { | 263 Node* Uint32Div(Node* a, Node* b) { |
264 return NewNode(machine()->Uint32Div(), a, b, graph()->start()); | 264 return AddNode(machine()->Uint32Div(), a, b, graph()->start()); |
265 } | 265 } |
266 Node* Uint32LessThan(Node* a, Node* b) { | 266 Node* Uint32LessThan(Node* a, Node* b) { |
267 return NewNode(machine()->Uint32LessThan(), a, b); | 267 return AddNode(machine()->Uint32LessThan(), a, b); |
268 } | 268 } |
269 Node* Uint32LessThanOrEqual(Node* a, Node* b) { | 269 Node* Uint32LessThanOrEqual(Node* a, Node* b) { |
270 return NewNode(machine()->Uint32LessThanOrEqual(), a, b); | 270 return AddNode(machine()->Uint32LessThanOrEqual(), a, b); |
271 } | 271 } |
272 Node* Uint32Mod(Node* a, Node* b) { | 272 Node* Uint32Mod(Node* a, Node* b) { |
273 return NewNode(machine()->Uint32Mod(), a, b, graph()->start()); | 273 return AddNode(machine()->Uint32Mod(), a, b, graph()->start()); |
274 } | 274 } |
275 Node* Uint32MulHigh(Node* a, Node* b) { | 275 Node* Uint32MulHigh(Node* a, Node* b) { |
276 return NewNode(machine()->Uint32MulHigh(), a, b); | 276 return AddNode(machine()->Uint32MulHigh(), a, b); |
277 } | 277 } |
278 Node* Int32GreaterThan(Node* a, Node* b) { return Int32LessThan(b, a); } | 278 Node* Int32GreaterThan(Node* a, Node* b) { return Int32LessThan(b, a); } |
279 Node* Int32GreaterThanOrEqual(Node* a, Node* b) { | 279 Node* Int32GreaterThanOrEqual(Node* a, Node* b) { |
280 return Int32LessThanOrEqual(b, a); | 280 return Int32LessThanOrEqual(b, a); |
281 } | 281 } |
282 Node* Int32Neg(Node* a) { return Int32Sub(Int32Constant(0), a); } | 282 Node* Int32Neg(Node* a) { return Int32Sub(Int32Constant(0), a); } |
283 | 283 |
284 Node* Int64Add(Node* a, Node* b) { | 284 Node* Int64Add(Node* a, Node* b) { |
285 return NewNode(machine()->Int64Add(), a, b); | 285 return AddNode(machine()->Int64Add(), a, b); |
286 } | 286 } |
287 Node* Int64Sub(Node* a, Node* b) { | 287 Node* Int64Sub(Node* a, Node* b) { |
288 return NewNode(machine()->Int64Sub(), a, b); | 288 return AddNode(machine()->Int64Sub(), a, b); |
289 } | 289 } |
290 Node* Int64Mul(Node* a, Node* b) { | 290 Node* Int64Mul(Node* a, Node* b) { |
291 return NewNode(machine()->Int64Mul(), a, b); | 291 return AddNode(machine()->Int64Mul(), a, b); |
292 } | 292 } |
293 Node* Int64Div(Node* a, Node* b) { | 293 Node* Int64Div(Node* a, Node* b) { |
294 return NewNode(machine()->Int64Div(), a, b); | 294 return AddNode(machine()->Int64Div(), a, b); |
295 } | 295 } |
296 Node* Int64Mod(Node* a, Node* b) { | 296 Node* Int64Mod(Node* a, Node* b) { |
297 return NewNode(machine()->Int64Mod(), a, b); | 297 return AddNode(machine()->Int64Mod(), a, b); |
298 } | 298 } |
299 Node* Int64Neg(Node* a) { return Int64Sub(Int64Constant(0), a); } | 299 Node* Int64Neg(Node* a) { return Int64Sub(Int64Constant(0), a); } |
300 Node* Int64LessThan(Node* a, Node* b) { | 300 Node* Int64LessThan(Node* a, Node* b) { |
301 return NewNode(machine()->Int64LessThan(), a, b); | 301 return AddNode(machine()->Int64LessThan(), a, b); |
302 } | 302 } |
303 Node* Int64LessThanOrEqual(Node* a, Node* b) { | 303 Node* Int64LessThanOrEqual(Node* a, Node* b) { |
304 return NewNode(machine()->Int64LessThanOrEqual(), a, b); | 304 return AddNode(machine()->Int64LessThanOrEqual(), a, b); |
305 } | 305 } |
306 Node* Uint64LessThan(Node* a, Node* b) { | 306 Node* Uint64LessThan(Node* a, Node* b) { |
307 return NewNode(machine()->Uint64LessThan(), a, b); | 307 return AddNode(machine()->Uint64LessThan(), a, b); |
308 } | 308 } |
309 Node* Uint64LessThanOrEqual(Node* a, Node* b) { | 309 Node* Uint64LessThanOrEqual(Node* a, Node* b) { |
310 return NewNode(machine()->Uint64LessThanOrEqual(), a, b); | 310 return AddNode(machine()->Uint64LessThanOrEqual(), a, b); |
311 } | 311 } |
312 Node* Int64GreaterThan(Node* a, Node* b) { return Int64LessThan(b, a); } | 312 Node* Int64GreaterThan(Node* a, Node* b) { return Int64LessThan(b, a); } |
313 Node* Int64GreaterThanOrEqual(Node* a, Node* b) { | 313 Node* Int64GreaterThanOrEqual(Node* a, Node* b) { |
314 return Int64LessThanOrEqual(b, a); | 314 return Int64LessThanOrEqual(b, a); |
315 } | 315 } |
316 Node* Uint64Div(Node* a, Node* b) { | 316 Node* Uint64Div(Node* a, Node* b) { |
317 return NewNode(machine()->Uint64Div(), a, b); | 317 return AddNode(machine()->Uint64Div(), a, b); |
318 } | 318 } |
319 Node* Uint64Mod(Node* a, Node* b) { | 319 Node* Uint64Mod(Node* a, Node* b) { |
320 return NewNode(machine()->Uint64Mod(), a, b); | 320 return AddNode(machine()->Uint64Mod(), a, b); |
321 } | 321 } |
322 | 322 |
323 #define INTPTR_BINOP(prefix, name) \ | 323 #define INTPTR_BINOP(prefix, name) \ |
324 Node* IntPtr##name(Node* a, Node* b) { \ | 324 Node* IntPtr##name(Node* a, Node* b) { \ |
325 return kPointerSize == 8 ? prefix##64##name(a, b) \ | 325 return kPointerSize == 8 ? prefix##64##name(a, b) \ |
326 : prefix##32##name(a, b); \ | 326 : prefix##32##name(a, b); \ |
327 } | 327 } |
328 | 328 |
329 INTPTR_BINOP(Int, Add); | 329 INTPTR_BINOP(Int, Add); |
330 INTPTR_BINOP(Int, Sub); | 330 INTPTR_BINOP(Int, Sub); |
331 INTPTR_BINOP(Int, LessThan); | 331 INTPTR_BINOP(Int, LessThan); |
332 INTPTR_BINOP(Int, LessThanOrEqual); | 332 INTPTR_BINOP(Int, LessThanOrEqual); |
333 INTPTR_BINOP(Word, Equal); | 333 INTPTR_BINOP(Word, Equal); |
334 INTPTR_BINOP(Word, NotEqual); | 334 INTPTR_BINOP(Word, NotEqual); |
335 INTPTR_BINOP(Int, GreaterThanOrEqual); | 335 INTPTR_BINOP(Int, GreaterThanOrEqual); |
336 INTPTR_BINOP(Int, GreaterThan); | 336 INTPTR_BINOP(Int, GreaterThan); |
337 | 337 |
338 #undef INTPTR_BINOP | 338 #undef INTPTR_BINOP |
339 | 339 |
340 Node* Float32Add(Node* a, Node* b) { | 340 Node* Float32Add(Node* a, Node* b) { |
341 return NewNode(machine()->Float32Add(), a, b); | 341 return AddNode(machine()->Float32Add(), a, b); |
342 } | 342 } |
343 Node* Float32Sub(Node* a, Node* b) { | 343 Node* Float32Sub(Node* a, Node* b) { |
344 return NewNode(machine()->Float32Sub(), a, b); | 344 return AddNode(machine()->Float32Sub(), a, b); |
345 } | 345 } |
346 Node* Float32Mul(Node* a, Node* b) { | 346 Node* Float32Mul(Node* a, Node* b) { |
347 return NewNode(machine()->Float32Mul(), a, b); | 347 return AddNode(machine()->Float32Mul(), a, b); |
348 } | 348 } |
349 Node* Float32Div(Node* a, Node* b) { | 349 Node* Float32Div(Node* a, Node* b) { |
350 return NewNode(machine()->Float32Div(), a, b); | 350 return AddNode(machine()->Float32Div(), a, b); |
351 } | 351 } |
352 Node* Float32Abs(Node* a) { return NewNode(machine()->Float32Abs(), a); } | 352 Node* Float32Abs(Node* a) { return AddNode(machine()->Float32Abs(), a); } |
353 Node* Float32Sqrt(Node* a) { return NewNode(machine()->Float32Sqrt(), a); } | 353 Node* Float32Sqrt(Node* a) { return AddNode(machine()->Float32Sqrt(), a); } |
354 Node* Float32Equal(Node* a, Node* b) { | 354 Node* Float32Equal(Node* a, Node* b) { |
355 return NewNode(machine()->Float32Equal(), a, b); | 355 return AddNode(machine()->Float32Equal(), a, b); |
356 } | 356 } |
357 Node* Float32NotEqual(Node* a, Node* b) { | 357 Node* Float32NotEqual(Node* a, Node* b) { |
358 return WordBinaryNot(Float32Equal(a, b)); | 358 return WordBinaryNot(Float32Equal(a, b)); |
359 } | 359 } |
360 Node* Float32LessThan(Node* a, Node* b) { | 360 Node* Float32LessThan(Node* a, Node* b) { |
361 return NewNode(machine()->Float32LessThan(), a, b); | 361 return AddNode(machine()->Float32LessThan(), a, b); |
362 } | 362 } |
363 Node* Float32LessThanOrEqual(Node* a, Node* b) { | 363 Node* Float32LessThanOrEqual(Node* a, Node* b) { |
364 return NewNode(machine()->Float32LessThanOrEqual(), a, b); | 364 return AddNode(machine()->Float32LessThanOrEqual(), a, b); |
365 } | 365 } |
366 Node* Float32GreaterThan(Node* a, Node* b) { return Float32LessThan(b, a); } | 366 Node* Float32GreaterThan(Node* a, Node* b) { return Float32LessThan(b, a); } |
367 Node* Float32GreaterThanOrEqual(Node* a, Node* b) { | 367 Node* Float32GreaterThanOrEqual(Node* a, Node* b) { |
368 return Float32LessThanOrEqual(b, a); | 368 return Float32LessThanOrEqual(b, a); |
369 } | 369 } |
370 | 370 |
371 Node* Float64Add(Node* a, Node* b) { | 371 Node* Float64Add(Node* a, Node* b) { |
372 return NewNode(machine()->Float64Add(), a, b); | 372 return AddNode(machine()->Float64Add(), a, b); |
373 } | 373 } |
374 Node* Float64Sub(Node* a, Node* b) { | 374 Node* Float64Sub(Node* a, Node* b) { |
375 return NewNode(machine()->Float64Sub(), a, b); | 375 return AddNode(machine()->Float64Sub(), a, b); |
376 } | 376 } |
377 Node* Float64Mul(Node* a, Node* b) { | 377 Node* Float64Mul(Node* a, Node* b) { |
378 return NewNode(machine()->Float64Mul(), a, b); | 378 return AddNode(machine()->Float64Mul(), a, b); |
379 } | 379 } |
380 Node* Float64Div(Node* a, Node* b) { | 380 Node* Float64Div(Node* a, Node* b) { |
381 return NewNode(machine()->Float64Div(), a, b); | 381 return AddNode(machine()->Float64Div(), a, b); |
382 } | 382 } |
383 Node* Float64Mod(Node* a, Node* b) { | 383 Node* Float64Mod(Node* a, Node* b) { |
384 return NewNode(machine()->Float64Mod(), a, b); | 384 return AddNode(machine()->Float64Mod(), a, b); |
385 } | 385 } |
386 Node* Float64Abs(Node* a) { return NewNode(machine()->Float64Abs(), a); } | 386 Node* Float64Abs(Node* a) { return AddNode(machine()->Float64Abs(), a); } |
387 Node* Float64Sqrt(Node* a) { return NewNode(machine()->Float64Sqrt(), a); } | 387 Node* Float64Sqrt(Node* a) { return AddNode(machine()->Float64Sqrt(), a); } |
388 Node* Float64Equal(Node* a, Node* b) { | 388 Node* Float64Equal(Node* a, Node* b) { |
389 return NewNode(machine()->Float64Equal(), a, b); | 389 return AddNode(machine()->Float64Equal(), a, b); |
390 } | 390 } |
391 Node* Float64NotEqual(Node* a, Node* b) { | 391 Node* Float64NotEqual(Node* a, Node* b) { |
392 return WordBinaryNot(Float64Equal(a, b)); | 392 return WordBinaryNot(Float64Equal(a, b)); |
393 } | 393 } |
394 Node* Float64LessThan(Node* a, Node* b) { | 394 Node* Float64LessThan(Node* a, Node* b) { |
395 return NewNode(machine()->Float64LessThan(), a, b); | 395 return AddNode(machine()->Float64LessThan(), a, b); |
396 } | 396 } |
397 Node* Float64LessThanOrEqual(Node* a, Node* b) { | 397 Node* Float64LessThanOrEqual(Node* a, Node* b) { |
398 return NewNode(machine()->Float64LessThanOrEqual(), a, b); | 398 return AddNode(machine()->Float64LessThanOrEqual(), a, b); |
399 } | 399 } |
400 Node* Float64GreaterThan(Node* a, Node* b) { return Float64LessThan(b, a); } | 400 Node* Float64GreaterThan(Node* a, Node* b) { return Float64LessThan(b, a); } |
401 Node* Float64GreaterThanOrEqual(Node* a, Node* b) { | 401 Node* Float64GreaterThanOrEqual(Node* a, Node* b) { |
402 return Float64LessThanOrEqual(b, a); | 402 return Float64LessThanOrEqual(b, a); |
403 } | 403 } |
404 | 404 |
405 // Conversions. | 405 // Conversions. |
406 Node* ChangeFloat32ToFloat64(Node* a) { | 406 Node* ChangeFloat32ToFloat64(Node* a) { |
407 return NewNode(machine()->ChangeFloat32ToFloat64(), a); | 407 return AddNode(machine()->ChangeFloat32ToFloat64(), a); |
408 } | 408 } |
409 Node* ChangeInt32ToFloat64(Node* a) { | 409 Node* ChangeInt32ToFloat64(Node* a) { |
410 return NewNode(machine()->ChangeInt32ToFloat64(), a); | 410 return AddNode(machine()->ChangeInt32ToFloat64(), a); |
411 } | 411 } |
412 Node* ChangeUint32ToFloat64(Node* a) { | 412 Node* ChangeUint32ToFloat64(Node* a) { |
413 return NewNode(machine()->ChangeUint32ToFloat64(), a); | 413 return AddNode(machine()->ChangeUint32ToFloat64(), a); |
414 } | 414 } |
415 Node* ChangeFloat64ToInt32(Node* a) { | 415 Node* ChangeFloat64ToInt32(Node* a) { |
416 return NewNode(machine()->ChangeFloat64ToInt32(), a); | 416 return AddNode(machine()->ChangeFloat64ToInt32(), a); |
417 } | 417 } |
418 Node* ChangeFloat64ToUint32(Node* a) { | 418 Node* ChangeFloat64ToUint32(Node* a) { |
419 return NewNode(machine()->ChangeFloat64ToUint32(), a); | 419 return AddNode(machine()->ChangeFloat64ToUint32(), a); |
420 } | 420 } |
421 Node* ChangeInt32ToInt64(Node* a) { | 421 Node* ChangeInt32ToInt64(Node* a) { |
422 return NewNode(machine()->ChangeInt32ToInt64(), a); | 422 return AddNode(machine()->ChangeInt32ToInt64(), a); |
423 } | 423 } |
424 Node* ChangeUint32ToUint64(Node* a) { | 424 Node* ChangeUint32ToUint64(Node* a) { |
425 return NewNode(machine()->ChangeUint32ToUint64(), a); | 425 return AddNode(machine()->ChangeUint32ToUint64(), a); |
426 } | 426 } |
427 Node* TruncateFloat64ToFloat32(Node* a) { | 427 Node* TruncateFloat64ToFloat32(Node* a) { |
428 return NewNode(machine()->TruncateFloat64ToFloat32(), a); | 428 return AddNode(machine()->TruncateFloat64ToFloat32(), a); |
429 } | 429 } |
430 Node* TruncateFloat64ToInt32(TruncationMode mode, Node* a) { | 430 Node* TruncateFloat64ToInt32(TruncationMode mode, Node* a) { |
431 return NewNode(machine()->TruncateFloat64ToInt32(mode), a); | 431 return AddNode(machine()->TruncateFloat64ToInt32(mode), a); |
432 } | 432 } |
433 Node* TruncateInt64ToInt32(Node* a) { | 433 Node* TruncateInt64ToInt32(Node* a) { |
434 return NewNode(machine()->TruncateInt64ToInt32(), a); | 434 return AddNode(machine()->TruncateInt64ToInt32(), a); |
435 } | 435 } |
436 Node* BitcastFloat32ToInt32(Node* a) { | 436 Node* BitcastFloat32ToInt32(Node* a) { |
437 return NewNode(machine()->BitcastFloat32ToInt32(), a); | 437 return AddNode(machine()->BitcastFloat32ToInt32(), a); |
438 } | 438 } |
439 Node* BitcastFloat64ToInt64(Node* a) { | 439 Node* BitcastFloat64ToInt64(Node* a) { |
440 return NewNode(machine()->BitcastFloat64ToInt64(), a); | 440 return AddNode(machine()->BitcastFloat64ToInt64(), a); |
441 } | 441 } |
442 Node* BitcastInt32ToFloat32(Node* a) { | 442 Node* BitcastInt32ToFloat32(Node* a) { |
443 return NewNode(machine()->BitcastInt32ToFloat32(), a); | 443 return AddNode(machine()->BitcastInt32ToFloat32(), a); |
444 } | 444 } |
445 Node* BitcastInt64ToFloat64(Node* a) { | 445 Node* BitcastInt64ToFloat64(Node* a) { |
446 return NewNode(machine()->BitcastInt64ToFloat64(), a); | 446 return AddNode(machine()->BitcastInt64ToFloat64(), a); |
447 } | 447 } |
448 Node* Float64RoundDown(Node* a) { | 448 Node* Float64RoundDown(Node* a) { |
449 return NewNode(machine()->Float64RoundDown().op(), a); | 449 return AddNode(machine()->Float64RoundDown().op(), a); |
450 } | 450 } |
451 Node* Float64RoundTruncate(Node* a) { | 451 Node* Float64RoundTruncate(Node* a) { |
452 return NewNode(machine()->Float64RoundTruncate().op(), a); | 452 return AddNode(machine()->Float64RoundTruncate().op(), a); |
453 } | 453 } |
454 Node* Float64RoundTiesAway(Node* a) { | 454 Node* Float64RoundTiesAway(Node* a) { |
455 return NewNode(machine()->Float64RoundTiesAway().op(), a); | 455 return AddNode(machine()->Float64RoundTiesAway().op(), a); |
456 } | 456 } |
457 | 457 |
458 // Float64 bit operations. | 458 // Float64 bit operations. |
459 Node* Float64ExtractLowWord32(Node* a) { | 459 Node* Float64ExtractLowWord32(Node* a) { |
460 return NewNode(machine()->Float64ExtractLowWord32(), a); | 460 return AddNode(machine()->Float64ExtractLowWord32(), a); |
461 } | 461 } |
462 Node* Float64ExtractHighWord32(Node* a) { | 462 Node* Float64ExtractHighWord32(Node* a) { |
463 return NewNode(machine()->Float64ExtractHighWord32(), a); | 463 return AddNode(machine()->Float64ExtractHighWord32(), a); |
464 } | 464 } |
465 Node* Float64InsertLowWord32(Node* a, Node* b) { | 465 Node* Float64InsertLowWord32(Node* a, Node* b) { |
466 return NewNode(machine()->Float64InsertLowWord32(), a, b); | 466 return AddNode(machine()->Float64InsertLowWord32(), a, b); |
467 } | 467 } |
468 Node* Float64InsertHighWord32(Node* a, Node* b) { | 468 Node* Float64InsertHighWord32(Node* a, Node* b) { |
469 return NewNode(machine()->Float64InsertHighWord32(), a, b); | 469 return AddNode(machine()->Float64InsertHighWord32(), a, b); |
470 } | 470 } |
471 | 471 |
472 // Stack operations. | 472 // Stack operations. |
473 Node* LoadStackPointer() { return NewNode(machine()->LoadStackPointer()); } | 473 Node* LoadStackPointer() { return AddNode(machine()->LoadStackPointer()); } |
474 Node* LoadFramePointer() { return NewNode(machine()->LoadFramePointer()); } | 474 Node* LoadFramePointer() { return AddNode(machine()->LoadFramePointer()); } |
475 | 475 |
476 // Parameters. | 476 // Parameters. |
477 Node* Parameter(size_t index); | 477 Node* Parameter(size_t index); |
478 | 478 |
479 // Pointer utilities. | 479 // Pointer utilities. |
480 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { | 480 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { |
481 return Load(rep, PointerConstant(address), Int32Constant(offset)); | 481 return Load(rep, PointerConstant(address), Int32Constant(offset)); |
482 } | 482 } |
483 Node* StoreToPointer(void* address, MachineType rep, Node* node) { | 483 Node* StoreToPointer(void* address, MachineType rep, Node* node) { |
484 return Store(rep, PointerConstant(address), node); | 484 return Store(rep, PointerConstant(address), node); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 void Goto(Label* label); | 528 void Goto(Label* label); |
529 void Branch(Node* condition, Label* true_val, Label* false_val); | 529 void Branch(Node* condition, Label* true_val, Label* false_val); |
530 void Switch(Node* index, Label* default_label, int32_t* case_values, | 530 void Switch(Node* index, Label* default_label, int32_t* case_values, |
531 Label** case_labels, size_t case_count); | 531 Label** case_labels, size_t case_count); |
532 void Return(Node* value); | 532 void Return(Node* value); |
533 void Bind(Label* label); | 533 void Bind(Label* label); |
534 void Deoptimize(Node* state); | 534 void Deoptimize(Node* state); |
535 | 535 |
536 // Variables. | 536 // Variables. |
537 Node* Phi(MachineType type, Node* n1, Node* n2) { | 537 Node* Phi(MachineType type, Node* n1, Node* n2) { |
538 return NewNode(common()->Phi(type, 2), n1, n2); | 538 return AddNode(common()->Phi(type, 2), n1, n2); |
539 } | 539 } |
540 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3) { | 540 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3) { |
541 return NewNode(common()->Phi(type, 3), n1, n2, n3); | 541 return AddNode(common()->Phi(type, 3), n1, n2, n3); |
542 } | 542 } |
543 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3, Node* n4) { | 543 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3, Node* n4) { |
544 return NewNode(common()->Phi(type, 4), n1, n2, n3, n4); | 544 return AddNode(common()->Phi(type, 4), n1, n2, n3, n4); |
545 } | 545 } |
546 | 546 |
547 // =========================================================================== | 547 // =========================================================================== |
548 // The following generic node creation methods can be used for operators that | 548 // The following generic node creation methods can be used for operators that |
549 // are not covered by the above utility methods. There should rarely be a need | 549 // are not covered by the above utility methods. There should rarely be a need |
550 // to do that outside of testing though. | 550 // to do that outside of testing though. |
551 | 551 |
552 Node* NewNode(const Operator* op) { | 552 Node* AddNode(const Operator* op, int input_count, Node** inputs); |
553 return MakeNode(op, 0, static_cast<Node**>(NULL)); | 553 |
| 554 Node* AddNode(const Operator* op) { |
| 555 return AddNode(op, 0, static_cast<Node**>(nullptr)); |
554 } | 556 } |
555 | 557 |
556 Node* NewNode(const Operator* op, Node* n1) { return MakeNode(op, 1, &n1); } | 558 Node* AddNode(const Operator* op, Node* n1) { return AddNode(op, 1, &n1); } |
557 | 559 |
558 Node* NewNode(const Operator* op, Node* n1, Node* n2) { | 560 template <class... TArgs> |
559 Node* buffer[] = {n1, n2}; | 561 Node* AddNode(const Operator* op, Node* n1, Node* n2, TArgs... args) { |
560 return MakeNode(op, arraysize(buffer), buffer); | 562 Node* buffer[] = {n1, n2, args...}; |
561 } | 563 return AddNode(op, sizeof...(args) + 2, buffer); |
562 | |
563 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) { | |
564 Node* buffer[] = {n1, n2, n3}; | |
565 return MakeNode(op, arraysize(buffer), buffer); | |
566 } | |
567 | |
568 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) { | |
569 Node* buffer[] = {n1, n2, n3, n4}; | |
570 return MakeNode(op, arraysize(buffer), buffer); | |
571 } | |
572 | |
573 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | |
574 Node* n5) { | |
575 Node* buffer[] = {n1, n2, n3, n4, n5}; | |
576 return MakeNode(op, arraysize(buffer), buffer); | |
577 } | |
578 | |
579 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | |
580 Node* n5, Node* n6) { | |
581 Node* nodes[] = {n1, n2, n3, n4, n5, n6}; | |
582 return MakeNode(op, arraysize(nodes), nodes); | |
583 } | |
584 | |
585 Node* NewNode(const Operator* op, int value_input_count, | |
586 Node** value_inputs) { | |
587 return MakeNode(op, value_input_count, value_inputs); | |
588 } | 564 } |
589 | 565 |
590 private: | 566 private: |
591 Node* MakeNode(const Operator* op, int input_count, Node** inputs); | 567 Node* MakeNode(const Operator* op, int input_count, Node** inputs); |
592 BasicBlock* Use(Label* label); | 568 BasicBlock* Use(Label* label); |
593 BasicBlock* EnsureBlock(Label* label); | 569 BasicBlock* EnsureBlock(Label* label); |
594 | 570 |
595 Isolate* isolate_; | 571 Isolate* isolate_; |
596 Graph* graph_; | 572 Graph* graph_; |
597 Schedule* schedule_; | 573 Schedule* schedule_; |
598 MachineOperatorBuilder machine_; | 574 MachineOperatorBuilder machine_; |
599 CommonOperatorBuilder common_; | 575 CommonOperatorBuilder common_; |
600 CallDescriptor* call_descriptor_; | 576 CallDescriptor* call_descriptor_; |
601 Node** parameters_; | 577 Node** parameters_; |
602 BasicBlock* current_block_; | 578 BasicBlock* current_block_; |
603 | 579 |
604 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); | 580 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); |
605 }; | 581 }; |
606 | 582 |
607 } // namespace compiler | 583 } // namespace compiler |
608 } // namespace internal | 584 } // namespace internal |
609 } // namespace v8 | 585 } // namespace v8 |
610 | 586 |
611 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 587 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
OLD | NEW |