[pypy-svn] r77776 - in pypy/branch/jitffi/pypy: jit/backend/llsupport rlib
antocuni at codespeak.net
antocuni at codespeak.net
Mon Oct 11 11:38:19 CEST 2010
Author: antocuni
Date: Mon Oct 11 11:38:17 2010
New Revision: 77776
Modified:
pypy/branch/jitffi/pypy/jit/backend/llsupport/ffisupport.py
pypy/branch/jitffi/pypy/rlib/libffi.py
Log:
move the logic from the jit to libffi, which is a more proper place
Modified: pypy/branch/jitffi/pypy/jit/backend/llsupport/ffisupport.py
==============================================================================
--- pypy/branch/jitffi/pypy/jit/backend/llsupport/ffisupport.py (original)
+++ pypy/branch/jitffi/pypy/jit/backend/llsupport/ffisupport.py Mon Oct 11 11:38:17 2010
@@ -21,43 +21,13 @@
return VoidCallDescr(arg_classes, extrainfo)
assert False
-
-# XXX: maybe we can turn this into a dictionary, but we need to do it at
-# runtime as libffi.types.* pointers
def get_ffi_type_kind(ffi_type):
from pypy.rlib.libffi import types
- if ffi_type is types.void:
- return history.VOID
- elif ffi_type is types.pointer:
+ kind = types.getkind(ffi_type)
+ if kind == 'i':
return history.INT
- elif ffi_type is types.double:
+ elif kind == 'f':
return history.FLOAT
- elif ffi_type is types.uchar:
- return history.INT
- elif ffi_type is types.uint8:
- return history.INT
- elif ffi_type is types.schar:
- return history.INT
- elif ffi_type is types.sint8:
- return history.INT
- elif ffi_type is types.uint16:
- return history.INT
- elif ffi_type is types.ushort:
- return history.INT
- elif ffi_type is types.sint16:
- return history.INT
- elif ffi_type is types.sshort:
- return history.INT
- elif ffi_type is types.uint:
- return history.INT
- elif ffi_type is types.uint32:
- return history.INT
- elif ffi_type is types.sint:
- return history.INT
- elif ffi_type is types.sint32:
- return history.INT
- ## elif ffi_type is types.uint64:
- ## return history.INT
- ## elif ffi_type is types.sint64:
- ## return history.INT
- raise KeyError
+ elif kind == 'v':
+ return history.VOID
+ assert False, "Unsuported kind '%s'" % kind
Modified: pypy/branch/jitffi/pypy/rlib/libffi.py
==============================================================================
--- pypy/branch/jitffi/pypy/rlib/libffi.py (original)
+++ pypy/branch/jitffi/pypy/rlib/libffi.py Mon Oct 11 11:38:17 2010
@@ -34,10 +34,42 @@
@staticmethod
@jit.purefunction
- def getkind(ffitype):
- # XXX: move this function outside the jit
- from pypy.jit.backend.llsupport.ffisupport import get_ffi_type_kind
- return get_ffi_type_kind(ffitype)
+ def getkind(ffi_type):
+ if ffi_type is types.void:
+ return 'v'
+ elif ffi_type is types.double:
+ return 'f'
+ elif ffi_type is types.pointer:
+ return 'i'
+ elif ffi_type is types.uchar:
+ return 'i'
+ elif ffi_type is types.uint8:
+ return 'i'
+ elif ffi_type is types.schar:
+ return 'i'
+ elif ffi_type is types.sint8:
+ return 'i'
+ elif ffi_type is types.uint16:
+ return 'i'
+ elif ffi_type is types.ushort:
+ return 'i'
+ elif ffi_type is types.sint16:
+ return 'i'
+ elif ffi_type is types.sshort:
+ return 'i'
+ elif ffi_type is types.uint:
+ return 'i'
+ elif ffi_type is types.uint32:
+ return 'i'
+ elif ffi_type is types.sint:
+ return 'i'
+ elif ffi_type is types.sint32:
+ return 'i'
+ ## elif ffi_type is types.uint64:
+ ## return 'i'
+ ## elif ffi_type is types.sint64:
+ ## return 'i'
+ raise KeyError
types._import()
More information about the Pypy-commit
mailing list