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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 } else if (mleft.right().Is(24) && m.right().Is(24)) { | 611 } else if (mleft.right().Is(24) && m.right().Is(24)) { |
612 Emit(kX64Movsxbl, g.DefineAsRegister(node), g.Use(mleft.left().node())); | 612 Emit(kX64Movsxbl, g.DefineAsRegister(node), g.Use(mleft.left().node())); |
613 return; | 613 return; |
614 } | 614 } |
615 } | 615 } |
616 VisitWord32Shift(this, node, kX64Sar32); | 616 VisitWord32Shift(this, node, kX64Sar32); |
617 } | 617 } |
618 | 618 |
619 | 619 |
620 void InstructionSelector::VisitWord64Sar(Node* node) { | 620 void InstructionSelector::VisitWord64Sar(Node* node) { |
621 X64OperandGenerator g(this); | |
622 Int64BinopMatcher m(node); | |
623 if (CanCover(m.node(), m.left().node()) && m.left().IsLoad() && | |
624 m.right().Is(32)) { | |
625 // Just load and sign-extend the interesting 4 bytes instead. This happens, | |
626 // for example, when we're loading and untagging SMIs. | |
627 BaseWithIndexAndDisplacement64Matcher mleft(m.left().node(), true); | |
628 if (mleft.matches() && (mleft.displacement() == nullptr || | |
629 g.CanBeImmediate(mleft.displacement()))) { | |
630 size_t input_count = 0; | |
631 InstructionOperand inputs[3]; | |
632 AddressingMode mode = g.GetEffectiveAddressMemoryOperand( | |
633 m.left().node(), inputs, &input_count); | |
634 if (mleft.displacement() == nullptr) { | |
635 // Make sure that the addressing mode indicates the presence of an | |
636 // immediate displacement. It seems that we never use M1 and M2, but we | |
637 // handle them here anyways. | |
638 switch (mode) { | |
639 case kMode_MR: | |
640 mode = kMode_MRI; | |
641 break; | |
642 case kMode_MR1: | |
643 mode = kMode_MR1I; | |
644 break; | |
645 case kMode_MR2: | |
646 mode = kMode_MR2I; | |
647 break; | |
648 case kMode_MR4: | |
649 mode = kMode_MR4I; | |
650 break; | |
651 case kMode_MR8: | |
652 mode = kMode_MR8I; | |
653 break; | |
654 case kMode_M1: | |
655 mode = kMode_M1I; | |
656 break; | |
657 case kMode_M2: | |
658 mode = kMode_M2I; | |
659 break; | |
660 case kMode_M4: | |
661 mode = kMode_M4I; | |
662 break; | |
663 case kMode_M8: | |
664 mode = kMode_M8I; | |
665 default: | |
Benedikt Meurer
2016/04/01 09:20:49
No default please, and use UNREACHABLE for cases t
| |
666 break; | |
667 } | |
668 inputs[input_count++] = ImmediateOperand(ImmediateOperand::INLINE, 4); | |
669 } else { | |
670 ImmediateOperand* op = ImmediateOperand::cast(&inputs[input_count - 1]); | |
671 int32_t displacement = sequence()->GetImmediate(op).ToInt32(); | |
672 *op = ImmediateOperand(ImmediateOperand::INLINE, displacement + 4); | |
673 } | |
674 InstructionOperand outputs[] = {g.DefineAsRegister(node)}; | |
675 InstructionCode code = kX64Movsxlq | AddressingModeField::encode(mode); | |
676 Emit(code, 1, outputs, input_count, inputs); | |
677 return; | |
678 } | |
679 } | |
621 VisitWord64Shift(this, node, kX64Sar); | 680 VisitWord64Shift(this, node, kX64Sar); |
622 } | 681 } |
623 | 682 |
624 | 683 |
625 void InstructionSelector::VisitWord32Ror(Node* node) { | 684 void InstructionSelector::VisitWord32Ror(Node* node) { |
626 VisitWord32Shift(this, node, kX64Ror32); | 685 VisitWord32Shift(this, node, kX64Ror32); |
627 } | 686 } |
628 | 687 |
629 | 688 |
630 void InstructionSelector::VisitWord64Ror(Node* node) { | 689 void InstructionSelector::VisitWord64Ror(Node* node) { |
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1972 MachineOperatorBuilder::kFloat64RoundTruncate | | 2031 MachineOperatorBuilder::kFloat64RoundTruncate | |
1973 MachineOperatorBuilder::kFloat32RoundTiesEven | | 2032 MachineOperatorBuilder::kFloat32RoundTiesEven | |
1974 MachineOperatorBuilder::kFloat64RoundTiesEven; | 2033 MachineOperatorBuilder::kFloat64RoundTiesEven; |
1975 } | 2034 } |
1976 return flags; | 2035 return flags; |
1977 } | 2036 } |
1978 | 2037 |
1979 } // namespace compiler | 2038 } // namespace compiler |
1980 } // namespace internal | 2039 } // namespace internal |
1981 } // namespace v8 | 2040 } // namespace v8 |
OLD | NEW |