OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/representation-change.h" | 5 #include "src/compiler/representation-change.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 return node; // Sloppy comparison -> word32 | 432 return node; // Sloppy comparison -> word32 |
433 } else if (output_rep == MachineRepresentation::kFloat64) { | 433 } else if (output_rep == MachineRepresentation::kFloat64) { |
434 if (output_type->Is(Type::Unsigned32())) { | 434 if (output_type->Is(Type::Unsigned32())) { |
435 op = machine()->ChangeFloat64ToUint32(); | 435 op = machine()->ChangeFloat64ToUint32(); |
436 } else if (output_type->Is(Type::Signed32())) { | 436 } else if (output_type->Is(Type::Signed32())) { |
437 op = machine()->ChangeFloat64ToInt32(); | 437 op = machine()->ChangeFloat64ToInt32(); |
438 } else if (use_info.truncation().IsUsedAsWord32()) { | 438 } else if (use_info.truncation().IsUsedAsWord32()) { |
439 op = machine()->TruncateFloat64ToWord32(); | 439 op = machine()->TruncateFloat64ToWord32(); |
440 } else if (use_info.type_check() == TypeCheckKind::kSignedSmall || | 440 } else if (use_info.type_check() == TypeCheckKind::kSignedSmall || |
441 use_info.type_check() == TypeCheckKind::kSigned32) { | 441 use_info.type_check() == TypeCheckKind::kSigned32) { |
442 op = simplified()->CheckedFloat64ToInt32(); | 442 op = simplified()->CheckedFloat64ToInt32( |
| 443 output_type->Maybe(Type::MinusZero()) |
| 444 ? CheckForMinusZeroMode::kCheckForMinusZero |
| 445 : CheckForMinusZeroMode::kDontCheckForMinusZero); |
443 } | 446 } |
444 } else if (output_rep == MachineRepresentation::kFloat32) { | 447 } else if (output_rep == MachineRepresentation::kFloat32) { |
445 node = InsertChangeFloat32ToFloat64(node); // float32 -> float64 -> int32 | 448 node = InsertChangeFloat32ToFloat64(node); // float32 -> float64 -> int32 |
446 if (output_type->Is(Type::Unsigned32())) { | 449 if (output_type->Is(Type::Unsigned32())) { |
447 op = machine()->ChangeFloat64ToUint32(); | 450 op = machine()->ChangeFloat64ToUint32(); |
448 } else if (output_type->Is(Type::Signed32())) { | 451 } else if (output_type->Is(Type::Signed32())) { |
449 op = machine()->ChangeFloat64ToInt32(); | 452 op = machine()->ChangeFloat64ToInt32(); |
450 } else if (use_info.truncation().IsUsedAsWord32()) { | 453 } else if (use_info.truncation().IsUsedAsWord32()) { |
451 op = machine()->TruncateFloat64ToWord32(); | 454 op = machine()->TruncateFloat64ToWord32(); |
452 } else if (use_info.type_check() == TypeCheckKind::kSignedSmall || | 455 } else if (use_info.type_check() == TypeCheckKind::kSignedSmall || |
453 use_info.type_check() == TypeCheckKind::kSigned32) { | 456 use_info.type_check() == TypeCheckKind::kSigned32) { |
454 op = simplified()->CheckedFloat64ToInt32(); | 457 op = simplified()->CheckedFloat64ToInt32( |
| 458 output_type->Maybe(Type::MinusZero()) |
| 459 ? CheckForMinusZeroMode::kCheckForMinusZero |
| 460 : CheckForMinusZeroMode::kDontCheckForMinusZero); |
455 } | 461 } |
456 } else if (output_rep == MachineRepresentation::kTagged) { | 462 } else if (output_rep == MachineRepresentation::kTagged) { |
457 if (output_type->Is(Type::TaggedSigned())) { | 463 if (output_type->Is(Type::TaggedSigned())) { |
458 op = simplified()->ChangeTaggedSignedToInt32(); | 464 op = simplified()->ChangeTaggedSignedToInt32(); |
459 } else if (output_type->Is(Type::Unsigned32())) { | 465 } else if (output_type->Is(Type::Unsigned32())) { |
460 op = simplified()->ChangeTaggedToUint32(); | 466 op = simplified()->ChangeTaggedToUint32(); |
461 } else if (output_type->Is(Type::Signed32())) { | 467 } else if (output_type->Is(Type::Signed32())) { |
462 op = simplified()->ChangeTaggedToInt32(); | 468 op = simplified()->ChangeTaggedToInt32(); |
463 } else if (use_info.truncation().IsUsedAsWord32()) { | 469 } else if (use_info.truncation().IsUsedAsWord32()) { |
464 if (use_info.type_check() != TypeCheckKind::kNone) { | 470 if (use_info.type_check() != TypeCheckKind::kNone) { |
465 op = simplified()->CheckedTruncateTaggedToWord32(); | 471 op = simplified()->CheckedTruncateTaggedToWord32(); |
466 } else { | 472 } else { |
467 op = simplified()->TruncateTaggedToWord32(); | 473 op = simplified()->TruncateTaggedToWord32(); |
468 } | 474 } |
469 } else if (use_info.type_check() == TypeCheckKind::kSignedSmall) { | 475 } else if (use_info.type_check() == TypeCheckKind::kSignedSmall) { |
470 op = simplified()->CheckedTaggedSignedToInt32(); | 476 op = simplified()->CheckedTaggedSignedToInt32(); |
471 } else if (use_info.type_check() == TypeCheckKind::kSigned32) { | 477 } else if (use_info.type_check() == TypeCheckKind::kSigned32) { |
472 op = simplified()->CheckedTaggedToInt32(); | 478 op = simplified()->CheckedTaggedToInt32( |
| 479 output_type->Maybe(Type::MinusZero()) |
| 480 ? CheckForMinusZeroMode::kCheckForMinusZero |
| 481 : CheckForMinusZeroMode::kDontCheckForMinusZero); |
473 } | 482 } |
474 } else if (output_rep == MachineRepresentation::kWord32) { | 483 } else if (output_rep == MachineRepresentation::kWord32) { |
475 // Only the checked case should get here, the non-checked case is | 484 // Only the checked case should get here, the non-checked case is |
476 // handled in GetRepresentationFor. | 485 // handled in GetRepresentationFor. |
477 if (use_info.type_check() == TypeCheckKind::kSignedSmall || | 486 if (use_info.type_check() == TypeCheckKind::kSignedSmall || |
478 use_info.type_check() == TypeCheckKind::kSigned32) { | 487 use_info.type_check() == TypeCheckKind::kSigned32) { |
479 if (output_type->Is(Type::Signed32())) { | 488 if (output_type->Is(Type::Signed32())) { |
480 return node; | 489 return node; |
481 } else if (output_type->Is(Type::Unsigned32())) { | 490 } else if (output_type->Is(Type::Unsigned32())) { |
482 op = simplified()->CheckedUint32ToInt32(); | 491 op = simplified()->CheckedUint32ToInt32(); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 } | 804 } |
796 | 805 |
797 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { | 806 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { |
798 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), | 807 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), |
799 node); | 808 node); |
800 } | 809 } |
801 | 810 |
802 } // namespace compiler | 811 } // namespace compiler |
803 } // namespace internal | 812 } // namespace internal |
804 } // namespace v8 | 813 } // namespace v8 |
OLD | NEW |