[pypy-svn] r28775 - pypy/dist/pypy/translator/llvm
rxe at codespeak.net
rxe at codespeak.net
Wed Jun 14 17:25:50 CEST 2006
Author: rxe
Date: Wed Jun 14 17:25:46 2006
New Revision: 28775
Modified:
pypy/dist/pypy/translator/llvm/database.py
pypy/dist/pypy/translator/llvm/externs2ll.py
pypy/dist/pypy/translator/llvm/extfunchelper.py
pypy/dist/pypy/translator/llvm/extfuncnode.py
pypy/dist/pypy/translator/llvm/genllvm.py
pypy/dist/pypy/translator/llvm/opwriter.py
Log:
hacks to make the tests run again
Modified: pypy/dist/pypy/translator/llvm/database.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/database.py (original)
+++ pypy/dist/pypy/translator/llvm/database.py Wed Jun 14 17:25:46 2006
@@ -24,10 +24,10 @@
self.obj2node = {}
self._pendingsetup = []
self._tmpcount = 1
-
+ self.helper2ptr = {}
# debug operation comments
self._opcomments = {}
-
+ self.externalfuncs = {}
self.primitives_init()
def primitives_init(self):
@@ -98,6 +98,7 @@
if isinstance(type_, lltype.FuncType):
if getattr(value._callable, "suggested_primitive", False):
node = ExternalFuncNode(self, value)
+ self.externalfuncs[node.callable] = value
else:
node = FuncNode(self, value)
Modified: pypy/dist/pypy/translator/llvm/externs2ll.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/externs2ll.py (original)
+++ pypy/dist/pypy/translator/llvm/externs2ll.py Wed Jun 14 17:25:46 2006
@@ -109,7 +109,7 @@
# hacks to make predeclare_all work
# XXX Rationalise this
db.standalone = True
- db.externalfuncs = {}
+
#XXX extfuncs need init. to use optimize=True
decls = list(predeclare_all(db, rtyper, optimize=False))
Modified: pypy/dist/pypy/translator/llvm/extfunchelper.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/extfunchelper.py (original)
+++ pypy/dist/pypy/translator/llvm/extfunchelper.py Wed Jun 14 17:25:46 2006
@@ -5,36 +5,40 @@
from pypy.rpython.lltypesystem.rstr import STR
from pypy.rpython.lltypesystem import rstr
from pypy.rpython.lltypesystem import rlist
-from pypy.rpython.module import ll_os, ll_time, ll_math, ll_strtod
+from pypy.rpython.module import ll_time, ll_math, ll_strtod
from pypy.rpython.module import ll_stackless, ll_stack
from pypy.module.thread.rpython import ll_thread
from pypy.module._socket.rpython import ll__socket
+from pypy.rpython.lltypesystem.module.ll_os import STAT_RESULT, Implementation as impl
+
+
# table of functions hand-written in src/ll_*.h
EXTERNALS = {
- ll_os .ll_os_open: 'LL_os_open',
- ll_os .ll_read_into: 'LL_read_into',
- ll_os .ll_os_write: 'LL_os_write',
- ll_os .ll_os_close: 'LL_os_close',
- ll_os .ll_os_dup: 'LL_os_dup',
- ll_os .ll_os_stat: 'LL_os_stat',
- ll_os .ll_os_fstat: 'LL_os_fstat',
- ll_os .ll_os_lseek: 'LL_os_lseek',
- ll_os .ll_os_isatty: 'LL_os_isatty',
- ll_os .ll_os_ftruncate:'LL_os_ftruncate',
- ll_os .ll_os_strerror: 'LL_os_strerror',
- ll_os .ll_os_system: 'LL_os_system',
- ll_os .ll_os_unlink: 'LL_os_unlink',
- ll_os .ll_os_getcwd: 'LL_os_getcwd',
- ll_os .ll_os_chdir: 'LL_os_chdir',
- ll_os .ll_os_mkdir: 'LL_os_mkdir',
- ll_os .ll_os_rmdir: 'LL_os_rmdir',
- ll_os .ll_os_putenv: 'LL_os_putenv',
- ll_os .ll_os_unsetenv:'LL_os_unsetenv',
- ll_os .ll_os_environ: 'LL_os_environ',
- ll_os .ll_os_opendir: 'LL_os_opendir',
- ll_os .ll_os_readdir: 'LL_os_readdir',
- ll_os .ll_os_closedir:'LL_os_closedir',
+ impl.ll_os_open.im_func: 'LL_os_open',
+ impl.ll_read_into: 'LL_read_into', # it's a staticmethod
+ impl.ll_os_write.im_func: 'LL_os_write',
+ impl.ll_os_close.im_func: 'LL_os_close',
+ impl.ll_os_dup.im_func: 'LL_os_dup',
+ impl.ll_os_stat.im_func: 'LL_os_stat',
+ impl.ll_os_fstat.im_func: 'LL_os_fstat',
+ impl.ll_os_lseek.im_func: 'LL_os_lseek',
+ impl.ll_os_isatty.im_func: 'LL_os_isatty',
+ impl.ll_os_ftruncate.im_func:'LL_os_ftruncate',
+ impl.ll_os_strerror.im_func: 'LL_os_strerror',
+ impl.ll_os_system.im_func: 'LL_os_system',
+ impl.ll_os_unlink.im_func: 'LL_os_unlink',
+ impl.ll_os_getcwd.im_func: 'LL_os_getcwd',
+ impl.ll_os_chdir.im_func: 'LL_os_chdir',
+ impl.ll_os_mkdir.im_func: 'LL_os_mkdir',
+ impl.ll_os_rmdir.im_func: 'LL_os_rmdir',
+ impl.ll_os_putenv.im_func: 'LL_os_putenv',
+ impl.ll_os_unsetenv.im_func:'LL_os_unsetenv',
+ impl.ll_os_environ.im_func: 'LL_os_environ',
+ impl.ll_os_opendir.im_func: 'LL_os_opendir',
+ impl.ll_os_readdir.im_func: 'LL_os_readdir',
+ impl.ll_os_closedir.im_func:'LL_os_closedir',
+
ll_time.ll_time_clock: 'LL_time_clock',
ll_time.ll_time_sleep: 'LL_time_sleep',
ll_time.ll_time_time: 'LL_time_time',
@@ -100,7 +104,7 @@
yield ('RPyListOfString', LIST_OF_STR)
yield ('RPyFREXP_RESULT', ll_math.FREXP_RESULT)
yield ('RPyMODF_RESULT', ll_math.MODF_RESULT)
- yield ('RPySTAT_RESULT', ll_os.STAT_RESULT)
+ yield ('RPySTAT_RESULT', STAT_RESULT)
yield ('RPySOCKET_ADDRINFO', ll__socket.ADDRINFO_RESULT)
yield ('RPySOCKET_SOCKNAME', ll__socket.SOCKNAME)
@@ -130,41 +134,26 @@
for fname, f in locals().items():
if isinstance(f, types.FunctionType):
- # hack: the defaults give the type of the arguments
- graph = rtyper.annotate_helper(f, f.func_defaults)
- yield (fname, graph)
+ # XXX this is painful :(
+ if (LIST_OF_STR, fname) in db.helper2ptr:
+ yield (fname, db.helper2ptr[LIST_OF_STR, fname])
+ else:
+ # hack: the defaults give the type of the arguments
+ graph = rtyper.annotate_helper(f, f.func_defaults)
+ db.helper2ptr[LIST_OF_STR, fname] = graph
+ yield (fname, graph)
+
def predeclare_extfunc_helpers(db, rtyper, optimize=True):
- def annotate(func, *argtypes):
- fptr = rtyper.annotate_helper(func, argtypes)
+ def annotate(func, args):
+ fptr = rtyper.annotate_helper(func, args)
+ db.helper2ptr[func] = fptr
return (func.__name__, fptr)
- if ll_math.ll_math_frexp in db.externalfuncs or not optimize:
- yield annotate(ll_math.ll_frexp_result, lltype.Float, lltype.Signed)
- yield ('LL_NEED_MATH_FREXP', 1)
-
- if ll_math.ll_math_modf in db.externalfuncs or not optimize:
- yield annotate(ll_math.ll_modf_result, lltype.Float, lltype.Float)
- yield ('LL_NEED_MATH_MODF', 1)
-
- if (ll_os.ll_os_stat in db.externalfuncs or
- ll_os.ll_os_fstat in db.externalfuncs or
- not optimize):
- yield annotate(ll_os.ll_stat_result, *([lltype.Signed] * 10))
- yield ('LL_NEED_OS_STAT', 1)
-
- if (ll__socket.ll__socket_nextaddrinfo in db.externalfuncs or
- not optimize):
- args = [lltype.Signed, lltype.Signed, lltype.Signed, lltype.Ptr(STR),
- lltype.Ptr(STR), lltype.Signed, lltype.Signed, lltype.Signed]
- yield annotate(ll__socket.ll__socket_addrinfo, *args)
- yield ('LL_NEED__SOCKET_ADDRINFO', 1)
-
- if (ll__socket.ll__socket_getpeername in db.externalfuncs or
- not optimize):
- args = [lltype.Ptr(STR), lltype.Signed, lltype.Signed, lltype.Signed]
- yield annotate(ll__socket.ll__socket_sockname, *args)
- yield ('LL_NEED__SOCKET_SOCKNAME', 1)
+ for func, args, symb in db.translator._implicitly_called_by_externals:
+ yield annotate(func, args)
+ yield ('LL_NEED_' + symb, 1)
+
def predeclare_extfuncs(db, rtyper, optimize=True):
modules = {}
Modified: pypy/dist/pypy/translator/llvm/extfuncnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/extfuncnode.py (original)
+++ pypy/dist/pypy/translator/llvm/extfuncnode.py Wed Jun 14 17:25:46 2006
@@ -1,6 +1,7 @@
from pypy.translator.llvm.node import ConstantLLVMNode
from pypy.translator.llvm.log import log
from pypy.translator.c.extfunc import EXTERNALS
+from pypy.rpython.lltypesystem import lltype
log = log.extfuncnode
@@ -32,9 +33,10 @@
name = value._callable.__name__
assert name.startswith("ll")
- mapped_name = EXTERNALS[value._callable]
+ self.callable = value._callable
+ mapped_name = EXTERNALS[self.callable]
self.ref = self.make_ref("%", mapped_name)
-
+
def setup(self):
self.db.prepare_type(self.value._TYPE.RESULT)
self.db.prepare_type_multi(self.value._TYPE._trueargs())
@@ -75,7 +77,7 @@
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]
+ argtypes = [self.db.repr_type(a) for a in T.ARGS if a is not lltype.Void]
return rettype, argtypes
def getdecl(self):
Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py Wed Jun 14 17:25:46 2006
@@ -25,7 +25,6 @@
# see open_file() below
function_count = {}
- llexterns_header = llexterns_functions = None
def __init__(self, translator, gcpolicy, exceptionpolicy, standalone,
debug=False, logging=True):
@@ -186,14 +185,11 @@
return c.value._obj
def generate_ll_externs(self):
- # we only cache the llexterns to make tests run faster
- if self.llexterns_header is None:
- assert self.llexterns_functions is None
- GenLLVM.llexterns_header, GenLLVM.llexterns_functions = \
- generate_llfile(self.db,
- self.extern_decls,
- self.entrynode,
- self.standalone)
+ self.llexterns_header, self.llexterns_functions = \
+ generate_llfile(self.db,
+ self.extern_decls,
+ self.entrynode,
+ self.standalone)
def create_codewriter(self):
# prevent running the same function twice in a test
Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py (original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py Wed Jun 14 17:25:46 2006
@@ -164,6 +164,10 @@
float_abs = int_abs
llong_abs = int_abs
+ def debug_log_exc(self, opr):
+ # XXX tmp
+ pass
+
def int_pow(self, opr):
self._generic_pow(opr, "1")
uint_pow = int_pow
More information about the Pypy-commit
mailing list