| 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/mips/macro-assembler-mips.h" | 9 #include "src/mips/macro-assembler-mips.h" |
| 10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 case kNotOverflow: | 257 case kNotOverflow: |
| 258 return eq; | 258 return eq; |
| 259 default: | 259 default: |
| 260 break; | 260 break; |
| 261 } | 261 } |
| 262 UNREACHABLE(); | 262 UNREACHABLE(); |
| 263 return kNoCondition; | 263 return kNoCondition; |
| 264 } | 264 } |
| 265 | 265 |
| 266 | 266 |
| 267 FPUCondition FlagsConditionToConditionCmpD(bool& predicate, | 267 FPUCondition FlagsConditionToConditionCmpFPU(bool& predicate, |
| 268 FlagsCondition condition) { | 268 FlagsCondition condition) { |
| 269 switch (condition) { | 269 switch (condition) { |
| 270 case kEqual: | 270 case kEqual: |
| 271 predicate = true; | 271 predicate = true; |
| 272 return EQ; | 272 return EQ; |
| 273 case kNotEqual: | 273 case kNotEqual: |
| 274 predicate = false; | 274 predicate = false; |
| 275 return EQ; | 275 return EQ; |
| 276 case kUnsignedLessThan: | 276 case kUnsignedLessThan: |
| 277 predicate = true; | 277 predicate = true; |
| 278 return OLT; | 278 return OLT; |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 __ dsra32(kScratchReg, i.OutputRegister(), 0); | 1054 __ dsra32(kScratchReg, i.OutputRegister(), 0); |
| 1055 __ sra(at, i.OutputRegister(), 31); | 1055 __ sra(at, i.OutputRegister(), 31); |
| 1056 __ Branch(USE_DELAY_SLOT, &done, cc, at, Operand(kScratchReg)); | 1056 __ Branch(USE_DELAY_SLOT, &done, cc, at, Operand(kScratchReg)); |
| 1057 __ li(result, Operand(1)); // In delay slot. | 1057 __ li(result, Operand(1)); // In delay slot. |
| 1058 } else if (instr->arch_opcode() == kMips64Cmp) { | 1058 } else if (instr->arch_opcode() == kMips64Cmp) { |
| 1059 Register left = i.InputRegister(0); | 1059 Register left = i.InputRegister(0); |
| 1060 Operand right = i.InputOperand(1); | 1060 Operand right = i.InputOperand(1); |
| 1061 cc = FlagsConditionToConditionCmp(condition); | 1061 cc = FlagsConditionToConditionCmp(condition); |
| 1062 __ Branch(USE_DELAY_SLOT, &done, cc, left, right); | 1062 __ Branch(USE_DELAY_SLOT, &done, cc, left, right); |
| 1063 __ li(result, Operand(1)); // In delay slot. | 1063 __ li(result, Operand(1)); // In delay slot. |
| 1064 } else if (instr->arch_opcode() == kMips64CmpD) { | 1064 } else if (instr->arch_opcode() == kMips64CmpD || |
| 1065 instr->arch_opcode() == kMips64CmpS) { |
| 1065 FPURegister left = i.InputDoubleRegister(0); | 1066 FPURegister left = i.InputDoubleRegister(0); |
| 1066 FPURegister right = i.InputDoubleRegister(1); | 1067 FPURegister right = i.InputDoubleRegister(1); |
| 1067 | 1068 |
| 1068 bool predicate; | 1069 bool predicate; |
| 1069 FPUCondition cc = FlagsConditionToConditionCmpD(predicate, condition); | 1070 FPUCondition cc = FlagsConditionToConditionCmpFPU(predicate, condition); |
| 1070 if (kArchVariant != kMips64r6) { | 1071 if (kArchVariant != kMips64r6) { |
| 1071 __ li(result, Operand(1)); | 1072 __ li(result, Operand(1)); |
| 1072 __ c(cc, D, left, right); | 1073 if (instr->arch_opcode() == kMips64CmpD) { |
| 1074 __ c(cc, D, left, right); |
| 1075 } else { |
| 1076 DCHECK(instr->arch_opcode() == kMips64CmpS); |
| 1077 __ c(cc, S, left, right); |
| 1078 } |
| 1073 if (predicate) { | 1079 if (predicate) { |
| 1074 __ Movf(result, zero_reg); | 1080 __ Movf(result, zero_reg); |
| 1075 } else { | 1081 } else { |
| 1076 __ Movt(result, zero_reg); | 1082 __ Movt(result, zero_reg); |
| 1077 } | 1083 } |
| 1078 } else { | 1084 } else { |
| 1079 __ cmp(cc, L, kDoubleCompareReg, left, right); | 1085 if (instr->arch_opcode() == kMips64CmpD) { |
| 1086 __ cmp(cc, L, kDoubleCompareReg, left, right); |
| 1087 } else { |
| 1088 DCHECK(instr->arch_opcode() == kMips64CmpS); |
| 1089 __ cmp(cc, W, kDoubleCompareReg, left, right); |
| 1090 } |
| 1080 __ dmfc1(at, kDoubleCompareReg); | 1091 __ dmfc1(at, kDoubleCompareReg); |
| 1081 __ dsrl32(result, at, 31); // Cmp returns all 1s for true. | 1092 __ dsrl32(result, at, 31); // Cmp returns all 1s for true. |
| 1082 if (!predicate) // Toggle result for not equal. | 1093 if (!predicate) // Toggle result for not equal. |
| 1083 __ xori(result, result, 1); | 1094 __ xori(result, result, 1); |
| 1084 } | 1095 } |
| 1085 return; | 1096 return; |
| 1086 } else { | 1097 } else { |
| 1087 PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", | 1098 PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", |
| 1088 instr->arch_opcode()); | 1099 instr->arch_opcode()); |
| 1089 TRACE_UNIMPL(); | 1100 TRACE_UNIMPL(); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 } | 1456 } |
| 1446 } | 1457 } |
| 1447 } | 1458 } |
| 1448 } | 1459 } |
| 1449 | 1460 |
| 1450 #undef __ | 1461 #undef __ |
| 1451 | 1462 |
| 1452 } // namespace compiler | 1463 } // namespace compiler |
| 1453 } // namespace internal | 1464 } // namespace internal |
| 1454 } // namespace v8 | 1465 } // namespace v8 |
| OLD | NEW |