[pypy-svn] pypy jit-longlong: Improve OS_LLONG_FROM_INT(constant).
arigo
commits-noreply at bitbucket.org
Sun Jan 9 12:56:56 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: jit-longlong
Changeset: r40514:dbe809035737
Date: 2011-01-09 12:56 +0100
http://bitbucket.org/pypy/pypy/changeset/dbe809035737/
Log: Improve OS_LLONG_FROM_INT(constant).
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
@@ -1116,13 +1116,12 @@
not_implemented("llong_to_int: %s" % (loc,))
def genop_llong_from_int(self, op, arglocs, resloc):
- assert isinstance(resloc, StackLoc)
loc = arglocs[0]
- if isinstance(loc, ImmedLoc):
- self.mc.MOV_bi(resloc.value, loc.value)
- self.mc.MOV_bi(resloc.value + 4, loc.value >> 31)
+ if isinstance(loc, ConstFloatLoc):
+ self.mc.MOVSD(resloc, loc)
else:
assert loc is eax
+ assert isinstance(resloc, StackLoc)
self.mc.CDQ() # eax -> eax:edx
self.mc.MOV_br(resloc.value, eax.value)
self.mc.MOV_br(resloc.value + 4, edx.value)
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
@@ -4,7 +4,7 @@
import os
from pypy.jit.metainterp.history import (Box, Const, ConstInt, ConstPtr,
- ResOperation, BoxPtr,
+ ResOperation, BoxPtr, ConstFloat,
LoopToken, INT, REF, FLOAT)
from pypy.jit.backend.x86.regloc import *
from pypy.rpython.lltypesystem import lltype, ll2ctypes, rffi, rstr
@@ -647,17 +647,26 @@
self.xrm.possibly_free_var(op.getarg(1))
def _consider_llong_from_int(self, op):
- # requires the argument to be in eax, and trash edx.
- # requires the result to be in the stack.
- loc0 = self.fm.loc(op.result)
- loc1 = self.rm.make_sure_var_in_reg(op.getarg(1), selected_reg=eax)
- if not isinstance(loc1, ImmedLoc):
+ assert IS_X86_32
+ box = op.getarg(1)
+ if isinstance(box, ConstInt):
+ from pypy.rlib.longlong2float import longlong2float
+ from pypy.rlib.rarithmetic import r_longlong
+ import pdb; pdb.set_trace()
+ value = r_longlong(box.value)
+ c = ConstFloat(longlong2float(value))
+ loc1 = self.xrm.convert_to_imm(c)
+ loc0 = self.xrm.force_allocate_reg(op.result)
+ else:
+ # requires the argument to be in eax, and trash edx.
+ # requires the result to be in the stack.
+ loc1 = self.rm.make_sure_var_in_reg(box, selected_reg=eax)
+ loc0 = self.fm.loc(op.result)
tmpvar = TempBox()
- self.rm.force_allocate_reg(tmpvar, [op.getarg(1)],
- selected_reg=edx)
+ self.rm.force_allocate_reg(tmpvar, [box], selected_reg=edx)
self.rm.possibly_free_var(tmpvar)
self.PerformLLong(op, [loc1], loc0)
- self.rm.possibly_free_var(op.getarg(1))
+ self.rm.possibly_free_var(box)
def _consider_llong_from_two_ints(self, op):
# requires the arguments to be in registers or immediates.
More information about the Pypy-commit
mailing list