From c2ed3aa9cbe22e5f0fc5ee23543db8a34fb2f5f6 Mon Sep 17 00:00:00 2001 From: Dragan Mladjenovic Date: Fri, 25 May 2018 12:31:12 +0200 Subject: [PATCH] Bug 1464366 : [MIPS] Provide implementation for CodeGenerator::visitTrunc{F}; r=jandem --HG-- extra : rebase_source : 11facc1f91e4a3155be8067e2293ff6001ee41b7 --- .../mips-shared/CodeGenerator-mips-shared.cpp | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp index 4e6ef1345c5a..e699739e206f 100644 --- a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp +++ b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp @@ -1455,13 +1455,43 @@ CodeGenerator::visitRoundF(LRoundF* lir) void CodeGenerator::visitTrunc(LTrunc* lir) { - MOZ_CRASH("visitTrunc"); + FloatRegister input = ToFloatRegister(lir->input()); + Register output = ToRegister(lir->output()); + + Label notZero; + masm.as_truncwd(ScratchFloat32Reg, input); + masm.as_cfc1(ScratchRegister, Assembler::FCSR); + masm.moveFromFloat32(ScratchFloat32Reg, output); + masm.ma_ext(ScratchRegister, ScratchRegister, Assembler::CauseV, 1); + + masm.ma_b(output, Imm32(0), ¬Zero, Assembler::NotEqual, ShortJump); + masm.moveFromDoubleHi(input, ScratchRegister); + // Check if input is in ]-1; -0] range by checking the sign bit. + masm.as_slt(ScratchRegister, ScratchRegister, zero); + masm.bind(¬Zero); + + bailoutCmp32(Assembler::NotEqual, ScratchRegister, Imm32(0), lir->snapshot()); } void CodeGenerator::visitTruncF(LTruncF* lir) { - MOZ_CRASH("visitTruncF"); + FloatRegister input = ToFloatRegister(lir->input()); + Register output = ToRegister(lir->output()); + + Label notZero; + masm.as_truncws(ScratchFloat32Reg, input); + masm.as_cfc1(ScratchRegister, Assembler::FCSR); + masm.moveFromFloat32(ScratchFloat32Reg, output); + masm.ma_ext(ScratchRegister, ScratchRegister, Assembler::CauseV, 1); + + masm.ma_b(output, Imm32(0), ¬Zero, Assembler::NotEqual, ShortJump); + masm.moveFromFloat32(input, ScratchRegister); + // Check if input is in ]-1; -0] range by checking the sign bit. + masm.as_slt(ScratchRegister, ScratchRegister, zero); + masm.bind(¬Zero); + + bailoutCmp32(Assembler::NotEqual, ScratchRegister, Imm32(0), lir->snapshot()); } void