tcg/optimize: Move prev_mb into OptContext

This will expose the variable to subroutines that
will be broken out of tcg_optimize.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2021-08-24 07:38:39 -07:00
parent dc84988a5f
commit d0ed5151b1

View file

@ -46,6 +46,7 @@ typedef struct TempOptInfo {
typedef struct OptContext { typedef struct OptContext {
TCGContext *tcg; TCGContext *tcg;
TCGOp *prev_mb;
TCGTempSet temps_used; TCGTempSet temps_used;
} OptContext; } OptContext;
@ -609,7 +610,7 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2)
void tcg_optimize(TCGContext *s) void tcg_optimize(TCGContext *s)
{ {
int nb_temps, nb_globals, i; int nb_temps, nb_globals, i;
TCGOp *op, *op_next, *prev_mb = NULL; TCGOp *op, *op_next;
OptContext ctx = { .tcg = s }; OptContext ctx = { .tcg = s };
/* Array VALS has an element for each temp. /* Array VALS has an element for each temp.
@ -1566,7 +1567,7 @@ void tcg_optimize(TCGContext *s)
} }
/* Eliminate duplicate and redundant fence instructions. */ /* Eliminate duplicate and redundant fence instructions. */
if (prev_mb) { if (ctx.prev_mb) {
switch (opc) { switch (opc) {
case INDEX_op_mb: case INDEX_op_mb:
/* Merge two barriers of the same type into one, /* Merge two barriers of the same type into one,
@ -1580,7 +1581,7 @@ void tcg_optimize(TCGContext *s)
* barrier. This is stricter than specified but for * barrier. This is stricter than specified but for
* the purposes of TCG is better than not optimizing. * the purposes of TCG is better than not optimizing.
*/ */
prev_mb->args[0] |= op->args[0]; ctx.prev_mb->args[0] |= op->args[0];
tcg_op_remove(s, op); tcg_op_remove(s, op);
break; break;
@ -1597,11 +1598,11 @@ void tcg_optimize(TCGContext *s)
case INDEX_op_qemu_st_i64: case INDEX_op_qemu_st_i64:
case INDEX_op_call: case INDEX_op_call:
/* Opcodes that touch guest memory stop the optimization. */ /* Opcodes that touch guest memory stop the optimization. */
prev_mb = NULL; ctx.prev_mb = NULL;
break; break;
} }
} else if (opc == INDEX_op_mb) { } else if (opc == INDEX_op_mb) {
prev_mb = op; ctx.prev_mb = op;
} }
} }
} }