[pypy-svn] r36867 - pypy/dist/pypy/translator/llvm
mwh at codespeak.net
mwh at codespeak.net
Wed Jan 17 12:44:06 CET 2007
Author: mwh
Date: Wed Jan 17 12:44:05 2007
New Revision: 36867
Modified:
pypy/dist/pypy/translator/llvm/database.py
pypy/dist/pypy/translator/llvm/extfuncnode.py
pypy/dist/pypy/translator/llvm/opwriter.py
Log:
small hacks to get some more of test_extfunc passing.
Modified: pypy/dist/pypy/translator/llvm/database.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/database.py (original)
+++ pypy/dist/pypy/translator/llvm/database.py Wed Jan 17 12:44:05 2007
@@ -3,7 +3,7 @@
from pypy.translator.llvm.log import log
from pypy.translator.llvm.funcnode import FuncNode, FuncTypeNode
-from pypy.translator.llvm.extfuncnode import ExternalFuncNode
+from pypy.translator.llvm.extfuncnode import ExternalFuncNode, SimplerExternalFuncNode
from pypy.translator.llvm.structnode import StructNode, StructVarsizeNode, \
StructTypeNode, StructVarsizeTypeNode, getindexhelper, \
FixedSizeArrayTypeNode, FixedSizeArrayNode
@@ -60,6 +60,8 @@
if getattr(value._callable, "suggested_primitive", False):
node = ExternalFuncNode(self, value)
self.externalfuncs[node.callable] = value
+ elif getattr(value, 'external', None) == 'C':
+ node = SimplerExternalFuncNode(self, value)
else:
node = FuncNode(self, value)
Modified: pypy/dist/pypy/translator/llvm/extfuncnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/extfuncnode.py (original)
+++ pypy/dist/pypy/translator/llvm/extfuncnode.py Wed Jan 17 12:44:05 2007
@@ -25,6 +25,30 @@
ext_func_sigs["%LL_os_write"] = ExtFuncSig(None, ["int", None])
ext_func_sigs["%LL_math_ldexp"] = ExtFuncSig(None, [None, "int"])
+
+class SimplerExternalFuncNode(ConstantLLVMNode):
+
+ def __init__(self, db, value):
+ self.db = db
+ self.value = value
+ self.ref = "%" + value._name
+
+ def writeglobalconstants(self, codewriter):
+ pass
+
+ def getdecl_parts(self):
+ T = self.value._TYPE
+ rettype = self.db.repr_type(T.RESULT)
+ argtypes = [self.db.repr_type(a) for a in T.ARGS if a is not lltype.Void]
+ return rettype, argtypes
+
+ def getdecl(self):
+ rettype, argtypes = self.getdecl_parts()
+ return "%s %s(%s)" % (rettype, self.ref, ", ".join(argtypes))
+
+ def writedecl(self, codewriter):
+ codewriter.declare(self.getdecl())
+
class ExternalFuncNode(ConstantLLVMNode):
def __init__(self, db, value):
Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py (original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py Wed Jan 17 12:44:05 2007
@@ -287,6 +287,8 @@
self.db.gcpolicy.zeromalloc(self.codewriter, opr.retref, opr.rettype,
atomic=arg_type._is_atomic(), exc_flag=exc)
+ zero_malloc = malloc
+
def malloc_varsize(self, opr):
# XXX transformation perhaps?
More information about the Pypy-commit
mailing list