OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
11 #include "src/x64/assembler-x64.h" | 11 #include "src/x64/assembler-x64.h" |
12 #include "src/x64/macro-assembler-x64.h" | 12 #include "src/x64/macro-assembler-x64.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 namespace compiler { | 16 namespace compiler { |
17 | 17 |
18 #define __ masm()-> | 18 #define __ masm()-> |
19 | 19 |
20 | 20 |
| 21 #define kScratchDoubleReg xmm0 |
| 22 |
| 23 |
21 // Adds X64 specific methods for decoding operands. | 24 // Adds X64 specific methods for decoding operands. |
22 class X64OperandConverter : public InstructionOperandConverter { | 25 class X64OperandConverter : public InstructionOperandConverter { |
23 public: | 26 public: |
24 X64OperandConverter(CodeGenerator* gen, Instruction* instr) | 27 X64OperandConverter(CodeGenerator* gen, Instruction* instr) |
25 : InstructionOperandConverter(gen, instr) {} | 28 : InstructionOperandConverter(gen, instr) {} |
26 | 29 |
27 Immediate InputImmediate(size_t index) { | 30 Immediate InputImmediate(size_t index) { |
28 return ToImmediate(instr_->InputAt(index)); | 31 return ToImmediate(instr_->InputAt(index)); |
29 } | 32 } |
30 | 33 |
31 Operand InputOperand(size_t index) { | 34 Operand InputOperand(size_t index, int extra = 0) { |
32 return ToOperand(instr_->InputAt(index)); | 35 return ToOperand(instr_->InputAt(index), extra); |
33 } | 36 } |
34 | 37 |
35 Operand OutputOperand() { return ToOperand(instr_->Output()); } | 38 Operand OutputOperand() { return ToOperand(instr_->Output()); } |
36 | 39 |
37 Immediate ToImmediate(InstructionOperand* operand) { | 40 Immediate ToImmediate(InstructionOperand* operand) { |
38 return Immediate(ToConstant(operand).ToInt32()); | 41 return Immediate(ToConstant(operand).ToInt32()); |
39 } | 42 } |
40 | 43 |
41 Operand ToOperand(InstructionOperand* op, int extra = 0) { | 44 Operand ToOperand(InstructionOperand* op, int extra = 0) { |
42 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 45 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 } | 804 } |
802 break; | 805 break; |
803 case kSSEUint32ToFloat64: | 806 case kSSEUint32ToFloat64: |
804 if (instr->InputAt(0)->IsRegister()) { | 807 if (instr->InputAt(0)->IsRegister()) { |
805 __ movl(kScratchRegister, i.InputRegister(0)); | 808 __ movl(kScratchRegister, i.InputRegister(0)); |
806 } else { | 809 } else { |
807 __ movl(kScratchRegister, i.InputOperand(0)); | 810 __ movl(kScratchRegister, i.InputOperand(0)); |
808 } | 811 } |
809 __ cvtqsi2sd(i.OutputDoubleRegister(), kScratchRegister); | 812 __ cvtqsi2sd(i.OutputDoubleRegister(), kScratchRegister); |
810 break; | 813 break; |
| 814 case kSSEFloat64ExtractLowWord32: |
| 815 if (instr->InputAt(0)->IsDoubleStackSlot()) { |
| 816 __ movl(i.OutputRegister(), i.InputOperand(0)); |
| 817 } else { |
| 818 __ movd(i.OutputRegister(), i.InputDoubleRegister(0)); |
| 819 } |
| 820 break; |
| 821 case kSSEFloat64ExtractHighWord32: |
| 822 if (instr->InputAt(0)->IsDoubleStackSlot()) { |
| 823 __ movl(i.OutputRegister(), i.InputOperand(0, kDoubleSize / 2)); |
| 824 } else { |
| 825 __ Pextrd(i.OutputRegister(), i.InputDoubleRegister(0), 1); |
| 826 } |
| 827 break; |
| 828 case kSSEFloat64InsertLowWord32: |
| 829 if (instr->InputAt(1)->IsRegister()) { |
| 830 __ Pinsrd(i.OutputDoubleRegister(), i.InputRegister(1), 0); |
| 831 } else { |
| 832 __ Pinsrd(i.OutputDoubleRegister(), i.InputOperand(1), 0); |
| 833 } |
| 834 break; |
| 835 case kSSEFloat64InsertHighWord32: |
| 836 if (instr->InputAt(1)->IsRegister()) { |
| 837 __ Pinsrd(i.OutputDoubleRegister(), i.InputRegister(1), 1); |
| 838 } else { |
| 839 __ Pinsrd(i.OutputDoubleRegister(), i.InputOperand(1), 1); |
| 840 } |
| 841 break; |
| 842 case kSSEFloat64LoadLowWord32: |
| 843 if (instr->InputAt(0)->IsRegister()) { |
| 844 __ movd(i.OutputDoubleRegister(), i.InputRegister(0)); |
| 845 } else { |
| 846 __ movd(i.OutputDoubleRegister(), i.InputOperand(0)); |
| 847 } |
| 848 break; |
811 case kAVXFloat64Add: | 849 case kAVXFloat64Add: |
812 ASSEMBLE_AVX_DOUBLE_BINOP(vaddsd); | 850 ASSEMBLE_AVX_DOUBLE_BINOP(vaddsd); |
813 break; | 851 break; |
814 case kAVXFloat64Sub: | 852 case kAVXFloat64Sub: |
815 ASSEMBLE_AVX_DOUBLE_BINOP(vsubsd); | 853 ASSEMBLE_AVX_DOUBLE_BINOP(vsubsd); |
816 break; | 854 break; |
817 case kAVXFloat64Mul: | 855 case kAVXFloat64Mul: |
818 ASSEMBLE_AVX_DOUBLE_BINOP(vmulsd); | 856 ASSEMBLE_AVX_DOUBLE_BINOP(vmulsd); |
819 break; | 857 break; |
820 case kAVXFloat64Div: | 858 case kAVXFloat64Div: |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 case kCheckedStoreWord32: | 1045 case kCheckedStoreWord32: |
1008 ASSEMBLE_CHECKED_STORE_INTEGER(movl); | 1046 ASSEMBLE_CHECKED_STORE_INTEGER(movl); |
1009 break; | 1047 break; |
1010 case kCheckedStoreFloat32: | 1048 case kCheckedStoreFloat32: |
1011 ASSEMBLE_CHECKED_STORE_FLOAT(movss); | 1049 ASSEMBLE_CHECKED_STORE_FLOAT(movss); |
1012 break; | 1050 break; |
1013 case kCheckedStoreFloat64: | 1051 case kCheckedStoreFloat64: |
1014 ASSEMBLE_CHECKED_STORE_FLOAT(movsd); | 1052 ASSEMBLE_CHECKED_STORE_FLOAT(movsd); |
1015 break; | 1053 break; |
1016 } | 1054 } |
1017 } | 1055 } // NOLINT(readability/fn_size) |
1018 | 1056 |
1019 | 1057 |
1020 // Assembles branches after this instruction. | 1058 // Assembles branches after this instruction. |
1021 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 1059 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
1022 X64OperandConverter i(this, instr); | 1060 X64OperandConverter i(this, instr); |
1023 Label::Distance flabel_distance = | 1061 Label::Distance flabel_distance = |
1024 branch->fallthru ? Label::kNear : Label::kFar; | 1062 branch->fallthru ? Label::kNear : Label::kFar; |
1025 Label* tlabel = branch->true_label; | 1063 Label* tlabel = branch->true_label; |
1026 Label* flabel = branch->false_label; | 1064 Label* flabel = branch->false_label; |
1027 switch (branch->condition) { | 1065 switch (branch->condition) { |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 } | 1489 } |
1452 } | 1490 } |
1453 MarkLazyDeoptSite(); | 1491 MarkLazyDeoptSite(); |
1454 } | 1492 } |
1455 | 1493 |
1456 #undef __ | 1494 #undef __ |
1457 | 1495 |
1458 } // namespace internal | 1496 } // namespace internal |
1459 } // namespace compiler | 1497 } // namespace compiler |
1460 } // namespace v8 | 1498 } // namespace v8 |
OLD | NEW |