From: Luke Kenneth Casson Leighton Date: Thu, 2 Apr 2020 15:40:13 +0000 (+0100) Subject: add form-extraction parsing X-Git-Tag: div_pipeline~1567 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8dfb9f992da5dbc3409a554ac7c261a4301b0b98;p=soc.git add form-extraction parsing --- 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()