mirror of https://github.com/xemu-project/xemu.git
tcg: add a CONST flag to TCG helpers
A const function only reads its arguments and does not use TCG globals variables. Hence a call to such a function does not save TCG globals variabes back to their canonical location. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7008 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
34d5a9ff63
commit
b9c18f5658
12
tcg/tcg.c
12
tcg/tcg.c
|
@ -1122,9 +1122,11 @@ static void tcg_liveness_analysis(TCGContext *s)
|
||||||
dead_temps[arg] = 1;
|
dead_temps[arg] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* globals are live (they may be used by the call) */
|
if (!(call_flags & TCG_CALL_CONST)) {
|
||||||
memset(dead_temps, 0, s->nb_globals);
|
/* globals are live (they may be used by the call) */
|
||||||
|
memset(dead_temps, 0, s->nb_globals);
|
||||||
|
}
|
||||||
|
|
||||||
/* input args are live */
|
/* input args are live */
|
||||||
dead_iargs = 0;
|
dead_iargs = 0;
|
||||||
for(i = 0; i < nb_iargs; i++) {
|
for(i = 0; i < nb_iargs; i++) {
|
||||||
|
@ -1821,7 +1823,9 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
|
||||||
|
|
||||||
/* store globals and free associated registers (we assume the call
|
/* store globals and free associated registers (we assume the call
|
||||||
can modify any global. */
|
can modify any global. */
|
||||||
save_globals(s, allocated_regs);
|
if (!(flags & TCG_CALL_CONST)) {
|
||||||
|
save_globals(s, allocated_regs);
|
||||||
|
}
|
||||||
|
|
||||||
tcg_out_op(s, opc, &func_arg, &const_func_arg);
|
tcg_out_op(s, opc, &func_arg, &const_func_arg);
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,10 @@ typedef int TCGv_i64;
|
||||||
and cannot raise exceptions. Hence a call to a pure function can be
|
and cannot raise exceptions. Hence a call to a pure function can be
|
||||||
safely suppressed if the return value is not used. */
|
safely suppressed if the return value is not used. */
|
||||||
#define TCG_CALL_PURE 0x0010
|
#define TCG_CALL_PURE 0x0010
|
||||||
|
/* A const function only reads its arguments and does not use TCG
|
||||||
|
globals variables. Hence a call to such a function does not
|
||||||
|
save TCG globals variabes back to their canonical location. */
|
||||||
|
#define TCG_CALL_CONST 0x0020
|
||||||
|
|
||||||
/* used to align parameters */
|
/* used to align parameters */
|
||||||
#define TCG_CALL_DUMMY_TCGV MAKE_TCGV_I32(-1)
|
#define TCG_CALL_DUMMY_TCGV MAKE_TCGV_I32(-1)
|
||||||
|
|
Loading…
Reference in New Issue