[pypy-commit] pypy stmgc-c7: Fix regloc, as far as test_regloc says.
arigo
noreply at buildbot.pypy.org
Sun Mar 23 14:51:07 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r70198:85dc2a0ebc48
Date: 2014-03-23 14:50 +0100
http://bitbucket.org/pypy/pypy/changeset/85dc2a0ebc48/
Log: Fix regloc, as far as test_regloc says.
diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -2671,8 +2671,8 @@
def raw_stack(offset, type=INT):
return RawEbpLoc(offset, type)
-def heap(addr):
- return AddressLoc(ImmedLoc(addr), imm0, 0, 0)
+def heap(segment, addr):
+ return AddressLoc(segment, ImmedLoc(addr), imm0, 0, 0)
def not_implemented(msg):
msg = '[x86/asm] %s\n' % msg
diff --git a/rpython/jit/backend/x86/codebuf.py b/rpython/jit/backend/x86/codebuf.py
--- a/rpython/jit/backend/x86/codebuf.py
+++ b/rpython/jit/backend/x86/codebuf.py
@@ -22,8 +22,7 @@
class MachineCodeBlockWrapper(BlockBuilderMixin,
LocationCodeBuilder,
codebuilder_cls):
- def __init__(self, cpu):
- self.stm = cpu.gc_ll_descr.stm
+ def __init__(self):
self.init_block_builder()
# a list of relative positions; for each position p, the bytes
# at [p-4:p] encode an absolute address that will need to be
@@ -54,47 +53,3 @@
adr[0] = intmask(adr[0] - p)
valgrind.discard_translations(addr, self.get_relative_pos())
self._dump(addr, "jit-backend-dump", backend_name)
-
- def in_tl_segment(self, adr):
- """Makes 'adr' relative to threadlocal-base if we run in STM.
- Before using such a relative address, call SEGTL()."""
- if self.stm and we_are_translated():
- # only for STM and not during tests
- from rpython.jit.backend.x86 import stmtlocal, rx86
- result = adr - stmtlocal.threadlocal_base()
- assert rx86.fits_in_32bits(result)
- return result
- return adr
-
- def SEGTL(self):
- """Insert segment prefix for thread-local memory if we run
- in STM and not during testing. This is used to access thread-local
- data structures like the struct stm_thread_local_s."""
- if self.stm and we_are_translated():
- from rpython.jit.backend.x86 import stmtlocal
- stmtlocal.tl_segment_prefix(self)
-
- def SEGC7(self):
- """Insert segment prefix for the stmgc-c7 segment of memory
- if we run in STM and not during testing. This is used to access
- any GC object, or things in the STM_SEGMENT structure."""
- if self.stm and we_are_translated():
- from rpython.jit.backend.x86 import stmtlocal
- stmtlocal.c7_segment_prefix(self)
-
- def SEGC7_if_gc(self, op):
- if self.stm and we_are_translated():
- from rpython.jit.backend.x86 import stmtlocal
- from rpython.jit.metainterp.resoperation import rop
- #
- opnum = op.getopnum()
- if opnum in (rop.GETFIELD_GC,
- rop.GETFIELD_GC_PURE,
- rop.GETARRAYITEM_GC,
- rop.GETARRAYITEM_GC_PURE,
- rop.GETINTERIORFIELD_GC,
- rop.SETFIELD_GC,
- rop.SETARRAYITEM_GC,
- rop.SETINTERIORFIELD_GC,
- ):
- stmtlocal.c7_segment_prefix(self)
diff --git a/rpython/jit/backend/x86/regloc.py b/rpython/jit/backend/x86/regloc.py
--- a/rpython/jit/backend/x86/regloc.py
+++ b/rpython/jit/backend/x86/regloc.py
@@ -3,7 +3,7 @@
from rpython.rlib.unroll import unrolling_iterable
from rpython.jit.backend.x86.arch import WORD, IS_X86_32, IS_X86_64
from rpython.tool.sourcetools import func_with_new_name
-from rpython.rlib.objectmodel import specialize, instantiate
+from rpython.rlib.objectmodel import specialize, instantiate, we_are_translated
from rpython.rlib.rarithmetic import intmask
from rpython.jit.metainterp.history import FLOAT, INT
from rpython.jit.codewriter import longlong
@@ -34,7 +34,7 @@
def value_r(self): return self.value
def value_b(self): return self.value
def value_s(self): return self.value
- def value_j(self): return self.value
+ def value_j(self): raise AssertionError("value_j undefined")
def value_i(self): return self.value
def value_x(self): return self.value
def value_a(self): raise AssertionError("value_a undefined")
@@ -206,7 +206,10 @@
_immutable_ = True
# The address is base_loc + (scaled_loc << scale) + static_offset
- def __init__(self, base_loc, scaled_loc, scale=0, static_offset=0):
+ def __init__(self, segment,base_loc, scaled_loc, scale=0, static_offset=0):
+ if not we_are_translated():
+ assert segment in (rx86.SEGMENT_NO, rx86.SEGMENT_FS,
+ rx86.SEGMENT_GS)
assert 0 <= scale < 4
assert isinstance(base_loc, ImmedLoc) or isinstance(base_loc, RegLoc)
assert isinstance(scaled_loc, ImmedLoc) or isinstance(scaled_loc, RegLoc)
@@ -214,18 +217,22 @@
if isinstance(base_loc, ImmedLoc):
if isinstance(scaled_loc, ImmedLoc):
self._location_code = 'j'
- self.value = base_loc.value + (scaled_loc.value << scale) + static_offset
+ self.loc_j = (segment, base_loc.value +
+ (scaled_loc.value << scale) + static_offset)
else:
self._location_code = 'a'
- self.loc_a = (rx86.NO_BASE_REGISTER, scaled_loc.value, scale, base_loc.value + static_offset)
+ self.loc_a = (segment, rx86.NO_BASE_REGISTER, scaled_loc.value,
+ scale, base_loc.value + static_offset)
else:
if isinstance(scaled_loc, ImmedLoc):
# FIXME: What if base_loc is ebp or esp?
self._location_code = 'm'
- self.loc_m = (base_loc.value, (scaled_loc.value << scale) + static_offset)
+ self.loc_m = (segment, base_loc.value,
+ (scaled_loc.value << scale) + static_offset)
else:
self._location_code = 'a'
- self.loc_a = (base_loc.value, scaled_loc.value, scale, static_offset)
+ self.loc_a = (segment, base_loc.value, scaled_loc.value,
+ scale, static_offset)
def __repr__(self):
dict = {'j': 'value', 'a': 'loc_a', 'm': 'loc_m', 'a':'loc_a'}
@@ -240,6 +247,9 @@
return False # not 100% true, but we don't use AddressLoc for locations
# really, so it's ok
+ def value_j(self):
+ return self.loc_j
+
def value_a(self):
return self.loc_a
@@ -248,15 +258,15 @@
def find_unused_reg(self):
if self._location_code == 'm':
- if self.loc_m[0] == eax.value:
+ if self.loc_m[1] == eax.value:
return edx
elif self._location_code == 'a':
- if self.loc_a[0] == eax.value:
- if self.loc_a[1] == edx.value:
+ if self.loc_a[1] == eax.value:
+ if self.loc_a[2] == edx.value:
return ecx
return edx
- if self.loc_a[1] == eax.value:
- if self.loc_a[0] == edx.value:
+ if self.loc_a[2] == eax.value:
+ if self.loc_a[1] == edx.value:
return ecx
return edx
return eax
@@ -265,11 +275,11 @@
result = instantiate(AddressLoc)
result._location_code = self._location_code
if self._location_code == 'm':
- result.loc_m = (self.loc_m[0], self.loc_m[1] + ofs)
+ result.loc_m = self.loc_m[:2] + (self.loc_m[2] + ofs)
elif self._location_code == 'a':
- result.loc_a = self.loc_a[:3] + (self.loc_a[3] + ofs,)
+ result.loc_a = self.loc_a[:4] + (self.loc_a[4] + ofs,)
elif self._location_code == 'j':
- result.value = self.value + ofs
+ result.loc_j = (self.loc_j[0], self.loc_j[1] + ofs)
else:
raise AssertionError(self._location_code)
return result
@@ -383,9 +393,9 @@
if code1 == 'j':
checkvalue = loc1.value_j()
elif code1 == 'm':
- checkvalue = loc1.value_m()[1]
+ checkvalue = loc1.value_m()[2]
elif code1 == 'a':
- checkvalue = loc1.value_a()[3]
+ checkvalue = loc1.value_a()[4]
else:
checkvalue = 0
if not rx86.fits_in_32bits(checkvalue):
@@ -468,13 +478,13 @@
val2 = self._addr_as_reg_offset(val2)
invoke(self, possible_code1 + "m", val1, val2)
return
- if possible_code1 == 'm' and not fits32(val1[1]):
+ if possible_code1 == 'm' and not fits32(val1[2]):
val1 = self._fix_static_offset_64_m(val1)
- if possible_code2 == 'm' and not fits32(val2[1]):
+ if possible_code2 == 'm' and not fits32(val2[2]):
val2 = self._fix_static_offset_64_m(val2)
- if possible_code1 == 'a' and not fits32(val1[3]):
+ if possible_code1 == 'a' and not fits32(val1[4]):
val1 = self._fix_static_offset_64_a(val1)
- if possible_code2 == 'a' and not fits32(val2[3]):
+ if possible_code2 == 'a' and not fits32(val2[4]):
val2 = self._fix_static_offset_64_a(val2)
invoke(self, possible_code1 + possible_code2, val1, val2)
return
@@ -498,9 +508,9 @@
val = self._addr_as_reg_offset(val)
_rx86_getattr(self, name + "_m")(val)
return
- if possible_code == 'm' and not fits32(val[1]):
+ if possible_code == 'm' and not fits32(val[2]):
val = self._fix_static_offset_64_m(val)
- if possible_code == 'a' and not fits32(val[3]):
+ if possible_code == 'a' and not fits32(val[4]):
val = self._fix_static_offset_64_a(val)
methname = name + "_" + possible_code
_rx86_getattr(self, methname)(val)
@@ -531,7 +541,7 @@
return func_with_new_name(INSN, "INSN_" + name)
- def _addr_as_reg_offset(self, addr):
+ def _addr_as_reg_offset(self, (segment, addr)):
# Encodes a (64-bit) address as an offset from the scratch register.
# If we are within a "reuse_scratch_register" block, we remember the
# last value we loaded to the scratch register and encode the address
@@ -539,7 +549,7 @@
if self._scratch_register_known:
offset = addr - self._scratch_register_value
if rx86.fits_in_32bits(offset):
- return (X86_64_SCRATCH_REG.value, offset)
+ return (segment, X86_64_SCRATCH_REG.value, offset)
# else: fall through
if self._reuse_scratch_register:
@@ -547,9 +557,9 @@
self._scratch_register_value = addr
self.MOV_ri(X86_64_SCRATCH_REG.value, addr)
- return (X86_64_SCRATCH_REG.value, 0)
+ return (segment, X86_64_SCRATCH_REG.value, 0)
- def _fix_static_offset_64_m(self, (basereg, static_offset)):
+ def _fix_static_offset_64_m(self, (segment, basereg, static_offset)):
# For cases where an AddressLoc has the location_code 'm', but
# where the static offset does not fit in 32-bits. We have to fall
# back to the X86_64_SCRATCH_REG. Returns a new location encoded
@@ -558,10 +568,10 @@
self._scratch_register_known = False
self.MOV_ri(X86_64_SCRATCH_REG.value, static_offset)
self.LEA_ra(X86_64_SCRATCH_REG.value,
- (basereg, X86_64_SCRATCH_REG.value, 0, 0))
- return (X86_64_SCRATCH_REG.value, 0)
+ (rx86.SEGMENT_NO, basereg, X86_64_SCRATCH_REG.value, 0, 0))
+ return (segment, X86_64_SCRATCH_REG.value, 0)
- def _fix_static_offset_64_a(self, (basereg, scalereg,
+ def _fix_static_offset_64_a(self, (segment, basereg, scalereg,
scale, static_offset)):
# For cases where an AddressLoc has the location_code 'a', but
# where the static offset does not fit in 32-bits. We have to fall
@@ -573,8 +583,8 @@
#
if basereg != rx86.NO_BASE_REGISTER:
self.LEA_ra(X86_64_SCRATCH_REG.value,
- (basereg, X86_64_SCRATCH_REG.value, 0, 0))
- return (X86_64_SCRATCH_REG.value, scalereg, scale, 0)
+ (rx86.SEGMENT_NO, basereg, X86_64_SCRATCH_REG.value, 0, 0))
+ return (segment, X86_64_SCRATCH_REG.value, scalereg, scale, 0)
def _load_scratch(self, value):
if (self._scratch_register_known
diff --git a/rpython/jit/backend/x86/test/test_regloc.py b/rpython/jit/backend/x86/test/test_regloc.py
--- a/rpython/jit/backend/x86/test/test_regloc.py
+++ b/rpython/jit/backend/x86/test/test_regloc.py
@@ -1,5 +1,6 @@
import struct, sys
from rpython.jit.backend.x86.rx86 import R
+from rpython.jit.backend.x86.rx86 import SEGMENT_NO, SEGMENT_FS
from rpython.jit.backend.x86.regloc import *
from rpython.jit.backend.x86.test.test_rx86 import CodeBuilder32, CodeBuilder64, assert_encodes_as
from rpython.jit.backend.x86.assembler import heap
@@ -24,7 +25,7 @@
# 32-bit
assert_encodes_as(cb32, "MOV16", (ecx, ebx), '\x66\x89\xD9')
assert_encodes_as(cb32, "MOV16",
- (AddressLoc(ecx, ImmedLoc(16), 0, 0), ebx),
+ (AddressLoc(SEGMENT_NO, ecx, ImmedLoc(16), 0, 0), ebx),
'\x66\x89\x59\x10')
# 64-bit
assert_encodes_as(cb64, "MOV16", (r8, ebx), '\x66\x41\x89\xD8') # 11 011 000
@@ -43,21 +44,25 @@
expected = '\x66\x41\xC7\xC1\xC7\xCF' # could be '\x66\x41\xB9\xC7\xCF'
assert_encodes_as(cb64, "MOV16", (r9, ImmedLoc(-12345)), expected)
assert_encodes_as(cb64, "MOV16",
- (AddressLoc(r13, ImmedLoc(0), 0, 0), ImmedLoc(12345)),
+ (AddressLoc(SEGMENT_NO, r13, ImmedLoc(0), 0, 0),
+ ImmedLoc(12345)),
'\x66\x41\xC7\x45\x00\x39\x30')
def test_cmp_16():
# only 'CMP16_mi' is supported
# 32-bit
assert_encodes_as(cb32, "CMP16",
- (AddressLoc(ecx, ImmedLoc(0), 0, 0), ImmedLoc(21324)),
+ (AddressLoc(SEGMENT_NO, ecx, ImmedLoc(0), 0, 0),
+ ImmedLoc(21324)),
'\x66\x81\x39\x4c\x53')
assert_encodes_as(cb32, "CMP16",
- (AddressLoc(esi, ImmedLoc(2), 0, 0), ImmedLoc(-12345)),
- '\x66\x81\x7e\x02\xc7\xcf')
+ (AddressLoc(SEGMENT_FS, esi, ImmedLoc(2), 0, 0),
+ ImmedLoc(-12345)),
+ '\x64\x66\x81\x7e\x02\xc7\xcf')
# 64-bit
assert_encodes_as(cb64, "CMP16",
- (AddressLoc(r13, ImmedLoc(0), 0, 0), ImmedLoc(12345)),
+ (AddressLoc(SEGMENT_NO, r13, ImmedLoc(0), 0, 0),
+ ImmedLoc(12345)),
'\x66\x41\x81\x7D\x00\x39\x30')
def test_relocation():
@@ -107,8 +112,8 @@
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
cb.begin_reuse_scratch_register()
- cb.MOV(ecx, heap(base_addr))
- cb.MOV(ecx, heap(base_addr + 8))
+ cb.MOV(ecx, heap(SEGMENT_NO, base_addr))
+ cb.MOV(ecx, heap(SEGMENT_FS, base_addr + 8))
cb.end_reuse_scratch_register()
expected_instructions = (
@@ -116,8 +121,8 @@
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE' +
# mov rcx, [r11]
'\x49\x8B\x0B' +
- # mov rcx, [r11+8]
- '\x49\x8B\x4B\x08'
+ # mov rcx, %fs:[r11+8]
+ '\x64\x49\x8B\x4B\x08'
)
assert cb.getvalue() == expected_instructions
@@ -126,35 +131,36 @@
def test_64bit_address_1(self):
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.CMP(ecx, AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr))
+ cb.CMP(ecx, AddressLoc(SEGMENT_FS, ImmedLoc(0), ImmedLoc(0),
+ 0, base_addr))
# this case is a CMP_rj
#
expected_instructions = (
# mov r11, 0xFEDCBA9876543210
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
- # cmp rcx, [r11]
- '\x49\x3B\x0B'
+ # cmp rcx, %fs:[r11]
+ '\x64\x49\x3B\x0B'
)
assert cb.getvalue() == expected_instructions
def test_64bit_address_2(self):
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(ecx, AddressLoc(ImmedLoc(0), edx, 3, base_addr))
+ cb.MOV(ecx, AddressLoc(SEGMENT_FS, ImmedLoc(0), edx, 3, base_addr))
# this case is a CMP_ra
#
expected_instructions = (
# mov r11, 0xFEDCBA9876543210
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
- # mov rcx, [r11+8*rdx]
- '\x49\x8B\x0C\xD3'
+ # mov rcx, %fs:[r11+8*rdx]
+ '\x64\x49\x8B\x0C\xD3'
)
assert cb.getvalue() == expected_instructions
def test_64bit_address_3(self):
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(ecx, AddressLoc(edx, ImmedLoc(0), 0, base_addr))
+ cb.MOV(ecx, AddressLoc(SEGMENT_FS, edx, ImmedLoc(0), 0, base_addr))
# this case is a CMP_rm
#
expected_instructions = (
@@ -162,8 +168,8 @@
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
# lea r11, [rdx+r11]
'\x4E\x8D\x1C\x1A'
- # mov rcx, [r11]
- '\x49\x8B\x0B'
+ # mov rcx, %fs:[r11]
+ '\x64\x49\x8B\x0B'
)
assert cb.getvalue() == expected_instructions
@@ -173,7 +179,7 @@
cb.begin_reuse_scratch_register()
assert cb._reuse_scratch_register is True
assert cb._scratch_register_known is False
- cb.MOV(ecx, AddressLoc(edx, esi, 2, base_addr))
+ cb.MOV(ecx, AddressLoc(SEGMENT_FS, edx, esi, 2, base_addr))
assert cb._reuse_scratch_register is True
assert cb._scratch_register_known is False
# this case is a CMP_ra
@@ -183,8 +189,8 @@
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
# lea r11, [rdx+r11]
'\x4E\x8D\x1C\x1A'
- # mov rcx, [r11+4*rsi]
- '\x49\x8B\x0C\xB3'
+ # mov rcx, %fs:[r11+4*rsi]
+ '\x64\x49\x8B\x0C\xB3'
)
assert cb.getvalue() == expected_instructions
@@ -204,13 +210,13 @@
def test_MOV_64bit_address_into_r11(self):
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(r11, heap(base_addr))
+ cb.MOV(r11, heap(SEGMENT_FS, base_addr))
expected_instructions = (
# mov r11, 0xFEDCBA9876543210
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE' +
- # mov r11, [r11]
- '\x4D\x8B\x1B'
+ # mov r11, %fs:[r11]
+ '\x64\x4D\x8B\x1B'
)
assert cb.getvalue() == expected_instructions
@@ -218,15 +224,15 @@
immed = -0x01234567
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr),
+ cb.MOV(AddressLoc(SEGMENT_FS, ImmedLoc(0), ImmedLoc(0), 0, base_addr),
ImmedLoc(immed))
# this case is a MOV_ji
#
expected_instructions = (
# mov r11, 0xFEDCBA9876543210
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
- # mov [r11], -0x01234567
- '\x49\xC7\x03\x99\xBA\xDC\xFE'
+ # mov %fs:[r11], -0x01234567
+ '\x64\x49\xC7\x03\x99\xBA\xDC\xFE'
)
assert cb.getvalue() == expected_instructions
@@ -234,15 +240,15 @@
immed = -0x01234567
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(AddressLoc(ImmedLoc(0), edx, 3, base_addr),
+ cb.MOV(AddressLoc(SEGMENT_FS, ImmedLoc(0), edx, 3, base_addr),
ImmedLoc(immed))
# this case is a MOV_ai
#
expected_instructions = (
# mov r11, 0xFEDCBA9876543210
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
- # mov [r11+8*rdx], -0x01234567
- '\x49\xC7\x04\xD3\x99\xBA\xDC\xFE'
+ # mov %fs:[r11+8*rdx], -0x01234567
+ '\x64\x49\xC7\x04\xD3\x99\xBA\xDC\xFE'
)
assert cb.getvalue() == expected_instructions
@@ -250,7 +256,7 @@
immed = -0x01234567
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(AddressLoc(edx, ImmedLoc(0), 0, base_addr),
+ cb.MOV(AddressLoc(SEGMENT_FS, edx, ImmedLoc(0), 0, base_addr),
ImmedLoc(immed))
# this case is a MOV_mi
#
@@ -259,8 +265,8 @@
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
# lea r11, [rdx+r11]
'\x4E\x8D\x1C\x1A'
- # mov [r11], -0x01234567
- '\x49\xC7\x03\x99\xBA\xDC\xFE'
+ # mov %fs:[r11], -0x01234567
+ '\x64\x49\xC7\x03\x99\xBA\xDC\xFE'
)
assert cb.getvalue() == expected_instructions
@@ -268,7 +274,7 @@
immed = -0x01234567
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(AddressLoc(edx, esi, 2, base_addr), ImmedLoc(immed))
+ cb.MOV(AddressLoc(SEGMENT_FS, edx, esi, 2, base_addr), ImmedLoc(immed))
# this case is a MOV_ai
#
expected_instructions = (
@@ -276,8 +282,8 @@
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
# lea r11, [rdx+r11]
'\x4E\x8D\x1C\x1A'
- # mov [r11+4*rsi], -0x01234567
- '\x49\xC7\x04\xB3\x99\xBA\xDC\xFE'
+ # mov %fs:[r11+4*rsi], -0x01234567
+ '\x64\x49\xC7\x04\xB3\x99\xBA\xDC\xFE'
)
assert cb.getvalue() == expected_instructions
@@ -287,7 +293,7 @@
immed = 0x0123456789ABCDEF
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr),
+ cb.MOV(AddressLoc(SEGMENT_FS, ImmedLoc(0), ImmedLoc(0), 0, base_addr),
ImmedLoc(immed))
# this case is a MOV_ji
#
@@ -298,8 +304,8 @@
'\x48\xB8\xEF\xCD\xAB\x89\x67\x45\x23\x01'
# mov r11, 0xFEDCBA9876543210
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
- # mov [r11], rax
- '\x49\x89\x03'
+ # mov %fs:[r11], rax
+ '\x64\x49\x89\x03'
# pop rax
'\x58'
)
@@ -309,7 +315,7 @@
immed = 0x0123456789ABCDEF
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(AddressLoc(ImmedLoc(0), edx, 3, base_addr),
+ cb.MOV(AddressLoc(SEGMENT_FS, ImmedLoc(0), edx, 3, base_addr),
ImmedLoc(immed))
# this case is a MOV_ai
#
@@ -320,8 +326,8 @@
'\x48\xB8\xEF\xCD\xAB\x89\x67\x45\x23\x01'
# mov r11, 0xFEDCBA9876543210
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
- # mov [r11+8*rdx], rax
- '\x49\x89\x04\xD3'
+ # mov %fs:[r11+8*rdx], rax
+ '\x64\x49\x89\x04\xD3'
# pop rax
'\x58'
)
@@ -331,7 +337,7 @@
immed = 0x0123456789ABCDEF
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(AddressLoc(eax, ImmedLoc(0), 0, base_addr),
+ cb.MOV(AddressLoc(SEGMENT_FS, eax, ImmedLoc(0), 0, base_addr),
ImmedLoc(immed))
# this case is a MOV_mi
#
@@ -344,8 +350,8 @@
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
# lea r11, [rax+r11]
'\x4E\x8D\x1C\x18'
- # mov [r11], rdx
- '\x49\x89\x13'
+ # mov %fs:[r11], rdx
+ '\x64\x49\x89\x13'
# pop rdx
'\x5A'
)
@@ -355,7 +361,7 @@
immed = 0x0123456789ABCDEF
base_addr = 0xFEDCBA9876543210
cb = LocationCodeBuilder64()
- cb.MOV(AddressLoc(edx, eax, 2, base_addr), ImmedLoc(immed))
+ cb.MOV(AddressLoc(SEGMENT_FS, edx, eax, 2, base_addr), ImmedLoc(immed))
# this case is a MOV_ai
#
expected_instructions = (
@@ -367,8 +373,8 @@
'\x49\xBB\x10\x32\x54\x76\x98\xBA\xDC\xFE'
# lea r11, [rdx+r11]
'\x4E\x8D\x1C\x1A'
- # mov [r11+4*rax], rcx
- '\x49\x89\x0C\x83'
+ # mov %fs:[r11+4*rax], rcx
+ '\x64\x49\x89\x0C\x83'
# pop rcx
'\x59'
)
@@ -392,14 +398,14 @@
def test_inc_64bit_address_1(self):
base_addr = 0x0123456789ABCDEF
cb = LocationCodeBuilder64()
- cb.INC(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr))
+ cb.INC(AddressLoc(SEGMENT_FS, ImmedLoc(0), ImmedLoc(0), 0, base_addr))
# this case is a INC_j
#
expected_instructions = (
# mov r11, 0x0123456789ABCDEF
'\x49\xBB\xEF\xCD\xAB\x89\x67\x45\x23\x01'
- # inc [r11]
- '\x49\xFF\x03'
+ # inc %fs:[r11]
+ '\x64\x49\xFF\x03'
)
assert cb.getvalue() == expected_instructions
@@ -407,14 +413,14 @@
py.test.skip("there is no unary instruction INSN_a so far")
base_addr = 0x0123456789ABCDEF
cb = LocationCodeBuilder64()
- cb.INC(AddressLoc(ImmedLoc(0), edx, 3, base_addr))
+ cb.INC(AddressLoc(SEGMENT_FS, ImmedLoc(0), edx, 3, base_addr))
# this case would be a INC_a
xxx
def test_inc_64bit_address_3(self):
base_addr = 0x0123456789ABCDEF
cb = LocationCodeBuilder64()
- cb.INC(AddressLoc(eax, ImmedLoc(0), 0, base_addr))
+ cb.INC(AddressLoc(SEGMENT_FS, eax, ImmedLoc(0), 0, base_addr))
# this case is a INC_m
#
expected_instructions = (
@@ -422,7 +428,7 @@
'\x49\xBB\xEF\xCD\xAB\x89\x67\x45\x23\x01'
# lea r11, [rax+r11]
'\x4E\x8D\x1C\x18'
- # inc [r11]
- '\x49\xFF\x03'
+ # inc %fs:[r11]
+ '\x64\x49\xFF\x03'
)
assert cb.getvalue() == expected_instructions
More information about the pypy-commit
mailing list