Index: src/mips/macro-assembler-mips.cc |
diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc |
index 14d8ed8e1e024289391ec97f4d0ad98ab8e96072..9b64fd8facbe6c588bb913c51abb46fdcca4e9bc 100644 |
--- a/src/mips/macro-assembler-mips.cc |
+++ b/src/mips/macro-assembler-mips.cc |
@@ -4297,70 +4297,104 @@ void MacroAssembler::SmiToDoubleFPURegister(Register smi, |
} |
-void MacroAssembler::AdduAndCheckForOverflow(Register dst, Register left, |
- const Operand& right, |
- Register overflow_dst, |
- Register scratch) { |
+void MacroAssembler::AdduAndCheckForOverflow( |
+ Register dst, Register left, const Operand& right, Label* overflow_label, |
+ Label* no_overflow_label, Register scratch, BranchDelaySlot bd) { |
+ DCHECK(overflow_label || no_overflow_label); |
if (right.is_reg()) { |
- AdduAndCheckForOverflow(dst, left, right.rm(), overflow_dst, scratch); |
+ AdduAndCheckForOverflow(dst, left, right.rm(), overflow_label, |
+ no_overflow_label, scratch, bd); |
} else { |
- if (dst.is(left)) { |
- mov(scratch, left); // Preserve left. |
- Addu(dst, left, right.immediate()); // Left is overwritten. |
- xor_(scratch, dst, scratch); // Original left. |
- // Load right since xori takes uint16 as immediate. |
- Addu(t9, zero_reg, right); |
- xor_(overflow_dst, dst, t9); |
- and_(overflow_dst, overflow_dst, scratch); |
+ if (IsMipsArchVariant(kMips32r6)) { |
+ DCHECK(!left.is(t9)); |
+ Register right_reg = t9; |
+ li(right_reg, Operand(right)); |
+ AdduAndCheckForOverflow(dst, left, right_reg, overflow_label, |
+ no_overflow_label); |
} else { |
- Addu(dst, left, right.immediate()); |
- xor_(overflow_dst, dst, left); |
- // Load right since xori takes uint16 as immediate. |
- Addu(t9, zero_reg, right); |
- xor_(scratch, dst, t9); |
- and_(overflow_dst, scratch, overflow_dst); |
+ Register overflow_dst = t9; |
+ if (dst.is(left)) { |
+ mov(scratch, left); // Preserve left. |
+ Addu(dst, left, right.immediate()); // Left is overwritten. |
+ xor_(scratch, dst, scratch); // Original left. |
+ // Load right since xori takes uint16 as immediate. |
+ Addu(overflow_dst, zero_reg, right); |
+ xor_(overflow_dst, dst, overflow_dst); |
+ and_(overflow_dst, overflow_dst, scratch); |
+ } else { |
+ Addu(dst, left, right.immediate()); |
+ xor_(overflow_dst, dst, left); |
+ // Load right since xori takes uint16 as immediate. |
+ Addu(scratch, zero_reg, right); |
+ xor_(scratch, dst, scratch); |
+ and_(overflow_dst, scratch, overflow_dst); |
+ } |
+ Branch(overflow_label, lt, overflow_dst, Operand(zero_reg)); |
+ if (no_overflow_label) bc(no_overflow_label); |
paul.l...
2015/11/13 02:16:20
This is not r6, you cannot use 'bc' here can you?
|
} |
} |
} |
-void MacroAssembler::AdduAndCheckForOverflow(Register dst, Register left, |
- Register right, |
- Register overflow_dst, |
- Register scratch) { |
- DCHECK(!dst.is(overflow_dst)); |
- DCHECK(!dst.is(scratch)); |
- DCHECK(!overflow_dst.is(scratch)); |
- DCHECK(!overflow_dst.is(left)); |
- DCHECK(!overflow_dst.is(right)); |
- |
- if (left.is(right) && dst.is(left)) { |
- DCHECK(!dst.is(t9)); |
- DCHECK(!scratch.is(t9)); |
- DCHECK(!left.is(t9)); |
- DCHECK(!right.is(t9)); |
- DCHECK(!overflow_dst.is(t9)); |
- mov(t9, right); |
- right = t9; |
- } |
- |
- if (dst.is(left)) { |
- mov(scratch, left); // Preserve left. |
- addu(dst, left, right); // Left is overwritten. |
- xor_(scratch, dst, scratch); // Original left. |
- xor_(overflow_dst, dst, right); |
- and_(overflow_dst, overflow_dst, scratch); |
- } else if (dst.is(right)) { |
- mov(scratch, right); // Preserve right. |
- addu(dst, left, right); // Right is overwritten. |
- xor_(scratch, dst, scratch); // Original right. |
- xor_(overflow_dst, dst, left); |
- and_(overflow_dst, overflow_dst, scratch); |
+void MacroAssembler::AdduAndCheckForOverflow( |
+ Register dst, Register left, Register right, Label* overflow_label, |
+ Label* no_overflow_label, Register scratch, BranchDelaySlot bd) { |
+ if (IsMipsArchVariant(kMips32r6)) { |
+ if (!overflow_label) { |
+ DCHECK(no_overflow_label); |
+ DCHECK(!dst.is(scratch)); |
+ DCHECK(!dst.is(t9)); |
+ Register left_reg = left.is(dst) ? scratch : left; |
+ Register right_reg = right.is(dst) ? t9 : right; |
+ DCHECK(!dst.is(left_reg)); |
+ DCHECK(!dst.is(right_reg)); |
+ Move(left_reg, left); |
+ Move(right_reg, right); |
+ addu(dst, left, right); |
+ bnvc(left_reg, right_reg, no_overflow_label); |
+ } else { |
+ bovc(left, right, overflow_label); |
+ addu(dst, left, right); |
+ if (no_overflow_label) bc(no_overflow_label); |
+ } |
} else { |
- addu(dst, left, right); |
- xor_(overflow_dst, dst, left); |
- xor_(scratch, dst, right); |
- and_(overflow_dst, scratch, overflow_dst); |
+ Register overflow_dst = t9; |
+ DCHECK(!dst.is(scratch)); |
+ DCHECK(!dst.is(overflow_dst)); |
+ DCHECK(!scratch.is(overflow_dst)); |
+ DCHECK(!left.is(overflow_dst)); |
+ DCHECK(!right.is(overflow_dst)); |
+ |
+ if (left.is(right) && dst.is(left)) { |
+ mov(overflow_dst, right); |
+ right = overflow_dst; |
+ } |
+ |
+ if (dst.is(left)) { |
+ mov(scratch, left); // Preserve left. |
+ addu(dst, left, right); // Left is overwritten. |
+ xor_(scratch, dst, scratch); // Original left. |
+ xor_(overflow_dst, dst, right); |
+ and_(overflow_dst, overflow_dst, scratch); |
+ } else if (dst.is(right)) { |
+ mov(scratch, right); // Preserve right. |
+ addu(dst, left, right); // Right is overwritten. |
+ xor_(scratch, dst, scratch); // Original right. |
+ xor_(overflow_dst, dst, left); |
+ and_(overflow_dst, overflow_dst, scratch); |
+ } else { |
+ addu(dst, left, right); |
+ xor_(overflow_dst, dst, left); |
+ xor_(scratch, dst, right); |
+ and_(overflow_dst, scratch, overflow_dst); |
+ } |
+ if (!overflow_label) { |
+ DCHECK(no_overflow_label); |
+ Branch(no_overflow_label, ge, overflow_dst, Operand(zero_reg)); |
+ } else { |
+ Branch(overflow_label, lt, overflow_dst, Operand(zero_reg)); |
+ if (no_overflow_label) bc(no_overflow_label); |
+ } |
} |
} |