[pypy-svn] r29485 - in pypy/dist/pypy: jit/llabstractinterp rpython rpython/lltypesystem rpython/test

arigo at codespeak.net arigo at codespeak.net
Thu Jun 29 12:24:02 CEST 2006


Author: arigo
Date: Thu Jun 29 12:24:00 2006
New Revision: 29485

Modified:
   pypy/dist/pypy/jit/llabstractinterp/llabstractinterp.py
   pypy/dist/pypy/jit/llabstractinterp/vlist.py
   pypy/dist/pypy/rpython/lltypesystem/rlist.py
   pypy/dist/pypy/rpython/rtyper.py
   pypy/dist/pypy/rpython/test/test_rlist.py
Log:
(pedronis, arre, arigo)
Trying to make various op-generating interfaces converge.


Modified: pypy/dist/pypy/jit/llabstractinterp/llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp/llabstractinterp.py	(original)
+++ pypy/dist/pypy/jit/llabstractinterp/llabstractinterp.py	Thu Jun 29 12:24:00 2006
@@ -538,12 +538,15 @@
             ls.link = cases[ls.exitcase]
         return b
 
-    def genop(self, opname, args, RESULT_TYPE):
+    def genop(self, opname, args, RESULT_TYPE=lltype.Void):
         return rgenop.genop(self.newblock, opname, args,
                             rgenop.constTYPE(RESULT_TYPE))
 
     def genconst(self, llvalue):
         return rgenop.genconst(llvalue)
+
+    def genvoidconst(self, placeholder):
+        return rgenop.placeholder(placeholder)
     
     def binding(self, v):
         assert isinstance(v, (Constant, Variable))

Modified: pypy/dist/pypy/jit/llabstractinterp/vlist.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp/vlist.py	(original)
+++ pypy/dist/pypy/jit/llabstractinterp/vlist.py	Thu Jun 29 12:24:00 2006
@@ -41,7 +41,7 @@
 
     def build_runtime_container(self, builder):
         items_v = [a.forcegenvarorconst(builder) for a in self.items_a]
-        v_result = self.T.list_builder(builder, items_v)
+        v_result = self.T.list_builder.build(builder, items_v)
         return v_result
 
     # ____________________________________________________________

Modified: pypy/dist/pypy/rpython/lltypesystem/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rlist.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rlist.py	Thu Jun 29 12:24:00 2006
@@ -116,22 +116,21 @@
         #self.c_dum_nocheck = inputconst(Void, dum_nocheck)
         #self.c_LIST = inputconst(Void, self.LIST)
 
-    def __call__(self, builder, items_v):
+    def build(self, llops, items_v):
         """Make the operations that would build a list containing the
         provided items."""
-        from pypy.rpython import rgenop
-        c_newlist = builder.genconst(self.newlist_ptr)
-        c_len  = builder.genconst(len(items_v))
-        v_result = builder.genop('direct_call',
-                                 [c_newlist, rgenop.placeholder(self.LIST), c_len],
-                                 self.LISTPTR)
-        c_setitem_nonneg = builder.genconst(self.setitem_nonneg_ptr)
-        for i, v in enumerate(items_v):
-            c_i = builder.genconst(i)
-            builder.genop('direct_call', [c_setitem_nonneg,
-                                          rgenop.placeholder(dum_nocheck),
-                                          v_result, c_i, v],
-                          Void)
+        c_newlist = llops.genconst(self.newlist_ptr)
+        c_len     = llops.genconst(len(items_v))
+        c_LIST    = llops.genvoidconst(self.LIST)
+        v_result = llops.genop('direct_call',
+                               [c_newlist, c_LIST, c_len],
+                               self.LISTPTR)
+        c_setitem_nonneg = llops.genconst(self.setitem_nonneg_ptr)
+        for i in range(len(items_v)):
+            c_i = llops.genconst(i)
+            llops.genop('direct_call', [c_setitem_nonneg,
+                                        llops.genvoidconst(dum_nocheck),
+                                        v_result, c_i, items_v[i]])
         return v_result
 
     def getlistptr(self):

Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py	(original)
+++ pypy/dist/pypy/rpython/rtyper.py	Thu Jun 29 12:24:00 2006
@@ -887,6 +887,12 @@
     def gencapicall(self, cfnname, args_v, resulttype=None, **flags):
         return self.genexternalcall(cfnname, args_v, resulttype=resulttype, external="C", **flags)
 
+    def genconst(self, ll_value):
+        return inputconst(typeOf(ll_value), ll_value)
+
+    def genvoidconst(self, placeholder):
+        return inputconst(Void, placeholder)
+
 # _______________________________________________________________________
 # this has the side-effect of registering the unary and binary operations
 # and the rtyper_chooserepr() methods

Modified: pypy/dist/pypy/rpython/test/test_rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rlist.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rlist.py	Thu Jun 29 12:24:00 2006
@@ -194,44 +194,19 @@
         lst.append(42)
         return lst
 
-    from pypy.rpython import rgenop
-    from pypy.rpython.module import support
-
-    class DummyBlockBuilder:
-
-        def __init__(self):
-            self.newblock = rgenop.newblock()
-            self.bareblock = support.from_opaque_object(self.newblock.obj)
-
-        def genop(self, opname, args, RESULT_TYPE):
-            return rgenop.genop(self.newblock, opname, args,
-                                rgenop.constTYPE(RESULT_TYPE))
-
-        def genconst(self, llvalue):
-            return rgenop.genconst(llvalue)
-
-        # inspection
-        def __getitem__(self, index):
-            return self.bareblock.operations[index]
-
-        def __len__(self):
-            return len(self.bareblock.operations)
-
+    from pypy.rpython.rtyper import LowLevelOpList
 
     for fn in [fixed_size_case, variable_size_case]:
         t = TranslationContext()
         t.buildannotator().build_types(fn, [])
         t.buildrtyper().specialize()
         LIST = t.graphs[0].getreturnvar().concretetype.TO
-        llop = DummyBlockBuilder()
+        llop = LowLevelOpList(None)
         v0 = Constant(42)
         v0.concretetype = Signed
-        opq_v0 = support.to_opaque_object(v0)
         v1 = Variable()
         v1.concretetype = Signed
-        opq_v1 = support.to_opaque_object(v1)
-        vr = LIST.list_builder(llop, [opq_v0, opq_v1])
-        vr = rgenop.reveal(vr)
+        vr = LIST.list_builder.build(llop, [v0, v1])
         assert len(llop) == 3
         assert llop[0].opname == 'direct_call'
         assert len(llop[0].args) == 3



More information about the Pypy-commit mailing list