+static void lightrec_do_early_unload(struct lightrec_cstate *state,
+ const struct block *block, u16 offset)
+{
+ struct regcache *reg_cache = state->reg_cache;
+ const struct opcode *op = &block->opcode_list[offset];
+ jit_state_t *_jit = block->_jit;
+ unsigned int i;
+ u8 reg;
+ struct {
+ u8 reg, op;
+ } reg_ops[3] = {
+ { op->r.rd, LIGHTREC_FLAGS_GET_RD(op->flags), },
+ { op->i.rt, LIGHTREC_FLAGS_GET_RT(op->flags), },
+ { op->i.rs, LIGHTREC_FLAGS_GET_RS(op->flags), },
+ };
+
+ for (i = 0; i < ARRAY_SIZE(reg_ops); i++) {
+ reg = reg_ops[i].reg;
+
+ switch (reg_ops[i].op) {
+ case LIGHTREC_REG_UNLOAD:
+ lightrec_clean_reg_if_loaded(reg_cache, _jit, reg, true);
+ break;
+
+ case LIGHTREC_REG_DISCARD:
+ lightrec_discard_reg_if_loaded(reg_cache, reg);
+ break;
+
+ case LIGHTREC_REG_CLEAN:
+ lightrec_clean_reg_if_loaded(reg_cache, _jit, reg, false);
+ break;
+ default:
+ break;
+ };
+ }
+}
+