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/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm/macro-assembler-arm.h" | 7 #include "src/arm/macro-assembler-arm.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 UNREACHABLE(); | 62 UNREACHABLE(); |
63 return LeaveCC; | 63 return LeaveCC; |
64 } | 64 } |
65 | 65 |
66 Operand InputImmediate(int index) { | 66 Operand InputImmediate(int index) { |
67 Constant constant = ToConstant(instr_->InputAt(index)); | 67 Constant constant = ToConstant(instr_->InputAt(index)); |
68 switch (constant.type()) { | 68 switch (constant.type()) { |
69 case Constant::kInt32: | 69 case Constant::kInt32: |
70 return Operand(constant.ToInt32()); | 70 return Operand(constant.ToInt32()); |
| 71 case Constant::kFloat32: |
| 72 return Operand( |
| 73 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED)); |
71 case Constant::kFloat64: | 74 case Constant::kFloat64: |
72 return Operand( | 75 return Operand( |
73 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED)); | 76 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED)); |
74 case Constant::kInt64: | 77 case Constant::kInt64: |
75 case Constant::kExternalReference: | 78 case Constant::kExternalReference: |
76 case Constant::kHeapObject: | 79 case Constant::kHeapObject: |
77 break; | 80 break; |
78 } | 81 } |
79 UNREACHABLE(); | 82 UNREACHABLE(); |
80 return Operand::Zero(); | 83 return Operand::Zero(); |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 DCHECK(destination->IsRegister() || destination->IsStackSlot()); | 746 DCHECK(destination->IsRegister() || destination->IsStackSlot()); |
744 MemOperand src = g.ToMemOperand(source); | 747 MemOperand src = g.ToMemOperand(source); |
745 if (destination->IsRegister()) { | 748 if (destination->IsRegister()) { |
746 __ ldr(g.ToRegister(destination), src); | 749 __ ldr(g.ToRegister(destination), src); |
747 } else { | 750 } else { |
748 Register temp = kScratchReg; | 751 Register temp = kScratchReg; |
749 __ ldr(temp, src); | 752 __ ldr(temp, src); |
750 __ str(temp, g.ToMemOperand(destination)); | 753 __ str(temp, g.ToMemOperand(destination)); |
751 } | 754 } |
752 } else if (source->IsConstant()) { | 755 } else if (source->IsConstant()) { |
| 756 Constant src = g.ToConstant(source); |
753 if (destination->IsRegister() || destination->IsStackSlot()) { | 757 if (destination->IsRegister() || destination->IsStackSlot()) { |
754 Register dst = | 758 Register dst = |
755 destination->IsRegister() ? g.ToRegister(destination) : kScratchReg; | 759 destination->IsRegister() ? g.ToRegister(destination) : kScratchReg; |
756 Constant src = g.ToConstant(source); | |
757 switch (src.type()) { | 760 switch (src.type()) { |
758 case Constant::kInt32: | 761 case Constant::kInt32: |
759 __ mov(dst, Operand(src.ToInt32())); | 762 __ mov(dst, Operand(src.ToInt32())); |
760 break; | 763 break; |
761 case Constant::kInt64: | 764 case Constant::kInt64: |
762 UNREACHABLE(); | 765 UNREACHABLE(); |
763 break; | 766 break; |
| 767 case Constant::kFloat32: |
| 768 __ Move(dst, |
| 769 isolate()->factory()->NewNumber(src.ToFloat32(), TENURED)); |
| 770 break; |
764 case Constant::kFloat64: | 771 case Constant::kFloat64: |
765 __ Move(dst, | 772 __ Move(dst, |
766 isolate()->factory()->NewNumber(src.ToFloat64(), TENURED)); | 773 isolate()->factory()->NewNumber(src.ToFloat64(), TENURED)); |
767 break; | 774 break; |
768 case Constant::kExternalReference: | 775 case Constant::kExternalReference: |
769 __ mov(dst, Operand(src.ToExternalReference())); | 776 __ mov(dst, Operand(src.ToExternalReference())); |
770 break; | 777 break; |
771 case Constant::kHeapObject: | 778 case Constant::kHeapObject: |
772 __ Move(dst, src.ToHeapObject()); | 779 __ Move(dst, src.ToHeapObject()); |
773 break; | 780 break; |
774 } | 781 } |
775 if (destination->IsStackSlot()) __ str(dst, g.ToMemOperand(destination)); | 782 if (destination->IsStackSlot()) __ str(dst, g.ToMemOperand(destination)); |
776 } else if (destination->IsDoubleRegister()) { | 783 } else if (src.type() == Constant::kFloat32) { |
777 DwVfpRegister result = g.ToDoubleRegister(destination); | 784 SwVfpRegister dst = destination->IsDoubleRegister() |
778 __ vmov(result, g.ToDouble(source)); | 785 ? g.ToFloat32Register(destination) |
| 786 : kScratchDoubleReg.low(); |
| 787 // TODO(turbofan): Can we do better here? |
| 788 __ mov(ip, Operand(bit_cast<int32_t>(src.ToFloat32()))); |
| 789 __ vmov(dst, ip); |
| 790 if (destination->IsDoubleStackSlot()) { |
| 791 __ vstr(dst, g.ToMemOperand(destination)); |
| 792 } |
779 } else { | 793 } else { |
780 DCHECK(destination->IsDoubleStackSlot()); | 794 DCHECK_EQ(Constant::kFloat64, src.type()); |
781 DwVfpRegister temp = kScratchDoubleReg; | 795 DwVfpRegister dst = destination->IsDoubleRegister() |
782 __ vmov(temp, g.ToDouble(source)); | 796 ? g.ToFloat64Register(destination) |
783 __ vstr(temp, g.ToMemOperand(destination)); | 797 : kScratchDoubleReg; |
| 798 __ vmov(dst, src.ToFloat64()); |
| 799 if (destination->IsDoubleStackSlot()) { |
| 800 __ vstr(dst, g.ToMemOperand(destination)); |
| 801 } |
784 } | 802 } |
785 } else if (source->IsDoubleRegister()) { | 803 } else if (source->IsDoubleRegister()) { |
786 DwVfpRegister src = g.ToDoubleRegister(source); | 804 DwVfpRegister src = g.ToDoubleRegister(source); |
787 if (destination->IsDoubleRegister()) { | 805 if (destination->IsDoubleRegister()) { |
788 DwVfpRegister dst = g.ToDoubleRegister(destination); | 806 DwVfpRegister dst = g.ToDoubleRegister(destination); |
789 __ Move(dst, src); | 807 __ Move(dst, src); |
790 } else { | 808 } else { |
791 DCHECK(destination->IsDoubleStackSlot()); | 809 DCHECK(destination->IsDoubleStackSlot()); |
792 __ vstr(src, g.ToMemOperand(destination)); | 810 __ vstr(src, g.ToMemOperand(destination)); |
793 } | 811 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 } | 915 } |
898 } | 916 } |
899 MarkLazyDeoptSite(); | 917 MarkLazyDeoptSite(); |
900 } | 918 } |
901 | 919 |
902 #undef __ | 920 #undef __ |
903 | 921 |
904 } // namespace compiler | 922 } // namespace compiler |
905 } // namespace internal | 923 } // namespace internal |
906 } // namespace v8 | 924 } // namespace v8 |
OLD | NEW |