accel/tcg/plugin: Don't search for the function pointer index

The function pointer is immediately after the output and input
operands; no need to search.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2022-11-10 22:58:57 +10:00
parent e2a9dd6b6b
commit 05d019abab
1 changed files with 11 additions and 18 deletions

View File

@ -381,32 +381,25 @@ static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op)
static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *empty_func, static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *empty_func,
void *func, int *cb_idx) void *func, int *cb_idx)
{ {
TCGOp *old_op;
int func_idx;
/* copy all ops until the call */ /* copy all ops until the call */
do { do {
op = copy_op_nocheck(begin_op, op); op = copy_op_nocheck(begin_op, op);
} while (op->opc != INDEX_op_call); } while (op->opc != INDEX_op_call);
/* fill in the op call */ /* fill in the op call */
op->param1 = (*begin_op)->param1; old_op = *begin_op;
op->param2 = (*begin_op)->param2; TCGOP_CALLI(op) = TCGOP_CALLI(old_op);
TCGOP_CALLO(op) = TCGOP_CALLO(old_op);
tcg_debug_assert(op->life == 0); tcg_debug_assert(op->life == 0);
if (*cb_idx == -1) {
int i;
/* func_idx = TCGOP_CALLO(op) + TCGOP_CALLI(op);
* Instead of working out the position of the callback in args[], just *cb_idx = func_idx;
* look for @empty_func, since it should be a unique pointer.
*/ op->args[func_idx] = (uintptr_t)func;
for (i = 0; i < MAX_OPC_PARAM_ARGS; i++) { op->args[func_idx + 1] = old_op->args[func_idx + 1];
if ((uintptr_t)(*begin_op)->args[i] == (uintptr_t)empty_func) {
*cb_idx = i;
break;
}
}
tcg_debug_assert(i < MAX_OPC_PARAM_ARGS);
}
op->args[*cb_idx] = (uintptr_t)func;
op->args[*cb_idx + 1] = (*begin_op)->args[*cb_idx + 1];
return op; return op;
} }