[pypy-svn] r17107 - pypy/dist/pypy/translator/llvm

ericvrp at codespeak.net ericvrp at codespeak.net
Wed Aug 31 00:08:55 CEST 2005


Author: ericvrp
Date: Wed Aug 31 00:08:54 2005
New Revision: 17107

Modified:
   pypy/dist/pypy/translator/llvm/genllvm.py
Log:
Prevent output of external functions where they are not used.
This makes the output of the example in getting-started.txt
somewhat better to read.


Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py	Wed Aug 31 00:08:54 2005
@@ -230,12 +230,13 @@
         self.translator.rtyper.specialize_more_blocks()
         self.db.setup_all()
 
+        using_external_functions = extfuncnode.ExternalFuncNode.used_external_functions.keys() != []
+
         if self.debug:
             self._print_node_stats()
 
-        if llcode_header is None:
+        if llcode_header is None and using_external_functions:
             self.generate_llfile(extern_decls)
-        lldeclarations, llimplementation = llcode_header, ll_functions
  
         #if self.debug:  print 'gen_llvm_source typ_decl.writedatatypedecl) ' + time.ctime()
         #if self.debug:  print 'gen_llvm_source n_nodes) %d' % len(self.db.getnodes())
@@ -256,9 +257,10 @@
         comment = codewriter.comment
         nl = codewriter.newline
 
-        nl(); comment("EXTERNAL FUNCTION DECLARATIONS") ; nl()
-        for s in lldeclarations.split('\n'):
-            codewriter.append(s)
+        if using_external_functions:
+            nl(); comment("EXTERNAL FUNCTION DECLARATIONS") ; nl()
+            for s in llcode_header.split('\n'):
+                codewriter.append(s)
 
         nl(); comment("Type Declarations"); nl()
 
@@ -382,9 +384,10 @@
                         codewriter.append(extfunc)
                     depdone[dep] = True
 
-        nl(); comment("EXTERNAL FUNCTION IMPLEMENTATION") ; nl()
-        for s in llimplementation.split('\n'):
-            codewriter.append(s)
+        if using_external_functions:
+            nl(); comment("EXTERNAL FUNCTION IMPLEMENTATION") ; nl()
+            for s in ll_functions.split('\n'):
+                codewriter.append(s)
 
         comment("End of file") ; nl()
         if self.debug:  print 'gen_llvm_source return) ' + time.ctime()



More information about the Pypy-commit mailing list