Author: Armin Rigo <ar...@tunes.org> Branch: optresult-unroll Changeset: r79473:27475ddd1350 Date: 2015-09-06 12:23 +0200 http://bitbucket.org/pypy/pypy/changeset/27475ddd1350/
Log: 32bit: fix fix fix diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py --- a/rpython/jit/backend/test/runner_test.py +++ b/rpython/jit/backend/test/runner_test.py @@ -27,11 +27,8 @@ IS_32_BIT = sys.maxint < 2**32 IS_64_BIT = sys.maxint > 2**32 -def constfloat(x): - return ConstFloat(longlong.getfloatstorage(x)) - -def boxfloat(x): - return InputArgFloat(longlong.getfloatstorage(x)) +boxfloat = InputArgFloat.fromfloat +constfloat = ConstFloat.fromfloat def clone(op): if op.type == 'i': @@ -421,6 +418,8 @@ from rpython.jit.metainterp.test.test_executor import get_float_tests for opnum, boxargs, rettype, retvalue in get_float_tests(self.cpu): res = self.execute_operation(opnum, boxargs, rettype) + if rettype == 'float': + res = longlong.getrealfloat(res) assert res == retvalue def test_ovf_operations(self, reversed=False): @@ -563,7 +562,7 @@ res = self.execute_operation(rop.CALL_F, [funcbox] + args, 'float', descr=calldescr) - assert abs(res - 4.6) < 0.0001 + assert abs(longlong.getrealfloat(res) - 4.6) < 0.0001 def test_call_many_arguments(self): # Test calling a function with a large number of arguments (more than @@ -648,7 +647,7 @@ res = self.execute_operation(rop.CALL_F, [funcbox, constfloat(1.5), constfloat(2.5)], 'float', descr=calldescr) - assert res == 4.0 + assert longlong.getrealfloat(res) == 4.0 def test_field_basic(self): @@ -706,13 +705,13 @@ 'void', descr=floatdescr) res = self.execute_operation(rop.GETFIELD_GC_F, [t_box], 'float', descr=floatdescr) - assert res == 3.4 + assert longlong.getrealfloat(res) == 3.4 # self.execute_operation(rop.SETFIELD_GC, [t_box, constfloat(-3.6)], 'void', descr=floatdescr) res = self.execute_operation(rop.GETFIELD_GC_F, [t_box], 'float', descr=floatdescr) - assert res == -3.6 + assert longlong.getrealfloat(res) == -3.6 def test_passing_guards(self): @@ -933,10 +932,10 @@ 'void', descr=arraydescr) r = self.execute_operation(rop.GETARRAYITEM_GC_F, [a_box, InputArgInt(1)], 'float', descr=arraydescr) - assert r == 3.5 + assert longlong.getrealfloat(r) == 3.5 r = self.execute_operation(rop.GETARRAYITEM_GC_F, [a_box, InputArgInt(2)], 'float', descr=arraydescr) - assert r == 4.5 + assert longlong.getrealfloat(r) == 4.5 # For platforms where sizeof(INT) != sizeof(Signed) (ie, x86-64) a_box, A = self.alloc_array_of(rffi.INT, 342) @@ -979,7 +978,7 @@ self.cpu.bh_setinteriorfield_gc_f(a_box.getref_base(), 3, longlong.getfloatstorage(2.5), kdescr) r = self.execute_operation(rop.GETINTERIORFIELD_GC_F, [a_box, InputArgInt(3)], 'float', descr=kdescr) - assert r == 2.5 + assert longlong.getrealfloat(r) == 2.5 # NUMBER_FIELDS = [('vs', lltype.Signed), ('vu', lltype.Unsigned), @@ -1133,9 +1132,9 @@ if self.cpu.supports_floats: r = self.execute_operation(rop.SAME_AS_F, [constfloat(5.5)], 'float') - assert r == 5.5 + assert longlong.getrealfloat(r) == 5.5 r = self.execute_operation(rop.SAME_AS_F, [boxfloat(5.5)], 'float') - assert r == 5.5 + assert longlong.getrealfloat(r) == 5.5 def test_virtual_ref(self): pass # VIRTUAL_REF must not reach the backend nowadays @@ -4128,7 +4127,7 @@ res = self.execute_operation(rop.CALL_F, [funcbox, boxfloat(arg)], 'float', descr=calldescr) - assert res == expected + assert longlong.getrealfloat(res) == expected def test_compile_loop_with_target(self): looptoken = JitCellToken() diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py --- a/rpython/jit/metainterp/history.py +++ b/rpython/jit/metainterp/history.py @@ -270,6 +270,10 @@ assert lltype.typeOf(valuestorage) is longlong.FLOATSTORAGE self.value = valuestorage + @staticmethod + def fromfloat(x): + return ConstFloat(longlong.getfloatstorage(x)) + def getfloatstorage(self): return self.value diff --git a/rpython/jit/metainterp/resoperation.py b/rpython/jit/metainterp/resoperation.py --- a/rpython/jit/metainterp/resoperation.py +++ b/rpython/jit/metainterp/resoperation.py @@ -482,6 +482,10 @@ def __init__(self, f=longlong.ZEROF): self.setfloatstorage(f) + @staticmethod + def fromfloat(x): + return InputArgFloat(longlong.getfloatstorage(x)) + class InputArgRef(RefOp, AbstractInputArg): def __init__(self, r=lltype.nullptr(llmemory.GCREF.TO)): self.setref_base(r) diff --git a/rpython/jit/metainterp/test/test_executor.py b/rpython/jit/metainterp/test/test_executor.py --- a/rpython/jit/metainterp/test/test_executor.py +++ b/rpython/jit/metainterp/test/test_executor.py @@ -63,11 +63,9 @@ def bh_strsetitem(self, string, index, newvalue): self.fakestrsetitem = (string, index, newvalue) -def boxfloat(x): - return InputArgFloat(longlong.getfloatstorage(x)) -def constfloat(x): - return ConstFloat(longlong.getfloatstorage(x)) +boxfloat = InputArgFloat.fromfloat +constfloat = ConstFloat.fromfloat def test_execute(): diff --git a/rpython/jit/tool/oparser.py b/rpython/jit/tool/oparser.py --- a/rpython/jit/tool/oparser.py +++ b/rpython/jit/tool/oparser.py @@ -171,7 +171,7 @@ if elem.startswith('i'): v = InputArgInt(0) elif elem.startswith('f'): - v = InputArgFloat(0.0) + v = InputArgFloat.fromfloat(0.0) else: from rpython.rtyper.lltypesystem import lltype, llmemory assert elem.startswith('p') _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit