'rvc_frs2': 2, 'rvc_frs2s': 2,
}
-def find_registers(fname, twin_predication):
+def find_registers(fname, insn, twin_predication, immed_offset):
# HACK! macro-skipping of instructions too painful
for notparallel in ['csr', 'lui', 'c_j', 'wfi', 'auipc',
'dret', 'uret', 'mret', 'sret',
- 'lr_d', 'lr_w', 'sc_d', 'sc_w']:
+ 'lr_d', 'lr_w', 'sc_d', 'sc_w',
+ 'c_addi4spn', 'c_addi16sp']:
if notparallel in fname:
return skip
res = []
res.append('#define REGS_PATTERN 0x%x' % isintfloat)
predargs = ['dest_pred'] * 4
+ if immed_offset: # C.LWSP
+ predargs.append('&src_pred')
+ fsrc = insn in ['c_flwsp', 'c_fldsp']
+ res.append('#define SRC_PREDINT %d' % (0 if fsrc else 1))
+
if twin_predication:
found = None
for search in ['rs1', 'rs2', 'rs3', 'rvc_rs1', 'rvc_rs1s',
res.append('#define SRC_PREDINT %d' % (0 if fsrc else 1))
res.append('#define SRC_REG %s' % found)
+ if len(predargs) == 4:
+ predargs.append('NULL')
+
res.append('#define PRED_ARGS %s' % ','.join(predargs))
offsargs = []
- for i in range(4):
- offsargs.append(predargs[i].replace('pred', 'offs'))
+ for i in range(len(predargs)):
+ offsargs.append(predargs[i].replace('pred', 'offs').replace("&", ''))
res.append('#define OFFS_ARGS %s' % ','.join(offsargs))
return '\n'.join(res)
regsname = "regs_%s.h" % insn
regsname = os.path.join(insns_dir, regsname)
twin_predication = False
+ immed_offset = False
with open(regsname, "w") as f:
txt = "\n#define INSN_%s\n" % insn.upper()
# help identify type of register
twin_predication = True
txt += "#define INSN_TYPE_LOAD\n"
elif insn in ['c_lwsp', 'c_ldsp', 'c_lqsp', 'c_flwsp', 'c_fldsp']:
+ twin_predication = True
+ immed_offset = True
txt += "\n#define INSN_TYPE_C_STACK_LD\n"
elif insn in ['c_swsp', 'c_sdsp', 'c_sqsp', 'c_fswsp', 'c_fsdsp']:
+ twin_predication = True
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"
txt += "#define INSN_TYPE_FP_BRANCH\n"
if twin_predication:
txt += "\n#define INSN_CATEGORY_TWINPREDICATION\n"
- txt += find_registers(fname, twin_predication)
+ txt += find_registers(fname, insn, twin_predication, immed_offset)
f.write(txt)
xstr(INSN), INSNCODE, s_insn.rd(), s_insn.rs1(), s_insn.rs2(),
vlen);
#ifdef INSN_CATEGORY_TWINPREDICATION
+#ifdef INSN_TYPE_C_STACK_LD
+ src_pred = insn.predicate(X_SP, SRC_PREDINT, zeroingsrc);
+#else
src_pred = insn.predicate(s_insn.SRC_REG(), SRC_PREDINT, zeroingsrc);
#endif
+#endif
#ifdef DEST_PREDINT
// use the ORIGINAL, i.e. NON-REDIRECTED, register here
dest_pred = insn.predicate(s_insn.DEST_REG(), DEST_PREDINT, zeroing);
public:
sv_insn_t(processor_t *pr, insn_bits_t bits, unsigned int f,
uint64_t &p_rd, uint64_t &p_rs1, uint64_t &p_rs2, uint64_t &p_rs3,
- int *o_rd, int *o_rs1, int *o_rs2, int *o_rs3) :
+ uint64_t *p_im,
+ int *o_rd, int *o_rs1, int *o_rs2, int *o_rs3, int *o_imm) :
insn_t(bits), p(pr), vloop_continue(false), fimap(f),
offs_rd(o_rd), offs_rs1(o_rs1), offs_rs2(o_rs2), offs_rs3(o_rs3),
prd(p_rd), prs1(p_rs1), prs2(p_rs2), prs3(p_rs3) {}