[pypy-svn] r35582 - in pypy/dist/pypy/jit/codegen/llvm: . test
ericvrp at codespeak.net
ericvrp at codespeak.net
Mon Dec 11 16:50:54 CET 2006
Author: ericvrp
Date: Mon Dec 11 16:50:53 2006
New Revision: 35582
Modified:
pypy/dist/pypy/jit/codegen/llvm/rgenop.py
pypy/dist/pypy/jit/codegen/llvm/test/test_operation.py
Log:
Extended genconst() for Char,UniChar,Unsigned and Float.
test_unsigned passes now, test_float_arithmetic still disabled.
Continuing the svn chat feature ;)
Modified: pypy/dist/pypy/jit/codegen/llvm/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/rgenop.py (original)
+++ pypy/dist/pypy/jit/codegen/llvm/rgenop.py Mon Dec 11 16:50:53 2006
@@ -38,8 +38,8 @@
return '%%v%d' % (self.n,)
-class IntConst(GenConst):
- type = 'int'
+class GenericConst(GenConst):
+ #type = 'generic'
def __init__(self, value):
self.value = value
@@ -60,6 +60,30 @@
return lltype.cast_primitive(T, self.value)
+class BoolConst(GenericConst):
+ type = 'int'
+
+
+class CharConst(GenericConst):
+ type = 'ubyte'
+
+
+class UniCharConst(GenericConst):
+ type = 'int'
+
+
+class IntConst(GenericConst):
+ type = 'int'
+
+
+class UIntConst(GenericConst):
+ type = 'uint'
+
+
+class FloatConst(GenericConst):
+ type = 'float'
+
+
class AddrConst(GenConst):
type = 'int*'
@@ -343,7 +367,7 @@
def op_int_neg(self, gv_x): return self._rgenop2_generic('sub', IntConst(0), gv_x)
def op_int_invert(self, gv_x): return self._rgenop2_generic('xor', gv_x, IntConst(-1))
- def op_uint_invert(self, gv_x): return self._rgenop2_generic('xor', gv_x, IntConst((1<<32)-1))
+ def op_uint_invert(self, gv_x): return self._rgenop2_generic('xor', gv_x, UIntConst((1<<32)-1))
def op_int_abs(self, gv_x):
gv_comp = Var('bool')
@@ -460,6 +484,10 @@
def op_float_is_true(self, gv_x): return self._is_true(gv_x, '0.0')
+ def genop_malloc_varsize(self, varsizealloctoken, gv_size):
+ gv_result = Var('sbyte') #XXX TODO
+ return gv_result
+
def genop_call(self, sigtoken, gv_fnptr, args_gv):
log('%s Builder.genop_call %s,%s,%s' % (
self.block.label, sigtoken, gv_fnptr, [v.operand() for v in args_gv]))
@@ -556,6 +584,14 @@
T = lltype.typeOf(llvalue)
if T is llmemory.Address:
return AddrConst(llvalue)
+ elif T is lltype.Bool:
+ return BoolConst(lltype.cast_primitive(lltype.Bool, llvalue))
+ elif T is lltype.Char:
+ return CharConst(lltype.cast_primitive(lltype.Char, llvalue))
+ elif T is lltype.Unsigned:
+ return UIntConst(lltype.cast_primitive(lltype.Unsigned, llvalue))
+ elif T is lltype.Float:
+ return FloatConst(lltype.cast_primitive(lltype.Float, llvalue))
elif isinstance(T, lltype.Primitive):
return IntConst(lltype.cast_primitive(lltype.Signed, llvalue))
elif isinstance(T, lltype.Ptr):
@@ -601,14 +637,14 @@
@staticmethod
@specialize.memo()
def varsizeAllocToken(T):
- XXX
+ #XXX TODO
if isinstance(T, lltype.Array):
- return RI386GenOp.arrayToken(T)
+ return RLLVMGenOp.arrayToken(T)
else:
# var-sized structs
arrayfield = T._arrayfld
ARRAYFIELD = getattr(T, arrayfield)
- arraytoken = RI386GenOp.arrayToken(ARRAYFIELD)
+ arraytoken = RLLVMGenOp.arrayToken(ARRAYFIELD)
length_offset, items_offset, item_size = arraytoken
arrayfield_offset = llmemory.offsetof(T, arrayfield)
return (arrayfield_offset+length_offset,
@@ -618,7 +654,7 @@
@staticmethod
@specialize.memo()
def arrayToken(A):
- XXX
+ #XXX TODO
return (llmemory.ArrayLengthOffset(A),
llmemory.ArrayItemsOffset(A),
llmemory.ItemOffset(A.OF))
Modified: pypy/dist/pypy/jit/codegen/llvm/test/test_operation.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/test/test_operation.py (original)
+++ pypy/dist/pypy/jit/codegen/llvm/test/test_operation.py Mon Dec 11 16:50:53 2006
@@ -19,15 +19,17 @@
def skip(self):
py.test.skip('WIP')
- test_unsigned = skip
+ #test_unsigned = skip
#XXX -r_uint(n) generated op_int_sub(0,n) , why not op_uint_sub?
# -AR- for me it crashes on the 'x%y' test. The LLVM ref manual
# seems to mention only 'srem' and 'urem' instructions and
# not 'rem'. Same for 'sdiv' and 'udiv' and no 'div'.
# Strange, the translator/llvm backend seems to produce
# 'div' and 'rem' anyway...
+ # -ER- the langref on llvm.org seems to be for the upcoming llvm version 2.0
# -AR- I see in llvm.rgenop that op_uint_invert uses an IntConst
# (should be UIntConst).
+ # -ER- indeed
test_float_arithmetic = skip
#XXX bool(f - 2.0) generated op_float_sub(f,IntConst(2)) , why not FloatConst(2.0) ?
@@ -42,6 +44,7 @@
# e.g. return UIntConst for unsigned integer types, FloatConst for
# float types, and possibly things like CharConst UniCharConst etc.
# based on what T is (the same kind of checks as in kindToken())
+ # -ER- extended genconst()
test_char_array = skip
test_char_varsize_array = skip
More information about the Pypy-commit
mailing list