Exemple #1
0
def test_unformat_assembler_lists():
    input = """
        foo F[%f0, %f3]
    """
    regs = {}
    ssarepr = unformat_assembler(input, regs)
    assert ssarepr.insns == [('foo',
                              ListOfKind('float', [regs['%f0'], regs['%f3']]))]
Exemple #2
0
def test_unformat_assembler_consts():
    input = """
        foo $123
    """
    ssarepr = unformat_assembler(input)
    assert ssarepr.insns == [
        ('foo', Constant(123, lltype.Signed)),
    ]
Exemple #3
0
def test_unformat_assembler_single_return():
    input = """
        foo -> %i0
    """
    regs = {}
    ssarepr = unformat_assembler(input, regs)
    assert ssarepr.insns == [
        ('foo', '->', regs['%i0']),
    ]
Exemple #4
0
def test_unformat_assembler_simple():
    input = """
        int_add %i0, %i1 -> %i2
        int_return %i2
    """
    regs = {}
    ssarepr = unformat_assembler(input, regs)
    assert regs['%i2'].kind == 'int'
    assert regs['%i2'].index == 2
    assert ssarepr.insns == [
        ('int_add', regs['%i0'], regs['%i1'], '->', regs['%i2']),
        ('int_return', regs['%i2']),
    ]
Exemple #5
0
def test_unformat_assembler_label():
    input = """
        L1:
        foo L2
        L2:
        bar L1
    """
    ssarepr = unformat_assembler(input)
    assert ssarepr.insns == [
        (Label('L1'), ),
        ('foo', TLabel('L2')),
        (Label('L2'), ),
        ('bar', TLabel('L1')),
    ]
Exemple #6
0
def test_unformat_switchdictdescr():
    input = """
        foo <SwitchDictDescr 4:L2, 5:L1>
        L1:
        L2:
    """
    regs = {}
    ssarepr = unformat_assembler(input, regs)
    sdd = ssarepr.insns[0][1]
    assert ssarepr.insns == [
        ('foo', sdd),
        (Label('L1'), ),
        (Label('L2'), ),
    ]
    assert isinstance(sdd, SwitchDictDescr)
    assert sdd._labels == [(4, TLabel('L2')), (5, TLabel('L1'))]
Exemple #7
0
 def liveness_test(self, input, output):
     ssarepr = unformat_assembler(input)
     compute_liveness(ssarepr)
     assert_format(ssarepr, output)
Exemple #8
0
 def liveness_test(self, input, output):
     ssarepr = unformat_assembler(input)
     compute_liveness(ssarepr)
     assert_format(ssarepr, output)