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

rxe at codespeak.net rxe at codespeak.net
Wed Nov 7 15:08:17 CET 2007


Author: rxe
Date: Wed Nov  7 15:08:15 2007
New Revision: 48361

Modified:
   pypy/dist/pypy/translator/llvm/codewriter.py
   pypy/dist/pypy/translator/llvm/genllvm.py
   pypy/dist/pypy/translator/llvm/module/support.py
Log:
forgot these calling conventions.  move the patching function to codewriter to save abusing _set_wordsize() even more

Modified: pypy/dist/pypy/translator/llvm/codewriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/codewriter.py	(original)
+++ pypy/dist/pypy/translator/llvm/codewriter.py	Wed Nov  7 15:08:15 2007
@@ -1,4 +1,5 @@
 from pypy.translator.llvm.log import log 
+from pypy.translator.llvm.buildllvm import postfix
 
 log = log.codewriter 
 
@@ -10,6 +11,7 @@
     def __init__(self, file, db, tail=None, cconv=None, linkage=None): 
         self.file = file
         self.word_repr = db.get_machine_word()
+        self.uword_repr = db.get_machine_uword()
         if tail is not None:
             self.tail = tail
         if cconv is not None:
@@ -43,8 +45,13 @@
     def _indent(self, line): 
         self._append("        " + line) 
 
-    def write_lines(self, lines):
+    def write_lines(self, lines, patch=False):
         for l in lines.split("\n"):
+            if patch:
+                l = l.replace('UWORD', self.uword_repr)
+                l = l.replace('WORD', self.word_repr)
+                l = l.replace('POSTFIX', postfix())
+                l = l.replace('CC', self.cconv)
             self._append(l)
     
     def comment(self, line, indent=True):

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  7 15:08:15 2007
@@ -16,7 +16,6 @@
 from pypy.translator.llvm.externs2ll import setup_externs, generate_llfile
 from pypy.translator.llvm.gc import GcPolicy
 from pypy.translator.llvm.log import log
-from pypy.translator.llvm.buildllvm import llvm_is_on_path, postfix
 
 class GenLLVM(object):
     # see create_codewriter() below
@@ -100,12 +99,6 @@
 
         return codewriter
 
-    def _set_wordsize(self, s):
-        s = s.replace('UWORD', self.db.get_machine_uword())
-        s = s.replace( 'WORD', self.db.get_machine_word())
-        s = s.replace('POSTFIX', postfix())
-        return s
-
     def write_headers(self, codewriter):
         # write external function headers
         codewriter.header_comment('External Function Headers')
@@ -134,7 +127,7 @@
         codewriter.header_comment("Function Prototypes")
 
         # write external protos
-        codewriter.write_lines(self._set_wordsize(extdeclarations))
+        codewriter.write_lines(extdeclarations, patch=True)
 
         # write node protos
         for node in self.db.getnodes():
@@ -149,9 +142,9 @@
         # write external function implementations
         codewriter.header_comment('External Function Implementation')
         codewriter.write_lines(self.llexterns_functions)
-        codewriter.write_lines(self._set_wordsize(extfunctions))
+        codewriter.write_lines(extfunctions, patch=True)
         if self.standalone:
-            codewriter.write_lines(self._set_wordsize(extfunctions_standalone))
+            codewriter.write_lines(extfunctions_standalone, patch=True)
         self.write_extern_impls(codewriter)
         self.write_setup_impl(codewriter)
         

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  7 15:08:15 2007
@@ -5,23 +5,23 @@
 """
 
 extfunctions = """
-internal fastcc sbyte* %RPyString_AsString(%RPyString* %structstring) {
+internal CC sbyte* %RPyString_AsString(%RPyString* %structstring) {
     %source1ptr = getelementptr %RPyString* %structstring, int 0, uint 1, uint 1
     %source1 = cast [0 x sbyte]* %source1ptr to sbyte*
     ret sbyte* %source1
 }
 
-internal fastcc WORD %RPyString_Size(%RPyString* %structstring) {
+internal CC WORD %RPyString_Size(%RPyString* %structstring) {
     %sizeptr = getelementptr %RPyString* %structstring, int 0, uint 1, uint 0
     %size = load WORD* %sizeptr
     ret WORD %size
 }
 
-internal fastcc %RPyString* %RPyString_FromString(sbyte* %s) {
+internal CC %RPyString* %RPyString_FromString(sbyte* %s) {
     %lenu      = call ccc uint %strlen(sbyte* %s)
     %lenuword  = cast uint %lenu to UWORD
     %lenword   = cast uint %lenu to WORD
-    %rpy       = call fastcc %RPyString* %pypy_RPyString_New__Signed(WORD %lenword)
+    %rpy       = call CC %RPyString* %pypy_RPyString_New__Signed(WORD %lenword)
     %rpystrptr = getelementptr %RPyString* %rpy, int 0, uint 1, uint 1
     %rpystr    = cast [0 x sbyte]* %rpystrptr to sbyte*
 
@@ -30,7 +30,7 @@
     ret %RPyString* %rpy
 }
 
-internal fastcc WORD %pypyop_int_abs(WORD %x) {
+internal CC WORD %pypyop_int_abs(WORD %x) {
 block0:
     %cond1 = setge WORD %x, 0
     br bool %cond1, label %return_block, label %block1
@@ -42,7 +42,7 @@
     ret WORD %result
 }
 
-internal fastcc long %pypyop_llong_abs(long %x) {
+internal CC long %pypyop_llong_abs(long %x) {
 block0:
     %cond1 = setge long %x, 0
     br bool %cond1, label %return_block, label %block1
@@ -54,7 +54,7 @@
     ret long %result
 }
 
-internal fastcc double %pypyop_float_abs(double %x) {
+internal CC double %pypyop_float_abs(double %x) {
 block0:
     %cond1 = setge double %x, 0.0
     br bool %cond1, label %return_block, label %block1
@@ -73,8 +73,8 @@
 from sys import maxint
 if maxint != 2**31-1:
     extfunctions_standalone += """
-internal fastcc int %pypy_entry_point(%RPyListOfString* %argv) {
-    %result = call fastcc long %pypy_entry_point(%RPyListOfString* %argv)
+internal CC int %pypy_entry_point(%RPyListOfString* %argv) {
+    %result = call CC long %pypy_entry_point(%RPyListOfString* %argv)
     %tmp = cast long %result to int
     ret int %tmp
 }
@@ -83,12 +83,11 @@
 
 
 def write_raise_exc(c_name, exc_repr, codewriter):
-
     l = """
-internal fastcc void %%raise%s(sbyte* %%msg) {
+internal CC void %%raise%s(sbyte* %%msg) {
     ;%%exception_value = cast %s to %%RPYTHON_EXCEPTION*
     ret void
 }
 """ % (c_name, exc_repr)
-    codewriter.write_lines(l)
+    codewriter.write_lines(l, patch=True)
 



More information about the Pypy-commit mailing list