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 #include "src/compiler/int64-lowering.h" | 5 #include "src/compiler/int64-lowering.h" |
6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/diamond.h" | 7 #include "src/compiler/diamond.h" |
8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 (descriptor->ReturnCount() == 1 && | 236 (descriptor->ReturnCount() == 1 && |
237 descriptor->GetReturnType(0) == MachineType::Int64())) { | 237 descriptor->GetReturnType(0) == MachineType::Int64())) { |
238 // We have to adjust the call descriptor. | 238 // We have to adjust the call descriptor. |
239 const Operator* op = common()->Call( | 239 const Operator* op = common()->Call( |
240 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), descriptor)); | 240 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), descriptor)); |
241 NodeProperties::ChangeOp(node, op); | 241 NodeProperties::ChangeOp(node, op); |
242 } | 242 } |
243 if (descriptor->ReturnCount() == 1 && | 243 if (descriptor->ReturnCount() == 1 && |
244 descriptor->GetReturnType(0) == MachineType::Int64()) { | 244 descriptor->GetReturnType(0) == MachineType::Int64()) { |
245 // We access the additional return values through projections. | 245 // We access the additional return values through projections. |
246 Node* low_node = graph()->NewNode(common()->Projection(0), node); | 246 Node* low_node = |
247 Node* high_node = graph()->NewNode(common()->Projection(1), node); | 247 graph()->NewNode(common()->Projection(0), node, graph()->start()); |
| 248 Node* high_node = |
| 249 graph()->NewNode(common()->Projection(1), node, graph()->start()); |
248 ReplaceNode(node, low_node, high_node); | 250 ReplaceNode(node, low_node, high_node); |
249 } | 251 } |
250 break; | 252 break; |
251 } | 253 } |
252 case IrOpcode::kWord64And: { | 254 case IrOpcode::kWord64And: { |
253 DCHECK(node->InputCount() == 2); | 255 DCHECK(node->InputCount() == 2); |
254 Node* left = node->InputAt(0); | 256 Node* left = node->InputAt(0); |
255 Node* right = node->InputAt(1); | 257 Node* right = node->InputAt(1); |
256 | 258 |
257 Node* low_node = | 259 Node* low_node = |
(...skipping 18 matching lines...) Expand all Loading... |
276 Node* right = node->InputAt(1); | 278 Node* right = node->InputAt(1); |
277 node->ReplaceInput(1, GetReplacementLow(right)); | 279 node->ReplaceInput(1, GetReplacementLow(right)); |
278 node->AppendInput(zone(), GetReplacementHigh(right)); | 280 node->AppendInput(zone(), GetReplacementHigh(right)); |
279 | 281 |
280 Node* left = node->InputAt(0); | 282 Node* left = node->InputAt(0); |
281 node->ReplaceInput(0, GetReplacementLow(left)); | 283 node->ReplaceInput(0, GetReplacementLow(left)); |
282 node->InsertInput(zone(), 1, GetReplacementHigh(left)); | 284 node->InsertInput(zone(), 1, GetReplacementHigh(left)); |
283 | 285 |
284 NodeProperties::ChangeOp(node, machine()->Int32PairAdd()); | 286 NodeProperties::ChangeOp(node, machine()->Int32PairAdd()); |
285 // We access the additional return values through projections. | 287 // We access the additional return values through projections. |
286 Node* low_node = graph()->NewNode(common()->Projection(0), node); | 288 Node* low_node = |
287 Node* high_node = graph()->NewNode(common()->Projection(1), node); | 289 graph()->NewNode(common()->Projection(0), node, graph()->start()); |
| 290 Node* high_node = |
| 291 graph()->NewNode(common()->Projection(1), node, graph()->start()); |
288 ReplaceNode(node, low_node, high_node); | 292 ReplaceNode(node, low_node, high_node); |
289 break; | 293 break; |
290 } | 294 } |
291 case IrOpcode::kInt64Sub: { | 295 case IrOpcode::kInt64Sub: { |
292 DCHECK(node->InputCount() == 2); | 296 DCHECK(node->InputCount() == 2); |
293 | 297 |
294 Node* right = node->InputAt(1); | 298 Node* right = node->InputAt(1); |
295 node->ReplaceInput(1, GetReplacementLow(right)); | 299 node->ReplaceInput(1, GetReplacementLow(right)); |
296 node->AppendInput(zone(), GetReplacementHigh(right)); | 300 node->AppendInput(zone(), GetReplacementHigh(right)); |
297 | 301 |
298 Node* left = node->InputAt(0); | 302 Node* left = node->InputAt(0); |
299 node->ReplaceInput(0, GetReplacementLow(left)); | 303 node->ReplaceInput(0, GetReplacementLow(left)); |
300 node->InsertInput(zone(), 1, GetReplacementHigh(left)); | 304 node->InsertInput(zone(), 1, GetReplacementHigh(left)); |
301 | 305 |
302 NodeProperties::ChangeOp(node, machine()->Int32PairSub()); | 306 NodeProperties::ChangeOp(node, machine()->Int32PairSub()); |
303 // We access the additional return values through projections. | 307 // We access the additional return values through projections. |
304 Node* low_node = graph()->NewNode(common()->Projection(0), node); | 308 Node* low_node = |
305 Node* high_node = graph()->NewNode(common()->Projection(1), node); | 309 graph()->NewNode(common()->Projection(0), node, graph()->start()); |
| 310 Node* high_node = |
| 311 graph()->NewNode(common()->Projection(1), node, graph()->start()); |
306 ReplaceNode(node, low_node, high_node); | 312 ReplaceNode(node, low_node, high_node); |
307 break; | 313 break; |
308 } | 314 } |
309 case IrOpcode::kInt64Mul: { | 315 case IrOpcode::kInt64Mul: { |
310 DCHECK(node->InputCount() == 2); | 316 DCHECK(node->InputCount() == 2); |
311 | 317 |
312 Node* right = node->InputAt(1); | 318 Node* right = node->InputAt(1); |
313 node->ReplaceInput(1, GetReplacementLow(right)); | 319 node->ReplaceInput(1, GetReplacementLow(right)); |
314 node->AppendInput(zone(), GetReplacementHigh(right)); | 320 node->AppendInput(zone(), GetReplacementHigh(right)); |
315 | 321 |
316 Node* left = node->InputAt(0); | 322 Node* left = node->InputAt(0); |
317 node->ReplaceInput(0, GetReplacementLow(left)); | 323 node->ReplaceInput(0, GetReplacementLow(left)); |
318 node->InsertInput(zone(), 1, GetReplacementHigh(left)); | 324 node->InsertInput(zone(), 1, GetReplacementHigh(left)); |
319 | 325 |
320 NodeProperties::ChangeOp(node, machine()->Int32PairMul()); | 326 NodeProperties::ChangeOp(node, machine()->Int32PairMul()); |
321 // We access the additional return values through projections. | 327 // We access the additional return values through projections. |
322 Node* low_node = graph()->NewNode(common()->Projection(0), node); | 328 Node* low_node = |
323 Node* high_node = graph()->NewNode(common()->Projection(1), node); | 329 graph()->NewNode(common()->Projection(0), node, graph()->start()); |
| 330 Node* high_node = |
| 331 graph()->NewNode(common()->Projection(1), node, graph()->start()); |
324 ReplaceNode(node, low_node, high_node); | 332 ReplaceNode(node, low_node, high_node); |
325 break; | 333 break; |
326 } | 334 } |
327 case IrOpcode::kWord64Or: { | 335 case IrOpcode::kWord64Or: { |
328 DCHECK(node->InputCount() == 2); | 336 DCHECK(node->InputCount() == 2); |
329 Node* left = node->InputAt(0); | 337 Node* left = node->InputAt(0); |
330 Node* right = node->InputAt(1); | 338 Node* right = node->InputAt(1); |
331 | 339 |
332 Node* low_node = | 340 Node* low_node = |
333 graph()->NewNode(machine()->Word32Or(), GetReplacementLow(left), | 341 graph()->NewNode(machine()->Word32Or(), GetReplacementLow(left), |
(...skipping 28 matching lines...) Expand all Loading... |
362 // the shift can only be between 0 and 63 anyways. | 370 // the shift can only be between 0 and 63 anyways. |
363 node->ReplaceInput(1, GetReplacementLow(shift)); | 371 node->ReplaceInput(1, GetReplacementLow(shift)); |
364 } | 372 } |
365 | 373 |
366 Node* value = node->InputAt(0); | 374 Node* value = node->InputAt(0); |
367 node->ReplaceInput(0, GetReplacementLow(value)); | 375 node->ReplaceInput(0, GetReplacementLow(value)); |
368 node->InsertInput(zone(), 1, GetReplacementHigh(value)); | 376 node->InsertInput(zone(), 1, GetReplacementHigh(value)); |
369 | 377 |
370 NodeProperties::ChangeOp(node, machine()->Word32PairShl()); | 378 NodeProperties::ChangeOp(node, machine()->Word32PairShl()); |
371 // We access the additional return values through projections. | 379 // We access the additional return values through projections. |
372 Node* low_node = graph()->NewNode(common()->Projection(0), node); | 380 Node* low_node = |
373 Node* high_node = graph()->NewNode(common()->Projection(1), node); | 381 graph()->NewNode(common()->Projection(0), node, graph()->start()); |
| 382 Node* high_node = |
| 383 graph()->NewNode(common()->Projection(1), node, graph()->start()); |
374 ReplaceNode(node, low_node, high_node); | 384 ReplaceNode(node, low_node, high_node); |
375 break; | 385 break; |
376 } | 386 } |
377 case IrOpcode::kWord64Shr: { | 387 case IrOpcode::kWord64Shr: { |
378 // TODO(turbofan): if the shift count >= 32, then we can set the low word | 388 // TODO(turbofan): if the shift count >= 32, then we can set the low word |
379 // of the output to 0 and just calculate the high word. | 389 // of the output to 0 and just calculate the high word. |
380 DCHECK(node->InputCount() == 2); | 390 DCHECK(node->InputCount() == 2); |
381 Node* shift = node->InputAt(1); | 391 Node* shift = node->InputAt(1); |
382 if (HasReplacementLow(shift)) { | 392 if (HasReplacementLow(shift)) { |
383 // We do not have to care about the high word replacement, because | 393 // We do not have to care about the high word replacement, because |
384 // the shift can only be between 0 and 63 anyways. | 394 // the shift can only be between 0 and 63 anyways. |
385 node->ReplaceInput(1, GetReplacementLow(shift)); | 395 node->ReplaceInput(1, GetReplacementLow(shift)); |
386 } | 396 } |
387 | 397 |
388 Node* value = node->InputAt(0); | 398 Node* value = node->InputAt(0); |
389 node->ReplaceInput(0, GetReplacementLow(value)); | 399 node->ReplaceInput(0, GetReplacementLow(value)); |
390 node->InsertInput(zone(), 1, GetReplacementHigh(value)); | 400 node->InsertInput(zone(), 1, GetReplacementHigh(value)); |
391 | 401 |
392 NodeProperties::ChangeOp(node, machine()->Word32PairShr()); | 402 NodeProperties::ChangeOp(node, machine()->Word32PairShr()); |
393 // We access the additional return values through projections. | 403 // We access the additional return values through projections. |
394 Node* low_node = graph()->NewNode(common()->Projection(0), node); | 404 Node* low_node = |
395 Node* high_node = graph()->NewNode(common()->Projection(1), node); | 405 graph()->NewNode(common()->Projection(0), node, graph()->start()); |
| 406 Node* high_node = |
| 407 graph()->NewNode(common()->Projection(1), node, graph()->start()); |
396 ReplaceNode(node, low_node, high_node); | 408 ReplaceNode(node, low_node, high_node); |
397 break; | 409 break; |
398 } | 410 } |
399 case IrOpcode::kWord64Sar: { | 411 case IrOpcode::kWord64Sar: { |
400 // TODO(turbofan): if the shift count >= 32, then we can set the low word | 412 // TODO(turbofan): if the shift count >= 32, then we can set the low word |
401 // of the output to 0 and just calculate the high word. | 413 // of the output to 0 and just calculate the high word. |
402 DCHECK(node->InputCount() == 2); | 414 DCHECK(node->InputCount() == 2); |
403 Node* shift = node->InputAt(1); | 415 Node* shift = node->InputAt(1); |
404 if (HasReplacementLow(shift)) { | 416 if (HasReplacementLow(shift)) { |
405 // We do not have to care about the high word replacement, because | 417 // We do not have to care about the high word replacement, because |
406 // the shift can only be between 0 and 63 anyways. | 418 // the shift can only be between 0 and 63 anyways. |
407 node->ReplaceInput(1, GetReplacementLow(shift)); | 419 node->ReplaceInput(1, GetReplacementLow(shift)); |
408 } | 420 } |
409 | 421 |
410 Node* value = node->InputAt(0); | 422 Node* value = node->InputAt(0); |
411 node->ReplaceInput(0, GetReplacementLow(value)); | 423 node->ReplaceInput(0, GetReplacementLow(value)); |
412 node->InsertInput(zone(), 1, GetReplacementHigh(value)); | 424 node->InsertInput(zone(), 1, GetReplacementHigh(value)); |
413 | 425 |
414 NodeProperties::ChangeOp(node, machine()->Word32PairSar()); | 426 NodeProperties::ChangeOp(node, machine()->Word32PairSar()); |
415 // We access the additional return values through projections. | 427 // We access the additional return values through projections. |
416 Node* low_node = graph()->NewNode(common()->Projection(0), node); | 428 Node* low_node = |
417 Node* high_node = graph()->NewNode(common()->Projection(1), node); | 429 graph()->NewNode(common()->Projection(0), node, graph()->start()); |
| 430 Node* high_node = |
| 431 graph()->NewNode(common()->Projection(1), node, graph()->start()); |
418 ReplaceNode(node, low_node, high_node); | 432 ReplaceNode(node, low_node, high_node); |
419 break; | 433 break; |
420 } | 434 } |
421 case IrOpcode::kWord64Equal: { | 435 case IrOpcode::kWord64Equal: { |
422 DCHECK(node->InputCount() == 2); | 436 DCHECK(node->InputCount() == 2); |
423 Node* left = node->InputAt(0); | 437 Node* left = node->InputAt(0); |
424 Node* right = node->InputAt(1); | 438 Node* right = node->InputAt(1); |
425 | 439 |
426 // TODO(wasm): Use explicit comparisons and && here? | 440 // TODO(wasm): Use explicit comparisons and && here? |
427 Node* replacement = graph()->NewNode( | 441 Node* replacement = graph()->NewNode( |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 common()->Phi(MachineRepresentation::kWord32, value_count), | 814 common()->Phi(MachineRepresentation::kWord32, value_count), |
801 value_count + 1, inputs_low, false), | 815 value_count + 1, inputs_low, false), |
802 graph()->NewNode( | 816 graph()->NewNode( |
803 common()->Phi(MachineRepresentation::kWord32, value_count), | 817 common()->Phi(MachineRepresentation::kWord32, value_count), |
804 value_count + 1, inputs_high, false)); | 818 value_count + 1, inputs_high, false)); |
805 } | 819 } |
806 } | 820 } |
807 } // namespace compiler | 821 } // namespace compiler |
808 } // namespace internal | 822 } // namespace internal |
809 } // namespace v8 | 823 } // namespace v8 |
OLD | NEW |