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"):
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))