From 8307560b0d0c2607de0fb95a8546d4039626f28d Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 24 Sep 2018 03:56:21 +0100 Subject: [PATCH] create #defines from identified registers, per opcode --- id_regs.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/id_regs.py b/id_regs.py index cc1596a..c3fbf79 100644 --- a/id_regs.py +++ b/id_regs.py @@ -26,7 +26,8 @@ def list_insns(): for fname in os.listdir(insns_dir): if not fname.endswith(".h"): continue - res.append(os.path.join(insns_dir, fname)) + insn = fname[:-2] + res.append((os.path.join(insns_dir, fname), insn)) return res patterns = ['WRITE_RD', 'RS1', 'RS2', 'RS3', @@ -44,10 +45,16 @@ def find_registers(fname): # botch-job/hack: RS1 also matches against FRS1 (etc.) # check letter before match: if "F", skip it. continue - res.append('REG_%s' % pattern) + p = pattern + if p.startswith('WRITE_'): + p = p[6:] + res.append('REG_%s' % p) + if len(res) == 0: + return "0" return ' | '.join(res) if __name__ == '__main__': + template = "#define REGS_%-12s %s" files = list_insns() - for fname in files: - print fname, find_registers(fname) + for (fname, insn) in files: + print template % (insn, find_registers(fname)) -- 2.30.2