[pypy-svn] r48412 - pypy/dist/pypy/translator/llvm
rxe at codespeak.net
rxe at codespeak.net
Thu Nov 8 14:24:03 CET 2007
Author: rxe
Date: Thu Nov 8 14:24:02 2007
New Revision: 48412
Modified:
pypy/dist/pypy/translator/llvm/opwriter.py
Log:
add cast_ptr_to_int operation. size_and_sign() seems to be returning signed for char/unichar - special case for now.
Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py (original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py Thu Nov 8 14:24:02 2007
@@ -141,7 +141,10 @@
self.shiftop(opr)
elif op.opname.startswith('cast_') or op.opname.startswith('truncate_'):
- self.cast_primitive(opr)
+ if op.opname == "cast_ptr_to_int":
+ self.cast_ptr_to_int(opr)
+ else:
+ self.cast_primitive(opr)
else:
meth = getattr(self, op.opname, None)
if not meth:
@@ -219,10 +222,11 @@
from_lltype = opr.op.args[0].concretetype
def issigned(ct):
- if ct is lltype.Bool:
+ # XXX why does size_and_sign() think lltype.Char, lltype.UniChar are signed??
+ if ct in [lltype.Bool, lltype.Char, lltype.UniChar]:
return False
from pypy.rpython.lltypesystem.rffi import size_and_sign
- return size_and_sign(ct)[1]
+ return not size_and_sign(ct)[1]
casttype = "bitcast"
@@ -270,6 +274,10 @@
opr.argrefs[0], opr.rettype, casttype)
same_as = cast_primitive
+ def cast_ptr_to_int(self, opr):
+ self.codewriter.cast(opr.retref, opr.argtypes[0],
+ opr.argrefs[0], opr.rettype, 'ptrtoint')
+
def int_is_true(self, opr):
self.codewriter.binaryop("icmp ne", opr.retref, opr.argtypes[0],
opr.argrefs[0], "0")
More information about the Pypy-commit
mailing list