[pypy-svn] r70203 - in pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86: . test
arigo at codespeak.net
arigo at codespeak.net
Fri Dec 18 19:14:07 CET 2009
Author: arigo
Date: Fri Dec 18 19:14:07 2009
New Revision: 70203
Modified:
pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/rx86.py
pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86.py
pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86_32_auto_encoding.py
pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86_64_auto_encoding.py
Log:
Group the register names in a class R.
Modified: pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/rx86.py
==============================================================================
--- pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/rx86.py (original)
+++ pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/rx86.py Fri Dec 18 19:14:07 2009
@@ -5,22 +5,21 @@
from pypy.rlib.unroll import unrolling_iterable
from pypy.rpython.lltypesystem import rffi
-# the following are synonyms for rax, rcx, etc. on 64 bits
-eax = 0
-ecx = 1
-edx = 2
-ebx = 3
-esp = 4
-ebp = 5
-esi = 6
-edi = 7
-
-# xmm registers
-xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 = range(8)
-
-# the following are extra registers available only on 64 bits
-r8, r9, r10, r11, r12, r13, r14, r15 = range(8, 16)
-xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 = range(8, 16)
+class R(object):
+ # the following are synonyms for rax, rcx, etc. on 64 bits
+ eax, ecx, edx, ebx, esp, ebp, esi, edi = range(8)
+
+ # xmm registers
+ xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 = range(8)
+
+ # the following are extra registers available only on 64 bits
+ r8, r9, r10, r11, r12, r13, r14, r15 = range(8, 16)
+ xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 = range(8, 16)
+
+ names = ['eax', 'ecx', 'edx', 'ebx', 'esp', 'ebp', 'esi', 'edi',
+ 'r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15']
+ xmmnames = ['xmm%d' % i for i in range(16)]
+
def single_byte(value):
return -128 <= value < 128
@@ -109,11 +108,11 @@
@specialize.arg(2)
def encode_stack(mc, offset, force_32bits, orbyte):
if not force_32bits and single_byte(offset):
- mc.writechar(chr(0x40 | orbyte | ebp))
+ mc.writechar(chr(0x40 | orbyte | R.ebp))
mc.writeimm8(offset)
else:
assert fits_in_32bits(offset)
- mc.writechar(chr(0x80 | orbyte | ebp))
+ mc.writechar(chr(0x80 | orbyte | R.ebp))
mc.writeimm32(offset)
return 0
@@ -127,7 +126,7 @@
# returns a 64-bits integer encoding "reg1+offset".
# * 'offset' is stored as bytes 1-4 of the result;
# * 'reg1' is stored as byte 5 of the result.
- assert reg != esp and reg != ebp
+ assert reg != R.esp and reg != R.ebp
assert fits_in_32bits(offset)
return (r_ulonglong(reg) << 32) | cast32to64(offset)
@@ -139,9 +138,9 @@
# 64-bits special cases for reg1 == r12 or r13
# (which look like esp or ebp after being truncated to 3 bits)
if mc.WORD == 8:
- if reg1 == esp: # forces an SIB byte:
- SIB = (esp<<3) | esp # use [r12+(no index)+offset]
- elif reg1 == ebp:
+ if reg1 == R.esp: # forces an SIB byte:
+ SIB = (R.esp<<3) | R.esp # use [r12+(no index)+offset]
+ elif reg1 == R.ebp:
no_offset = False
# end of 64-bits special cases
if no_offset:
@@ -174,8 +173,8 @@
# * 'offset' is stored as bytes 1-4 of the result;
# * the SIB byte is computed and stored as byte 5 of the result;
# * for 64-bits mode, the optional REX.B and REX.X flags go to byte 6.
- assert 0 <= reg1 < 16 and reg1 != ebp
- assert 0 <= reg2 < 16 and reg2 != esp
+ assert 0 <= reg1 < 16 and reg1 != R.ebp
+ assert 0 <= reg2 < 16 and reg2 != R.esp
assert 0 <= scaleshift < 4
assert fits_in_32bits(offset)
encoding = 0
@@ -201,7 +200,7 @@
# 64-bits special case for reg1 == r13
# (which look like ebp after being truncated to 3 bits)
if mc.WORD == 8:
- if (encoding & 7) == ebp:
+ if (encoding & 7) == R.ebp:
no_offset = False
# end of 64-bits special case
if no_offset:
Modified: pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86.py
==============================================================================
--- pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86.py (original)
+++ pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86.py Fri Dec 18 19:14:07 2009
@@ -1,5 +1,6 @@
import py
from pypy.jit.backend.x86.rx86 import *
+globals().update(R.__dict__)
class CodeBuilderMixin(object):
def __init__(self):
Modified: pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86_32_auto_encoding.py
==============================================================================
--- pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86_32_auto_encoding.py (original)
+++ pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86_32_auto_encoding.py Fri Dec 18 19:14:07 2009
@@ -44,7 +44,8 @@
X86_CodeBuilder = rx86.X86_32_CodeBuilder
REGNAMES = ['%eax', '%ecx', '%edx', '%ebx', '%esp', '%ebp', '%esi', '%edi']
REGS = range(8)
- NONSPECREGS = [rx86.eax, rx86.ecx, rx86.edx, rx86.ebx, rx86.esi, rx86.edi]
+ NONSPECREGS = [rx86.R.eax, rx86.R.ecx, rx86.R.edx, rx86.R.ebx,
+ rx86.R.esi, rx86.R.edi]
def reg_tests(self):
return self.REGS
@@ -207,11 +208,11 @@
# special cases
if methname in ('ADD_ri', 'AND_ri', 'CMP_ri', 'OR_ri',
'SUB_ri', 'XOR_ri'):
- if args[0] == rx86.eax:
+ if args[0] == rx86.R.eax:
return [] # ADD EAX, constant: there is a special encoding
- if methname == 'MOV_rj' and args[0] == rx86.eax:
+ if methname == 'MOV_rj' and args[0] == rx86.R.eax:
return [] # MOV EAX, [immediate]: there is a special encoding
- if methname == 'MOV_jr' and args[1] == rx86.eax:
+ if methname == 'MOV_jr' and args[1] == rx86.R.eax:
return [] # MOV [immediate], EAX: there is a special encoding
return [args]
Modified: pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86_64_auto_encoding.py
==============================================================================
--- pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86_64_auto_encoding.py (original)
+++ pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86/test/test_rx86_64_auto_encoding.py Fri Dec 18 19:14:07 2009
@@ -10,9 +10,10 @@
REGNAMES = ['%rax', '%rcx', '%rdx', '%rbx', '%rsp', '%rbp', '%rsi', '%rdi',
'%r8', '%r9', '%r10', '%r11', '%r12', '%r13', '%r14', '%r15']
REGS = range(16)
- NONSPECREGS = [rx86.eax, rx86.ecx, rx86.edx, rx86.ebx, rx86.esi, rx86.edi,
- rx86.r8, rx86.r9, rx86.r10, rx86.r11,
- rx86.r12, rx86.r13, rx86.r14, rx86.r15]
+ NONSPECREGS = [rx86.R.eax, rx86.R.ecx, rx86.R.edx, rx86.R.ebx,
+ rx86.R.esi, rx86.R.edi,
+ rx86.R.r8, rx86.R.r9, rx86.R.r10, rx86.R.r11,
+ rx86.R.r12, rx86.R.r13, rx86.R.r14, rx86.R.r15]
def array_tests(self):
# reduce a little bit -- we spend too long in these tests
More information about the Pypy-commit
mailing list