Пример #1
0
def builtin_test(oopspec_name, args, RESTYPE, expected):
    v_result = varoftype(RESTYPE)
    tr = Transformer(FakeCPU(), FakeCallControl())
    tr.immutable_arrays = {}
    tr.vable_array_vars = {}
    if '/' in oopspec_name:
        oopspec_name, property = oopspec_name.split('/')
        def force_flags(op):
            if property == 'NONNEG':   return True
            if property == 'NEG':      return False
            raise ValueError(property)
        tr._get_list_nonneg_canraise_flags = force_flags
    op = SpaceOperation('direct_call',
                        [Constant("myfunc", lltype.Void)] + args,
                        v_result)
    try:
        oplist = tr._handle_list_call(op, oopspec_name, args)
    except NotSupported:
        assert expected is NotSupported
    else:
        assert expected is not NotSupported
        assert oplist is not None
        flattener = GraphFlattener(None, fake_regallocs())
        if not isinstance(oplist, list):
            oplist = [oplist]
        for op1 in oplist:
            flattener.serialize_op(op1)
        assert_format(flattener.ssarepr, expected)
Пример #2
0
 def test_descr(self):
     class FooDescr(AbstractDescr):
         def __repr__(self):
             return 'hi_there!'
     op = SpaceOperation('foobar', [FooDescr()], None)
     flattener = GraphFlattener(None, fake_regallocs())
     flattener.serialize_op(op)
     assert_format(flattener.ssarepr, """
         foobar hi_there!
     """)
Пример #3
0
    def test_descr(self):
        class FooDescr(AbstractDescr):
            def __repr__(self):
                return 'hi_there!'

        op = SpaceOperation('foobar', [FooDescr()], None)
        flattener = GraphFlattener(None, fake_regallocs())
        flattener.serialize_op(op)
        assert_format(flattener.ssarepr, """
            foobar hi_there!
        """)
Пример #4
0
 def check_assembler(self, graph, expected, transform=False,
                     callcontrol=None):
     # 'transform' can be False only for simple graphs.  More complex
     # graphs must first be transformed by jtransform.py before they can be
     # subjected to register allocation and flattening.
     if transform:
         from pypy.jit.codewriter.jtransform import transform_graph
         transform_graph(graph, callcontrol=callcontrol)
     regalloc = perform_register_allocation(graph, 'int')
     regalloc2 = perform_register_allocation(graph, 'ref')
     ssarepr = flatten_graph(graph, {'int': regalloc,
                                     'ref': regalloc2})
     assert_format(ssarepr, expected)
Пример #5
0
 def encoding_test(self, func, args, expected,
                   transform=False, liveness=False, cc=None, jd=None):
     graphs = self.make_graphs(func, args)
     #graphs[0].show()
     if transform:
         from pypy.jit.codewriter.jtransform import transform_graph
         cc = cc or FakeCallControl()
         transform_graph(graphs[0], FakeCPU(self.rtyper), cc, jd)
     ssarepr = flatten_graph(graphs[0], fake_regallocs(),
                             _include_all_exc_links=not transform)
     if liveness:
         from pypy.jit.codewriter.liveness import compute_liveness
         compute_liveness(ssarepr)
     assert_format(ssarepr, expected)
Пример #6
0
 def check_assembler(self,
                     graph,
                     expected,
                     transform=False,
                     callcontrol=None):
     # 'transform' can be False only for simple graphs.  More complex
     # graphs must first be transformed by jtransform.py before they can be
     # subjected to register allocation and flattening.
     if transform:
         from pypy.jit.codewriter.jtransform import transform_graph
         transform_graph(graph, callcontrol=callcontrol)
     regalloc = perform_register_allocation(graph, 'int')
     regalloc2 = perform_register_allocation(graph, 'ref')
     ssarepr = flatten_graph(graph, {'int': regalloc, 'ref': regalloc2})
     assert_format(ssarepr, expected)
Пример #7
0
 def test_arg_sublist_1(self):
     v1 = varoftype(lltype.Signed)
     v2 = varoftype(lltype.Char)
     v3 = varoftype(rclass.OBJECTPTR)
     v4 = varoftype(lltype.Ptr(rstr.STR))
     v5 = varoftype(lltype.Float)
     op = SpaceOperation('residual_call_ir_f',
                         [Constant(12345, lltype.Signed),  # function ptr
                          ListOfKind('int', [v1, v2]),     # int args
                          ListOfKind('ref', [v3, v4])],    # ref args
                         v5)                    # result
     flattener = GraphFlattener(None, fake_regallocs())
     flattener.serialize_op(op)
     assert_format(flattener.ssarepr, """
         residual_call_ir_f $12345, I[%i0, %i1], R[%r0, %r1] -> %f0
     """)
Пример #8
0
 def test_arg_sublist_1(self):
     v1 = varoftype(lltype.Signed)
     v2 = varoftype(lltype.Char)
     v3 = varoftype(rclass.OBJECTPTR)
     v4 = varoftype(lltype.Ptr(rstr.STR))
     v5 = varoftype(lltype.Float)
     op = SpaceOperation(
         'residual_call_ir_f',
         [
             Constant(12345, lltype.Signed),  # function ptr
             ListOfKind('int', [v1, v2]),  # int args
             ListOfKind('ref', [v3, v4])
         ],  # ref args
         v5)  # result
     flattener = GraphFlattener(None, fake_regallocs())
     flattener.serialize_op(op)
     assert_format(
         flattener.ssarepr, """
         residual_call_ir_f $12345, I[%i0, %i1], R[%r0, %r1] -> %f0
     """)
Пример #9
0
 def encoding_test(self,
                   func,
                   args,
                   expected,
                   transform=False,
                   liveness=False,
                   cc=None,
                   jd=None):
     graphs = self.make_graphs(func, args)
     #graphs[0].show()
     if transform:
         from pypy.jit.codewriter.jtransform import transform_graph
         cc = cc or FakeCallControl()
         transform_graph(graphs[0], FakeCPU(self.rtyper), cc, jd)
     ssarepr = flatten_graph(graphs[0],
                             fake_regallocs(),
                             _include_all_exc_links=not transform)
     if liveness:
         from pypy.jit.codewriter.liveness import compute_liveness
         compute_liveness(ssarepr)
     assert_format(ssarepr, expected)
Пример #10
0
 def liveness_test(self, input, output):
     ssarepr = unformat_assembler(input)
     compute_liveness(ssarepr)
     assert_format(ssarepr, output)
Пример #11
0
 def liveness_test(self, input, output):
     ssarepr = unformat_assembler(input)
     compute_liveness(ssarepr)
     assert_format(ssarepr, output)