[pypy-svn] pypy jit-longlong: In-progress: removing the usage of "imm_fine".

arigo commits-noreply at bitbucket.org
Fri Jan 14 16:12:50 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: jit-longlong
Changeset: r40677:6e01b70c2d92
Date: 2011-01-14 16:05 +0100
http://bitbucket.org/pypy/pypy/changeset/6e01b70c2d92/

Log:	In-progress: removing the usage of "imm_fine".

diff --git a/pypy/jit/backend/x86/rx86.py b/pypy/jit/backend/x86/rx86.py
--- a/pypy/jit/backend/x86/rx86.py
+++ b/pypy/jit/backend/x86/rx86.py
@@ -551,14 +551,7 @@
 
     MOVD_rx = xmminsn('\x66', rex_w, '\x0F\x7E', register(2, 8), register(1), '\xC0')
     MOVD_xr = xmminsn('\x66', rex_w, '\x0F\x6E', register(1, 8), register(2), '\xC0')
-    PADDQ_xx = xmminsn('\x66', rex_nw, '\x0F\xD4', register(1, 8), register(2), '\xC0')
-    PSUBQ_xx = xmminsn('\x66', rex_nw, '\x0F\xFB', register(1, 8), register(2), '\xC0')
-    PAND_xx = xmminsn('\x66', rex_nw, '\x0F\xDB', register(1, 8), register(2), '\xC0')
-    POR_xx  = xmminsn('\x66', rex_nw, '\x0F\xEB', register(1, 8), register(2), '\xC0')
-    PXOR_xx = xmminsn('\x66', rex_nw, '\x0F\xEF', register(1, 8), register(2), '\xC0')
-    PUNPCKLDQ_xx = xmminsn('\x66', rex_nw, '\x0F\x62', register(1, 8), register(2), '\xC0')
     PMOVMSKB_rx = xmminsn('\x66', rex_w, '\x0F\xD7', register(1, 8), register(2), '\xC0')
-    PCMPEQD_xx = xmminsn('\x66', rex_nw, '\x0F\x76', register(1, 8), register(2), '\xC0')
 
     # ------------------------------------------------------------
 
@@ -674,6 +667,26 @@
 define_modrm_modes('XORPD_x*', ['\x66', rex_nw, '\x0F\x57', register(1, 8)], regtype='XMM')
 define_modrm_modes('ANDPD_x*', ['\x66', rex_nw, '\x0F\x54', register(1, 8)], regtype='XMM')
 
+def define_pxmm_insn(insnname_template, insn_char):
+    def add_insn(char, *post):
+        methname = insnname_template.replace('*', char)
+        insn_func = xmminsn('\x66', rex_nw, '\x0F' + insn_char,
+                            register(1, 8), *post)
+        assert not hasattr(AbstractX86CodeBuilder, methname)
+        setattr(AbstractX86CodeBuilder, methname, insn_func)
+    #
+    assert insnname_template.count('*') == 1
+    add_insn('x', register(2), '\xC0')
+    add_insn('j', '\x05', immediate(2))
+
+define_pxmm_insn('PADDQ_x*',     '\xD4')
+define_pxmm_insn('PSUBQ_x*',     '\xFB')
+define_pxmm_insn('PAND_x*',      '\xDB')
+define_pxmm_insn('POR_x*',       '\xEB')
+define_pxmm_insn('PXOR_x*',      '\xEF')
+define_pxmm_insn('PUNPCKLDQ_x*', '\x62')
+define_pxmm_insn('PCMPEQD_x*',   '\x76')
+
 # ____________________________________________________________
 
 _classes = (AbstractX86CodeBuilder, X86_64_CodeBuilder, X86_32_CodeBuilder)

diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py
--- a/pypy/jit/backend/x86/regalloc.py
+++ b/pypy/jit/backend/x86/regalloc.py
@@ -5,7 +5,7 @@
 import os
 from pypy.jit.metainterp.history import (Box, Const, ConstInt, ConstPtr,
                                          ResOperation, BoxPtr, ConstFloat,
-                                         LoopToken, INT, REF, FLOAT)
+                                         BoxFloat, LoopToken, INT, REF, FLOAT)
 from pypy.jit.backend.x86.regloc import *
 from pypy.rpython.lltypesystem import lltype, ll2ctypes, rffi, rstr
 from pypy.rlib.objectmodel import we_are_translated
@@ -74,6 +74,12 @@
         rffi.cast(rffi.CArrayPtr(rffi.DOUBLE), adr)[0] = c.getfloat()
         return ConstFloatLoc(adr)
 
+    def convert_to_imm_16bytes_align(self, c):
+        adr = self.assembler.datablockwrapper.malloc_aligned(16, 16)
+        rffi.cast(rffi.CArrayPtr(rffi.DOUBLE), adr)[0] = c.getfloat()
+        rffi.cast(rffi.CArrayPtr(rffi.DOUBLE), adr)[1] = 0.0
+        return ConstFloatLoc(adr)
+
     def after_call(self, v):
         # the result is stored in st0, but we don't have this around,
         # so genop_call will move it to some frame location immediately
@@ -231,6 +237,14 @@
             return self.rm.force_allocate_reg(var, forbidden_vars,
                                               selected_reg, need_lower_byte)
 
+    def load_xmm_aligned_16_bytes(self, var):
+        # Load 'var' in a register; but if it is a constant, we can return
+        # a 16-bytes-aligned ConstFloatLoc.
+        if isinstance(var, Const):
+            return self.xrm.convert_to_imm_16bytes_align(var)
+        else:
+            return self.xrm.make_sure_var_in_reg(var)
+
     def _compute_loop_consts(self, inputargs, jump, looptoken):
         if jump.getopnum() != rop.JUMP or jump.getdescr() is not looptoken:
             loop_consts = {}
@@ -642,14 +656,16 @@
 
     def _consider_llong_binop_xx(self, op):
         # must force both arguments into xmm registers, because we don't
-        # know if they will be suitably aligned
+        # know if they will be suitably aligned.  Exception: if the second
+        # argument is a constant, we can ask it to be aligned to 16 bytes.
         args = [op.getarg(1), op.getarg(2)]
-        loc1 = self.xrm.make_sure_var_in_reg(args[1], imm_fine=False)
+        loc1 = self.load_xmm_aligned_16_bytes(args[1])
         loc0 = self.xrm.force_result_in_reg(op.result, args[0], args)
         self.PerformLLong(op, [loc0, loc1], loc0)
         self.xrm.possibly_free_vars(args)
 
-    def _consider_llong_cmp_xx(self, op):
+    def _consider_llong_eq_xx(self, op):
+        # (also handles llong_ne.)
         # must force both arguments into xmm registers, because we don't
         # know if they will be suitably aligned
         args = [op.getarg(1), op.getarg(2)]
@@ -672,7 +688,8 @@
             return False
         # "x < 0"
         box = op.getarg(1)
-        loc1 = self.xrm.make_sure_var_in_reg(box, imm_fine=False)
+        assert isinstance(box, BoxFloat)
+        loc1 = self.xrm.make_sure_var_in_reg(box)
         loc0 = self.rm.force_allocate_reg(op.result)
         self.PerformLLong(op, [loc1], loc0)
         self.xrm.possibly_free_var(box)
@@ -791,9 +808,9 @@
                     return self._consider_llong_from_int(op)
                 if oopspecindex == EffectInfo.OS_LLONG_FROM_TWO_INTS:
                     return self._consider_llong_from_two_ints(op)
-                if (oopspecindex == EffectInfo.OS_LLONG_EQ or
-                    oopspecindex == EffectInfo.OS_LLONG_NE):
-                    return self._consider_llong_cmp_xx(op)
+                #if (oopspecindex == EffectInfo.OS_LLONG_EQ or
+                #    oopspecindex == EffectInfo.OS_LLONG_NE):
+                #    return self._consider_llong_eq_xx(op)
                 if oopspecindex == EffectInfo.OS_LLONG_LT:
                     if self._maybe_consider_llong_lt(op):
                         return


More information about the Pypy-commit mailing list