| 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/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
| 6 | 6 |
| 7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
| 9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
| 10 #include "src/compiler/representation-change.h" | 10 #include "src/compiler/representation-change.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 MachineTypeUnion use_rep = use & kRepMask; | 446 MachineTypeUnion use_rep = use & kRepMask; |
| 447 if (lower()) { | 447 if (lower()) { |
| 448 MachineTypeUnion in = GetInfo(node->InputAt(0))->output; | 448 MachineTypeUnion in = GetInfo(node->InputAt(0))->output; |
| 449 if ((in & kTypeMask) == kTypeInt32 || (in & kRepMask) == kRepWord32) { | 449 if ((in & kTypeMask) == kTypeInt32 || (in & kRepMask) == kRepWord32) { |
| 450 // If the input has type int32, or is already a word32, just change | 450 // If the input has type int32, or is already a word32, just change |
| 451 // representation if necessary. | 451 // representation if necessary. |
| 452 VisitUnop(node, kTypeInt32 | use_rep, kTypeInt32 | use_rep); | 452 VisitUnop(node, kTypeInt32 | use_rep, kTypeInt32 | use_rep); |
| 453 DeferReplacement(node, node->InputAt(0)); | 453 DeferReplacement(node, node->InputAt(0)); |
| 454 } else { | 454 } else { |
| 455 // Require the input in float64 format and perform truncation. | 455 // Require the input in float64 format and perform truncation. |
| 456 // TODO(turbofan): could also avoid the truncation with a tag check. | 456 // TODO(turbofan): avoid a truncation with a smi check. |
| 457 VisitUnop(node, kTypeInt32 | kRepFloat64, kTypeInt32 | kRepWord32); | 457 VisitUnop(node, kTypeInt32 | kRepFloat64, kTypeInt32 | kRepWord32); |
| 458 // TODO(titzer): should be a truncation. | 458 node->set_op(lowering->machine()->TruncateFloat64ToInt32()); |
| 459 node->set_op(lowering->machine()->ChangeFloat64ToInt32()); | |
| 460 } | 459 } |
| 461 } else { | 460 } else { |
| 462 // Propagate a type to the input, but pass through representation. | 461 // Propagate a type to the input, but pass through representation. |
| 463 VisitUnop(node, kTypeInt32, kTypeInt32 | use_rep); | 462 VisitUnop(node, kTypeInt32, kTypeInt32 | use_rep); |
| 464 } | 463 } |
| 465 break; | 464 break; |
| 466 } | 465 } |
| 467 case IrOpcode::kNumberToUint32: { | 466 case IrOpcode::kNumberToUint32: { |
| 468 MachineTypeUnion use_rep = use & kRepMask; | 467 MachineTypeUnion use_rep = use & kRepMask; |
| 469 if (lower()) { | 468 if (lower()) { |
| 470 MachineTypeUnion in = GetInfo(node->InputAt(0))->output; | 469 MachineTypeUnion in = GetInfo(node->InputAt(0))->output; |
| 471 if ((in & kTypeMask) == kTypeUint32 || | 470 if ((in & kTypeMask) == kTypeUint32 || |
| 472 (in & kRepMask) == kRepWord32) { | 471 (in & kRepMask) == kRepWord32) { |
| 473 // The input has type int32, just change representation. | 472 // The input has type int32, just change representation. |
| 474 VisitUnop(node, kTypeUint32 | use_rep, kTypeUint32 | use_rep); | 473 VisitUnop(node, kTypeUint32 | use_rep, kTypeUint32 | use_rep); |
| 475 DeferReplacement(node, node->InputAt(0)); | 474 DeferReplacement(node, node->InputAt(0)); |
| 476 } else { | 475 } else { |
| 477 // Require the input in float64 format to perform truncation. | 476 // Require the input in float64 format to perform truncation. |
| 478 // TODO(turbofan): could also avoid the truncation with a tag check. | 477 // TODO(turbofan): avoid the truncation with a smi check. |
| 479 VisitUnop(node, kTypeUint32 | kRepFloat64, | 478 VisitUnop(node, kTypeUint32 | kRepFloat64, |
| 480 kTypeUint32 | kRepWord32); | 479 kTypeUint32 | kRepWord32); |
| 481 // TODO(titzer): should be a truncation. | 480 node->set_op(lowering->machine()->TruncateFloat64ToInt32()); |
| 482 node->set_op(lowering->machine()->ChangeFloat64ToUint32()); | |
| 483 } | 481 } |
| 484 } else { | 482 } else { |
| 485 // Propagate a type to the input, but pass through representation. | 483 // Propagate a type to the input, but pass through representation. |
| 486 VisitUnop(node, kTypeUint32, kTypeUint32 | use_rep); | 484 VisitUnop(node, kTypeUint32, kTypeUint32 | use_rep); |
| 487 } | 485 } |
| 488 break; | 486 break; |
| 489 } | 487 } |
| 490 case IrOpcode::kReferenceEqual: { | 488 case IrOpcode::kReferenceEqual: { |
| 491 VisitBinop(node, kMachAnyTagged, kRepBit); | 489 VisitBinop(node, kMachAnyTagged, kRepBit); |
| 492 if (lower()) node->set_op(lowering->machine()->WordEqual()); | 490 if (lower()) node->set_op(lowering->machine()->WordEqual()); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 WriteBarrierKind kind = ComputeWriteBarrierKind( | 803 WriteBarrierKind kind = ComputeWriteBarrierKind( |
| 806 access.base_is_tagged, access.machine_type, access.type); | 804 access.base_is_tagged, access.machine_type, access.type); |
| 807 node->set_op(machine_.Store(access.machine_type, kind)); | 805 node->set_op(machine_.Store(access.machine_type, kind)); |
| 808 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 806 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
| 809 } | 807 } |
| 810 | 808 |
| 811 | 809 |
| 812 } // namespace compiler | 810 } // namespace compiler |
| 813 } // namespace internal | 811 } // namespace internal |
| 814 } // namespace v8 | 812 } // namespace v8 |
| OLD | NEW |