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

ericvrp at codespeak.net ericvrp at codespeak.net
Wed Jan 18 11:19:43 CET 2006


Author: ericvrp
Date: Wed Jan 18 11:19:39 2006
New Revision: 22271

Modified:
   pypy/dist/pypy/translator/llvm/extfuncnode.py
   pypy/dist/pypy/translator/llvm/module/support.py
   pypy/dist/pypy/translator/llvm/opwriter.py
Log:
Fixes for 64 bit machines


Modified: pypy/dist/pypy/translator/llvm/extfuncnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/extfuncnode.py	(original)
+++ pypy/dist/pypy/translator/llvm/extfuncnode.py	Wed Jan 18 11:19:39 2006
@@ -5,9 +5,9 @@
 log = log.extfuncnode
 
 class ExtFuncSig(object):
-    def __init__(self, retval, args):
+    def __init__(self, rettype, args):
+        self.rettype = rettype
         self.args = args
-        self.rettype = retval
 
 # signature of external functions differ from C's implementation
 ext_func_sigs = {
@@ -15,8 +15,23 @@
     "%LL_stack_too_big" : ExtFuncSig("int", None),
     "%LL_os_lseek" : ExtFuncSig("int", None),
     "%LL_thread_acquirelock" : ExtFuncSig("int", [None, "int"]),
-    "%LL_thread_start" : ExtFuncSig(None, ["sbyte*", "sbyte*"])}
-    
+    "%LL_thread_start" : ExtFuncSig(None, ["sbyte*", "sbyte*"]),
+    }
+
+#on 64 bit systems we need a wrapper for everything the takes or returns an int
+from sys import maxint
+if maxint != 2**31-1:
+    extra_ext_func_sigs = {
+        "%LL_os_dup" : ExtFuncSig("int", ["int"]),
+        "%LL_os_open" : ExtFuncSig("int", [None, "int", "int"]),
+        "%LL_os_write" : ExtFuncSig(None, ["int", None]),
+        "%LL_read_into" : ExtFuncSig(None, ["int", None]),
+        "%LL_os_close" : ExtFuncSig(None, ["int"]),
+        "%pypy_ll_stat_result__Signed_Signed_Signed_Signed_Signed_Signed_Signed_Signed_Signed_Signed" : ExtFuncSig(None, ["int"]*10)
+        }
+    ext_func_sigs.update(extra_ext_func_sigs)
+
+
 class ExternalFuncNode(ConstantLLVMNode):
 
     def __init__(self, db, value):
@@ -28,7 +43,11 @@
         mapped_name = EXTERNALS[value._callable]
         self.ref = self.make_ref("%", mapped_name)
         self.wrapper = ext_func_sigs.get(self.ref, None)
-        
+        if self.wrapper is None and maxint != 2**31-1:
+            #XXX if returntype or param in ('int', 'uint'):
+            #         add wrapper to return from long->int
+            pass
+
     def __str__(self):
         return "<ExternalFuncNode %r>" % self.ref
 

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 Jan 18 11:19:39 2006
@@ -79,6 +79,17 @@
 
 """
 
+from sys import maxint
+if maxint != 2**31-1:
+    extfunctions = """
+internal fastcc void %pypy_ll_raise_OSError__Signed(int %errno_0) {
+    %tmp = cast int %errno_0 to long
+    call void %pypy_ll_raise_OSError__Signed(long %tmp)
+    ret void
+}
+
+"""
+
 def write_raise_exc(c_name, exc_repr, codewriter):
 
     l = """

Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py	(original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py	Wed Jan 18 11:19:39 2006
@@ -81,6 +81,8 @@
     def __init__(self, db, codewriter):
         self.db = db
         self.codewriter = codewriter
+        self.word = db.get_machine_word()
+        self.uword = db.get_machine_uword()
 
     def _tmp(self, count=1):
         if count == 1:
@@ -89,6 +91,8 @@
             return [self.db.repr_tmpvar() for ii in range(count)]
         
     def write_operation(self, op):
+        #log(op)
+
         if op.opname in ("direct_call", 'indirect_call'):
             opr = OpReprCall(op, self.db)
         else:
@@ -373,20 +377,17 @@
                                       opr.argrefs[0], [("uint", 0)])
         self.codewriter.load(opr.retref, opr.rettype, tmpvar)
 
-        
-    # XXX use machine word size
-    
     def adr_delta(self, opr):
         addr1, addr2 = self._tmp(2)
-        self.codewriter.cast(addr1, opr.argtypes[0], opr.argrefs[0], "int")
-        self.codewriter.cast(addr2, opr.argtypes[1], opr.argrefs[1], "int")
+        self.codewriter.cast(addr1, opr.argtypes[0], opr.argrefs[0], self.word)
+        self.codewriter.cast(addr2, opr.argtypes[1], opr.argrefs[1], self.word)
         self.codewriter.binaryop("sub", opr.retref, opr.rettype, addr1, addr2)
 
     def _op_adr_generic(self, opr, llvm_op):
         addr, res = self._tmp(2)
-        self.codewriter.cast(addr, opr.argtypes[0], opr.argrefs[0], "int")
-        self.codewriter.binaryop(llvm_op, res, "int", addr, opr.argrefs[1])
-        self.codewriter.cast(opr.retref, "int", res, opr.rettype)
+        self.codewriter.cast(addr, opr.argtypes[0], opr.argrefs[0], self.word)
+        self.codewriter.binaryop(llvm_op, res, self.word, addr, opr.argrefs[1])
+        self.codewriter.cast(opr.retref, self.word, res, opr.rettype)
 
     def adr_add(self, opr):
         self._op_adr_generic(opr, "add")
@@ -396,10 +397,10 @@
 
     def _op_adr_cmp(self, opr, llvm_op):
         addr1, addr2 = self._tmp(2)
-        self.codewriter.cast(addr1, opr.argtypes[0], opr.argrefs[0], "int")
-        self.codewriter.cast(addr2, opr.argtypes[1], opr.argrefs[1], "int")
+        self.codewriter.cast(addr1, opr.argtypes[0], opr.argrefs[0], self.word)
+        self.codewriter.cast(addr2, opr.argtypes[1], opr.argrefs[1], self.word)
         assert opr.rettype == "bool"
-        self.codewriter.binaryop(llvm_op, opr.retref, "int", addr1, addr2)
+        self.codewriter.binaryop(llvm_op, opr.retref, self.word, addr1, addr2)
 
     def adr_eq(self, opr):
         self._op_adr_cmp(opr, "seteq")



More information about the Pypy-commit mailing list