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

ericvrp at codespeak.net ericvrp at codespeak.net
Wed May 10 13:16:54 CEST 2006


Author: ericvrp
Date: Wed May 10 13:16:53 2006
New Revision: 27045

Modified:
   pypy/dist/pypy/translator/llvm/buildllvm.py
   pypy/dist/pypy/translator/llvm/gc.py
Log:
Fixed translation with backend=llvm gc=none.


Modified: pypy/dist/pypy/translator/llvm/buildllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/buildllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm/buildllvm.py	Wed May 10 13:16:53 2006
@@ -35,8 +35,6 @@
         opts += "-globalopt -constmerge -ipsccp -deadargelim -inline " \
                 "-instcombine -scalarrepl -globalsmodref-aa -licm -load-vn " \
                 "-gcse -instcombine -simplifycfg -globaldce "
-        if use_gcc:
-            opts +=  "-inline-threshold=100 "
     return opts
 
 def compile_module(module, source_files, object_files, library_files):
@@ -60,6 +58,9 @@
                           pyxfile=None, optimize=True, exe_name=None,
                           profile=False, cleanup=False, use_gcc=True):
 
+    if exe_name:
+        use_gcc = False #XXX trying to get of gcc (at least for standalones)
+
     # where we are building
     dirpath = llvmfile.dirpath()
 
@@ -92,6 +93,8 @@
 
     if not use_gcc:
         llc_params = llvm_version() > 1.6 and '-enable-x86-fastcc' or ''
+        if llc_params and exe_name:
+            llc_params += ' -relocation-model=static'   #XXX while llvm jumptables not with PIC
         cmds.append("llc %s %s %s.bc -f -o %s.s" % (llc_params, genllvm.db.exceptionpolicy.llc_options(), b, b))
         cmds.append("as %s.s -o %s.o" % (b, b))
 
@@ -102,7 +105,7 @@
     else:
         cmds.append("llc %s %s.bc -march=c -f -o %s.c" % (genllvm.db.exceptionpolicy.llc_options(), b, b))
         if exe_name:
-            cmd = "gcc %s.c -c -O3 -fno-inline -pipe" % b
+            cmd = "gcc %s.c -c -O3 -pipe" % b
             if profile:
                 cmd += ' -pg'
             else:

Modified: pypy/dist/pypy/translator/llvm/gc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/gc.py	(original)
+++ pypy/dist/pypy/translator/llvm/gc.py	Wed May 10 13:16:53 2006
@@ -20,6 +20,9 @@
     def malloc(self, codewriter, targetvar, type_, size=1, atomic=False):
         raise NotImplementedError, 'GcPolicy should not be used directly'
 
+    def var_malloc(self, codewriter, targetvar, type_, node, len, atomic=False):
+        raise NotImplementedError, 'GcPolicy should not be used directly'
+
     def new(db, gcpolicy=None):
         """ factory """
         gcpolicy = gcpolicy or 'boehm'
@@ -37,21 +40,33 @@
             gcpolicy = BoehmGcPolicy(db)
         elif gcpolicy == 'ref':
             gcpolicy = RefcountingGcPolicy(db)
-        elif gcpolicy == 'raw':
+        elif gcpolicy in ('none', 'raw'):
             gcpolicy = RawGcPolicy(db)
         else:
             raise Exception, 'unknown gcpolicy: ' + str(gcpolicy)
         return gcpolicy
     new = staticmethod(new)
 
+
 class RawGcPolicy(GcPolicy):
     def __init__(self, db):
-        self.db = db
+        self.boehm = BoehmGcPolicy(db)
+
+    def malloc(self, codewriter, targetvar, type_, size=1, atomic=False, exc_flag=False):
+        return self.boehm.malloc(codewriter, targetvar, type_, size, atomic, exc_flag)
+
+    def var_malloc(self, codewriter, targetvar, type_, node, len, atomic=False):
+        return self.boehm.var_malloc(codewriter, targetvar, type_, node, len, atomic)
+
+    def genextern_code(self):
+        r = ''
+        r += '#define __GC_STARTUP_CODE__\n'
+        r += '#define __GC_SETUP_CODE__\n'
+        r += 'char* pypy_malloc(int size)        { return calloc(1, size); }\n'
+        r += 'char* pypy_malloc_atomic(int size) { return calloc(1, size); }\n'
+        return r
+
 
-    def malloc(self, codewriter, targetvar, type_, size=1, atomic=False):
-        codewriter.malloc(targetvar, type_, size)
-        #XXX memset
-        
 class BoehmGcPolicy(GcPolicy):
 
     def __init__(self, db, exc_useringbuf=False):
@@ -171,6 +186,7 @@
                                  targetvar,  indices_to_arraylength)
         codewriter.store(lentype, len, arraylength)
 
+
 class RefcountingGcPolicy(GcPolicy):
     def __init__(self, db):
         raise NotImplementedError, 'RefcountingGcPolicy'



More information about the Pypy-commit mailing list