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

ericvrp at codespeak.net ericvrp at codespeak.net
Fri Sep 23 17:14:19 CEST 2005


Author: ericvrp
Date: Fri Sep 23 17:14:18 2005
New Revision: 17796

Modified:
   pypy/dist/pypy/translator/llvm/codewriter.py
   pypy/dist/pypy/translator/llvm/database.py
   pypy/dist/pypy/translator/llvm/externs2ll.py
   pypy/dist/pypy/translator/llvm/funcnode.py
   pypy/dist/pypy/translator/llvm/genllvm.py
   pypy/dist/pypy/translator/llvm/module/extfunction.py
Log:
Added internel to function implementations.
This exposed a bug with the external functions that return a bool.
Since C returns an int here there is a mismatch that I fixed
by injecting a small function that calls the int version and 
return the bool one.


Modified: pypy/dist/pypy/translator/llvm/codewriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/codewriter.py	(original)
+++ pypy/dist/pypy/translator/llvm/codewriter.py	Fri Sep 23 17:14:18 2005
@@ -71,10 +71,11 @@
 
     def openfunc(self, decl, is_entrynode=False, cconv=DEFAULT_CCONV): 
         self.newline()
-        if is_entrynode:
-            linkage_type = ''
-        else:
-            linkage_type = ''	#'internal '
+        #if is_entrynode:
+        #    linkage_type = ''
+        #else:
+        #    linkage_type = 'internal '
+        linkage_type = 'internal '
         self.append("%s%s %s {" % (linkage_type, cconv, decl,))
 
     def closefunc(self): 

Modified: pypy/dist/pypy/translator/llvm/database.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/database.py	(original)
+++ pypy/dist/pypy/translator/llvm/database.py	Fri Sep 23 17:14:18 2005
@@ -124,7 +124,7 @@
         assert key not in self.obj2node, (
             "node with key %r already known!" %(key,))
         
-        log("added to pending nodes:", type(key), node)        
+        #log("added to pending nodes:", type(key), node)        
 
         self.obj2node[key] = node 
         self._pendingsetup.append(node)
@@ -171,7 +171,7 @@
             type_ = type_.TO
             value = value._obj
 
-            log.prepareconstant("preparing ptr", value)
+            #log.prepareconstant("preparing ptr", value)
 
             # we dont need a node for nulls
             if value is None:
@@ -191,7 +191,7 @@
         if isinstance(const_or_var, Constant):
             ct = const_or_var.concretetype
             if isinstance(ct, lltype.Primitive):
-                log.prepare(const_or_var, "(is primitive)")
+                #log.prepare(const_or_var, "(is primitive)")
                 return
 
             assert isinstance(ct, lltype.Ptr), "Preparation of non primitive and non pointer" 
@@ -201,7 +201,7 @@
             if isinstance(ct, lltype.Array) or isinstance(ct, lltype.Struct):
                 p, c = lltype.parentlink(value)
                 if p is None:
-                    log.prepareargvalue("skipping preparing non root", value)
+                    #log.prepareargvalue("skipping preparing non root", value)
                     return
 
             if value is not None and value not in self.obj2node:
@@ -211,7 +211,7 @@
 
 
     def prepare_arg(self, const_or_var):
-        log.prepare(const_or_var)
+        #log.prepare(const_or_var)
         self.prepare_type(const_or_var.concretetype)
         self.prepare_arg_value(const_or_var)
 
@@ -219,7 +219,7 @@
     def setup_all(self):
         while self._pendingsetup: 
             node = self._pendingsetup.pop()
-            log.settingup(node)
+            #log.settingup(node)
             node.setup()
 
     def set_entrynode(self, key):

Modified: pypy/dist/pypy/translator/llvm/externs2ll.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/externs2ll.py	(original)
+++ pypy/dist/pypy/translator/llvm/externs2ll.py	Fri Sep 23 17:14:18 2005
@@ -38,7 +38,7 @@
            funcname  , s = s.split('(', 1)
            funcnames[funcname] = True
            if line.find("internal") == -1:
-                line = '%s %s' % (DEFAULT_CCONV, line,)
+                line = 'internal %s %s' % (DEFAULT_CCONV, line,)
         ll_lines.append(line)
 
     # patch calls to function that we just declared fastcc
@@ -62,7 +62,17 @@
         ll_lines2.append(line)
 
     llcode = '\n'.join(ll_lines2)
-    return llcode.split('implementation')
+    decl, impl = llcode.split('implementation')
+    impl += """;functions that should return a bool according to
+    ; pypy/rpython/extfunctable.py  , but C doesn't have bools!
+
+internal fastcc bool %LL_os_isatty(int %fd) {
+    %t = call fastcc int %LL_os_isatty(int %fd)
+    %b = cast int %t to bool
+    ret bool %b
+}
+    """
+    return decl, impl
 
 
 def post_setup_externs(db):
@@ -123,9 +133,9 @@
 
     for f in include_files:
         ccode.append(open(f).read())
+    ccode = "".join(ccode)
 
     if debug:
-        ccode = "".join(ccode)
         filename = udir.join("ccode.c")
         f = open(str(filename), "w")
         f.write(ccode)

Modified: pypy/dist/pypy/translator/llvm/funcnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/funcnode.py	(original)
+++ pypy/dist/pypy/translator/llvm/funcnode.py	Fri Sep 23 17:14:18 2005
@@ -44,7 +44,7 @@
         return "<FuncNode %r>" %(self.ref,)
     
     def setup(self):
-        log("setup", self)
+        #log("setup", self)
         def visit(node):
             if isinstance(node, Link):
                 map(self.db.prepare_arg, node.args)

Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py	Fri Sep 23 17:14:18 2005
@@ -31,7 +31,7 @@
 
 class GenLLVM(object):
 
-    def __init__(self, translator, gcpolicy=None, exceptionpolicy=None, debug=True):
+    def __init__(self, translator, gcpolicy=None, exceptionpolicy=None, debug=False):
     
         # reset counters
         LLVMNode.nodename_count = {}    

Modified: pypy/dist/pypy/translator/llvm/module/extfunction.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/module/extfunction.py	(original)
+++ pypy/dist/pypy/translator/llvm/module/extfunction.py	Fri Sep 23 17:14:18 2005
@@ -1,6 +1,6 @@
 extdeclarations =  '''
-%last_exception_type  = global %RPYTHON_EXCEPTION_VTABLE* null
-%last_exception_value = global %RPYTHON_EXCEPTION* null
+%last_exception_type  = internal global %RPYTHON_EXCEPTION_VTABLE* null
+%last_exception_value = internal global %RPYTHON_EXCEPTION* null
 '''
 
 extfunctions = {}   #dependencies, llvm-code



More information about the Pypy-commit mailing list