зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1272939 - IonMonkey: MIPS: Refactor MacroAssembler::convertFloat32/DoubleToInt32. r=arai
--- js/src/jit/mips32/MacroAssembler-mips32.cpp | 34 ++++++++++------------------- js/src/jit/mips64/MacroAssembler-mips64.cpp | 33 ++++++++++------------------ 2 files changed, 23 insertions(+), 44 deletions(-)
This commit is contained in:
Родитель
05d76a6ef9
Коммит
c66e207696
|
@ -120,23 +120,19 @@ void
|
|||
MacroAssemblerMIPSCompat::convertDoubleToInt32(FloatRegister src, Register dest,
|
||||
Label* fail, bool negativeZeroCheck)
|
||||
{
|
||||
if (negativeZeroCheck) {
|
||||
moveFromDoubleHi(src, dest);
|
||||
moveFromDoubleLo(src, ScratchRegister);
|
||||
as_movn(dest, zero, ScratchRegister);
|
||||
ma_b(dest, Imm32(INT32_MIN), fail, Assembler::Equal);
|
||||
}
|
||||
|
||||
// Convert double to int, then convert back and check if we have the
|
||||
// same number.
|
||||
as_cvtwd(ScratchDoubleReg, src);
|
||||
as_mfc1(dest, ScratchDoubleReg);
|
||||
as_cvtdw(ScratchDoubleReg, ScratchDoubleReg);
|
||||
ma_bc1d(src, ScratchDoubleReg, fail, Assembler::DoubleNotEqualOrUnordered);
|
||||
|
||||
if (negativeZeroCheck) {
|
||||
Label notZero;
|
||||
ma_b(dest, Imm32(0), ¬Zero, Assembler::NotEqual, ShortJump);
|
||||
// Test and bail for -0.0, when integer result is 0
|
||||
// Move the top word of the double into the output reg, if it is
|
||||
// non-zero, then the original value was -0.0
|
||||
moveFromDoubleHi(src, dest);
|
||||
ma_b(dest, Imm32(INT32_MIN), fail, Assembler::Equal);
|
||||
bind(¬Zero);
|
||||
}
|
||||
}
|
||||
|
||||
// Checks whether a float32 is representable as a 32-bit integer. If so, the
|
||||
|
@ -146,6 +142,11 @@ void
|
|||
MacroAssemblerMIPSCompat::convertFloat32ToInt32(FloatRegister src, Register dest,
|
||||
Label* fail, bool negativeZeroCheck)
|
||||
{
|
||||
if (negativeZeroCheck) {
|
||||
moveFromFloat32(src, dest);
|
||||
ma_b(dest, Imm32(INT32_MIN), fail, Assembler::Equal);
|
||||
}
|
||||
|
||||
// Converting the floating point value to an integer and then converting it
|
||||
// back to a float32 would not work, as float to int32 conversions are
|
||||
// clamping (e.g. float(INT32_MAX + 1) would get converted into INT32_MAX
|
||||
|
@ -158,17 +159,6 @@ MacroAssemblerMIPSCompat::convertFloat32ToInt32(FloatRegister src, Register dest
|
|||
|
||||
// Bail out in the clamped cases.
|
||||
ma_b(dest, Imm32(INT32_MAX), fail, Assembler::Equal);
|
||||
|
||||
if (negativeZeroCheck) {
|
||||
Label notZero;
|
||||
ma_b(dest, Imm32(0), ¬Zero, Assembler::NotEqual, ShortJump);
|
||||
// Test and bail for -0.0, when integer result is 0
|
||||
// Move the top word of the double into the output reg,
|
||||
// if it is non-zero, then the original value was -0.0
|
||||
moveFromDoubleHi(src, dest);
|
||||
ma_b(dest, Imm32(INT32_MIN), fail, Assembler::Equal);
|
||||
bind(¬Zero);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -129,23 +129,18 @@ void
|
|||
MacroAssemblerMIPS64Compat::convertDoubleToInt32(FloatRegister src, Register dest,
|
||||
Label* fail, bool negativeZeroCheck)
|
||||
{
|
||||
if (negativeZeroCheck) {
|
||||
moveFromDouble(src, dest);
|
||||
ma_drol(dest, dest, Imm32(1));
|
||||
ma_b(dest, Imm32(1), fail, Assembler::Equal);
|
||||
}
|
||||
|
||||
// Convert double to int, then convert back and check if we have the
|
||||
// same number.
|
||||
as_cvtwd(ScratchDoubleReg, src);
|
||||
as_mfc1(dest, ScratchDoubleReg);
|
||||
as_cvtdw(ScratchDoubleReg, ScratchDoubleReg);
|
||||
ma_bc1d(src, ScratchDoubleReg, fail, Assembler::DoubleNotEqualOrUnordered);
|
||||
|
||||
if (negativeZeroCheck) {
|
||||
Label notZero;
|
||||
ma_b(dest, Imm32(0), ¬Zero, Assembler::NotEqual, ShortJump);
|
||||
// Test and bail for -0.0, when integer result is 0
|
||||
// Move the top word of the double into the output reg, if it is
|
||||
// non-zero, then the original value was -0.0
|
||||
moveFromDoubleHi(src, dest);
|
||||
ma_b(dest, Imm32(INT32_MIN), fail, Assembler::Equal);
|
||||
bind(¬Zero);
|
||||
}
|
||||
}
|
||||
|
||||
// Checks whether a float32 is representable as a 32-bit integer. If so, the
|
||||
|
@ -155,6 +150,11 @@ void
|
|||
MacroAssemblerMIPS64Compat::convertFloat32ToInt32(FloatRegister src, Register dest,
|
||||
Label* fail, bool negativeZeroCheck)
|
||||
{
|
||||
if (negativeZeroCheck) {
|
||||
moveFromFloat32(src, dest);
|
||||
ma_b(dest, Imm32(INT32_MIN), fail, Assembler::Equal);
|
||||
}
|
||||
|
||||
// Converting the floating point value to an integer and then converting it
|
||||
// back to a float32 would not work, as float to int32 conversions are
|
||||
// clamping (e.g. float(INT32_MAX + 1) would get converted into INT32_MAX
|
||||
|
@ -167,17 +167,6 @@ MacroAssemblerMIPS64Compat::convertFloat32ToInt32(FloatRegister src, Register de
|
|||
|
||||
// Bail out in the clamped cases.
|
||||
ma_b(dest, Imm32(INT32_MAX), fail, Assembler::Equal);
|
||||
|
||||
if (negativeZeroCheck) {
|
||||
Label notZero;
|
||||
ma_b(dest, Imm32(0), ¬Zero, Assembler::NotEqual, ShortJump);
|
||||
// Test and bail for -0.0, when integer result is 0
|
||||
// Move the top word of the double into the output reg,
|
||||
// if it is non-zero, then the original value was -0.0
|
||||
moveFromDoubleHi(src, dest);
|
||||
ma_b(dest, Imm32(INT32_MIN), fail, Assembler::Equal);
|
||||
bind(¬Zero);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче