From: Luke Kenneth Casson Leighton Date: Tue, 25 Sep 2018 22:04:09 +0000 (+0100) Subject: change to instruction template parsing, create one file per instruction X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cb158882a7e1de23e73a37b8b5b682f8d467535e;p=riscv-isa-sim.git 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 --- 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))