| 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 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 DCHECK_NE(0u, instr->OutputCount()); | 1039 DCHECK_NE(0u, instr->OutputCount()); |
| 1040 Register result = i.OutputRegister(instr->OutputCount() - 1); | 1040 Register result = i.OutputRegister(instr->OutputCount() - 1); |
| 1041 Condition cc = kNoCondition; | 1041 Condition cc = kNoCondition; |
| 1042 // MIPS does not have condition code flags, so compare and branch are | 1042 // MIPS does not have condition code flags, so compare and branch are |
| 1043 // implemented differently than on the other arch's. The compare operations | 1043 // implemented differently than on the other arch's. The compare operations |
| 1044 // emit mips pseudo-instructions, which are checked and handled here. | 1044 // emit mips pseudo-instructions, which are checked and handled here. |
| 1045 | 1045 |
| 1046 if (instr->arch_opcode() == kMips64Tst) { | 1046 if (instr->arch_opcode() == kMips64Tst) { |
| 1047 cc = FlagsConditionToConditionTst(condition); | 1047 cc = FlagsConditionToConditionTst(condition); |
| 1048 __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1)); | 1048 __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1)); |
| 1049 __ xori(result, zero_reg, 1); // Create 1 for true. | 1049 __ Sltu(result, zero_reg, kScratchReg); |
| 1050 if (kArchVariant == kMips64r6) { | 1050 if (cc == eq) { |
| 1051 if (cc == eq) { | 1051 // Sltu produces 0 for equality, invert the result. |
| 1052 __ seleqz(result, result, kScratchReg); | 1052 __ xori(result, result, 1); |
| 1053 } else { | |
| 1054 __ selnez(result, result, kScratchReg); | |
| 1055 } | |
| 1056 } else { | |
| 1057 if (cc == eq) { | |
| 1058 __ Movn(result, zero_reg, kScratchReg); | |
| 1059 } else { | |
| 1060 __ Movz(result, zero_reg, kScratchReg); | |
| 1061 } | |
| 1062 } | 1053 } |
| 1063 return; | 1054 return; |
| 1064 } else if (instr->arch_opcode() == kMips64Dadd || | 1055 } else if (instr->arch_opcode() == kMips64Dadd || |
| 1065 instr->arch_opcode() == kMips64Dsub) { | 1056 instr->arch_opcode() == kMips64Dsub) { |
| 1066 cc = FlagsConditionToConditionOvf(condition); | 1057 cc = FlagsConditionToConditionOvf(condition); |
| 1067 // Check for overflow creates 1 or 0 for result. | 1058 // Check for overflow creates 1 or 0 for result. |
| 1068 __ dsrl32(kScratchReg, i.OutputRegister(), 31); | 1059 __ dsrl32(kScratchReg, i.OutputRegister(), 31); |
| 1069 __ srl(at, i.OutputRegister(), 31); | 1060 __ srl(at, i.OutputRegister(), 31); |
| 1070 __ xor_(result, kScratchReg, at); | 1061 __ xor_(result, kScratchReg, at); |
| 1071 if (cc == eq) // Toggle result for not overflow. | 1062 if (cc == eq) // Toggle result for not overflow. |
| 1072 __ xori(result, result, 1); | 1063 __ xori(result, result, 1); |
| 1073 return; | 1064 return; |
| 1074 } else if (instr->arch_opcode() == kMips64Cmp) { | 1065 } else if (instr->arch_opcode() == kMips64Cmp) { |
| 1075 cc = FlagsConditionToConditionCmp(condition); | 1066 cc = FlagsConditionToConditionCmp(condition); |
| 1076 switch (cc) { | 1067 switch (cc) { |
| 1077 case eq: | 1068 case eq: |
| 1078 case ne: { | 1069 case ne: { |
| 1079 Register left = i.InputRegister(0); | 1070 Register left = i.InputRegister(0); |
| 1080 Operand right = i.InputOperand(1); | 1071 Operand right = i.InputOperand(1); |
| 1081 __ Dsubu(kScratchReg, left, right); | 1072 Register select; |
| 1082 __ xori(result, zero_reg, 1); | 1073 if (instr->InputAt(1)->IsImmediate() && right.immediate() == 0) { |
| 1083 if (kArchVariant == kMips64r6) { | 1074 // Pass left operand if right is zero. |
| 1084 if (cc == eq) { | 1075 select = left; |
| 1085 __ seleqz(result, result, kScratchReg); | |
| 1086 } else { | |
| 1087 __ selnez(result, result, kScratchReg); | |
| 1088 } | |
| 1089 } else { | 1076 } else { |
| 1090 if (cc == eq) { | 1077 __ Dsubu(kScratchReg, left, right); |
| 1091 __ Movn(result, zero_reg, kScratchReg); | 1078 select = kScratchReg; |
| 1092 } else { | 1079 } |
| 1093 __ Movz(result, zero_reg, kScratchReg); | 1080 __ Sltu(result, zero_reg, select); |
| 1094 } | 1081 if (cc == eq) { |
| 1082 // Sltu produces 0 for equality, invert the result. |
| 1083 __ xori(result, result, 1); |
| 1095 } | 1084 } |
| 1096 } break; | 1085 } break; |
| 1097 case lt: | 1086 case lt: |
| 1098 case ge: { | 1087 case ge: { |
| 1099 Register left = i.InputRegister(0); | 1088 Register left = i.InputRegister(0); |
| 1100 Operand right = i.InputOperand(1); | 1089 Operand right = i.InputOperand(1); |
| 1101 __ Slt(result, left, right); | 1090 __ Slt(result, left, right); |
| 1102 if (cc == ge) { | 1091 if (cc == ge) { |
| 1103 __ xori(result, result, 1); | 1092 __ xori(result, result, 1); |
| 1104 } | 1093 } |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 padding_size -= v8::internal::Assembler::kInstrSize; | 1510 padding_size -= v8::internal::Assembler::kInstrSize; |
| 1522 } | 1511 } |
| 1523 } | 1512 } |
| 1524 } | 1513 } |
| 1525 | 1514 |
| 1526 #undef __ | 1515 #undef __ |
| 1527 | 1516 |
| 1528 } // namespace compiler | 1517 } // namespace compiler |
| 1529 } // namespace internal | 1518 } // namespace internal |
| 1530 } // namespace v8 | 1519 } // namespace v8 |
| OLD | NEW |