Author: Armin Rigo <ar...@tunes.org> Branch: reusing-r11 Changeset: r90967:b5e006d2ab59 Date: 2017-04-05 16:05 +0200 http://bitbucket.org/pypy/pypy/changeset/b5e006d2ab59/
Log: fixes 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 @@ -556,13 +556,13 @@ offset = r_uint(addr) - r_uint(self._scratch_register_value) offset = intmask(offset) if rx86.fits_in_32bits(offset): - print '_addr_as_reg_offset(%x) [REUSED r11+%d]' % ( - addr, offset) + #print '_addr_as_reg_offset(%x) [REUSED r11+%d]' % ( + # addr, offset) return (X86_64_SCRATCH_REG.value, offset) - print '_addr_as_reg_offset(%x) [too far]' % (addr,) + #print '_addr_as_reg_offset(%x) [too far]' % (addr,) # else: fall through - else: - print '_addr_as_reg_offset(%x) [new]' % (addr,) + #else: + # print '_addr_as_reg_offset(%x) [new]' % (addr,) self._scratch_register_value = addr self.MOV_ri(X86_64_SCRATCH_REG.value, addr) return (X86_64_SCRATCH_REG.value, 0) @@ -572,10 +572,9 @@ # 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 # as mode 'm' too. These are all possibly rare cases. - ofs = self._addr_as_reg_offset(static_offset) + reg, ofs = self._addr_as_reg_offset(static_offset) self.forget_scratch_register() - self.LEA_ra(X86_64_SCRATCH_REG.value, - (basereg, X86_64_SCRATCH_REG.value, 0, ofs)) + self.LEA_ra(X86_64_SCRATCH_REG.value, (basereg, reg, 0, ofs)) return (X86_64_SCRATCH_REG.value, 0) def _fix_static_offset_64_a(self, (basereg, scalereg, @@ -584,38 +583,38 @@ # where the static offset does not fit in 32-bits. We have to fall # back to the X86_64_SCRATCH_REG. In one case it is even more # annoying. These are all possibly rare cases. - ofs = self._addr_as_reg_offset(static_offset) + reg, ofs = self._addr_as_reg_offset(static_offset) # if basereg != rx86.NO_BASE_REGISTER: self.forget_scratch_register() - self.LEA_ra(X86_64_SCRATCH_REG.value, - (basereg, X86_64_SCRATCH_REG.value, 0, ofs)) + self.LEA_ra(X86_64_SCRATCH_REG.value, (basereg, reg, 0, ofs)) + reg = X86_64_SCRATCH_REG.value ofs = 0 - return (X86_64_SCRATCH_REG.value, scalereg, scale, ofs) + return (reg, scalereg, scale, ofs) def _load_scratch(self, value): if self._scratch_register_value != 0: if self._scratch_register_value == value: - print '_load_scratch(%x) [REUSED]' % (value,) + #print '_load_scratch(%x) [REUSED]' % (value,) return offset = r_uint(value) - r_uint(self._scratch_register_value) offset = intmask(offset) if rx86.fits_in_32bits(offset): - print '_load_scratch(%x) [LEA r11+%d]' % (value, offset) - global COUNT_ - try: - COUNT_ += 1 - except NameError: - COUNT_ = 1 - if COUNT_ % 182 == 0: - import pdb;pdb.set_trace() + #print '_load_scratch(%x) [LEA r11+%d]' % (value, offset) + #global COUNT_ + #try: + # COUNT_ += 1 + #except NameError: + # COUNT_ = 1 + #if COUNT_ % 182 == 0: + # import pdb;pdb.set_trace() self.LEA_rm(X86_64_SCRATCH_REG.value, (X86_64_SCRATCH_REG.value, offset)) self._scratch_register_value = value return - print '_load_scratch(%x) [too far]' % (value,) - else: - print '_load_scratch(%x) [new]' % (value,) + #print '_load_scratch(%x) [too far]' % (value,) + #else: + # print '_load_scratch(%x) [new]' % (value,) self._scratch_register_value = value self.MOV_ri(X86_64_SCRATCH_REG.value, value) diff --git a/rpython/jit/backend/x86/test/test_jump.py b/rpython/jit/backend/x86/test/test_jump.py --- a/rpython/jit/backend/x86/test/test_jump.py +++ b/rpython/jit/backend/x86/test/test_jump.py @@ -26,6 +26,11 @@ assert isinstance(to_loc, FrameLoc) self.ops.append(('immedmem2mem', from_loc, to_loc)) + class mc: + @staticmethod + def forget_scratch_register(): + pass + def got(self, expected): print '------------------------ comparing ---------------------------' for op1, op2 in zip(self.ops, expected): @@ -405,6 +410,10 @@ print "pop", x def regalloc_immedmem2mem(self, x, y): print "?????????????????????????" + class mc: + @staticmethod + def forget_scratch_register(): + pass def main(): srclocs = [FrameLoc(9999, x, 'i') for x,y in CASE] dstlocs = [FrameLoc(9999, y, 'i') for x,y in CASE] 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 @@ -149,10 +149,8 @@ def test_reuse_scratch_register(self): base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() - cb.begin_reuse_scratch_register() cb.MOV(ecx, heap(base_addr)) cb.MOV(ecx, heap(base_addr + 8)) - cb.end_reuse_scratch_register() expected_instructions = ( # mov r11, 0xFEDCBA9876543210 @@ -213,12 +211,9 @@ def test_64bit_address_4(self): base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() - cb.begin_reuse_scratch_register() - assert cb._reuse_scratch_register is True - assert cb._scratch_register_known is False + assert cb._scratch_register_value == 0 cb.MOV(ecx, AddressLoc(edx, esi, 2, base_addr)) - assert cb._reuse_scratch_register is True - assert cb._scratch_register_known is False + assert cb._scratch_register_value == 0 # this case is a CMP_ra # expected_instructions = ( _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit