def evaluate_row(s, i, alignment):
    m = E.g_if_patt.match(s)
    if m:
        d = {\
               'i<10' : i < 10,
               'tail_jump' : (i == 9) and (alignment != 0),
               'tail_here' : (i == 9) and (alignment == 0),
               'aligned'   : alignment == 0,
            }
        s = P.evaluate_if(s, d, m.group(1), m.group(2))

    m = E.g_iplus_patt.search(s)
    if m:
        s = s.replace(m.group(), '%s' % (int(m.group(1)) + i))
    s = re.sub(r'\bi\b', '%s' % i, s)

    m = E.g_v_patt.match(s)
    if m:
        s = extract_v(int(m.group(2)), alignment, m.group(1))

    m = E.g_array_patt.search(s)
    if m:
        j = int(m.group(2))
        if j == 0:
            s = s.replace(m.group(), '(%s)' % m.group(1))
        else:
            s = s.replace(m.group(), '%s(%s)' % (j * 8, m.group(1)))

    return s
def evaluate_row(s, i, alignment):
    m = E.g_if_patt.match(s)
    if m:
        d = \
                {\
                    'tail_jump' : (i == 8) and (alignment != 0),
                    'tail_here' : (i == 8) and (alignment == 0),
                }
        s = P.evaluate_if(s, d, m.group(1), m.group(2))

    if i is not None:
        while True:
            m = g_iplus_minus_patt.search(s)
            if not m:
                break
            if m.group(1) == '+':
                s = s.replace(m.group(), '%s' % (i + int(m.group(2))))
            else:
                s = s.replace(m.group(), '%s' % (i - int(m.group(2))))
        s = re.sub(r'\bi\b', '%s' % i, s)

    m = E.g_v_patt.match(s)
    if m:
        s = extract_v(int(m.group(2)), alignment, m.group(1))

    m = E.g_array_patt.search(s)
    if m:
        j = int(m.group(2))
        if j == 0:
            s = s.replace(m.group(), '(%s)' % m.group(1))
        else:
            s = s.replace(m.group(), '%s(%s)' % (j * 8, m.group(1)))

    m = L.g_ad2_patt.match(s)
    if m:
        return \
                [
                    '%sx %s, %s' % (m.group(1), m.group(2), m.group(3)),
                    'movq %s, %s' % (m.group(3), m.group(2))
                ]

    return [s]
예제 #3
0
def evaluate_row(s, i, extra, aligned):
    m = g_if_patt.match(s)
    if m:
        d = \
                {\
                    'extra': extra,
                    'tail_jump' : (i == 6) and (not aligned),
                    'tail_here' : (i == 6) and aligned,
                }
        s = P.evaluate_if(s, d, m.group(1), m.group(2))

    m = g_iplus_patt.search(s)
    if m:
        s = s.replace(m.group(), '%s' % (int(m.group(1)) + i))
    s = re.sub(r'\bi\b', '%s' % i, s)

    m = g_v_patt.match(s)
    if m:
        return [extract_v(int(m.group(2)), aligned, m.group(1))]

    m = g_array_patt.search(s)
    if m:
        j = int(m.group(2))
        if j == 0:
            s = s.replace(m.group(), '(%s)' % m.group(1))
        else:
            s = s.replace(m.group(), '%s(%s)' % (j * 8, m.group(1)))

    m = g_ad2_patt.match(s)
    if m:
        return \
                [
                    '%sx %s, %s' % (m.group(1), m.group(2), m.group(3)),
                    'movq %s, %s' % (m.group(3), m.group(2))
                ]

    return [s]