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/arm64/macro-assembler-arm64.h" | 7 #include "src/arm64/macro-assembler-arm64.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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return ToImmediate(op); | 82 return ToImmediate(op); |
83 } | 83 } |
84 | 84 |
85 Operand ToImmediate(InstructionOperand* operand) { | 85 Operand ToImmediate(InstructionOperand* operand) { |
86 Constant constant = ToConstant(operand); | 86 Constant constant = ToConstant(operand); |
87 switch (constant.type()) { | 87 switch (constant.type()) { |
88 case Constant::kInt32: | 88 case Constant::kInt32: |
89 return Operand(constant.ToInt32()); | 89 return Operand(constant.ToInt32()); |
90 case Constant::kInt64: | 90 case Constant::kInt64: |
91 return Operand(constant.ToInt64()); | 91 return Operand(constant.ToInt64()); |
| 92 case Constant::kFloat32: |
| 93 return Operand( |
| 94 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED)); |
92 case Constant::kFloat64: | 95 case Constant::kFloat64: |
93 return Operand( | 96 return Operand( |
94 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED)); | 97 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED)); |
95 case Constant::kExternalReference: | 98 case Constant::kExternalReference: |
96 return Operand(constant.ToExternalReference()); | 99 return Operand(constant.ToExternalReference()); |
97 case Constant::kHeapObject: | 100 case Constant::kHeapObject: |
98 return Operand(constant.ToHeapObject()); | 101 return Operand(constant.ToHeapObject()); |
99 } | 102 } |
100 UNREACHABLE(); | 103 UNREACHABLE(); |
101 return Operand(-1); | 104 return Operand(-1); |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 DCHECK(destination->IsRegister() || destination->IsStackSlot()); | 754 DCHECK(destination->IsRegister() || destination->IsStackSlot()); |
752 if (destination->IsRegister()) { | 755 if (destination->IsRegister()) { |
753 __ Ldr(g.ToRegister(destination), src); | 756 __ Ldr(g.ToRegister(destination), src); |
754 } else { | 757 } else { |
755 UseScratchRegisterScope scope(masm()); | 758 UseScratchRegisterScope scope(masm()); |
756 Register temp = scope.AcquireX(); | 759 Register temp = scope.AcquireX(); |
757 __ Ldr(temp, src); | 760 __ Ldr(temp, src); |
758 __ Str(temp, g.ToMemOperand(destination, masm())); | 761 __ Str(temp, g.ToMemOperand(destination, masm())); |
759 } | 762 } |
760 } else if (source->IsConstant()) { | 763 } else if (source->IsConstant()) { |
761 ConstantOperand* constant_source = ConstantOperand::cast(source); | 764 Constant src = g.ToConstant(ConstantOperand::cast(source)); |
762 if (destination->IsRegister() || destination->IsStackSlot()) { | 765 if (destination->IsRegister() || destination->IsStackSlot()) { |
763 UseScratchRegisterScope scope(masm()); | 766 UseScratchRegisterScope scope(masm()); |
764 Register dst = destination->IsRegister() ? g.ToRegister(destination) | 767 Register dst = destination->IsRegister() ? g.ToRegister(destination) |
765 : scope.AcquireX(); | 768 : scope.AcquireX(); |
766 Constant src = g.ToConstant(source); | |
767 if (src.type() == Constant::kHeapObject) { | 769 if (src.type() == Constant::kHeapObject) { |
768 __ LoadObject(dst, src.ToHeapObject()); | 770 __ LoadObject(dst, src.ToHeapObject()); |
769 } else { | 771 } else { |
770 __ Mov(dst, g.ToImmediate(source)); | 772 __ Mov(dst, g.ToImmediate(source)); |
771 } | 773 } |
772 if (destination->IsStackSlot()) { | 774 if (destination->IsStackSlot()) { |
773 __ Str(dst, g.ToMemOperand(destination, masm())); | 775 __ Str(dst, g.ToMemOperand(destination, masm())); |
774 } | 776 } |
775 } else if (destination->IsDoubleRegister()) { | 777 } else if (src.type() == Constant::kFloat32) { |
776 FPRegister result = g.ToDoubleRegister(destination); | 778 if (destination->IsDoubleRegister()) { |
777 __ Fmov(result, g.ToDouble(constant_source)); | 779 FPRegister dst = g.ToDoubleRegister(destination).S(); |
| 780 __ Fmov(dst, src.ToFloat32()); |
| 781 } else { |
| 782 DCHECK(destination->IsDoubleStackSlot()); |
| 783 UseScratchRegisterScope scope(masm()); |
| 784 FPRegister temp = scope.AcquireS(); |
| 785 __ Fmov(temp, src.ToFloat32()); |
| 786 __ Str(temp, g.ToMemOperand(destination, masm())); |
| 787 } |
778 } else { | 788 } else { |
779 DCHECK(destination->IsDoubleStackSlot()); | 789 DCHECK_EQ(Constant::kFloat64, src.type()); |
780 UseScratchRegisterScope scope(masm()); | 790 if (destination->IsDoubleRegister()) { |
781 FPRegister temp = scope.AcquireD(); | 791 FPRegister dst = g.ToDoubleRegister(destination); |
782 __ Fmov(temp, g.ToDouble(constant_source)); | 792 __ Fmov(dst, src.ToFloat64()); |
783 __ Str(temp, g.ToMemOperand(destination, masm())); | 793 } else { |
| 794 DCHECK(destination->IsDoubleStackSlot()); |
| 795 UseScratchRegisterScope scope(masm()); |
| 796 FPRegister temp = scope.AcquireD(); |
| 797 __ Fmov(temp, src.ToFloat64()); |
| 798 __ Str(temp, g.ToMemOperand(destination, masm())); |
| 799 } |
784 } | 800 } |
785 } else if (source->IsDoubleRegister()) { | 801 } else if (source->IsDoubleRegister()) { |
786 FPRegister src = g.ToDoubleRegister(source); | 802 FPRegister src = g.ToDoubleRegister(source); |
787 if (destination->IsDoubleRegister()) { | 803 if (destination->IsDoubleRegister()) { |
788 FPRegister dst = g.ToDoubleRegister(destination); | 804 FPRegister dst = g.ToDoubleRegister(destination); |
789 __ Fmov(dst, src); | 805 __ Fmov(dst, src); |
790 } else { | 806 } else { |
791 DCHECK(destination->IsDoubleStackSlot()); | 807 DCHECK(destination->IsDoubleStackSlot()); |
792 __ Str(src, g.ToMemOperand(destination, masm())); | 808 __ Str(src, g.ToMemOperand(destination, masm())); |
793 } | 809 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 } | 902 } |
887 } | 903 } |
888 MarkLazyDeoptSite(); | 904 MarkLazyDeoptSite(); |
889 } | 905 } |
890 | 906 |
891 #undef __ | 907 #undef __ |
892 | 908 |
893 } // namespace compiler | 909 } // namespace compiler |
894 } // namespace internal | 910 } // namespace internal |
895 } // namespace v8 | 911 } // namespace v8 |
OLD | NEW |