| Index: src/mips64/macro-assembler-mips64.cc
|
| diff --git a/src/mips64/macro-assembler-mips64.cc b/src/mips64/macro-assembler-mips64.cc
|
| index d21e686115a05c9e692e04d0e174172b8b0a366c..72f2e16b75fae2a2975efeea385eb64fc2b603a5 100644
|
| --- a/src/mips64/macro-assembler-mips64.cc
|
| +++ b/src/mips64/macro-assembler-mips64.cc
|
| @@ -5022,153 +5022,194 @@ void MacroAssembler::SmiToDoubleFPURegister(Register smi,
|
| cvt_d_w(value, value);
|
| }
|
|
|
| +static inline void BranchOvfHelper(MacroAssembler* masm, Register overflow_dst,
|
| + Label* overflow_label,
|
| + Label* no_overflow_label) {
|
| + DCHECK(overflow_label || no_overflow_label);
|
| + if (!overflow_label) {
|
| + DCHECK(no_overflow_label);
|
| + masm->Branch(no_overflow_label, ge, overflow_dst, Operand(zero_reg));
|
| + } else {
|
| + masm->Branch(overflow_label, lt, overflow_dst, Operand(zero_reg));
|
| + if (no_overflow_label) masm->Branch(no_overflow_label);
|
| + }
|
| +}
|
|
|
| -void MacroAssembler::AdduAndCheckForOverflow(Register dst, Register left,
|
| - const Operand& right,
|
| - Register overflow_dst,
|
| - Register scratch) {
|
| +void MacroAssembler::AddBranchOvf(Register dst, Register left,
|
| + const Operand& right, Label* overflow_label,
|
| + Label* no_overflow_label, Register scratch) {
|
| if (right.is_reg()) {
|
| - AdduAndCheckForOverflow(dst, left, right.rm(), overflow_dst, scratch);
|
| + AddBranchOvf(dst, left, right.rm(), overflow_label, no_overflow_label,
|
| + scratch);
|
| } else {
|
| - if (dst.is(left)) {
|
| - li(t9, right); // Load right.
|
| - mov(scratch, left); // Preserve left.
|
| - addu(dst, left, t9); // Left is overwritten.
|
| - xor_(scratch, dst, scratch); // Original left.
|
| - xor_(overflow_dst, dst, t9);
|
| - and_(overflow_dst, overflow_dst, scratch);
|
| + if (kArchVariant == kMips64r6) {
|
| + Register right_reg = t9;
|
| + DCHECK(!left.is(right_reg));
|
| + li(right_reg, Operand(right));
|
| + AddBranchOvf(dst, left, right_reg, overflow_label, no_overflow_label);
|
| } else {
|
| - li(t9, right);
|
| - addu(dst, left, t9);
|
| - xor_(overflow_dst, dst, left);
|
| - xor_(scratch, dst, t9);
|
| - 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));
|
| + if (dst.is(left)) {
|
| + mov(scratch, left); // Preserve left.
|
| + // Left is overwritten.
|
| + Addu(dst, left, static_cast<int32_t>(right.immediate()));
|
| + 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, static_cast<int32_t>(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);
|
| + }
|
| + BranchOvfHelper(this, overflow_dst, overflow_label, no_overflow_label);
|
| }
|
| }
|
| }
|
|
|
| -
|
| -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::AddBranchOvf(Register dst, Register left, Register right,
|
| + Label* overflow_label,
|
| + Label* no_overflow_label, Register scratch) {
|
| + if (kArchVariant == kMips64r6) {
|
| + if (!overflow_label) {
|
| + DCHECK(no_overflow_label);
|
| + DCHECK(!dst.is(scratch));
|
| + 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));
|
| + DCHECK(!left.is(scratch));
|
| + DCHECK(!right.is(scratch));
|
|
|
| + if (left.is(right) && dst.is(left)) {
|
| + mov(overflow_dst, right);
|
| + right = overflow_dst;
|
| + }
|
|
|
| -void MacroAssembler::DadduAndCheckForOverflow(Register dst, Register left,
|
| - const Operand& right,
|
| - Register overflow_dst,
|
| - Register scratch) {
|
| - if (right.is_reg()) {
|
| - DadduAndCheckForOverflow(dst, left, right.rm(), overflow_dst, scratch);
|
| - } else {
|
| if (dst.is(left)) {
|
| - li(t9, right); // Load right.
|
| mov(scratch, left); // Preserve left.
|
| - daddu(dst, left, t9); // Left is overwritten.
|
| + addu(dst, left, right); // Left is overwritten.
|
| xor_(scratch, dst, scratch); // Original left.
|
| - xor_(overflow_dst, dst, t9);
|
| + 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 {
|
| - li(t9, right); // Load right.
|
| - Daddu(dst, left, t9);
|
| + addu(dst, left, right);
|
| xor_(overflow_dst, dst, left);
|
| - xor_(scratch, dst, t9);
|
| + xor_(scratch, dst, right);
|
| and_(overflow_dst, scratch, overflow_dst);
|
| }
|
| + BranchOvfHelper(this, overflow_dst, overflow_label, no_overflow_label);
|
| }
|
| }
|
|
|
| +void MacroAssembler::SubBranchOvf(Register dst, Register left,
|
| + const Operand& right, Label* overflow_label,
|
| + Label* no_overflow_label, Register scratch) {
|
| + DCHECK(overflow_label || no_overflow_label);
|
| + if (right.is_reg()) {
|
| + SubBranchOvf(dst, left, right.rm(), overflow_label, no_overflow_label,
|
| + scratch);
|
| + } else {
|
| + Register overflow_dst = t9;
|
| + DCHECK(!dst.is(scratch));
|
| + DCHECK(!dst.is(overflow_dst));
|
| + DCHECK(!scratch.is(overflow_dst));
|
| + DCHECK(!left.is(overflow_dst));
|
| + DCHECK(!left.is(scratch));
|
| + if (dst.is(left)) {
|
| + mov(scratch, left); // Preserve left.
|
| + // Left is overwritten.
|
| + Subu(dst, left, static_cast<int32_t>(right.immediate()));
|
| + // Load right since xori takes uint16 as immediate.
|
| + Addu(overflow_dst, zero_reg, right);
|
| + xor_(overflow_dst, scratch, overflow_dst); // scratch is original left.
|
| + xor_(scratch, dst, scratch); // scratch is original left.
|
| + and_(overflow_dst, scratch, overflow_dst);
|
| + } else {
|
| + Subu(dst, left, right);
|
| + xor_(overflow_dst, dst, left);
|
| + // Load right since xori takes uint16 as immediate.
|
| + Addu(scratch, zero_reg, right);
|
| + xor_(scratch, left, scratch);
|
| + and_(overflow_dst, scratch, overflow_dst);
|
| + }
|
| + BranchOvfHelper(this, overflow_dst, overflow_label, no_overflow_label);
|
| + }
|
| +}
|
|
|
| -void MacroAssembler::DadduAndCheckForOverflow(Register dst, Register left,
|
| - Register right,
|
| - Register overflow_dst,
|
| - Register scratch) {
|
| - DCHECK(!dst.is(overflow_dst));
|
| +void MacroAssembler::SubBranchOvf(Register dst, Register left, Register right,
|
| + Label* overflow_label,
|
| + Label* no_overflow_label, Register scratch) {
|
| + DCHECK(overflow_label || no_overflow_label);
|
| + Register overflow_dst = t9;
|
| DCHECK(!dst.is(scratch));
|
| - DCHECK(!overflow_dst.is(scratch));
|
| + DCHECK(!dst.is(overflow_dst));
|
| + DCHECK(!scratch.is(overflow_dst));
|
| DCHECK(!overflow_dst.is(left));
|
| DCHECK(!overflow_dst.is(right));
|
| + DCHECK(!scratch.is(left));
|
| + DCHECK(!scratch.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;
|
| + // This happens with some crankshaft code. Since Subu works fine if
|
| + // left == right, let's not make that restriction here.
|
| + if (left.is(right)) {
|
| + mov(dst, zero_reg);
|
| + if (no_overflow_label) {
|
| + Branch(no_overflow_label);
|
| + }
|
| }
|
|
|
| if (dst.is(left)) {
|
| mov(scratch, left); // Preserve left.
|
| - daddu(dst, left, right); // Left is overwritten.
|
| - xor_(scratch, dst, scratch); // Original left.
|
| - xor_(overflow_dst, dst, right);
|
| - and_(overflow_dst, overflow_dst, scratch);
|
| + subu(dst, left, right); // Left is overwritten.
|
| + xor_(overflow_dst, dst, scratch); // scratch is original left.
|
| + xor_(scratch, scratch, right); // scratch is original left.
|
| + and_(overflow_dst, scratch, overflow_dst);
|
| } else if (dst.is(right)) {
|
| mov(scratch, right); // Preserve right.
|
| - daddu(dst, left, right); // Right is overwritten.
|
| - xor_(scratch, dst, scratch); // Original right.
|
| + subu(dst, left, right); // Right is overwritten.
|
| xor_(overflow_dst, dst, left);
|
| - and_(overflow_dst, overflow_dst, scratch);
|
| + xor_(scratch, left, scratch); // Original right.
|
| + and_(overflow_dst, scratch, overflow_dst);
|
| } else {
|
| - daddu(dst, left, right);
|
| + subu(dst, left, right);
|
| xor_(overflow_dst, dst, left);
|
| - xor_(scratch, dst, right);
|
| + xor_(scratch, left, right);
|
| and_(overflow_dst, scratch, overflow_dst);
|
| }
|
| + BranchOvfHelper(this, overflow_dst, overflow_label, no_overflow_label);
|
| }
|
|
|
| -
|
| -static inline void BranchOvfHelper(MacroAssembler* masm, Register overflow_dst,
|
| - Label* overflow_label,
|
| - Label* no_overflow_label) {
|
| - DCHECK(overflow_label || no_overflow_label);
|
| - if (!overflow_label) {
|
| - DCHECK(no_overflow_label);
|
| - masm->Branch(no_overflow_label, ge, overflow_dst, Operand(zero_reg));
|
| - } else {
|
| - masm->Branch(overflow_label, lt, overflow_dst, Operand(zero_reg));
|
| - if (no_overflow_label) masm->Branch(no_overflow_label);
|
| - }
|
| -}
|
| -
|
| -
|
| void MacroAssembler::DaddBranchOvf(Register dst, Register left,
|
| const Operand& right, Label* overflow_label,
|
| Label* no_overflow_label, Register scratch) {
|
| @@ -5238,138 +5279,6 @@ void MacroAssembler::DaddBranchOvf(Register dst, Register left, Register right,
|
| }
|
|
|
|
|
| -void MacroAssembler::SubuAndCheckForOverflow(Register dst, Register left,
|
| - const Operand& right,
|
| - Register overflow_dst,
|
| - Register scratch) {
|
| - if (right.is_reg()) {
|
| - SubuAndCheckForOverflow(dst, left, right.rm(), overflow_dst, scratch);
|
| - } else {
|
| - if (dst.is(left)) {
|
| - li(t9, right); // Load right.
|
| - mov(scratch, left); // Preserve left.
|
| - Subu(dst, left, t9); // Left is overwritten.
|
| - xor_(overflow_dst, dst, scratch); // scratch is original left.
|
| - xor_(scratch, scratch, t9); // scratch is original left.
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - } else {
|
| - li(t9, right);
|
| - subu(dst, left, t9);
|
| - xor_(overflow_dst, dst, left);
|
| - xor_(scratch, left, t9);
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - }
|
| - }
|
| -}
|
| -
|
| -
|
| -void MacroAssembler::SubuAndCheckForOverflow(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));
|
| - DCHECK(!scratch.is(left));
|
| - DCHECK(!scratch.is(right));
|
| -
|
| - // This happens with some crankshaft code. Since Subu works fine if
|
| - // left == right, let's not make that restriction here.
|
| - if (left.is(right)) {
|
| - mov(dst, zero_reg);
|
| - mov(overflow_dst, zero_reg);
|
| - return;
|
| - }
|
| -
|
| - if (dst.is(left)) {
|
| - mov(scratch, left); // Preserve left.
|
| - subu(dst, left, right); // Left is overwritten.
|
| - xor_(overflow_dst, dst, scratch); // scratch is original left.
|
| - xor_(scratch, scratch, right); // scratch is original left.
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - } else if (dst.is(right)) {
|
| - mov(scratch, right); // Preserve right.
|
| - subu(dst, left, right); // Right is overwritten.
|
| - xor_(overflow_dst, dst, left);
|
| - xor_(scratch, left, scratch); // Original right.
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - } else {
|
| - subu(dst, left, right);
|
| - xor_(overflow_dst, dst, left);
|
| - xor_(scratch, left, right);
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - }
|
| -}
|
| -
|
| -
|
| -void MacroAssembler::DsubuAndCheckForOverflow(Register dst, Register left,
|
| - const Operand& right,
|
| - Register overflow_dst,
|
| - Register scratch) {
|
| - if (right.is_reg()) {
|
| - DsubuAndCheckForOverflow(dst, left, right.rm(), overflow_dst, scratch);
|
| - } else {
|
| - if (dst.is(left)) {
|
| - li(t9, right); // Load right.
|
| - mov(scratch, left); // Preserve left.
|
| - dsubu(dst, left, t9); // Left is overwritten.
|
| - xor_(overflow_dst, dst, scratch); // scratch is original left.
|
| - xor_(scratch, scratch, t9); // scratch is original left.
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - } else {
|
| - li(t9, right);
|
| - dsubu(dst, left, t9);
|
| - xor_(overflow_dst, dst, left);
|
| - xor_(scratch, left, t9);
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - }
|
| - }
|
| -}
|
| -
|
| -
|
| -void MacroAssembler::DsubuAndCheckForOverflow(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));
|
| - DCHECK(!scratch.is(left));
|
| - DCHECK(!scratch.is(right));
|
| -
|
| - // This happens with some crankshaft code. Since Subu works fine if
|
| - // left == right, let's not make that restriction here.
|
| - if (left.is(right)) {
|
| - mov(dst, zero_reg);
|
| - mov(overflow_dst, zero_reg);
|
| - return;
|
| - }
|
| -
|
| - if (dst.is(left)) {
|
| - mov(scratch, left); // Preserve left.
|
| - dsubu(dst, left, right); // Left is overwritten.
|
| - xor_(overflow_dst, dst, scratch); // scratch is original left.
|
| - xor_(scratch, scratch, right); // scratch is original left.
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - } else if (dst.is(right)) {
|
| - mov(scratch, right); // Preserve right.
|
| - dsubu(dst, left, right); // Right is overwritten.
|
| - xor_(overflow_dst, dst, left);
|
| - xor_(scratch, left, scratch); // Original right.
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - } else {
|
| - dsubu(dst, left, right);
|
| - xor_(overflow_dst, dst, left);
|
| - xor_(scratch, left, right);
|
| - and_(overflow_dst, scratch, overflow_dst);
|
| - }
|
| -}
|
| -
|
| -
|
| void MacroAssembler::DsubBranchOvf(Register dst, Register left,
|
| const Operand& right, Label* overflow_label,
|
| Label* no_overflow_label, Register scratch) {
|
|
|