identify type of instruction with additional #defines
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 1 Oct 2018 01:04:57 +0000 (02:04 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 1 Oct 2018 01:04:57 +0000 (02:04 +0100)
id_regs.py

index 0d732b355cae9124e993763061bf827086d85a06..1812e4ac62cdaedf2dc6807ef7001d187f24fb24 100644 (file)
@@ -107,4 +107,29 @@ if __name__ == '__main__':
         with open(regsname, "w") as f:
             txt = find_registers(fname)
             txt += "\n#define INSN_%s\n" % insn.upper()
+            # help identify type of register
+            if insn in ['beq', 'bne', 'blt', 'bltu', 'bge', 'bgeu']:
+                txt += "#define INSN_TYPE_BRANCH\n"
+            elif insn in ['c_ld', 'c_bnez']:
+                txt += "\n#define INSN_TYPE_C_BRANCH\n"
+            elif insn in ['c_lwsp', 'c_ldsp', 'c_lqsp', 'c_flwsp', 'c_fldsp']:
+                txt += "\n#define INSN_TYPE_C_STACK_LD\n"
+            elif insn in ['c_swsp', 'c_sdsp', 'c_sqsp', 'c_fswsp', 'c_fsdsp']:
+                txt += "\n#define INSN_TYPE_C_STACK_ST\n"
+            elif insn in ['c_lw', 'c_ld', 'c_lq', 'c_flw', 'c_fld']:
+                txt += "\n#define INSN_TYPE_C_LD\n"
+            elif insn in ['c_sw', 'c_sd', 'c_sq', 'c_fsw', 'c_fsd']:
+                txt += "\n#define INSN_TYPE_C_ST\n"
+            elif insn in ['c_beqz', 'c_bnez']:
+                txt += "\n#define INSN_TYPE_C_BRANCH\n"
+            elif insn.startswith("c_"):
+                txt += "#define INSN_TYPE_C\n"
+            elif insn.startswith("fmv") or \
+                 insn.startswith("fcvt") or \
+                 insn.startswith("fsgn"):
+                txt += "#define INSN_TYPE_FP_DUALOP\n"
+            elif insn.startswith("feq") or \
+                 insn.startswith("flt") or \
+                 insn.startswith("fle"):
+                txt += "#define INSN_TYPE_FP_BRANCH\n"
             f.write(txt)