Bug 1393723 - Handle wasm i64 sign extend on mips. r=lth
authorDragan Mladjenovic <dragan.mladjenovic@rt-rk.com>
Fri, 25 Aug 2017 02:49:00 -0400
changeset 377605 81cdf89896a3
parent 377604 166c94ca628c
child 377606 d601a7f3f97f
push id32411
push userkwierso@gmail.com
push dateTue, 29 Aug 2017 23:14:35 +0000
treeherdermozilla-central@db7f19e26e57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1393723
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1393723 - Handle wasm i64 sign extend on mips. r=lth
js/src/jit/mips-shared/Lowering-mips-shared.cpp
js/src/jit/mips32/CodeGenerator-mips32.cpp
js/src/jit/mips32/CodeGenerator-mips32.h
js/src/jit/mips64/CodeGenerator-mips64.cpp
js/src/jit/mips64/CodeGenerator-mips64.h
--- a/js/src/jit/mips-shared/Lowering-mips-shared.cpp
+++ b/js/src/jit/mips-shared/Lowering-mips-shared.cpp
@@ -765,10 +765,10 @@ void
 LIRGeneratorMIPSShared::visitExtendInt32ToInt64(MExtendInt32ToInt64* ins)
 {
     defineInt64(new(alloc()) LExtendInt32ToInt64(useRegisterAtStart(ins->input())), ins);
 }
 
 void
 LIRGeneratorMIPSShared::visitSignExtendInt64(MSignExtendInt64* ins)
 {
-    MOZ_CRASH("NYI : SignExtendInt64");
+    defineInt64(new(alloc()) LSignExtendInt64(useInt64RegisterAtStart(ins->input())), ins);
 }
--- a/js/src/jit/mips32/CodeGenerator-mips32.cpp
+++ b/js/src/jit/mips32/CodeGenerator-mips32.cpp
@@ -686,16 +686,35 @@ CodeGeneratorMIPS::visitWrapInt64ToInt32
 
     if (lir->mir()->bottomHalf())
         masm.move32(ToRegister(input.low()), output);
     else
         masm.move32(ToRegister(input.high()), output);
 }
 
 void
+CodeGeneratorMIPS::visitSignExtendInt64(LSignExtendInt64* lir)
+{
+    Register64 input = ToRegister64(lir->getInt64Operand(0));
+    Register64 output = ToOutRegister64(lir);
+    switch (lir->mode()) {
+      case MSignExtendInt64::Byte:
+        masm.move8SignExtend(input.low, output.low);
+        break;
+      case MSignExtendInt64::Half:
+        masm.move16SignExtend(input.low, output.low);
+        break;
+      case MSignExtendInt64::Word:
+        masm.move32(input.low, output.low);
+        break;
+    }
+    masm.ma_sra(output.high, output.low, Imm32(31));
+}
+
+void
 CodeGeneratorMIPS::visitClzI64(LClzI64* lir)
 {
     Register64 input = ToRegister64(lir->getInt64Operand(0));
     Register64 output = ToOutRegister64(lir);
     masm.clz64(input, output.low);
     masm.move32(Imm32(0), output.high);
 }
 
@@ -804,9 +823,9 @@ CodeGeneratorMIPS::visitTestI64AndBranch
 
 void
 CodeGeneratorMIPS::setReturnDoubleRegs(LiveRegisterSet* regs)
 {
     MOZ_ASSERT(ReturnFloat32Reg.code_ == ReturnDoubleReg.code_);
     regs->add(ReturnFloat32Reg);
     regs->add(ReturnDoubleReg.singleOverlay(1));
     regs->add(ReturnDoubleReg);
-}
+}
\ No newline at end of file
--- a/js/src/jit/mips32/CodeGenerator-mips32.h
+++ b/js/src/jit/mips32/CodeGenerator-mips32.h
@@ -51,16 +51,17 @@ class CodeGeneratorMIPS : public CodeGen
     void visitWasmUnalignedLoadI64(LWasmUnalignedLoadI64* lir);
     void visitWasmStoreI64(LWasmStoreI64* ins);
     void visitWasmUnalignedStoreI64(LWasmUnalignedStoreI64* ins);
     void visitWasmSelectI64(LWasmSelectI64* lir);
     void visitWasmReinterpretFromI64(LWasmReinterpretFromI64* lir);
     void visitWasmReinterpretToI64(LWasmReinterpretToI64* lir);
     void visitExtendInt32ToInt64(LExtendInt32ToInt64* lir);
     void visitWrapInt64ToInt32(LWrapInt64ToInt32* lir);
+    void visitSignExtendInt64(LSignExtendInt64* ins);
     void visitClzI64(LClzI64* ins);
     void visitCtzI64(LCtzI64* ins);
     void visitNotI64(LNotI64* ins);
     void visitWasmTruncateToInt64(LWasmTruncateToInt64* ins);
     void visitInt64ToFloatingPoint(LInt64ToFloatingPoint* lir);
     void visitTestI64AndBranch(LTestI64AndBranch* lir);
 
     // Out of line visitors.
--- a/js/src/jit/mips64/CodeGenerator-mips64.cpp
+++ b/js/src/jit/mips64/CodeGenerator-mips64.cpp
@@ -601,16 +601,34 @@ CodeGeneratorMIPS64::visitWrapInt64ToInt
         else
             masm.ma_sll(output, ToRegister(input), Imm32(0));
     } else {
         MOZ_CRASH("Not implemented.");
     }
 }
 
 void
+CodeGeneratorMIPS::visitSignExtendInt64(LSignExtendInt64* lir)
+{
+    Register64 input = ToRegister64(lir->getInt64Operand(0));
+    Register64 output = ToOutRegister64(lir);
+    switch (lir->mode()) {
+      case MSignExtendInt64::Byte:
+        masm.move8SignExtend(input.reg, output.reg);
+        break;
+      case MSignExtendInt64::Half:
+        masm.move16SignExtend(input.reg, output.reg);
+        break;
+      case MSignExtendInt64::Word:
+        masm.ma_sll(output.reg, input.reg, Imm32(0));
+        break;
+    }
+}
+
+void
 CodeGeneratorMIPS64::visitClzI64(LClzI64* lir)
 {
     Register64 input = ToRegister64(lir->getInt64Operand(0));
     Register64 output = ToOutRegister64(lir);
     masm.clz64(input, output.reg);
 }
 
 void
--- a/js/src/jit/mips64/CodeGenerator-mips64.h
+++ b/js/src/jit/mips64/CodeGenerator-mips64.h
@@ -57,16 +57,17 @@ class CodeGeneratorMIPS64 : public CodeG
     void visitWasmUnalignedLoadI64(LWasmUnalignedLoadI64* lir);
     void visitWasmStoreI64(LWasmStoreI64* ins);
     void visitWasmUnalignedStoreI64(LWasmUnalignedStoreI64* ins);
     void visitWasmSelectI64(LWasmSelectI64* ins);
     void visitWasmReinterpretFromI64(LWasmReinterpretFromI64* lir);
     void visitWasmReinterpretToI64(LWasmReinterpretToI64* lir);
     void visitExtendInt32ToInt64(LExtendInt32ToInt64* lir);
     void visitWrapInt64ToInt32(LWrapInt64ToInt32* lir);
+    void visitSignExtendInt64(LSignExtendInt64* ins);
     void visitClzI64(LClzI64* lir);
     void visitCtzI64(LCtzI64* lir);
     void visitNotI64(LNotI64* lir);
     void visitWasmTruncateToInt64(LWasmTruncateToInt64* lir);
     void visitInt64ToFloatingPoint(LInt64ToFloatingPoint* lir);
     void visitTestI64AndBranch(LTestI64AndBranch* lir);
 
     // Out of line visitors.