Commit a364d7bc authored by Alan Marchiori's avatar Alan Marchiori
Browse files

now supports 5stage output

parent 735485dd
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ type_lut = {
    'slti': 'arth',
    'slt': 'arth',
    'snez': 'arth',
    '-': 'nop', # nop and such
}

def profile(f, itypes = type_lut):
@@ -119,21 +120,27 @@ def profile(f, itypes = type_lut):
    results = {k:0 for k in set(itypes.values())}
    i = 0


    with open(f, 'r') as of:
        i += 1
        for line in of:
            if line.startswith('Cyc'):

                #someone change this to a regex.
                instruction = line[124:-1] #strip newline
                op = instruction.split(" ")[0]
                if 'PC=' in line:
                    instruction = line[124:].strip()
                elif 'ExeInst' in line:
                    instruction = line[113:].strip()
                else:
                    raise("Unsuppoted out file.")

                op = instruction.split()[0]

                if op not in itypes:
                    print("Insturction on line {}: {}, is not supported.".format(
                    print("Insturction on line {}: '{}', is not supported.".format(
                        i, op
                    ))
                    print(line.strip())

                    exit(-5)
                results[itypes[op]] += 1

    return results