[pypy-svn] r76576 - in pypy/trunk/pypy/jit/backend/x86: . test
jcreigh at codespeak.net
jcreigh at codespeak.net
Tue Aug 10 20:09:04 CEST 2010
Author: jcreigh
Date: Tue Aug 10 20:09:03 2010
New Revision: 76576
Modified:
pypy/trunk/pypy/jit/backend/x86/rx86.py
pypy/trunk/pypy/jit/backend/x86/test/test_regloc.py
Log:
rx86: add tests to expose bug in MOV16/CMP16, and a hack to fix it
Modified: pypy/trunk/pypy/jit/backend/x86/rx86.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/rx86.py (original)
+++ pypy/trunk/pypy/jit/backend/x86/rx86.py Tue Aug 10 20:09:03 2010
@@ -290,6 +290,9 @@
def encode_rex(mc, rexbyte, basevalue, orbyte):
if mc.WORD == 8:
assert 0 <= rexbyte < 8
+ # XXX: Hack. Ignore REX.W if we are using 16-bit operands
+ if mc._use_16_bit_immediate:
+ basevalue &= ~REX_W
if basevalue != 0x40 or rexbyte != 0:
mc.writechar(chr(basevalue | rexbyte))
else:
Modified: pypy/trunk/pypy/jit/backend/x86/test/test_regloc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/test/test_regloc.py (original)
+++ pypy/trunk/pypy/jit/backend/x86/test/test_regloc.py Tue Aug 10 20:09:03 2010
@@ -16,13 +16,27 @@
cb64 = LocationCodeBuilder64
def test_mov_16():
+ # 32-bit
assert_encodes_as(cb32, "MOV16", (ecx, ebx), '\x66\x89\xD9')
assert_encodes_as(cb32, "MOV16", (ecx, ImmedLoc(12345)), '\x66\xB9\x39\x30')
+ # 64-bit
+ assert_encodes_as(cb64, "MOV16", (ecx, ebx), '\x66\x89\xD9')
+ # XXX: What we are testing for here is actually not the most compact
+ # encoding.
+ assert_encodes_as(cb64, "MOV16", (ecx, ImmedLoc(12345)), '\x66\xC7\xC1\x39\x30')
+ assert_encodes_as(cb64, "MOV16", (AddressLoc(r13, ImmedLoc(0), 0, 0), ImmedLoc(12345)), '\x66\x41\xC7\x45\x00\x39\x30')
+
def test_cmp_16():
+ # 32-bit
assert_encodes_as(cb32, "CMP16", (ecx, ebx), '\x66\x39\xD9')
assert_encodes_as(cb32, "CMP16", (ecx, ImmedLoc(12345)), '\x66\x81\xF9\x39\x30')
+ # 64-bit
+ assert_encodes_as(cb64, "CMP16", (ecx, ebx), '\x66\x39\xD9')
+ assert_encodes_as(cb64, "CMP16", (ecx, ImmedLoc(12345)), '\x66\x81\xF9\x39\x30')
+ assert_encodes_as(cb64, "CMP16", (AddressLoc(r13, ImmedLoc(0), 0, 0), ImmedLoc(12345)), '\x66\x41\x81\x7D\x00\x39\x30')
+
def test_jmp_wraparound():
if not IS_X86_32:
py.test.skip()
More information about the Pypy-commit
mailing list