mirror of https://github.com/xemu-project/xemu.git
tcg: replace op_dead_iargs by op_dead_args
Allow all args to be dead by replacing the input specific op_dead_iargs variable by op_dead_args. Note this is a purely mechanical change. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
6eba5c82cf
commit
866cb6cb21
71
tcg/tcg.c
71
tcg/tcg.c
|
@ -1193,7 +1193,7 @@ static inline void tcg_la_bb_end(TCGContext *s, uint8_t *dead_temps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Liveness analysis : update the opc_dead_iargs array to tell if a
|
/* Liveness analysis : update the opc_dead_args array to tell if a
|
||||||
given input arguments is dead. Instructions updating dead
|
given input arguments is dead. Instructions updating dead
|
||||||
temporaries are removed. */
|
temporaries are removed. */
|
||||||
static void tcg_liveness_analysis(TCGContext *s)
|
static void tcg_liveness_analysis(TCGContext *s)
|
||||||
|
@ -1203,13 +1203,13 @@ static void tcg_liveness_analysis(TCGContext *s)
|
||||||
TCGArg *args;
|
TCGArg *args;
|
||||||
const TCGOpDef *def;
|
const TCGOpDef *def;
|
||||||
uint8_t *dead_temps;
|
uint8_t *dead_temps;
|
||||||
unsigned int dead_iargs;
|
unsigned int dead_args;
|
||||||
|
|
||||||
gen_opc_ptr++; /* skip end */
|
gen_opc_ptr++; /* skip end */
|
||||||
|
|
||||||
nb_ops = gen_opc_ptr - gen_opc_buf;
|
nb_ops = gen_opc_ptr - gen_opc_buf;
|
||||||
|
|
||||||
s->op_dead_iargs = tcg_malloc(nb_ops * sizeof(uint16_t));
|
s->op_dead_args = tcg_malloc(nb_ops * sizeof(uint16_t));
|
||||||
|
|
||||||
dead_temps = tcg_malloc(s->nb_temps);
|
dead_temps = tcg_malloc(s->nb_temps);
|
||||||
memset(dead_temps, 1, s->nb_temps);
|
memset(dead_temps, 1, s->nb_temps);
|
||||||
|
@ -1256,17 +1256,17 @@ static void tcg_liveness_analysis(TCGContext *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* input args are live */
|
/* input args are live */
|
||||||
dead_iargs = 0;
|
dead_args = 0;
|
||||||
for(i = 0; i < nb_iargs; i++) {
|
for(i = nb_oargs; i < nb_iargs + nb_oargs; i++) {
|
||||||
arg = args[i + nb_oargs];
|
arg = args[i];
|
||||||
if (arg != TCG_CALL_DUMMY_ARG) {
|
if (arg != TCG_CALL_DUMMY_ARG) {
|
||||||
if (dead_temps[arg]) {
|
if (dead_temps[arg]) {
|
||||||
dead_iargs |= (1 << i);
|
dead_args |= (1 << i);
|
||||||
}
|
}
|
||||||
dead_temps[arg] = 0;
|
dead_temps[arg] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s->op_dead_iargs[op_index] = dead_iargs;
|
s->op_dead_args[op_index] = dead_args;
|
||||||
}
|
}
|
||||||
args--;
|
args--;
|
||||||
}
|
}
|
||||||
|
@ -1327,15 +1327,15 @@ static void tcg_liveness_analysis(TCGContext *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* input args are live */
|
/* input args are live */
|
||||||
dead_iargs = 0;
|
dead_args = 0;
|
||||||
for(i = 0; i < nb_iargs; i++) {
|
for(i = nb_oargs; i < nb_oargs + nb_iargs; i++) {
|
||||||
arg = args[i + nb_oargs];
|
arg = args[i];
|
||||||
if (dead_temps[arg]) {
|
if (dead_temps[arg]) {
|
||||||
dead_iargs |= (1 << i);
|
dead_args |= (1 << i);
|
||||||
}
|
}
|
||||||
dead_temps[arg] = 0;
|
dead_temps[arg] = 0;
|
||||||
}
|
}
|
||||||
s->op_dead_iargs[op_index] = dead_iargs;
|
s->op_dead_args[op_index] = dead_args;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1352,8 +1352,8 @@ static void tcg_liveness_analysis(TCGContext *s)
|
||||||
int nb_ops;
|
int nb_ops;
|
||||||
nb_ops = gen_opc_ptr - gen_opc_buf;
|
nb_ops = gen_opc_ptr - gen_opc_buf;
|
||||||
|
|
||||||
s->op_dead_iargs = tcg_malloc(nb_ops * sizeof(uint16_t));
|
s->op_dead_args = tcg_malloc(nb_ops * sizeof(uint16_t));
|
||||||
memset(s->op_dead_iargs, 0, nb_ops * sizeof(uint16_t));
|
memset(s->op_dead_args, 0, nb_ops * sizeof(uint16_t));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1557,7 +1557,7 @@ static void tcg_reg_alloc_bb_end(TCGContext *s, TCGRegSet allocated_regs)
|
||||||
save_globals(s, allocated_regs);
|
save_globals(s, allocated_regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_DEAD_IARG(n) ((dead_iargs >> (n)) & 1)
|
#define IS_DEAD_ARG(n) ((dead_args >> (n)) & 1)
|
||||||
|
|
||||||
static void tcg_reg_alloc_movi(TCGContext *s, const TCGArg *args)
|
static void tcg_reg_alloc_movi(TCGContext *s, const TCGArg *args)
|
||||||
{
|
{
|
||||||
|
@ -1582,7 +1582,7 @@ static void tcg_reg_alloc_movi(TCGContext *s, const TCGArg *args)
|
||||||
|
|
||||||
static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
|
static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
|
||||||
const TCGArg *args,
|
const TCGArg *args,
|
||||||
unsigned int dead_iargs)
|
unsigned int dead_args)
|
||||||
{
|
{
|
||||||
TCGTemp *ts, *ots;
|
TCGTemp *ts, *ots;
|
||||||
int reg;
|
int reg;
|
||||||
|
@ -1592,9 +1592,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
|
||||||
ts = &s->temps[args[1]];
|
ts = &s->temps[args[1]];
|
||||||
arg_ct = &def->args_ct[0];
|
arg_ct = &def->args_ct[0];
|
||||||
|
|
||||||
/* XXX: always mark arg dead if IS_DEAD_IARG(0) */
|
/* XXX: always mark arg dead if IS_DEAD_ARG(1) */
|
||||||
if (ts->val_type == TEMP_VAL_REG) {
|
if (ts->val_type == TEMP_VAL_REG) {
|
||||||
if (IS_DEAD_IARG(0) && !ts->fixed_reg && !ots->fixed_reg) {
|
if (IS_DEAD_ARG(1) && !ts->fixed_reg && !ots->fixed_reg) {
|
||||||
/* the mov can be suppressed */
|
/* the mov can be suppressed */
|
||||||
if (ots->val_type == TEMP_VAL_REG)
|
if (ots->val_type == TEMP_VAL_REG)
|
||||||
s->reg_to_temp[ots->reg] = -1;
|
s->reg_to_temp[ots->reg] = -1;
|
||||||
|
@ -1642,7 +1642,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
|
||||||
static void tcg_reg_alloc_op(TCGContext *s,
|
static void tcg_reg_alloc_op(TCGContext *s,
|
||||||
const TCGOpDef *def, TCGOpcode opc,
|
const TCGOpDef *def, TCGOpcode opc,
|
||||||
const TCGArg *args,
|
const TCGArg *args,
|
||||||
unsigned int dead_iargs)
|
unsigned int dead_args)
|
||||||
{
|
{
|
||||||
TCGRegSet allocated_regs;
|
TCGRegSet allocated_regs;
|
||||||
int i, k, nb_iargs, nb_oargs, reg;
|
int i, k, nb_iargs, nb_oargs, reg;
|
||||||
|
@ -1701,8 +1701,9 @@ static void tcg_reg_alloc_op(TCGContext *s,
|
||||||
/* if the input is aliased to an output and if it is
|
/* if the input is aliased to an output and if it is
|
||||||
not dead after the instruction, we must allocate
|
not dead after the instruction, we must allocate
|
||||||
a new register and move it */
|
a new register and move it */
|
||||||
if (!IS_DEAD_IARG(i - nb_oargs))
|
if (!IS_DEAD_ARG(i)) {
|
||||||
goto allocate_in_reg;
|
goto allocate_in_reg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reg = ts->reg;
|
reg = ts->reg;
|
||||||
|
@ -1725,9 +1726,9 @@ static void tcg_reg_alloc_op(TCGContext *s,
|
||||||
tcg_reg_alloc_bb_end(s, allocated_regs);
|
tcg_reg_alloc_bb_end(s, allocated_regs);
|
||||||
} else {
|
} else {
|
||||||
/* mark dead temporaries and free the associated registers */
|
/* mark dead temporaries and free the associated registers */
|
||||||
for(i = 0; i < nb_iargs; i++) {
|
for(i = nb_oargs; i < nb_oargs + nb_iargs; i++) {
|
||||||
arg = args[nb_oargs + i];
|
arg = args[i];
|
||||||
if (IS_DEAD_IARG(i)) {
|
if (IS_DEAD_ARG(i)) {
|
||||||
ts = &s->temps[arg];
|
ts = &s->temps[arg];
|
||||||
if (!ts->fixed_reg) {
|
if (!ts->fixed_reg) {
|
||||||
if (ts->val_type == TEMP_VAL_REG)
|
if (ts->val_type == TEMP_VAL_REG)
|
||||||
|
@ -1808,7 +1809,7 @@ static void tcg_reg_alloc_op(TCGContext *s,
|
||||||
|
|
||||||
static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
|
static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
|
||||||
TCGOpcode opc, const TCGArg *args,
|
TCGOpcode opc, const TCGArg *args,
|
||||||
unsigned int dead_iargs)
|
unsigned int dead_args)
|
||||||
{
|
{
|
||||||
int nb_iargs, nb_oargs, flags, nb_regs, i, reg, nb_params;
|
int nb_iargs, nb_oargs, flags, nb_regs, i, reg, nb_params;
|
||||||
TCGArg arg, func_arg;
|
TCGArg arg, func_arg;
|
||||||
|
@ -1930,9 +1931,9 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
|
||||||
|
|
||||||
|
|
||||||
/* mark dead temporaries and free the associated registers */
|
/* mark dead temporaries and free the associated registers */
|
||||||
for(i = 0; i < nb_iargs; i++) {
|
for(i = nb_oargs; i < nb_iargs + nb_oargs; i++) {
|
||||||
arg = args[nb_oargs + i];
|
arg = args[i];
|
||||||
if (IS_DEAD_IARG(i)) {
|
if (IS_DEAD_ARG(i)) {
|
||||||
ts = &s->temps[arg];
|
ts = &s->temps[arg];
|
||||||
if (!ts->fixed_reg) {
|
if (!ts->fixed_reg) {
|
||||||
if (ts->val_type == TEMP_VAL_REG)
|
if (ts->val_type == TEMP_VAL_REG)
|
||||||
|
@ -2007,7 +2008,7 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,
|
||||||
TCGOpcode opc;
|
TCGOpcode opc;
|
||||||
int op_index;
|
int op_index;
|
||||||
const TCGOpDef *def;
|
const TCGOpDef *def;
|
||||||
unsigned int dead_iargs;
|
unsigned int dead_args;
|
||||||
const TCGArg *args;
|
const TCGArg *args;
|
||||||
|
|
||||||
#ifdef DEBUG_DISAS
|
#ifdef DEBUG_DISAS
|
||||||
|
@ -2058,8 +2059,8 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,
|
||||||
#if TCG_TARGET_REG_BITS == 64
|
#if TCG_TARGET_REG_BITS == 64
|
||||||
case INDEX_op_mov_i64:
|
case INDEX_op_mov_i64:
|
||||||
#endif
|
#endif
|
||||||
dead_iargs = s->op_dead_iargs[op_index];
|
dead_args = s->op_dead_args[op_index];
|
||||||
tcg_reg_alloc_mov(s, def, args, dead_iargs);
|
tcg_reg_alloc_mov(s, def, args, dead_args);
|
||||||
break;
|
break;
|
||||||
case INDEX_op_movi_i32:
|
case INDEX_op_movi_i32:
|
||||||
#if TCG_TARGET_REG_BITS == 64
|
#if TCG_TARGET_REG_BITS == 64
|
||||||
|
@ -2095,8 +2096,8 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,
|
||||||
tcg_out_label(s, args[0], (long)s->code_ptr);
|
tcg_out_label(s, args[0], (long)s->code_ptr);
|
||||||
break;
|
break;
|
||||||
case INDEX_op_call:
|
case INDEX_op_call:
|
||||||
dead_iargs = s->op_dead_iargs[op_index];
|
dead_args = s->op_dead_args[op_index];
|
||||||
args += tcg_reg_alloc_call(s, def, opc, args, dead_iargs);
|
args += tcg_reg_alloc_call(s, def, opc, args, dead_args);
|
||||||
goto next;
|
goto next;
|
||||||
case INDEX_op_end:
|
case INDEX_op_end:
|
||||||
goto the_end;
|
goto the_end;
|
||||||
|
@ -2104,8 +2105,8 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,
|
||||||
/* Note: in order to speed up the code, it would be much
|
/* Note: in order to speed up the code, it would be much
|
||||||
faster to have specialized register allocator functions for
|
faster to have specialized register allocator functions for
|
||||||
some common argument patterns */
|
some common argument patterns */
|
||||||
dead_iargs = s->op_dead_iargs[op_index];
|
dead_args = s->op_dead_args[op_index];
|
||||||
tcg_reg_alloc_op(s, def, opc, args, dead_iargs);
|
tcg_reg_alloc_op(s, def, opc, args, dead_args);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
args += def->nb_args;
|
args += def->nb_args;
|
||||||
|
|
|
@ -286,8 +286,8 @@ struct TCGContext {
|
||||||
uint16_t *tb_jmp_offset; /* != NULL if USE_DIRECT_JUMP */
|
uint16_t *tb_jmp_offset; /* != NULL if USE_DIRECT_JUMP */
|
||||||
|
|
||||||
/* liveness analysis */
|
/* liveness analysis */
|
||||||
uint16_t *op_dead_iargs; /* for each operation, each bit tells if the
|
uint16_t *op_dead_args; /* for each operation, each bit tells if the
|
||||||
corresponding input argument is dead */
|
corresponding argument is dead */
|
||||||
|
|
||||||
/* tells in which temporary a given register is. It does not take
|
/* tells in which temporary a given register is. It does not take
|
||||||
into account fixed registers */
|
into account fixed registers */
|
||||||
|
|
Loading…
Reference in New Issue