[pypy-svn] r19945 - in pypy/dist/pypy/translator/llvm: . module

rxe at codespeak.net rxe at codespeak.net
Wed Nov 16 20:14:05 CET 2005


Author: rxe
Date: Wed Nov 16 20:14:02 2005
New Revision: 19945

Removed:
   pypy/dist/pypy/translator/llvm/module/extfunction.py
Modified:
   pypy/dist/pypy/translator/llvm/genllvm.py
   pypy/dist/pypy/translator/llvm/module/support.py
   pypy/dist/pypy/translator/llvm/opwriter.py
Log:
WIP towards implementing external operations that can raise.
Remove dependencies list for hand written externals as this doesnt make
so much sense when we start writing the extern ops in C.
  


Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py	Wed Nov 16 20:14:02 2005
@@ -8,8 +8,7 @@
 from pypy.tool.udir import udir
 from pypy.translator.llvm.codewriter import CodeWriter
 from pypy.translator.llvm import extfuncnode
-from pypy.translator.llvm.module.extfunction import extdeclarations, \
-     extfunctions, dependencies
+from pypy.translator.llvm.module.support import extdeclarations, extfunctions
 from pypy.translator.llvm.node import LLVMNode
 from pypy.translator.llvm.externs2ll import post_setup_externs, generate_llfile
 from pypy.translator.llvm.gc import GcPolicy
@@ -61,7 +60,6 @@
     
         # reset counters
         LLVMNode.nodename_count = {}    
-        extfuncnode.ExternalFuncNode.used_external_functions = {}
 
         # create and set internals
         self.db = Database(self, translator)
@@ -77,7 +75,6 @@
         # process
         self.logging = logging
 
-
     def gen_llvm_source(self, func=None):
 
         self._checkpoint()
@@ -104,13 +101,12 @@
         self._print_node_stats()
 
         # create ll file from c code 
-        using_external_functions = self.setup_externs(extern_decls)
+        self.setup_externs(extern_decls)
         self._checkpoint('setup_externs')
     
         # write external function headers
-        if using_external_functions:
-            codewriter.header_comment('External Function Headers')
-            codewriter.append(self.llexterns_header)
+        codewriter.header_comment('External Function Headers')
+        codewriter.append(self.llexterns_header)
 
         codewriter.header_comment("Type Declarations")
 
@@ -149,30 +145,33 @@
         codewriter.header_comment("Function Implementation")
 
         # write external function implementations
-        if using_external_functions:
-            codewriter.header_comment('External Function Implementation')
-            codewriter.append(self.llexterns_functions)
+        codewriter.header_comment('External Function Implementation')
+        codewriter.append(self.llexterns_functions)
 
         self._checkpoint('write external functions')
 
         # write exception implementaions
         codewriter.append(self.exceptionpolicy.llvmcode(self.entrynode))
 
-        # write all node implementations
+        # write support implementations
         for key, (deps, impl) in extfunctions.items():
             print key
             if key in ["%main_noargs", "%main"]:
                 continue
             codewriter.append(impl)
+        self._checkpoint('write support implentations')
 
+        # write all node implementations
         for typ_decl in self.db.getnodes():
             typ_decl.writeimpl(codewriter)
         self._checkpoint('write node implementations')
 
+        # write entry point if there is one
         self.write_entry_point(codewriter)
-        self._checkpoint('write support implentations')
-
         codewriter.comment("End of file")
+
+        self._checkpoint('done')
+
         return filename
     
     def get_entry_point(self, func):
@@ -186,15 +185,11 @@
         return c.value._obj, func.func_name
 
     def setup_externs(self, extern_decls):
-        extern_funcs = extfuncnode.ExternalFuncNode.used_external_functions
-        using_external_functions = extern_funcs.keys() != []
-
         # we cache the llexterns to make tests run faster
-        if using_external_functions and self.llexterns_header is None:
+        if self.llexterns_header is None:
             assert self.llexterns_functions is None
             self.llexterns_header, self.llexterns_functions = \
                                    generate_llfile(self.db, extern_decls)
-        return using_external_functions
 
     def create_codewrite(self, func_name):
         # prevent running the same function twice in a test
@@ -218,8 +213,13 @@
                 codewriter.append(l)
 
     def write_entry_point(self, codewriter):
-        # XXX we need to create our own main() that calls the actual entry_point function
-        entryfunc_name = self.entrynode.getdecl().split('%pypy_', 1)[1].split('(')[0]
+        # XXX we need to create our own main() that calls the actual
+        # entry_point function
+        entryfunc_name = self.entrynode.getdecl().split('%pypy_', 1)[1]
+        entryfunc_name = entryfunc_name.split('(')[0]
+        print entryfunc_name
+        if entryfunc_name not in ["main_noargs", "main"]:
+            return
         llcode = extfunctions["%" + entryfunc_name][1]        
         codewriter.append(llcode)
 

Modified: pypy/dist/pypy/translator/llvm/module/support.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/module/support.py	(original)
+++ pypy/dist/pypy/translator/llvm/module/support.py	Wed Nov 16 20:14:02 2005
@@ -1,5 +1,12 @@
 
 extdeclarations = """
+%last_exception_type  = internal global %RPYTHON_EXCEPTION_VTABLE* null
+%last_exception_value = internal global %RPYTHON_EXCEPTION* null
+
+;8208=8192+16 in the next line because the last one (16 bytes maxsize) might start at 8190 for instance.
+%exception_ringbuffer = internal global [8208 x sbyte] zeroinitializer
+%exception_ringbuffer_index = internal global uint 0
+
 declare ccc uint %strlen(sbyte*)
 declare ccc void %llvm.memset(sbyte*, ubyte, uint, uint)
 declare ccc void %llvm.memcpy(sbyte*, sbyte*, uint, uint)

Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py	(original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py	Wed Nov 16 20:14:02 2005
@@ -1,6 +1,6 @@
 from pypy.objspace.flow.model import Constant
 from pypy.rpython.lltypesystem import lltype
-from pypy.translator.llvm.module.extfunction import extfunctions
+from pypy.translator.llvm.module.support import extfunctions
 from pypy.translator.llvm.extfuncnode import ExternalFuncNode
 from pypy.translator.llvm.log import log 
 log = log.opwriter



More information about the Pypy-commit mailing list