[pypy-svn] r70202 - in pypy/branch/remove-ri386-multimethod-2/pypy/jit/backend/x86: . test
arigo at codespeak.net
arigo at codespeak.net
Fri Dec 18 18:50:15 CET 2009
Author: arigo
Date: Fri Dec 18 18:50:14 2009
New Revision: 70202
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
Log:
Test and fix and document.
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 18:50:14 2009
@@ -29,8 +29,15 @@
return -2147483648 <= value <= 2147483647
def intmask32(value):
+ # extract the 32 lower bits of 'value', returning a regular signed int
+ # (it is negative if 'value' is negative according to the 32-bits repr)
return intmask(rffi.cast(rffi.INT, value))
+def cast32to64(value):
+ # returns 'value' in the 32 lower bits of a 64-bit integer,
+ # with the remaining bits set to 0 (even if value is negative).
+ return r_ulonglong(rffi.cast(rffi.UINT, value))
+
# ____________________________________________________________
# Emit a single char
@@ -122,7 +129,7 @@
# * 'reg1' is stored as byte 5 of the result.
assert reg != esp and reg != ebp
assert fits_in_32bits(offset)
- return (r_ulonglong(reg) << 32) | r_ulonglong(rffi.r_uint(offset))
+ return (r_ulonglong(reg) << 32) | cast32to64(offset)
def encode_mem_reg_plus_const(mc, reg1_offset, _, orbyte):
reg1 = reg_number_3bits(mc, intmask(reg1_offset >> 32))
@@ -179,7 +186,7 @@
encoding |= REX_X << 8
reg2 &= 7
encoding |= (scaleshift<<6) | (reg2<<3) | reg1
- return (r_ulonglong(encoding) << 32) | r_ulonglong(rffi.r_uint(offset))
+ return (r_ulonglong(encoding) << 32) | cast32to64(offset)
def encode_mem_reg_plus_scaled_reg_plus_const(mc, reg1_reg2_scaleshift_offset,
_, orbyte):
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 18:50:14 2009
@@ -100,3 +100,8 @@
s.MOV_rm(edx, reg_offset(r12, 0))
s.MOV_rm(edx, reg_offset(r13, 0))
assert s.getvalue() == '\x48\x8B\x17\x49\x8b\x14\x24\x49\x8b\x55\x00'
+
+def test_mov_rm_negative_64():
+ s = CodeBuilder64()
+ s.MOV_rm(edx, reg_offset(edi, -1))
+ assert s.getvalue() == '\x48\x8B\x57\xFF'
More information about the Pypy-commit
mailing list