[pypy-commit] pypy default: Refactor away the 'width' attribute on AssemblerLocation.
arigo
noreply at buildbot.pypy.org
Wed Dec 14 12:35:07 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r50499:1665fe50f5da
Date: 2011-12-14 12:30 +0100
http://bitbucket.org/pypy/pypy/changeset/1665fe50f5da/
Log: Refactor away the 'width' attribute on AssemblerLocation.
diff --git a/pypy/jit/backend/x86/assembler.py b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -838,7 +838,7 @@
if isinstance(loc, RegLoc) and loc.is_xmm:
self.mc.SUB_ri(esp.value, 8) # = size of doubles
self.mc.MOVSD_sx(0, loc.value)
- elif WORD == 4 and isinstance(loc, StackLoc) and loc.width == 8:
+ elif WORD == 4 and isinstance(loc, StackLoc) and loc.get_width() == 8:
# XXX evil trick
self.mc.PUSH_b(get_ebp_ofs(loc.position))
self.mc.PUSH_b(get_ebp_ofs(loc.position + 1))
@@ -849,7 +849,7 @@
if isinstance(loc, RegLoc) and loc.is_xmm:
self.mc.MOVSD_xs(loc.value, 0)
self.mc.ADD_ri(esp.value, 8) # = size of doubles
- elif WORD == 4 and isinstance(loc, StackLoc) and loc.width == 8:
+ elif WORD == 4 and isinstance(loc, StackLoc) and loc.get_width() == 8:
# XXX evil trick
self.mc.POP_b(get_ebp_ofs(loc.position + 1))
self.mc.POP_b(get_ebp_ofs(loc.position))
@@ -1019,18 +1019,18 @@
self.mc.MOVSD_sx(p, loc.value)
else:
self.mc.MOV_sr(p, loc.value)
- p += round_up_to_4(loc.width)
+ p += loc.get_width()
p = 0
for i in range(start, n):
loc = arglocs[i]
if not isinstance(loc, RegLoc):
- if loc.width == 8:
+ if loc.get_width() == 8:
self.mc.MOVSD(xmm0, loc)
self.mc.MOVSD_sx(p, xmm0.value)
else:
self.mc.MOV(tmp, loc)
self.mc.MOV_sr(p, tmp.value)
- p += round_up_to_4(loc.width)
+ p += loc.get_width()
self._regalloc.reserve_param(p//WORD)
# x is a location
self.mc.CALL(x)
@@ -2083,7 +2083,7 @@
argtypes=op.getdescr().get_arg_types(),
callconv=op.getdescr().get_call_conv())
- if IS_X86_32 and isinstance(resloc, StackLoc) and resloc.width == 8:
+ if IS_X86_32 and isinstance(resloc, StackLoc) and resloc.type == FLOAT:
# a float or a long long return
if op.getdescr().get_return_type() == 'L':
self.mc.MOV_br(resloc.value, eax.value) # long long
@@ -2568,11 +2568,6 @@
num = getattr(rop, opname.upper())
genop_list[num] = value
-def round_up_to_4(size):
- if size < 4:
- return 4
- return size
-
# XXX: ri386 migration shims:
def addr_add(reg_or_imm1, reg_or_imm2, offset=0, scale=0):
return AddressLoc(reg_or_imm1, reg_or_imm2, scale, offset)
diff --git a/pypy/jit/backend/x86/jump.py b/pypy/jit/backend/x86/jump.py
--- a/pypy/jit/backend/x86/jump.py
+++ b/pypy/jit/backend/x86/jump.py
@@ -94,7 +94,7 @@
dstloc = dst_locations2[i]
if isinstance(loc, StackLoc):
key = loc._getregkey()
- if (key in dst_keys or (loc.width > WORD and
+ if (key in dst_keys or (loc.get_width() > WORD and
(key + WORD) in dst_keys)):
assembler.regalloc_push(loc)
extrapushes.append(dstloc)
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
@@ -130,9 +130,9 @@
@staticmethod
def frame_pos(i, box_type):
if IS_X86_32 and box_type == FLOAT:
- return StackLoc(i, get_ebp_ofs(i+1), 2, box_type)
+ return StackLoc(i, get_ebp_ofs(i+1), box_type)
else:
- return StackLoc(i, get_ebp_ofs(i), 1, box_type)
+ return StackLoc(i, get_ebp_ofs(i), box_type)
@staticmethod
def frame_size(box_type):
if IS_X86_32 and box_type == FLOAT:
diff --git a/pypy/jit/backend/x86/regloc.py b/pypy/jit/backend/x86/regloc.py
--- a/pypy/jit/backend/x86/regloc.py
+++ b/pypy/jit/backend/x86/regloc.py
@@ -16,8 +16,7 @@
#
class AssemblerLocation(object):
- # XXX: Is adding "width" here correct?
- _attrs_ = ('value', 'width', '_location_code')
+ _attrs_ = ('value', '_location_code')
_immutable_ = True
def _getregkey(self):
return self.value
@@ -28,6 +27,9 @@
def location_code(self):
return self._location_code
+ def get_width(self):
+ raise NotImplementedError
+
def value_r(self): return self.value
def value_b(self): return self.value
def value_s(self): return self.value
@@ -43,17 +45,21 @@
_immutable_ = True
_location_code = 'b'
- def __init__(self, position, ebp_offset, num_words, type):
+ def __init__(self, position, ebp_offset, type):
# _getregkey() returns self.value; the value returned must not
# conflict with RegLoc._getregkey(). It doesn't a bit by chance,
# so let it fail the following assert if it no longer does.
assert not (0 <= ebp_offset < 8 + 8 * IS_X86_64)
self.position = position
self.value = ebp_offset
- self.width = num_words * WORD
# One of INT, REF, FLOAT
self.type = type
+ def get_width(self):
+ if self.type == FLOAT:
+ return 8
+ return WORD
+
def __repr__(self):
return '%d(%%ebp)' % (self.value,)
@@ -67,10 +73,8 @@
self.value = regnum
self.is_xmm = is_xmm
if self.is_xmm:
- self.width = 8
self._location_code = 'x'
else:
- self.width = WORD
self._location_code = 'r'
def __repr__(self):
if self.is_xmm:
@@ -78,6 +82,11 @@
else:
return rx86.R.names[self.value]
+ def get_width(self):
+ if self.is_xmm:
+ return 8
+ return WORD
+
def lowest8bits(self):
assert not self.is_xmm
return RegLoc(rx86.low_byte(self.value), False)
@@ -100,7 +109,6 @@
class ImmedLoc(ImmediateAssemblerLocation):
_immutable_ = True
- width = WORD
_location_code = 'i'
def __init__(self, value):
@@ -111,6 +119,9 @@
def getint(self):
return self.value
+ def get_width(self):
+ return WORD
+
def __repr__(self):
return "ImmedLoc(%d)" % (self.value)
@@ -123,7 +134,6 @@
class AddressLoc(AssemblerLocation):
_immutable_ = True
- width = WORD
# The address is base_loc + (scaled_loc << scale) + static_offset
def __init__(self, base_loc, scaled_loc, scale=0, static_offset=0):
assert 0 <= scale < 4
@@ -152,6 +162,9 @@
info = getattr(self, attr, '?')
return '<AddressLoc %r: %s>' % (self._location_code, info)
+ def get_width(self):
+ return WORD
+
def value_a(self):
return self.loc_a
@@ -187,15 +200,15 @@
return result
class ConstFloatLoc(ImmediateAssemblerLocation):
- # XXX: We have to use this class instead of just AddressLoc because
- # we want a width of 8 (... I think. Check this!)
_immutable_ = True
- width = 8
_location_code = 'j'
def __init__(self, address):
self.value = address
+ def get_width(self):
+ return 8
+
def __repr__(self):
return '<ConstFloatLoc @%s>' % (self.value,)
@@ -206,12 +219,14 @@
# in two 32-bit halves. On 64-bit, FloatImmedLoc() is a function
# instead; see below.
_immutable_ = True
- width = 8
_location_code = '#' # don't use me
def __init__(self, floatstorage):
self.aslonglong = floatstorage
+ def get_width(self):
+ return 8
+
def low_part(self):
return intmask(self.aslonglong)
More information about the pypy-commit
mailing list