Author: hager <[email protected]>
Branch: ppc-jit-backend
Changeset: r52238:18df2e1a3175
Date: 2012-02-08 16:30 +0100
http://bitbucket.org/pypy/pypy/changeset/18df2e1a3175/
Log: kill more unused code
diff --git a/pypy/jit/backend/ppc/func_builder.py
b/pypy/jit/backend/ppc/func_builder.py
deleted file mode 100644
--- a/pypy/jit/backend/ppc/func_builder.py
+++ /dev/null
@@ -1,160 +0,0 @@
-from pypy.jit.backend.ppc.ppc_assembler import PPCAssembler
-from pypy.jit.backend.ppc.symbol_lookup import lookup
-from pypy.jit.backend.ppc.regname import *
-
-def load_arg(code, argi, typecode):
- rD = r3+argi
- code.lwz(rD, r4, 12 + 4*argi)
- if typecode == 'i':
- code.load_word(r0, lookup("PyInt_Type"))
- code.lwz(r31, rD, 4) # XXX ick!
- code.cmpw(r0, r31)
- code.bne("argserror")
- code.lwz(rD, rD, 8)
- elif typecode == 'f':
- code.load_word(r0, lookup("PyFloat_Type"))
- code.lwz(r31, rD, 4)
- code.cmpw(r0, r31)
- code.bne("argserror")
- code.lfd(rD-2, rD, 8)
- elif typecode != "O":
- raise Exception, "erk"
-
-FAST_ENTRY_LABEL = "FAST-ENTRY-LABEL"
-
-def make_func(code, retcode, signature, localwords=0):
- """code shouldn't contain prologue/epilogue (or touch r31)"""
-
- stacksize = 80 + 4*localwords
-
- argcount = len(signature)
-
- ourcode = MyPPCAssembler()
- ourcode.mflr(r0)
- ourcode.stmw(r31, r1, -4)
- ourcode.stw(r0, r1, 8)
- ourcode.stwu(r1, r1, -stacksize)
-
- ourcode.lwz(r3, r4, 8)
- ourcode.cmpwi(r3, argcount)
- ourcode.bne("argserror")
-
- assert argcount < 9
-
- if argcount > 0:
- load_arg(ourcode, 0, signature[0])
- for i in range(2, argcount):
- load_arg(ourcode, i, signature[i])
- if argcount > 1:
- load_arg(ourcode, 1, signature[1])
-
- ourcode.bl(FAST_ENTRY_LABEL)
-
- if retcode == 'i':
- s = lookup("PyInt_FromLong")
- ourcode.load_word(r0, s)
- ourcode.mtctr(r0)
- ourcode.bctrl()
- elif retcode == 'f':
- s = lookup("PyFloat_FromDouble")
- ourcode.load_word(r0, s)
- ourcode.mtctr(r0)
- ourcode.bctrl()
-
- ourcode.label("epilogue")
- ourcode.lwz(r0, r1, stacksize + 8)
- ourcode.addi(r1, r1, stacksize)
- ourcode.mtlr(r0)
- ourcode.lmw(r31, r1, -4)
- ourcode.blr()
-
- err_set = lookup("PyErr_SetObject")
- exc = lookup("PyExc_TypeError")
-
- ourcode.label("argserror")
- ourcode.load_word(r5, err_set)
- ourcode.mtctr(r5)
- ourcode.load_from(r3, exc)
- ourcode.mr(r4, r3)
- ourcode.bctrl()
-
- ourcode.li(r3, 0)
- ourcode.b("epilogue")
-
- ourcode.label(FAST_ENTRY_LABEL)
- # err, should be an Assembler method:
- l = {}
- for k in code.labels:
- l[k] = code.labels[k] + 4*len(ourcode.insts)
- r = code.rlabels.copy()
- for k in code.rlabels:
- r[k + 4*len(ourcode.insts)] = code.rlabels[k]
- ourcode.insts.extend(code.insts)
- ourcode.labels.update(l)
- ourcode.rlabels.update(r)
-
- r = ourcode.assemble()
- r.FAST_ENTRY_LABEL = ourcode.labels[FAST_ENTRY_LABEL]
- return r
-
-def wrap(funcname, retcode, signature):
-
- argcount = len(signature)
-
- ourcode = MyPPCAssembler()
- ourcode.mflr(r0)
- ourcode.stmw(r31, r1, -4)
- ourcode.stw(r0, r1, 8)
- ourcode.stwu(r1, r1, -80)
-
- ourcode.lwz(r3, r4, 8)
- ourcode.cmpwi(r3, argcount)
- ourcode.bne("argserror")
-
- assert argcount < 9
-
- if argcount > 0:
- load_arg(ourcode, 0, signature[0])
- for i in range(2, argcount):
- load_arg(ourcode, i, signature[i])
- if argcount > 1:
- load_arg(ourcode, 1, signature[1])
-
-
- ourcode.load_word(r0, lookup(funcname))
- ourcode.mtctr(r0)
- ourcode.bctrl()
-
- if retcode == 'i':
- s = lookup("PyInt_FromLong")
- ourcode.load_word(r0, s)
- ourcode.mtctr(r0)
- ourcode.bctrl()
- elif retcode == 'f':
- s = lookup("PyFloat_FromDouble")
- ourcode.load_word(r0, s)
- ourcode.mtctr(r0)
- ourcode.bctrl()
-
- ourcode.label("epilogue")
- ourcode.lwz(r0, r1, 88)
- ourcode.addi(r1, r1, 80)
- ourcode.mtlr(r0)
- ourcode.lmw(r31, r1, -4)
- ourcode.blr()
-
- err_set = lookup("PyErr_SetObject")
- exc = lookup("PyExc_TypeError")
-
- ourcode.label("argserror")
- ourcode.load_word(r5, err_set)
- ourcode.mtctr(r5)
- ourcode.load_from(r3, exc)
- ourcode.mr(r4, r3)
- ourcode.bctrl()
-
- ourcode.li(r3, 0)
- ourcode.b("epilogue")
-
- return ourcode.assemble()
-
diff --git a/pypy/jit/backend/ppc/test/test_func_builder.py
b/pypy/jit/backend/ppc/test/test_func_builder.py
deleted file mode 100644
--- a/pypy/jit/backend/ppc/test/test_func_builder.py
+++ /dev/null
@@ -1,87 +0,0 @@
-import py
-import random, sys, os
-
-from pypy.jit.backend.ppc.ppc_assembler import MyPPCAssembler
-from pypy.jit.backend.ppc.symbol_lookup import lookup
-from pypy.jit.backend.ppc.func_builder import make_func
-from pypy.jit.backend.ppc import form, func_builder
-from pypy.jit.backend.ppc.regname import *
-from pypy.jit.backend.detect_cpu import autodetect_main_model
-
-class TestFuncBuilderTest(object):
- def setup_class(cls):
- if autodetect_main_model() not in ["ppc", "ppc64"]:
- py.test.skip("can't test all of ppcgen on non-PPC!")
-
- def test_simple(self):
- a = MyPPCAssembler()
- a.blr()
- f = make_func(a, "O", "O")
- assert f(1) == 1
- raises(TypeError, f)
- raises(TypeError, f, 1, 2)
-
- def test_less_simple(self):
- a = MyPPCAssembler()
- s = lookup("PyNumber_Add")
- a.load_word(r5, s)
- a.mtctr(r5)
- a.bctr()
- f = make_func(a, "O", "OO")
- raises(TypeError, f)
- raises(TypeError, f, 1)
- assert f(1, 2) == 3
- raises(TypeError, f, 1, 2, 3)
-
- def test_signature(self):
- a = MyPPCAssembler()
- a.add(r3, r3, r4)
- a.blr()
- f = make_func(a, "i", "ii")
- raises(TypeError, f)
- raises(TypeError, f, 1)
- assert f(1, 2) == 3
- raises(TypeError, f, 1, 2, 3)
- raises(TypeError, f, 1, "2")
-
- def test_signature2(self):
- a = MyPPCAssembler()
- a.add(r3, r3, r4)
- a.add(r3, r3, r5)
- a.add(r3, r3, r6)
- a.add(r3, r3, r7)
- s = lookup("PyInt_FromLong")
- a.load_word(r0, s)
- a.mtctr(r0)
- a.bctr()
- f = make_func(a, "O", "iiiii")
- raises(TypeError, f)
- raises(TypeError, f, 1)
- assert f(1, 2, 3, 4, 5) == 1 + 2 + 3 + 4 + 5
- raises(TypeError, f, 1, 2, 3)
- raises(TypeError, f, 1, "2", 3, 4, 5)
-
- def test_floats(self):
- a = MyPPCAssembler()
- a.fadd(fr1, fr1, fr2)
- a.blr()
- f = make_func(a, 'f', 'ff')
- raises(TypeError, f)
- raises(TypeError, f, 1.0)
- assert f(1.0, 2.0) == 3.0
- raises(TypeError, f, 1.0, 2.0, 3.0)
- raises(TypeError, f, 1.0, 2)
-
- def test_fast_entry(self):
- a = MyPPCAssembler()
- a.blr()
- f = make_func(a, "O", "O")
- assert f(1) == 1
- b = MyPPCAssembler()
- from pypy.jit.backend.ppc import util
- # eurgh!:
- b.load_word(r0, util.access_at(id(f.code), 8) + f.FAST_ENTRY_LABEL)
- b.mtctr(r0)
- b.bctr()
- g = make_func(b, "O", "O")
- assert g(1) == 1
diff --git a/pypy/jit/backend/ppc/util.py b/pypy/jit/backend/ppc/util.py
deleted file mode 100644
--- a/pypy/jit/backend/ppc/util.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from pypy.jit.codegen.ppc.ppc_assembler import MyPPCAssembler
-from pypy.jit.codegen.ppc.func_builder import make_func
-
-from regname import *
-
-def access_at():
- a = MyPPCAssembler()
-
- a.lwzx(r3, r3, r4)
- a.blr()
-
- return make_func(a, "i", "ii")
-
-access_at = access_at()
-
-def itoO():
- a = MyPPCAssembler()
-
- a.blr()
-
- return make_func(a, "O", "i")
-
-itoO = itoO()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit