[pypy-svn] r37690 - in pypy/dist/pypy/jit/codegen: ppc ppc/test test
mwh at codespeak.net
mwh at codespeak.net
Wed Jan 31 20:54:20 CET 2007
Author: mwh
Date: Wed Jan 31 20:54:19 2007
New Revision: 37690
Modified:
pypy/dist/pypy/jit/codegen/ppc/emit_moves.py
pypy/dist/pypy/jit/codegen/ppc/rgenop.py
pypy/dist/pypy/jit/codegen/ppc/test/test_emit_moves.py
pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py
pypy/dist/pypy/jit/codegen/test/rgenop_tests.py
Log:
point the first: emit_moves depended on dictionary order. fix that.
point the second: it has a bug when sources are read more than one. add a
skipped test to rgenop_tests that demonstrates this and a boiled down one to
test_emit_moves. the fix will have to wait until tomorrow, or friday more
likely...
Modified: pypy/dist/pypy/jit/codegen/ppc/emit_moves.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/emit_moves.py (original)
+++ pypy/dist/pypy/jit/codegen/ppc/emit_moves.py Wed Jan 31 20:54:19 2007
@@ -10,7 +10,7 @@
# emitted -> list of emitted targets
pass
-def emit_moves(gen, tar2src, tar2loc, src2loc):
+def emit_moves(gen, tarvars, tar2src, tar2loc, src2loc):
# Basic idea:
#
@@ -33,8 +33,6 @@
# its dependent moves have been performed, so you can emit the
# node's move and return.
- tarvars = tar2src.keys()
-
data = CycleData()
data.tar2src = tar2src
data.src2tar = {}
Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/rgenop.py (original)
+++ pypy/dist/pypy/jit/codegen/ppc/rgenop.py Wed Jan 31 20:54:19 2007
@@ -167,6 +167,7 @@
# construct mapping of targets to sources; note that "target vars"
# and "target locs" are the same thing right now
targetlocs = target.arg_locations
+ tarvars = []
if DEBUG_PRINT:
print targetlocs
@@ -178,9 +179,10 @@
if isinstance(src, Var):
tar2loc[tloc] = tloc
tar2src[tloc] = src
+ tarvars.append(tloc)
gen = JumpPatchupGenerator(insns, allocator)
- emit_moves(gen, tar2src, tar2loc, src2loc)
+ emit_moves(gen, tarvars, tar2src, tar2loc, src2loc)
for i in range(len(targetlocs)):
tloc = targetlocs[i]
Modified: pypy/dist/pypy/jit/codegen/ppc/test/test_emit_moves.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/test/test_emit_moves.py (original)
+++ pypy/dist/pypy/jit/codegen/ppc/test/test_emit_moves.py Wed Jan 31 20:54:19 2007
@@ -20,7 +20,7 @@
src2loc = {'a':0, 'b':1}
assert heap.data[0] == 0
assert heap.data[1] == 1
- emit_moves(heap, tar2src, tar2loc, src2loc)
+ emit_moves(heap, tar2src.keys(), tar2src, tar2loc, src2loc)
assert heap.data[0] == 1
assert heap.data[1] == 0
assert heap.numlocs == 3 # only creates 1 extra loc
@@ -33,7 +33,7 @@
assert heap.data[0] == 0
assert heap.data[1] == 1
assert heap.data[2] == 2
- emit_moves(heap, tar2src, tar2loc, src2loc)
+ emit_moves(heap, tar2src.keys(), tar2src, tar2loc, src2loc)
assert heap.data[0] == 1
assert heap.data[1] == 2
assert heap.data[2] == 0
@@ -47,8 +47,24 @@
assert heap.data[0] == 0
assert heap.data[1] == 1
assert heap.data[2] == 2
- emit_moves(heap, tar2src, tar2loc, src2loc)
+ emit_moves(heap, tar2src.keys(), tar2src, tar2loc, src2loc)
assert heap.data[0] == 1
assert heap.data[1] == 2
assert heap.data[2] == 2
assert heap.numlocs == 3 # only creates 1 extra loc
+
+
+def test_one_to_many():
+ py.test.skip("failing :(")
+ heap = TheHeap(4)
+ tar2src = {'A':'a', 'B':'b', 'C':'a'}
+ tar2loc = {'A':2, 'B':1, 'C':3}
+ src2loc = {'a':1, 'b':0}
+ assert heap.data[0] == 0 # b
+ assert heap.data[1] == 1 # a
+ assert heap.data[2] == 2
+ assert heap.data[3] == 3
+ emit_moves(heap, ['B', 'A', 'C'], tar2src, tar2loc, src2loc)
+ assert heap.data[1] == 0 # B
+ assert heap.data[2] == 1 # A
+ assert heap.data[3] == 1 # C
Modified: pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py (original)
+++ pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py Wed Jan 31 20:54:19 2007
@@ -25,6 +25,9 @@
def test_read_frame_place_direct(self): py.test.skip("in-progress")
def test_read_frame_place_compile(self): py.test.skip("in-progress")
+ def test_from_random_4_direct(self):
+ py.test.skip("failing :( -- see test_one_to_many in test_emit_moves")
+
class TestRPPCGenopNoRegs(TestRPPCGenop):
RGenOp = FewRegisters
Modified: pypy/dist/pypy/jit/codegen/test/rgenop_tests.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/test/rgenop_tests.py (original)
+++ pypy/dist/pypy/jit/codegen/test/rgenop_tests.py Wed Jan 31 20:54:19 2007
@@ -1576,3 +1576,62 @@
res = fnptr(2, 10, 10, 400, 0)
assert res == 0
+
+ def test_from_random_4_direct(self):
+ rgenop = self.RGenOp()
+ signed_kind = rgenop.kindToken(lltype.Signed)
+ bool_kind = rgenop.kindToken(lltype.Bool)
+
+ builder0, gv_callable, [v0, v1, v2] = rgenop.newgraph(
+ rgenop.sigToken(FUNC3), 'compiled_dummyfn')
+
+ builder0.start_writing()
+
+ args_gv = [v0, v1, v2]
+ label0 = builder0.enter_next_block([signed_kind, signed_kind, signed_kind], args_gv)
+ [v3, v4, v5] = args_gv
+
+ v6 = builder0.genop2('int_add', v5, v4)
+ v7 = builder0.genop1('int_is_true', v4)
+ builder1 = builder0.jump_if_false(v7, [v4, v5, v3, v6])
+
+ args_gv = [v3, v4, v5]
+ label1 = builder0.enter_next_block([signed_kind, signed_kind, signed_kind], args_gv)
+ [v8, v9, v10] = args_gv
+
+ v11 = builder0.genop1('int_is_true', v10)
+ builder2 = builder0.jump_if_true(v11, [v9, v10, v8])
+
+ builder0.finish_and_goto([v8, v9, v10], label1)
+
+ builder1.start_writing()
+ v24 = builder1.genop2('int_sub', v3, rgenop.genconst(1))
+ v25 = builder1.genop1('int_is_true', v24)
+ builder7 = builder1.jump_if_true(v25, [v24, v4, v5])
+
+ args_gv = [v5, v6, v4]
+ label4 = builder1.enter_next_block([signed_kind, signed_kind, signed_kind], args_gv)
+ [v26, v27, v28] = args_gv
+
+ builder1.finish_and_return(rgenop.sigToken(FUNC3), v27)
+
+ builder2.start_writing()
+ v33 = builder2.genop2('int_sub', v8, rgenop.genconst(1))
+ v34 = builder2.genop1('int_is_true', v33)
+ builder8 = builder2.jump_if_false(v34, [v10, v9])
+
+ builder2.finish_and_goto([v33, v9, v10], label1)
+
+ print 'waatch!'
+ builder8.start_writing()
+ builder8.finish_and_goto([v10, v9, v9], label4)
+ print 'stop!'
+
+ builder7.start_writing()
+ builder7.finish_and_goto([v24, v4, v5], label0)
+ builder7.end()
+
+ fnptr = self.cast(gv_callable, 3)
+
+ res = fnptr(10, 29, 12)
+ assert res == 29
More information about the Pypy-commit
mailing list