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 #include "src/compiler/code-generator-impl.h" | 6 #include "src/compiler/code-generator-impl.h" |
7 #include "src/compiler/gap-resolver.h" | 7 #include "src/compiler/gap-resolver.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/osr.h" | 9 #include "src/compiler/osr.h" |
10 #include "src/mips/macro-assembler-mips.h" | 10 #include "src/mips/macro-assembler-mips.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 FloatRegister InputSingleRegister(size_t index) { | 47 FloatRegister InputSingleRegister(size_t index) { |
48 return ToSingleRegister(instr_->InputAt(index)); | 48 return ToSingleRegister(instr_->InputAt(index)); |
49 } | 49 } |
50 | 50 |
51 FloatRegister ToSingleRegister(InstructionOperand* op) { | 51 FloatRegister ToSingleRegister(InstructionOperand* op) { |
52 // Single (Float) and Double register namespace is same on MIPS, | 52 // Single (Float) and Double register namespace is same on MIPS, |
53 // both are typedefs of FPURegister. | 53 // both are typedefs of FPURegister. |
54 return ToDoubleRegister(op); | 54 return ToDoubleRegister(op); |
55 } | 55 } |
56 | 56 |
| 57 DoubleRegister InputOrZeroDoubleRegister(size_t index) { |
| 58 if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; |
| 59 |
| 60 return InputDoubleRegister(index); |
| 61 } |
| 62 |
| 63 DoubleRegister InputOrZeroSingleRegister(size_t index) { |
| 64 if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; |
| 65 |
| 66 return InputSingleRegister(index); |
| 67 } |
| 68 |
57 Operand InputImmediate(size_t index) { | 69 Operand InputImmediate(size_t index) { |
58 Constant constant = ToConstant(instr_->InputAt(index)); | 70 Constant constant = ToConstant(instr_->InputAt(index)); |
59 switch (constant.type()) { | 71 switch (constant.type()) { |
60 case Constant::kInt32: | 72 case Constant::kInt32: |
61 return Operand(constant.ToInt32()); | 73 return Operand(constant.ToInt32()); |
62 case Constant::kFloat32: | 74 case Constant::kFloat32: |
63 return Operand( | 75 return Operand( |
64 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED)); | 76 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED)); |
65 case Constant::kFloat64: | 77 case Constant::kFloat64: |
66 return Operand( | 78 return Operand( |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 // kMipsAddOvf, SubOvf emit negative result to 'kCompareReg' on overflow. | 932 // kMipsAddOvf, SubOvf emit negative result to 'kCompareReg' on overflow. |
921 cc = FlagsConditionToConditionOvf(branch->condition); | 933 cc = FlagsConditionToConditionOvf(branch->condition); |
922 __ Branch(tlabel, cc, kCompareReg, Operand(zero_reg)); | 934 __ Branch(tlabel, cc, kCompareReg, Operand(zero_reg)); |
923 } else if (instr->arch_opcode() == kMipsCmp) { | 935 } else if (instr->arch_opcode() == kMipsCmp) { |
924 cc = FlagsConditionToConditionCmp(branch->condition); | 936 cc = FlagsConditionToConditionCmp(branch->condition); |
925 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); | 937 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); |
926 } else if (instr->arch_opcode() == kMipsCmpS) { | 938 } else if (instr->arch_opcode() == kMipsCmpS) { |
927 if (!convertCondition(branch->condition, cc)) { | 939 if (!convertCondition(branch->condition, cc)) { |
928 UNSUPPORTED_COND(kMips64CmpS, branch->condition); | 940 UNSUPPORTED_COND(kMips64CmpS, branch->condition); |
929 } | 941 } |
930 __ BranchF32(tlabel, NULL, cc, i.InputSingleRegister(0), | 942 FPURegister left = i.InputOrZeroSingleRegister(0); |
931 i.InputSingleRegister(1)); | 943 FPURegister right = i.InputOrZeroSingleRegister(1); |
| 944 if ((left.is(kDoubleRegZero) || right.is(kDoubleRegZero)) && |
| 945 !__ IsDoubleZeroRegSet()) { |
| 946 __ Move(kDoubleRegZero, 0.0); |
| 947 } |
| 948 __ BranchF32(tlabel, NULL, cc, left, right); |
932 } else if (instr->arch_opcode() == kMipsCmpD) { | 949 } else if (instr->arch_opcode() == kMipsCmpD) { |
933 if (!convertCondition(branch->condition, cc)) { | 950 if (!convertCondition(branch->condition, cc)) { |
934 UNSUPPORTED_COND(kMips64CmpD, branch->condition); | 951 UNSUPPORTED_COND(kMips64CmpD, branch->condition); |
935 } | 952 } |
936 __ BranchF64(tlabel, NULL, cc, i.InputDoubleRegister(0), | 953 FPURegister left = i.InputOrZeroDoubleRegister(0); |
937 i.InputDoubleRegister(1)); | 954 FPURegister right = i.InputOrZeroDoubleRegister(1); |
| 955 if ((left.is(kDoubleRegZero) || right.is(kDoubleRegZero)) && |
| 956 !__ IsDoubleZeroRegSet()) { |
| 957 __ Move(kDoubleRegZero, 0.0); |
| 958 } |
| 959 __ BranchF64(tlabel, NULL, cc, left, right); |
938 } else { | 960 } else { |
939 PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", | 961 PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", |
940 instr->arch_opcode()); | 962 instr->arch_opcode()); |
941 UNIMPLEMENTED(); | 963 UNIMPLEMENTED(); |
942 } | 964 } |
943 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. | 965 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. |
944 } | 966 } |
945 | 967 |
946 | 968 |
947 void CodeGenerator::AssembleArchJump(RpoNumber target) { | 969 void CodeGenerator::AssembleArchJump(RpoNumber target) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 if (cc == ls) { | 1061 if (cc == ls) { |
1040 __ xori(result, result, 1); | 1062 __ xori(result, result, 1); |
1041 } | 1063 } |
1042 } break; | 1064 } break; |
1043 default: | 1065 default: |
1044 UNREACHABLE(); | 1066 UNREACHABLE(); |
1045 } | 1067 } |
1046 return; | 1068 return; |
1047 } else if (instr->arch_opcode() == kMipsCmpD || | 1069 } else if (instr->arch_opcode() == kMipsCmpD || |
1048 instr->arch_opcode() == kMipsCmpS) { | 1070 instr->arch_opcode() == kMipsCmpS) { |
1049 FPURegister left = i.InputDoubleRegister(0); | 1071 FPURegister left = i.InputOrZeroDoubleRegister(0); |
1050 FPURegister right = i.InputDoubleRegister(1); | 1072 FPURegister right = i.InputOrZeroDoubleRegister(1); |
| 1073 if ((left.is(kDoubleRegZero) || right.is(kDoubleRegZero)) && |
| 1074 !__ IsDoubleZeroRegSet()) { |
| 1075 __ Move(kDoubleRegZero, 0.0); |
| 1076 } |
1051 bool predicate; | 1077 bool predicate; |
1052 FPUCondition cc = FlagsConditionToConditionCmpFPU(predicate, condition); | 1078 FPUCondition cc = FlagsConditionToConditionCmpFPU(predicate, condition); |
1053 if (!IsMipsArchVariant(kMips32r6)) { | 1079 if (!IsMipsArchVariant(kMips32r6)) { |
1054 __ li(result, Operand(1)); | 1080 __ li(result, Operand(1)); |
1055 if (instr->arch_opcode() == kMipsCmpD) { | 1081 if (instr->arch_opcode() == kMipsCmpD) { |
1056 __ c(cc, D, left, right); | 1082 __ c(cc, D, left, right); |
1057 } else { | 1083 } else { |
1058 DCHECK(instr->arch_opcode() == kMipsCmpS); | 1084 DCHECK(instr->arch_opcode() == kMipsCmpS); |
1059 __ c(cc, S, left, right); | 1085 __ c(cc, S, left, right); |
1060 } | 1086 } |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 padding_size -= v8::internal::Assembler::kInstrSize; | 1455 padding_size -= v8::internal::Assembler::kInstrSize; |
1430 } | 1456 } |
1431 } | 1457 } |
1432 } | 1458 } |
1433 | 1459 |
1434 #undef __ | 1460 #undef __ |
1435 | 1461 |
1436 } // namespace compiler | 1462 } // namespace compiler |
1437 } // namespace internal | 1463 } // namespace internal |
1438 } // namespace v8 | 1464 } // namespace v8 |
OLD | NEW |