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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 __ CheckPageFlag(object, scratch0, | 577 __ CheckPageFlag(object, scratch0, |
578 MemoryChunk::kPointersFromHereAreInterestingMask, ne, | 578 MemoryChunk::kPointersFromHereAreInterestingMask, ne, |
579 ool->entry()); | 579 ool->entry()); |
580 __ bind(ool->exit()); | 580 __ bind(ool->exit()); |
581 break; | 581 break; |
582 } | 582 } |
583 case kMipsAdd: | 583 case kMipsAdd: |
584 __ Addu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); | 584 __ Addu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); |
585 break; | 585 break; |
586 case kMipsAddOvf: | 586 case kMipsAddOvf: |
587 __ AdduAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), | 587 // Noop, AdduAndCheckForOverflow() executed at branch/result processing. |
paul.l...
2015/11/13 02:16:20
Other similar opcodes use:
// Pseudo-instruction u
balazs.kilvady
2015/11/20 19:28:08
Done.
| |
588 i.InputOperand(1), kCompareReg, kScratchReg); | |
589 break; | 588 break; |
590 case kMipsSub: | 589 case kMipsSub: |
591 __ Subu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); | 590 __ Subu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); |
592 break; | 591 break; |
593 case kMipsSubOvf: | 592 case kMipsSubOvf: |
594 __ SubuAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), | 593 __ SubuAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), |
595 i.InputOperand(1), kCompareReg, kScratchReg); | 594 i.InputOperand(1), kCompareReg, kScratchReg); |
596 break; | 595 break; |
597 case kMipsMul: | 596 case kMipsMul: |
598 __ Mul(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); | 597 __ Mul(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1029 // implemented differently than on the other arch's. The compare operations | 1028 // implemented differently than on the other arch's. The compare operations |
1030 // emit mips pseudo-instructions, which are handled here by branch | 1029 // emit mips pseudo-instructions, which are handled here by branch |
1031 // instructions that do the actual comparison. Essential that the input | 1030 // instructions that do the actual comparison. Essential that the input |
1032 // registers to compare pseudo-op are not modified before this branch op, as | 1031 // registers to compare pseudo-op are not modified before this branch op, as |
1033 // they are tested here. | 1032 // they are tested here. |
1034 | 1033 |
1035 if (instr->arch_opcode() == kMipsTst) { | 1034 if (instr->arch_opcode() == kMipsTst) { |
1036 cc = FlagsConditionToConditionTst(branch->condition); | 1035 cc = FlagsConditionToConditionTst(branch->condition); |
1037 __ And(at, i.InputRegister(0), i.InputOperand(1)); | 1036 __ And(at, i.InputRegister(0), i.InputOperand(1)); |
1038 __ Branch(tlabel, cc, at, Operand(zero_reg)); | 1037 __ Branch(tlabel, cc, at, Operand(zero_reg)); |
1039 } else if (instr->arch_opcode() == kMipsAddOvf || | 1038 } else if (instr->arch_opcode() == kMipsAddOvf) { |
1040 instr->arch_opcode() == kMipsSubOvf) { | 1039 switch (branch->condition) { |
1041 // kMipsAddOvf, SubOvf emit negative result to 'kCompareReg' on overflow. | 1040 case kOverflow: |
1041 __ AdduAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), | |
1042 i.InputOperand(1), tlabel, flabel); | |
1043 break; | |
1044 case kNotOverflow: | |
1045 __ AdduAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), | |
1046 i.InputOperand(1), flabel, tlabel); | |
1047 break; | |
1048 default: | |
1049 UNSUPPORTED_COND(kMipsAddOvf, branch->condition); | |
1050 break; | |
1051 } | |
1052 } else if (instr->arch_opcode() == kMipsSubOvf) { | |
1053 // kMipsSubOvf emit negative result to 'kCompareReg' on overflow. | |
1042 cc = FlagsConditionToConditionOvf(branch->condition); | 1054 cc = FlagsConditionToConditionOvf(branch->condition); |
1043 __ Branch(tlabel, cc, kCompareReg, Operand(zero_reg)); | 1055 __ Branch(tlabel, cc, kCompareReg, Operand(zero_reg)); |
1044 } else if (instr->arch_opcode() == kMipsCmp) { | 1056 } else if (instr->arch_opcode() == kMipsCmp) { |
1045 cc = FlagsConditionToConditionCmp(branch->condition); | 1057 cc = FlagsConditionToConditionCmp(branch->condition); |
1046 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); | 1058 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); |
1047 } else if (instr->arch_opcode() == kMipsCmpS) { | 1059 } else if (instr->arch_opcode() == kMipsCmpS) { |
1048 if (!convertCondition(branch->condition, cc)) { | 1060 if (!convertCondition(branch->condition, cc)) { |
1049 UNSUPPORTED_COND(kMips64CmpS, branch->condition); | 1061 UNSUPPORTED_COND(kMips64CmpS, branch->condition); |
1050 } | 1062 } |
1051 FPURegister left = i.InputOrZeroSingleRegister(0); | 1063 FPURegister left = i.InputOrZeroSingleRegister(0); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1098 | 1110 |
1099 if (instr->arch_opcode() == kMipsTst) { | 1111 if (instr->arch_opcode() == kMipsTst) { |
1100 cc = FlagsConditionToConditionTst(condition); | 1112 cc = FlagsConditionToConditionTst(condition); |
1101 __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1)); | 1113 __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1)); |
1102 __ Sltu(result, zero_reg, kScratchReg); | 1114 __ Sltu(result, zero_reg, kScratchReg); |
1103 if (cc == eq) { | 1115 if (cc == eq) { |
1104 // Sltu produces 0 for equality, invert the result. | 1116 // Sltu produces 0 for equality, invert the result. |
1105 __ xori(result, result, 1); | 1117 __ xori(result, result, 1); |
1106 } | 1118 } |
1107 return; | 1119 return; |
1108 } else if (instr->arch_opcode() == kMipsAddOvf || | 1120 } else if (instr->arch_opcode() == kMipsAddOvf) { |
1109 instr->arch_opcode() == kMipsSubOvf) { | 1121 Label flabel, tlabel; |
1122 __ AdduAndCheckForOverflow(i.OutputRegister(), i.InputRegister(0), | |
1123 i.InputOperand(1), nullptr, &flabel); | |
1124 __ li(result, 1); | |
Alan Li
2015/11/20 01:28:39
So I guess another very easy way to detect unsigne
balazs.kilvady
2015/11/20 19:28:08
i.OutputRegister() is never (unsigned) less then i
| |
1125 __ Branch(&tlabel); | |
1126 __ bind(&flabel); | |
1127 __ li(result, 0); | |
1128 __ bind(&tlabel); | |
1129 } else if (instr->arch_opcode() == kMipsSubOvf) { | |
1110 // kMipsAddOvf, SubOvf emits negative result to 'kCompareReg' on overflow. | 1130 // kMipsAddOvf, SubOvf emits negative result to 'kCompareReg' on overflow. |
1111 cc = FlagsConditionToConditionOvf(condition); | 1131 cc = FlagsConditionToConditionOvf(condition); |
1112 // Return 1 on overflow. | 1132 // Return 1 on overflow. |
1113 __ Slt(result, kCompareReg, Operand(zero_reg)); | 1133 __ Slt(result, kCompareReg, Operand(zero_reg)); |
1114 if (cc == ge) // Invert result on not overflow. | 1134 if (cc == ge) // Invert result on not overflow. |
1115 __ xori(result, result, 1); | 1135 __ xori(result, result, 1); |
1116 return; | 1136 return; |
1117 } else if (instr->arch_opcode() == kMipsCmp) { | 1137 } else if (instr->arch_opcode() == kMipsCmp) { |
1118 cc = FlagsConditionToConditionCmp(condition); | 1138 cc = FlagsConditionToConditionCmp(condition); |
1119 switch (cc) { | 1139 switch (cc) { |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1564 padding_size -= v8::internal::Assembler::kInstrSize; | 1584 padding_size -= v8::internal::Assembler::kInstrSize; |
1565 } | 1585 } |
1566 } | 1586 } |
1567 } | 1587 } |
1568 | 1588 |
1569 #undef __ | 1589 #undef __ |
1570 | 1590 |
1571 } // namespace compiler | 1591 } // namespace compiler |
1572 } // namespace internal | 1592 } // namespace internal |
1573 } // namespace v8 | 1593 } // namespace v8 |
OLD | NEW |