Bug 1229057 - Part 12: Move MacroAssembler::mulBy3 into generic macro assembler. r=sstangl
authorTooru Fujisawa <arai_a@mac.com>
Tue, 01 Dec 2015 17:03:40 +0900
changeset 316153 0066457f638ecfb6f2a1b96e91d6d99487dcd7ce
parent 316152 3482ddbcca569e67b8b477c0d6dfe26db8c324c5
child 316154 c2635431b09592d64b709451db402ad053d3878b
push id8516
push userjlund@mozilla.com
push dateFri, 18 Dec 2015 00:52:34 +0000
reviewerssstangl
bugs1229057
milestone46.0a1
Bug 1229057 - Part 12: Move MacroAssembler::mulBy3 into generic macro assembler. r=sstangl
js/src/jit/MacroAssembler.h
js/src/jit/arm/MacroAssembler-arm-inl.h
js/src/jit/arm/MacroAssembler-arm.h
js/src/jit/arm64/MacroAssembler-arm64-inl.h
js/src/jit/arm64/MacroAssembler-arm64.h
js/src/jit/mips32/MacroAssembler-mips32-inl.h
js/src/jit/mips32/MacroAssembler-mips32.h
js/src/jit/mips64/MacroAssembler-mips64-inl.h
js/src/jit/mips64/MacroAssembler-mips64.h
js/src/jit/none/MacroAssembler-none.h
js/src/jit/x64/MacroAssembler-x64-inl.h
js/src/jit/x64/MacroAssembler-x64.h
js/src/jit/x86/MacroAssembler-x86-inl.h
js/src/jit/x86/MacroAssembler-x86.h
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -764,16 +764,18 @@ class MacroAssembler : public MacroAssem
     inline void subPtr(const Address& addr, Register dest) DEFINED_ON(mips_shared, arm, arm64, x86, x64);
 
     inline void subDouble(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH;
 
     inline void mul32(Register src1, Register src2, Register dest, Label* onOver, Label* onZero) DEFINED_ON(arm64);
 
     inline void mul64(Imm64 imm, const Register64& dest) PER_ARCH;
 
+    inline void mulBy3(Register src, Register dest) PER_ARCH;
+
     // ===============================================================
     // Shift functions
 
     inline void lshiftPtr(Imm32 imm, Register dest) PER_ARCH;
 
     inline void lshift64(Imm32 imm, Register64 dest) PER_ARCH;
 
     inline void rshiftPtr(Imm32 imm, Register dest) PER_ARCH;
--- a/js/src/jit/arm/MacroAssembler-arm-inl.h
+++ b/js/src/jit/arm/MacroAssembler-arm-inl.h
@@ -293,16 +293,22 @@ MacroAssembler::mul64(Imm64 imm, const R
     else
         MOZ_CRASH("Not supported imm");
     as_add(dest.high, dest.high, O2Reg(secondScratchReg_));
 
     // LOW(dest) = low;
     ma_mov(ScratchRegister, dest.low);
 }
 
+void
+MacroAssembler::mulBy3(Register src, Register dest)
+{
+    as_add(dest, src, lsl(src, 1));
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     ma_lsl(imm, dest, dest);
 }
--- a/js/src/jit/arm/MacroAssembler-arm.h
+++ b/js/src/jit/arm/MacroAssembler-arm.h
@@ -1626,20 +1626,16 @@ class MacroAssemblerARMCompat : public M
     void cmpPtr(Register lhs, ImmGCPtr rhs);
     void cmpPtr(Register lhs, Imm32 rhs);
     void cmpPtr(const Address& lhs, Register rhs);
     void cmpPtr(const Address& lhs, ImmWord rhs);
     void cmpPtr(const Address& lhs, ImmPtr rhs);
     void cmpPtr(const Address& lhs, ImmGCPtr rhs);
     void cmpPtr(const Address& lhs, Imm32 rhs);
 
-    void mulBy3(const Register& src, const Register& dest) {
-        as_add(dest, src, lsl(src, 1));
-    }
-
     void convertUInt64ToDouble(Register64 src, Register temp, FloatRegister dest);
     void mulDoublePtr(ImmPtr imm, Register temp, FloatRegister dest) {
         movePtr(imm, ScratchRegister);
         loadDouble(Address(ScratchRegister, 0), ScratchDoubleReg);
         mulDouble(ScratchDoubleReg, dest);
     }
 
     void setStackArg(Register reg, uint32_t arg);
--- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h
+++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h
@@ -328,16 +328,24 @@ MacroAssembler::mul64(Imm64 imm, const R
 {
     vixl::UseScratchRegisterScope temps(this);
     const ARMRegister scratch64 = temps.AcquireX();
     MOZ_ASSERT(dest.reg != scratch64.asUnsized());
     mov(ImmWord(imm.value), scratch64.asUnsized());
     Mul(ARMRegister(dest.reg, 64), ARMRegister(dest.reg, 64), scratch64);
 }
 
+void
+MacroAssembler::mulBy3(Register src, Register dest)
+{
+    ARMRegister xdest(dest, 64);
+    ARMRegister xsrc(src, 64);
+    Add(xdest, xsrc, Operand(xsrc, vixl::LSL, 1));
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     Lsl(ARMRegister(dest, 64), ARMRegister(dest, 64), imm.value);
 }
--- a/js/src/jit/arm64/MacroAssembler-arm64.h
+++ b/js/src/jit/arm64/MacroAssembler-arm64.h
@@ -2838,22 +2838,16 @@ class MacroAssemblerCompat : public vixl
 #endif
     }
 
     void abiret() {
         syncStackPtr(); // SP is always used to transmit the stack between calls.
         vixl::MacroAssembler::Ret(vixl::lr);
     }
 
-    void mulBy3(Register src, Register dest) {
-        ARMRegister xdest(dest, 64);
-        ARMRegister xsrc(src, 64);
-        Add(xdest, xsrc, Operand(xsrc, vixl::LSL, 1));
-    }
-
     void convertUInt64ToDouble(Register64 src, Register temp, FloatRegister dest) {
         Ucvtf(ARMFPRegister(dest, 64), ARMRegister(src.reg, 64));
     }
     void mulDoublePtr(ImmPtr imm, Register temp, FloatRegister dest) {
         vixl::UseScratchRegisterScope temps(this);
         const Register scratch = temps.AcquireX().asUnsized();
         MOZ_ASSERT(temp != scratch);
         movePtr(imm, scratch);
--- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h
+++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h
@@ -165,16 +165,23 @@ MacroAssembler::mul64(Imm64 imm, const R
         as_mflo(ScratchRegister);
         as_addu(dest.high, dest.high, ScratchRegister);
 
         // LOW(dest) = tmp;
         ma_move(dest.low, SecondScratchReg);
     }
 }
 
+void
+MacroAssembler::mulBy3(Register src, Register dest)
+{
+    as_addu(dest, src, src);
+    as_addu(dest, dest, src);
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     ma_sll(dest, dest, imm);
 }
--- a/js/src/jit/mips32/MacroAssembler-mips32.h
+++ b/js/src/jit/mips32/MacroAssembler-mips32.h
@@ -1219,21 +1219,16 @@ class MacroAssemblerMIPSCompat : public 
 
     void zeroDouble(FloatRegister reg) {
         moveToDoubleLo(zero, reg);
         moveToDoubleHi(zero, reg);
     }
 
     void clampIntToUint8(Register reg);
 
-    void mulBy3(const Register& src, const Register& dest) {
-        as_addu(dest, src, src);
-        as_addu(dest, dest, src);
-    }
-
     void convertUInt64ToDouble(Register64 src, Register temp, FloatRegister dest);
     void mulDoublePtr(ImmPtr imm, Register temp, FloatRegister dest) {
         movePtr(imm, ScratchRegister);
         loadDouble(Address(ScratchRegister, 0), ScratchDoubleReg);
         mulDouble(ScratchDoubleReg, dest);
     }
 
     void breakpoint();
--- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h
+++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h
@@ -123,16 +123,23 @@ void
 MacroAssembler::mul64(Imm64 imm, const Register64& dest)
 {
     MOZ_ASSERT(dest.reg != ScratchRegister);
     mov(ImmWord(imm.value), ScratchRegister);
     as_dmultu(dest.reg, ScratchRegister);
     as_mflo(dest.reg);
 }
 
+void
+MacroAssembler::mulBy3(Register src, Register dest)
+{
+    as_daddu(dest, src, src);
+    as_daddu(dest, dest, src);
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     ma_dsll(dest, dest, imm);
 }
--- a/js/src/jit/mips64/MacroAssembler-mips64.h
+++ b/js/src/jit/mips64/MacroAssembler-mips64.h
@@ -1232,21 +1232,16 @@ class MacroAssemblerMIPS64Compat : publi
     }
 
     void zeroDouble(FloatRegister reg) {
         moveToDouble(zero, reg);
     }
 
     void clampIntToUint8(Register reg);
 
-    void mulBy3(const Register& src, const Register& dest) {
-        as_daddu(dest, src, src);
-        as_daddu(dest, dest, src);
-    }
-
     void convertUInt64ToDouble(Register64 src, Register temp, FloatRegister dest);
     void mulDoublePtr(ImmPtr imm, Register temp, FloatRegister dest) {
         movePtr(imm, ScratchRegister);
         loadDouble(Address(ScratchRegister, 0), ScratchDoubleReg);
         mulDouble(ScratchDoubleReg, dest);
     }
 
     void breakpoint();
--- a/js/src/jit/none/MacroAssembler-none.h
+++ b/js/src/jit/none/MacroAssembler-none.h
@@ -230,17 +230,16 @@ class MacroAssemblerNone : public Assemb
     void testNullSet(Condition, ValueOperand, Register) { MOZ_CRASH(); }
     void testObjectSet(Condition, ValueOperand, Register) { MOZ_CRASH(); }
     void testUndefinedSet(Condition, ValueOperand, Register) { MOZ_CRASH(); }
 
     template <typename T, typename S> void cmpPtrSet(Condition, T, S, Register) { MOZ_CRASH(); }
     template <typename T, typename S> void cmp32Set(Condition, T, S, Register) { MOZ_CRASH(); }
 
     void neg32(Register) { MOZ_CRASH(); }
-    void mulBy3(Register, Register) { MOZ_CRASH(); }
 
     void negateDouble(FloatRegister) { MOZ_CRASH(); }
     void mulDouble(FloatRegister, FloatRegister) { MOZ_CRASH(); }
     void divDouble(FloatRegister, FloatRegister) { MOZ_CRASH(); }
 
     template <typename T, typename S> void branch32(Condition, T, S, Label*) { MOZ_CRASH(); }
     template <typename T, typename S> void branchTest32(Condition, T, S, Label*) { MOZ_CRASH(); }
     template <typename T, typename S> void branchAdd32(Condition, T, S, Label*) { MOZ_CRASH(); }
--- a/js/src/jit/x64/MacroAssembler-x64-inl.h
+++ b/js/src/jit/x64/MacroAssembler-x64-inl.h
@@ -156,16 +156,22 @@ MacroAssembler::subPtr(const Address& ad
 
 void
 MacroAssembler::mul64(Imm64 imm, const Register64& dest)
 {
     movq(ImmWord(uintptr_t(imm.value)), ScratchReg);
     imulq(ScratchReg, dest.reg);
 }
 
+void
+MacroAssembler::mulBy3(Register src, Register dest)
+{
+    lea(Operand(src, src, TimesTwo), dest);
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     shlq(imm, dest);
 }
--- a/js/src/jit/x64/MacroAssembler-x64.h
+++ b/js/src/jit/x64/MacroAssembler-x64.h
@@ -538,20 +538,16 @@ class MacroAssemblerX64 : public MacroAs
         cmpPtr(lhs, rhs);
         emitSet(cond, dest);
     }
 
     /////////////////////////////////////////////////////////////////
     // Common interface.
     /////////////////////////////////////////////////////////////////
 
-    void mulBy3(const Register& src, const Register& dest) {
-        lea(Operand(src, src, TimesTwo), dest);
-    }
-
     void branch32(Condition cond, AbsoluteAddress lhs, Imm32 rhs, Label* label) {
         if (X86Encoding::IsAddressImmediate(lhs.addr)) {
             branch32(cond, Operand(lhs), rhs, label);
         } else {
             ScratchRegisterScope scratch(asMasm());
             mov(ImmPtr(lhs.addr), scratch);
             branch32(cond, Address(scratch, 0), rhs, label);
         }
--- a/js/src/jit/x86/MacroAssembler-x86-inl.h
+++ b/js/src/jit/x86/MacroAssembler-x86-inl.h
@@ -192,16 +192,22 @@ MacroAssembler::mul64(Imm64 imm, const R
     else
         MOZ_CRASH("Unsupported imm");
     addl(edx, dest.high);
 
     // LOW(dest) = eax;
     movl(eax, dest.low);
 }
 
+void
+MacroAssembler::mulBy3(Register src, Register dest)
+{
+    lea(Operand(src, src, TimesTwo), dest);
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     shll(imm, dest);
 }
--- a/js/src/jit/x86/MacroAssembler-x86.h
+++ b/js/src/jit/x86/MacroAssembler-x86.h
@@ -561,20 +561,16 @@ class MacroAssemblerX86 : public MacroAs
         cmpPtr(lhs, rhs);
         emitSet(cond, dest);
     }
 
     /////////////////////////////////////////////////////////////////
     // Common interface.
     /////////////////////////////////////////////////////////////////
 
-    void mulBy3(const Register& src, const Register& dest) {
-        lea(Operand(src, src, TimesTwo), dest);
-    }
-
     void branch32(Condition cond, AbsoluteAddress lhs, Imm32 rhs, Label* label) {
         cmp32(Operand(lhs), rhs);
         j(cond, label);
     }
     void branch32(Condition cond, wasm::SymbolicAddress lhs, Imm32 rhs, Label* label) {
         cmpl(rhs, lhs);
         j(cond, label);
     }