From cb158882a7e1de23e73a37b8b5b682f8d467535e Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 25 Sep 2018 23:04:09 +0100 Subject: [PATCH] change to instruction template parsing, create one file per instruction id_regs.py looks for patterns in riscv/insns/*.h to find the use of registers --- id_regs.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/id_regs.py b/id_regs.py index c3fbf79..1dd6cf4 100644 --- a/id_regs.py +++ b/id_regs.py @@ -20,8 +20,8 @@ import os +insns_dir = "./riscv/insns" def list_insns(): - insns_dir = "./riscv/insns" res = [] for fname in os.listdir(insns_dir): if not fname.endswith(".h"): @@ -48,13 +48,15 @@ def find_registers(fname): p = pattern if p.startswith('WRITE_'): p = p[6:] - res.append('REG_%s' % p) + res.append('#define USING_REG_%s' % p) if len(res) == 0: return "0" - return ' | '.join(res) + return '\n'.join(res) if __name__ == '__main__': - template = "#define REGS_%-12s %s" files = list_insns() for (fname, insn) in files: - print template % (insn, find_registers(fname)) + regsname = "regs_%s.h" % insn + regsname = os.path.join(insns_dir, regsname) + with open(regsname, "w") as f: + f.write(find_registers(fname)) -- 2.30.2