Author: Maciej Fijalkowski <[email protected]>
Branch: optresult
Changeset: r74586:2902163d7469
Date: 2014-11-18 15:31 +0200
http://bitbucket.org/pypy/pypy/changeset/2902163d7469/

Log:    fix llgraph backend to run the first test

diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -25,7 +25,9 @@
         # We need to clone the list of operations because the
         # front-end will mutate them under our feet again.  We also
         # need to make sure things get freed.
-        def mapping(box, _cache={}):
+        _cache={}
+        
+        def mapping(box):
             if isinstance(box, Const) or box is None:
                 return box
             try:
@@ -44,10 +46,10 @@
                     newdescr = WeakrefDescr(op.getdescr())
             else:
                 newdescr = None
-            newop = op.copy_and_change(op.getopnum(),
+            newop = op._copy_and_change(op.getopnum(),
                                        map(mapping, op.getarglist()),
-                                       mapping(op.result),
                                        newdescr)
+            _cache[op] = newop
             if op.getfailargs() is not None:
                 newop.setfailargs(map(mapping, op.getfailargs()))
             self.operations.append(newop)
@@ -749,8 +751,8 @@
                     i = 0
                 self.do_renaming(targetargs, j.args)
                 continue
-            if op.result is not None:
-                self.setenv(op.result, resval)
+            if op.type != 'v':
+                self.setenv(op, resval)
             else:
                 assert resval is None
             i += 1
diff --git a/rpython/jit/backend/test/runner_test.py 
b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -7,7 +7,7 @@
                                          JitCellToken, TargetToken,
                                          ConstInt, ConstPtr,
                                          BoxFloat, ConstFloat)
-from rpython.jit.metainterp.resoperation import ResOperation, rop
+from rpython.jit.metainterp.resoperation import ResOperation, rop, InputArgInt
 from rpython.jit.metainterp.typesystem import deref
 from rpython.jit.codewriter.effectinfo import EffectInfo
 from rpython.jit.tool.oparser import parse
@@ -123,12 +123,10 @@
         self.cpu.done_with_this_frame_descr_void = None
 
     def test_compile_linear_loop(self):
-        i0 = BoxInt()
-        i1 = BoxInt()
-        operations = [
-            ResOperation(rop.INT_ADD, [i0, ConstInt(1)], i1),
-            ResOperation(rop.FINISH, [i1], None, descr=BasicFinalDescr(1))
-            ]
+        i0 = InputArgInt(0)
+        op0 = ResOperation(rop.INT_ADD, [i0, ConstInt(1)])
+        op1 = ResOperation(rop.FINISH, [op0], descr=BasicFinalDescr(1))
+        operations = [op0, op1]
         inputargs = [i0]
         looptoken = JitCellToken()
         self.cpu.compile_loop(inputargs, operations, looptoken)
diff --git a/rpython/jit/metainterp/resoperation.py 
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -86,7 +86,7 @@
     # common methods
     # --------------
 
-    def _copy_and_change(self, opnum, args=None, result=None, descr=None):
+    def _copy_and_change(self, opnum, args=None, descr=None):
         "shallow copy: the returned operation is meant to be used in place of 
self"
         if args is None:
             args = self.getarglist()
@@ -270,8 +270,8 @@
     def setfailargs(self, fail_args):
         self._fail_args = fail_args
 
-    def _copy_and_change(self, opnum, args=None, result=None, descr=None):
-        newop = AbstractResOp._copy_and_change(self, opnum, args, result, 
descr)
+    def _copy_and_change(self, opnum, args=None, descr=None):
+        newop = AbstractResOp._copy_and_change(self, opnum, args, descr)
         newop.setfailargs(self.getfailargs())
         return newop
 
@@ -345,15 +345,15 @@
         return None
         
 class InputArgInt(IntOp, AbstractInputArg):
-    def __init__(self, intval):
+    def __init__(self, intval=0):
         self.setint(intval)            
 
 class InputArgFloat(FloatOp, AbstractInputArg):
-    def __init__(self, f):
+    def __init__(self, f=0.0):
         self.setfloatstorage(f)
 
 class InputArgRef(RefOp, AbstractInputArg):
-    def __init__(self, r):
+    def __init__(self, r=lltype.nullptr(llmemory.GCREF.TO)):
         self.setref_base(r)
 
 # ============
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to