From 8dfb9f992da5dbc3409a554ac7c261a4301b0b98 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 2 Apr 2020 16:40:13 +0100 Subject: [PATCH] add form-extraction parsing --- src/soc/decoder/pseudo/pagereader.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/soc/decoder/pseudo/pagereader.py b/src/soc/decoder/pseudo/pagereader.py index 13c9c869..0b3a3c36 100644 --- a/src/soc/decoder/pseudo/pagereader.py +++ b/src/soc/decoder/pseudo/pagereader.py @@ -63,6 +63,7 @@ class ISA: def __init__(self): self.instr = OrderedDict() + self.forms = {} def read_file(self, fname): fname = os.path.join(get_isa_dir(), fname) @@ -132,17 +133,25 @@ class ISA: # add in opcode for o in opcodes: - opcode, regs = o[0], o[1:] - op = copy(d) - op['regs'] = regs - op['opcode'] = opcode - self.instr[opcode] = op + self.add_op(o, d) # expect and drop whitespace while lines: l = lines.pop(0).rstrip() if len(l) != 0: break + def add_op(self, o, d): + opcode, regs = o[0], o[1:] + op = copy(d) + op['regs'] = regs + op['opcode'] = opcode + self.instr[opcode] = op + + # create list of instructions by form + form = op['form'] + fl = self.forms.get(form, []) + self.forms[form] = fl + [opcode] + def pprint_ops(self): for k, v in self.instr.items(): print ("# %s %s" % (v['opcode'], v['desc'])) @@ -151,6 +160,8 @@ class ISA: print ("Specials") print ('\n'.join(map(lambda x: " %s" % x, v['sregs']))) print () + for k, v in isa.forms.items(): + print (k, v) if __name__ == '__main__': isa = ISA() -- 2.30.2