[pypy-svn] r16101 - in pypy/dist/pypy/translator/llvm2: . module tool

ericvrp at codespeak.net ericvrp at codespeak.net
Tue Aug 16 16:20:58 CEST 2005


Author: ericvrp
Date: Tue Aug 16 16:20:57 2005
New Revision: 16101

Added:
   pypy/dist/pypy/translator/llvm2/module/ll_strtod.py   (contents, props changed)
Modified:
   pypy/dist/pypy/translator/llvm2/genllvm.py
   pypy/dist/pypy/translator/llvm2/module/extfunction.py
   pypy/dist/pypy/translator/llvm2/module/ll_os.py
   pypy/dist/pypy/translator/llvm2/module/support.py
   pypy/dist/pypy/translator/llvm2/tool/suggested_primitive.py
Log:
* proper main(int,char** argv)
* moved some functions to ll_strtod.py



Modified: pypy/dist/pypy/translator/llvm2/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm2/genllvm.py	Tue Aug 16 16:20:57 2005
@@ -240,9 +240,27 @@
         # XXX we need to create our own main() that calls the actual entry_point function
         entryfunc_name = t[1].split('(')[0]
         if entryfunc_name != 'main' and entryfunc_name == 'entry_point': #XXX just to get on with translate_pypy
-            codewriter.append("int %main() {")
-            codewriter.append("    %argv = call fastcc %structtype.list* %ll_newlist__listPtrConst_Signed.2(int 0)")
-            codewriter.append("    %ret  = call fastcc int %entry_point(%structtype.list* %argv)")
+            codewriter.append("int %main(int% argc, sbyte** %argv) {")
+            codewriter.append("entry:")
+            codewriter.append("    %pypy_argv = call fastcc %RPyListOfString* %ll_newlist__listPtrConst_Signed.2(int 0)")
+            codewriter.append("    br label %no_exit")
+            codewriter.newline()
+            codewriter.append("no_exit:")
+            codewriter.append("    %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]")
+            codewriter.append("    %i.0.0 = cast uint %indvar to int")
+            codewriter.append("    %tmp.8 = getelementptr sbyte** %argv, uint %indvar")
+            codewriter.append("    %tmp.9 = load sbyte** %tmp.8")
+            codewriter.newline()
+            codewriter.append("    %rpy = call fastcc %RPyString* %string_to_RPyString(sbyte* %tmp.9)")
+            codewriter.append("    call fastcc void %ll_append__listPtr_rpy_stringPtr(%RPyListOfString* %pypy_argv, %RPyString* %rpy)")
+            codewriter.newline()
+            codewriter.append("    %inc = add int %i.0.0, 1")
+            codewriter.append("    %tmp.2 = setlt int %inc, %argc")
+            codewriter.append("    %indvar.next = add uint %indvar, 1")
+            codewriter.append("    br bool %tmp.2, label %no_exit, label %loopexit")
+            codewriter.append("loopexit:")
+            codewriter.newline()
+            codewriter.append("    %ret  = call fastcc int %entry_point(%structtype.list* %pypy_argv)")
             codewriter.append("    ret int %ret")
             codewriter.append("}")
             codewriter.newline()

Modified: pypy/dist/pypy/translator/llvm2/module/extfunction.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/extfunction.py	(original)
+++ pypy/dist/pypy/translator/llvm2/module/extfunction.py	Tue Aug 16 16:20:57 2005
@@ -36,9 +36,9 @@
 
 extfunctions = {}   #dependencies, llvm-code
 
-import support, ll_os, ll_os_path, ll_time, ll_math
+import support, ll_os, ll_os_path, ll_time, ll_math, ll_strtod
 
-for module in (support, ll_os, ll_os_path, ll_time, ll_math):
+for module in (support, ll_os, ll_os_path, ll_time, ll_math, ll_strtod):
     extdeclarations += module.extdeclarations
     extfunctions.update(module.extfunctions)
 extdeclarations += '\n;application function prototypes'

Modified: pypy/dist/pypy/translator/llvm2/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/ll_os.py	(original)
+++ pypy/dist/pypy/translator/llvm2/module/ll_os.py	Tue Aug 16 16:20:57 2005
@@ -21,8 +21,6 @@
 %__ll_os_lseek              = internal constant [12 x sbyte] c"lseek......\\00"
 %__ll_os_stat               = internal constant [12 x sbyte] c"stat.......\\00"
 %__ll_os_fstat              = internal constant [12 x sbyte] c"fstat......\\00"
-%__ll_strtod_formatd        = internal constant [12 x sbyte] c"formatd....\\00"
-%__ll_strtod_parts_to_float = internal constant [12 x sbyte] c"parts2flt..\\00"
 """
 
 extfunctions = {}
@@ -219,17 +217,3 @@
 }
 
 """)
-
-extfunctions["%ll_strtod_formatd"] = (("%__debug",), """
-internal fastcc %RPyString* %ll_strtod_formatd(%RPyString* %s, double %x) {
-    call fastcc void %__debug([12 x sbyte]* %__ll_strtod_formatd) ; XXX: TODO: ll_strtod_formatd
-    ret %RPyString* null
-}
-""")
-
-extfunctions["%ll_strtod_parts_to_float"] = (("%__debug",), """
-internal fastcc double %ll_strtod_parts_to_float(%RPyString* s0, %RPyString* s1, %RPyString* s2, %RPyString* s3) {
-    call fastcc void %__debug([12 x sbyte]* %__ll_strtod_parts_to_float) ; XXX: TODO: ll_strtod_parts_to_float
-    ret double 0.0
-}
-""")

Added: pypy/dist/pypy/translator/llvm2/module/ll_strtod.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm2/module/ll_strtod.py	Tue Aug 16 16:20:57 2005
@@ -0,0 +1,21 @@
+extdeclarations = """
+;ll_strtod.py
+%__ll_strtod_formatd        = internal constant [12 x sbyte] c"formatd....\\00"
+%__ll_strtod_parts_to_float = internal constant [12 x sbyte] c"parts2flt..\\00"
+"""
+
+extfunctions = {}
+
+extfunctions["%ll_strtod_formatd"] = (("%__debug",), """
+internal fastcc %RPyString* %ll_strtod_formatd(%RPyString* %s, double %x) {
+    call fastcc void %__debug([12 x sbyte]* %__ll_strtod_formatd) ; XXX: TODO: ll_strtod_formatd
+    ret %RPyString* null
+}
+""")
+
+extfunctions["%ll_strtod_parts_to_float"] = (("%__debug",), """
+internal fastcc double %ll_strtod_parts_to_float(%RPyString* s0, %RPyString* s1, %RPyString* s2, %RPyString* s3) {
+    call fastcc void %__debug([12 x sbyte]* %__ll_strtod_parts_to_float) ; XXX: TODO: ll_strtod_parts_to_float
+    ret double 0.0
+}
+""")

Modified: pypy/dist/pypy/translator/llvm2/module/support.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/support.py	(original)
+++ pypy/dist/pypy/translator/llvm2/module/support.py	Tue Aug 16 16:20:57 2005
@@ -16,7 +16,7 @@
 
 """)
 
-extfunctions["%cast"] = ((), """
+extfunctions["%cast"] = (("%string_to_RPyString",), """
 internal fastcc sbyte* %cast(%RPyString* %structstring) {
     %source1ptr = getelementptr %RPyString* %structstring, int 0, uint 1, uint 1
     %source1 = cast [0 x sbyte]* %source1ptr to sbyte*

Modified: pypy/dist/pypy/translator/llvm2/tool/suggested_primitive.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/tool/suggested_primitive.py	(original)
+++ pypy/dist/pypy/translator/llvm2/tool/suggested_primitive.py	Tue Aug 16 16:20:57 2005
@@ -3,12 +3,12 @@
 import autopath
 from sets import Set
 
-from pypy.rpython.module import ll_os, ll_os_path, ll_time, ll_math #XXX keep this list up-to-date
+from pypy.rpython.module import ll_os, ll_os_path, ll_time, ll_math, ll_strtod #XXX keep this list up-to-date
 from pypy.translator.llvm2.module.extfunction import extfunctions
 
 def main():
     seen = Set()
-    for module in (ll_os, ll_os_path, ll_time, ll_math):    #XXX keep this list up-to-date too
+    for module in (ll_os, ll_os_path, ll_time, ll_math, ll_strtod):    #XXX keep this list up-to-date too
         suggested_primitives   = Set( [func for func in dir(module) if func not in seen and getattr(module.__dict__[func], 'suggested_primitive', False)] )
         seen |= suggested_primitives
         implemented_primitives = Set( [f[1:] for f in extfunctions.keys()] )



More information about the Pypy-commit mailing list