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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 return lt; | 256 return lt; |
257 case kNotOverflow: | 257 case kNotOverflow: |
258 return ge; | 258 return ge; |
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 FPUCondition FlagsConditionToConditionCmpD(bool& predicate, | 266 FPUCondition FlagsConditionToConditionCmpFPU(bool& predicate, |
267 FlagsCondition condition) { | 267 FlagsCondition condition) { |
268 switch (condition) { | 268 switch (condition) { |
269 case kEqual: | 269 case kEqual: |
270 predicate = true; | 270 predicate = true; |
271 return EQ; | 271 return EQ; |
272 case kNotEqual: | 272 case kNotEqual: |
273 predicate = false; | 273 predicate = false; |
274 return EQ; | 274 return EQ; |
275 case kUnsignedLessThan: | 275 case kUnsignedLessThan: |
276 predicate = true; | 276 predicate = true; |
277 return OLT; | 277 return OLT; |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 __ Branch(USE_DELAY_SLOT, &done, cc, kCompareReg, Operand(zero_reg)); | 985 __ Branch(USE_DELAY_SLOT, &done, cc, kCompareReg, Operand(zero_reg)); |
986 __ li(result, Operand(1)); // In delay slot. | 986 __ li(result, Operand(1)); // In delay slot. |
987 | 987 |
988 } else if (instr->arch_opcode() == kMipsCmp) { | 988 } else if (instr->arch_opcode() == kMipsCmp) { |
989 Register left = i.InputRegister(0); | 989 Register left = i.InputRegister(0); |
990 Operand right = i.InputOperand(1); | 990 Operand right = i.InputOperand(1); |
991 cc = FlagsConditionToConditionCmp(condition); | 991 cc = FlagsConditionToConditionCmp(condition); |
992 __ Branch(USE_DELAY_SLOT, &done, cc, left, right); | 992 __ Branch(USE_DELAY_SLOT, &done, cc, left, right); |
993 __ li(result, Operand(1)); // In delay slot. | 993 __ li(result, Operand(1)); // In delay slot. |
994 | 994 |
995 } else if (instr->arch_opcode() == kMipsCmpD) { | 995 } else if (instr->arch_opcode() == kMipsCmpD || |
| 996 instr->arch_opcode() == kMipsCmpS) { |
996 FPURegister left = i.InputDoubleRegister(0); | 997 FPURegister left = i.InputDoubleRegister(0); |
997 FPURegister right = i.InputDoubleRegister(1); | 998 FPURegister right = i.InputDoubleRegister(1); |
998 | 999 |
999 bool predicate; | 1000 bool predicate; |
1000 FPUCondition cc = FlagsConditionToConditionCmpD(predicate, condition); | 1001 FPUCondition cc = FlagsConditionToConditionCmpFPU(predicate, condition); |
1001 if (!IsMipsArchVariant(kMips32r6)) { | 1002 if (!IsMipsArchVariant(kMips32r6)) { |
1002 __ li(result, Operand(1)); | 1003 __ li(result, Operand(1)); |
1003 __ c(cc, D, left, right); | 1004 if (instr->arch_opcode() == kMipsCmpD) { |
| 1005 __ c(cc, D, left, right); |
| 1006 } else { |
| 1007 DCHECK(instr->arch_opcode() == kMipsCmpS); |
| 1008 __ c(cc, S, left, right); |
| 1009 } |
1004 if (predicate) { | 1010 if (predicate) { |
1005 __ Movf(result, zero_reg); | 1011 __ Movf(result, zero_reg); |
1006 } else { | 1012 } else { |
1007 __ Movt(result, zero_reg); | 1013 __ Movt(result, zero_reg); |
1008 } | 1014 } |
1009 } else { | 1015 } else { |
1010 __ cmp(cc, L, kDoubleCompareReg, left, right); | 1016 if (instr->arch_opcode() == kMipsCmpD) { |
| 1017 __ cmp(cc, L, kDoubleCompareReg, left, right); |
| 1018 } else { |
| 1019 DCHECK(instr->arch_opcode() == kMipsCmpS); |
| 1020 __ cmp(cc, W, kDoubleCompareReg, left, right); |
| 1021 } |
1011 __ mfc1(at, kDoubleCompareReg); | 1022 __ mfc1(at, kDoubleCompareReg); |
1012 __ srl(result, at, 31); // Cmp returns all 1s for true. | 1023 __ srl(result, at, 31); // Cmp returns all 1s for true. |
1013 if (!predicate) // Toggle result for not equal. | 1024 if (!predicate) // Toggle result for not equal. |
1014 __ xori(result, result, 1); | 1025 __ xori(result, result, 1); |
1015 } | 1026 } |
1016 return; | 1027 return; |
1017 } else { | 1028 } else { |
1018 PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", | 1029 PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", |
1019 instr->arch_opcode()); | 1030 instr->arch_opcode()); |
1020 TRACE_UNIMPL(); | 1031 TRACE_UNIMPL(); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 } | 1383 } |
1373 } | 1384 } |
1374 } | 1385 } |
1375 } | 1386 } |
1376 | 1387 |
1377 #undef __ | 1388 #undef __ |
1378 | 1389 |
1379 } // namespace compiler | 1390 } // namespace compiler |
1380 } // namespace internal | 1391 } // namespace internal |
1381 } // namespace v8 | 1392 } // namespace v8 |
OLD | NEW |