Beispiel #1
0
 def test_is_true(self):
     for opname, T in [('llong_is_true', lltype.SignedLongLong),
                       ('ullong_is_true', lltype.UnsignedLongLong)]:
         v = varoftype(T)
         v_result = varoftype(lltype.Bool)
         op = SpaceOperation(opname, [v], v_result)
         tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
         oplist = tr.rewrite_operation(op)
         assert len(oplist) == 2
         assert oplist[0].opname == 'residual_call_irf_f'
         assert oplist[0].args[0].value == opname.split(
             '_')[0] + '_from_int'
         assert list(oplist[0].args[1]) == [const(0)]
         assert list(oplist[0].args[2]) == []
         assert list(oplist[0].args[3]) == []
         assert oplist[0].args[4] == 'calldescr-84'
         v_x = oplist[0].result
         assert isinstance(v_x, Variable)
         assert v_x.concretetype is T
         assert oplist[1].opname == 'residual_call_irf_i'
         assert oplist[1].args[0].value == 'llong_ne'
         assert list(oplist[1].args[1]) == []
         assert list(oplist[1].args[2]) == []
         assert list(oplist[1].args[3]) == [v, v_x]
         assert oplist[1].args[4] == 'calldescr-76'
         assert oplist[1].result == v_result
Beispiel #2
0
 def test_is_true(self):
     for opname, T in [('llong_is_true', lltype.SignedLongLong),
                       ('ullong_is_true', lltype.UnsignedLongLong)]:
         v = varoftype(T)
         v_result = varoftype(lltype.Bool)
         op = SpaceOperation(opname, [v], v_result)
         tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
         oplist = tr.rewrite_operation(op)
         assert len(oplist) == 2
         assert oplist[0].opname == 'residual_call_irf_f'
         assert oplist[0].args[0].value == opname.split('_')[0]+'_from_int'
         assert list(oplist[0].args[1]) == [const(0)]
         assert list(oplist[0].args[2]) == []
         assert list(oplist[0].args[3]) == []
         assert oplist[0].args[4] == 'calldescr-84'
         v_x = oplist[0].result
         assert isinstance(v_x, Variable)
         assert v_x.concretetype is T
         assert oplist[1].opname == 'residual_call_irf_i'
         assert oplist[1].args[0].value == 'llong_ne'
         assert list(oplist[1].args[1]) == []
         assert list(oplist[1].args[2]) == []
         assert list(oplist[1].args[3]) == [v, v_x]
         assert oplist[1].args[4] == 'calldescr-76'
         assert oplist[1].result == v_result
Beispiel #3
0
 def test_constants(self):
     for TYPE in [lltype.SignedLongLong, lltype.UnsignedLongLong]:
         v_x = varoftype(TYPE)
         vlist = [v_x, const(rffi.cast(TYPE, 7))]
         v_result = varoftype(TYPE)
         op = SpaceOperation('llong_add', vlist, v_result)
         tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
         op1 = tr.rewrite_operation(op)
         #
         assert op1.opname == 'residual_call_irf_f'
         assert list(op1.args[1]) == []
         assert list(op1.args[2]) == []
         assert list(op1.args[3]) == vlist
         assert op1.result == v_result
Beispiel #4
0
 def test_constants(self):
     for TYPE in [lltype.SignedLongLong, lltype.UnsignedLongLong]:
         v_x = varoftype(TYPE)
         vlist = [v_x, const(rffi.cast(TYPE, 7))]
         v_result = varoftype(TYPE)
         op = SpaceOperation('llong_add', vlist, v_result)
         tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
         op1 = tr.rewrite_operation(op)
         #
         assert op1.opname == 'residual_call_irf_f'
         assert list(op1.args[1]) == []
         assert list(op1.args[2]) == []
         assert list(op1.args[3]) == vlist
         assert op1.result == v_result
Beispiel #5
0
 def test_llong_neg(self):
     T = lltype.SignedLongLong
     v = varoftype(T)
     v_result = varoftype(T)
     op = SpaceOperation('llong_neg', [v], v_result)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     oplist = tr.rewrite_operation(op)
     assert len(oplist) == 2
     assert oplist[0].opname == 'residual_call_irf_f'
     assert oplist[0].args[0].value == 'llong_from_int'
     assert list(oplist[0].args[1]) == [const(0)]
     assert list(oplist[0].args[2]) == []
     assert list(oplist[0].args[3]) == []
     assert oplist[0].args[4] == 'calldescr-84'
     v_x = oplist[0].result
     assert isinstance(v_x, Variable)
     assert oplist[1].opname == 'residual_call_irf_f'
     assert oplist[1].args[0].value == 'llong_sub'
     assert list(oplist[1].args[1]) == []
     assert list(oplist[1].args[2]) == []
     assert list(oplist[1].args[3]) == [v_x, v]
     assert oplist[1].args[4] == 'calldescr-71'
     assert oplist[1].result == v_result
Beispiel #6
0
 def test_llong_neg(self):
     T = lltype.SignedLongLong
     v = varoftype(T)
     v_result = varoftype(T)
     op = SpaceOperation('llong_neg', [v], v_result)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     oplist = tr.rewrite_operation(op)
     assert len(oplist) == 2
     assert oplist[0].opname == 'residual_call_irf_f'
     assert oplist[0].args[0].value == 'llong_from_int'
     assert list(oplist[0].args[1]) == [const(0)]
     assert list(oplist[0].args[2]) == []
     assert list(oplist[0].args[3]) == []
     assert oplist[0].args[4] == 'calldescr-84'
     v_x = oplist[0].result
     assert isinstance(v_x, Variable)
     assert oplist[1].opname == 'residual_call_irf_f'
     assert oplist[1].args[0].value == 'llong_sub'
     assert list(oplist[1].args[1]) == []
     assert list(oplist[1].args[2]) == []
     assert list(oplist[1].args[3]) == [v_x, v]
     assert oplist[1].args[4] == 'calldescr-71'
     assert oplist[1].result == v_result