+static void rec_alloc_rs_rd(struct regcache *reg_cache,
+ jit_state_t *_jit,
+ const struct opcode *op,
+ u8 rs, u8 rd,
+ u8 in_flags, u8 out_flags,
+ u8 *rs_out, u8 *rd_out)
+{
+ bool unload, discard;
+ u32 unload_flags;
+
+ if (OPT_EARLY_UNLOAD) {
+ unload_flags = LIGHTREC_FLAGS_GET_RS(op->flags);
+ unload = unload_flags == LIGHTREC_REG_UNLOAD;
+ discard = unload_flags == LIGHTREC_REG_DISCARD;
+ }
+
+ if (OPT_EARLY_UNLOAD && rs && rd != rs && (unload || discard)) {
+ rs = lightrec_alloc_reg_in(reg_cache, _jit, rs, in_flags);
+ lightrec_remap_reg(reg_cache, _jit, rs, rd, discard);
+ lightrec_set_reg_out_flags(reg_cache, rs, out_flags);
+ rd = rs;
+ } else {
+ rs = lightrec_alloc_reg_in(reg_cache, _jit, rs, in_flags);
+ rd = lightrec_alloc_reg_out(reg_cache, _jit, rd, out_flags);
+ }
+
+ *rs_out = rs;
+ *rd_out = rd;
+}
+