[pypy-svn] r23037 - in pypy/dist/pypy/jit: . test
arigo at codespeak.net
arigo at codespeak.net
Sun Feb 5 14:34:03 CET 2006
Author: arigo
Date: Sun Feb 5 14:33:57 2006
New Revision: 23037
Modified:
pypy/dist/pypy/jit/hintrconstant.py
pypy/dist/pypy/jit/hintrtyper.py
pypy/dist/pypy/jit/test/test_hint_rtyping.py
Log:
Some minor progress. Moved fixedrepr() in hintrconstant.getfixedrepr(),
to be consistent with e.g. getinstancerepr() usage in the rtyper.
Modified: pypy/dist/pypy/jit/hintrconstant.py
==============================================================================
--- pypy/dist/pypy/jit/hintrconstant.py (original)
+++ pypy/dist/pypy/jit/hintrconstant.py Sun Feb 5 14:33:57 2006
@@ -2,12 +2,13 @@
from pypy.jit.hintrtyper import HintTypeSystem
from pypy.jit.hintmodel import SomeLLAbstractConstant
from pypy.rpython.rmodel import Repr
+from pypy.rpython.lltypesystem import lltype
class __extend__(pairtype(HintTypeSystem, SomeLLAbstractConstant)):
def rtyper_makerepr((ts, hs_c), rtyper):
if hs_c.is_fixed() or hs_c.eager_concrete:
- return LLFixedConstantRepr(hs_c.concretetype)
+ return getfixedrepr(rtyper, hs_c.concretetype)
else:
XXX
@@ -15,12 +16,31 @@
fixed = hs_c.is_fixed() or hs_c.eager_concrete
return hs_c.__class__, fixed, hs_c.concretetype
+
class LLFixedConstantRepr(Repr):
def __init__(self, lowleveltype):
self.lowleveltype = lowleveltype
-#...
-#
-# def rtype_int_add(_, hop):
-# hop.inputargs(
+ def rtype_hint(self, hop):
+ # discard the hint operation
+ return hop.inputarg(self, arg=0)
+
+
+class __extend__(pairtype(LLFixedConstantRepr, LLFixedConstantRepr)):
+
+ def rtype_int_add(_, hop):
+ vlist = hop.inputargs(fixed_signed_repr, fixed_signed_repr)
+ return hop.genop('int_add', vlist, resulttype=lltype.Signed)
+
+# ____________________________________________________________
+
+def getfixedrepr(rtyper, lowleveltype):
+ try:
+ return rtyper._fixed_reprs[lowleveltype]
+ except KeyError:
+ r = LLFixedConstantRepr(lowleveltype)
+ rtyper._fixed_reprs[lowleveltype] = r
+ return r
+
+fixed_signed_repr = LLFixedConstantRepr(lltype.Signed)
Modified: pypy/dist/pypy/jit/hintrtyper.py
==============================================================================
--- pypy/dist/pypy/jit/hintrtyper.py (original)
+++ pypy/dist/pypy/jit/hintrtyper.py Sun Feb 5 14:33:57 2006
@@ -17,17 +17,11 @@
def __init__(self, hannotator):
RPythonTyper.__init__(self, hannotator,
type_system=HintTypeSystem.instance)
- self._canonical_reprs = {}
-
- def fixedrepr(self, lowleveltype):
- key = True, lowleveltype
- try:
- repr = self._canonical_reprs[key]
- except KeyError:
- hs = hintmodel.SomeLLAbstractConstant(lowleveltype, {})
- hs.eager_concrete = True
- repr = self._canonical_reprs[key] = self.getrepr(hs)
- return repr
+ self._fixed_reprs = {}
+ # insert the precomputed fixed reprs
+ for key, value in hintrconstant.__dict__.items():
+ if isinstance(value, hintrconstant.LLFixedConstantRepr):
+ self._fixed_reprs[value.lowleveltype] = value
# register operations from model
HintTyper._registeroperations(hintmodel)
Modified: pypy/dist/pypy/jit/test/test_hint_rtyping.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_rtyping.py (original)
+++ pypy/dist/pypy/jit/test/test_hint_rtyping.py Sun Feb 5 14:33:57 2006
@@ -39,12 +39,21 @@
def test_canonical_reprs():
from pypy.jit import hintrconstant
htyper = HintTyper(None)
- r_fixed_signed = htyper.fixedrepr(lltype.Signed)
+ r_fixed_signed = hintrconstant.getfixedrepr(htyper, lltype.Signed)
assert isinstance(r_fixed_signed, hintrconstant.LLFixedConstantRepr)
assert r_fixed_signed.lowleveltype == lltype.Signed
- r_fixed_signed2 = htyper.fixedrepr(lltype.Signed)
+ r_fixed_signed2 = hintrconstant.getfixedrepr(htyper, lltype.Signed)
assert r_fixed_signed2 is r_fixed_signed
+def test_simple_fixed():
+ def ll_function(x, y):
+ return hint(x + y, concrete=True)
+ hs, ha = hannotate(ll_function, [int, int], annotator=True)
+ htyper = HintTyper(ha)
+ htyper.specialize()
+ if conftest.option.view:
+ ha.translator.view()
+
def test_simple():
py.test.skip("in-progress")
def ll_function(x, y):
More information about the Pypy-commit
mailing list