[pypy-svn] r15434 - in pypy/dist/pypy/translator/llvm2: . test
rxe at codespeak.net
rxe at codespeak.net
Sat Jul 30 20:34:40 CEST 2005
Author: rxe
Date: Sat Jul 30 20:34:35 2005
New Revision: 15434
Modified:
pypy/dist/pypy/translator/llvm2/funcnode.py
pypy/dist/pypy/translator/llvm2/genllvm.py
pypy/dist/pypy/translator/llvm2/opwriter.py
pypy/dist/pypy/translator/llvm2/structnode.py
pypy/dist/pypy/translator/llvm2/test/llvmsnippet.py
pypy/dist/pypy/translator/llvm2/test/test_class.py
Log:
* annotator.simplify() is a nono. Rewriting the remove_void() functionality at
code generation as now breaks check_graph()
* test_classes() updates.
* Some better formatting for struct constants.
Modified: pypy/dist/pypy/translator/llvm2/funcnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/funcnode.py (original)
+++ pypy/dist/pypy/translator/llvm2/funcnode.py Sat Jul 30 20:34:35 2005
@@ -95,8 +95,12 @@
def getdecl(self):
startblock = self.graph.startblock
returnblock = self.graph.returnblock
- inputargs = self.db.repr_arg_multi(startblock.inputargs)
- inputargtypes = self.db.repr_arg_type_multi(startblock.inputargs)
+ # XXX hack as per remove_voids()
+ startblock_inputargs = [a for a in startblock.inputargs
+ if a.concretetype is not lltype.Void]
+
+ inputargs = self.db.repr_arg_multi(startblock_inputargs)
+ inputargtypes = self.db.repr_arg_type_multi(startblock_inputargs)
returntype = self.db.repr_arg_type(self.graph.returnblock.inputargs[0])
result = "%s %s" % (returntype, self.ref)
args = ["%s %s" % item for item in zip(inputargtypes, inputargs)]
@@ -122,7 +126,7 @@
link.prevblock.exits[0].target != block:
blocknames[i] += '_exception_found_branchto_' + self.block_to_name[block]
if type_ != "void":
- codewriter.phi(arg, type_, names, blocknames)
+ codewriter.phi(arg, type_, names, blocknames)
def write_block_branches(self, codewriter, block):
#assert len(block.exits) <= 2 #more exits are possible (esp. in combination with exceptions)
Modified: pypy/dist/pypy/translator/llvm2/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm2/genllvm.py Sat Jul 30 20:34:35 2005
@@ -30,7 +30,7 @@
self.translator = translator
self.embedexterns = embedexterns
# transformations
- remove_void(translator)
+ #remove_void(translator)
#rename_extfunc_calls(translator)
translator.checkgraphs()
ExternalFuncNode.used_external_functions = {}
@@ -163,7 +163,6 @@
t = Translator(function)
a = t.annotate(annotate)
t.specialize()
- a.simplify()
if view:
t.view()
return genllvm(t, embedexterns=embedexterns)
Modified: pypy/dist/pypy/translator/llvm2/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/opwriter.py (original)
+++ pypy/dist/pypy/translator/llvm2/opwriter.py Sat Jul 30 20:34:35 2005
@@ -166,12 +166,16 @@
"null")
def direct_call(self, op):
- assert len(op.args) >= 1
+
+ op_args = [arg for arg in op.args
+ if arg.concretetype is not lltype.Void]
+
+ assert len(op_args) >= 1
targetvar = self.db.repr_arg(op.result)
returntype = self.db.repr_arg_type(op.result)
- functionref = self.db.repr_arg(op.args[0])
- argrefs = self.db.repr_arg_multi(op.args[1:])
- argtypes = self.db.repr_arg_type_multi(op.args[1:])
+ functionref = self.db.repr_arg(op_args[0])
+ argrefs = self.db.repr_arg_multi(op_args[1:])
+ argtypes = self.db.repr_arg_type_multi(op_args[1:])
if returntype != "void":
self.codewriter.call(targetvar, returntype, functionref, argrefs,
argtypes)
@@ -179,7 +183,11 @@
self.codewriter.call_void(functionref, argrefs, argtypes)
def direct_invoke(self, op):
- assert len(op.args) >= 1
+ # XXX hack as per remove_voids()
+ op_args = [arg for arg in op.args
+ if arg.concretetype is not Void]
+
+ assert len(op_args) >= 1
assert len(self.block.exits) >= 2 #at least one label and one exception label
link = self.block.exits[0]
@@ -187,9 +195,9 @@
targetvar = self.db.repr_arg(op.result)
returntype = self.db.repr_arg_type(op.result)
- functionref = self.db.repr_arg(op.args[0])
- argrefs = self.db.repr_arg_multi(op.args[1:])
- argtypes = self.db.repr_arg_type_multi(op.args[1:])
+ functionref = self.db.repr_arg(op_args[0])
+ argrefs = self.db.repr_arg_multi(op_args[1:])
+ argtypes = self.db.repr_arg_type_multi(op_args[1:])
none_label = self.node.block_to_name[link.target]
block_label = self.node.block_to_name[self.block]
@@ -229,7 +237,7 @@
self.codewriter.call(ll_issubclass_cond,
'bool',
ll_exception_match,
- [tmpvar2, self.db.repr_arg_type(type)],
+ [tmpvar2, type.ref],
[lltype_of_exception_type, lltype_of_exception_type])
self.codewriter.br(ll_issubclass_cond, not_this_exception_label, exc_found_label)
self.codewriter.label(not_this_exception_label)
Modified: pypy/dist/pypy/translator/llvm2/structnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/structnode.py (original)
+++ pypy/dist/pypy/translator/llvm2/structnode.py Sat Jul 30 20:34:35 2005
@@ -142,7 +142,8 @@
def constantvalue(self):
""" Returns the constant representation for this node. """
values = self._getvalues()
- return "%s {%s}" % (self.get_typerepr(), ", ".join(values))
+ all_values = ",\n ".join(values)
+ return "%s {\n %s\n }\n\n" % (self.get_typerepr(), all_values)
# ______________________________________________________________________
# main entry points from genllvm
Modified: pypy/dist/pypy/translator/llvm2/test/llvmsnippet.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/llvmsnippet.py (original)
+++ pypy/dist/pypy/translator/llvm2/test/llvmsnippet.py Sat Jul 30 20:34:35 2005
@@ -212,7 +212,6 @@
c = C(b)
return c.a.a
-
class AA(object):
x = 8
def __init__(self):
@@ -234,7 +233,7 @@
def class_inherit2():
aa = AA()
bb = BB()
- return aa.g() + bb.g()
+ return aa.g() + bb.g()
class D(object):
def __init__(self, a, length):
@@ -266,6 +265,7 @@
ggg.c.append(x)
d = ggg.b[1]
ggg.a = x
+ 36 + d + 3
return previous + d + previous1
def degrading_func(obj):
Modified: pypy/dist/pypy/translator/llvm2/test/test_class.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_class.py (original)
+++ pypy/dist/pypy/translator/llvm2/test/test_class.py Sat Jul 30 20:34:35 2005
@@ -6,6 +6,8 @@
from pypy.translator.llvm2.genllvm import compile_function
from pypy.translator.llvm2.test import llvmsnippet
+#py.log.setconsumer("genllvm", py.log.STDOUT)
+
class TestClass(object):
def test_classsimple(self):
f = compile_function(llvmsnippet.class_simple, [])
@@ -29,22 +31,21 @@
assert f() == 11
def test_inherit2(self):
- py.test.skip("not working yet (segfault)")
+ py.test.skip("function redefinition problem")
f = compile_function(llvmsnippet.class_inherit2, [])
- assert f() == 11
+ assert f() == 1
def test_method_of_base_class(self):
- py.test.skip("not working yet (segfault)")
- f = compile_function(llvmsnippet.method_of_base_class, [], view=True)
+ py.test.skip("rtyper problem")
+ f = compile_function(llvmsnippet.method_of_base_class, [])
assert f() == 14
def test_attribute_from_base_class(self):
- py.test.skip("not working yet (segfault)")
f = compile_function(llvmsnippet.attribute_from_base_class, [])
assert f() == 4
def test_direct_call_of_virtual_method(self):
- py.test.skip("not working yet (segfault)")
+ py.test.skip("function redefinition problem")
f = compile_function(llvmsnippet.direct_call_of_virtual_method, [])
assert f() == 14
@@ -63,14 +64,14 @@
assert f(False) == 2
def test_global_instance(self):
- py.test.skip("modify global instance not working properly yet")
+ py.test.skip("function redefinition problems")
f = compile_function(llvmsnippet.global_instance, [int])
assert f(-1) == llvmsnippet.global_instance(-1)
for i in range(20):
assert f(i) == llvmsnippet.global_instance(i)
def test_call_degrading_func(self):
- py.test.skip("call degrading not working yet")
+ py.test.skip("rtyper problem")
f = compile_function(llvmsnippet.call_degrading_func, [bool])
assert f(True) == llvmsnippet.call_degrading_func(True) #-36
assert f(False) == llvmsnippet.call_degrading_func(False) #14
More information about the Pypy-commit
mailing list