From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PULL 09/12] tcg: Change temp_dead argument to TCGTemp
Date: Sat, 6 Feb 2016 11:09:27 +1100 [thread overview]
Message-ID: <1454717370-17516-10-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1454717370-17516-1-git-send-email-rth@twiddle.net>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
tcg/tcg.c | 48 +++++++++++++++++++++++-------------------------
1 file changed, 23 insertions(+), 25 deletions(-)
diff --git a/tcg/tcg.c b/tcg/tcg.c
index baa8a14..bd3707b 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1708,20 +1708,16 @@ static TCGReg tcg_reg_alloc(TCGContext *s, TCGRegSet reg1, TCGRegSet reg2)
}
/* mark a temporary as dead. */
-static inline void temp_dead(TCGContext *s, int temp)
+static inline void temp_dead(TCGContext *s, TCGTemp *ts)
{
- TCGTemp *ts = &s->temps[temp];
-
- if (!ts->fixed_reg) {
- if (ts->val_type == TEMP_VAL_REG) {
- s->reg_to_temp[ts->reg] = NULL;
- }
- if (temp < s->nb_globals || ts->temp_local) {
- ts->val_type = TEMP_VAL_MEM;
- } else {
- ts->val_type = TEMP_VAL_DEAD;
- }
+ if (ts->fixed_reg) {
+ return;
}
+ if (ts->val_type == TEMP_VAL_REG) {
+ s->reg_to_temp[ts->reg] = NULL;
+ }
+ ts->val_type = (temp_idx(s, ts) < s->nb_globals || ts->temp_local
+ ? TEMP_VAL_MEM : TEMP_VAL_DEAD);
}
/* sync a temporary to memory. 'allocated_regs' is used in case a
@@ -1756,13 +1752,15 @@ static inline void temp_sync(TCGContext *s, int temp, TCGRegSet allocated_regs)
temporary registers needs to be allocated to store a constant. */
static inline void temp_save(TCGContext *s, int temp, TCGRegSet allocated_regs)
{
+ TCGTemp *ts = &s->temps[temp];
+
#ifdef USE_LIVENESS_ANALYSIS
/* The liveness analysis already ensures that globals are back
in memory. Keep an assert for safety. */
- assert(s->temps[temp].val_type == TEMP_VAL_MEM || s->temps[temp].fixed_reg);
+ tcg_debug_assert(ts->val_type == TEMP_VAL_MEM || ts->fixed_reg);
#else
temp_sync(s, temp, allocated_regs);
- temp_dead(s, temp);
+ temp_dead(s, ts);
#endif
}
@@ -1812,7 +1810,7 @@ static void tcg_reg_alloc_bb_end(TCGContext *s, TCGRegSet allocated_regs)
Keep an assert for safety. */
assert(ts->val_type == TEMP_VAL_DEAD);
#else
- temp_dead(s, i);
+ temp_dead(s, ts);
#endif
}
}
@@ -1848,7 +1846,7 @@ static void tcg_reg_alloc_movi(TCGContext *s, const TCGArg *args,
temp_sync(s, args[0], s->reserved_regs);
}
if (IS_DEAD_ARG(0)) {
- temp_dead(s, args[0]);
+ temp_dead(s, ots);
}
}
@@ -1898,9 +1896,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
}
tcg_out_st(s, otype, ts->reg, ots->mem_base->reg, ots->mem_offset);
if (IS_DEAD_ARG(1)) {
- temp_dead(s, args[1]);
+ temp_dead(s, ts);
}
- temp_dead(s, args[0]);
+ temp_dead(s, ots);
} else if (ts->val_type == TEMP_VAL_CONST) {
/* propagate constant */
if (ots->val_type == TEMP_VAL_REG) {
@@ -1909,7 +1907,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
ots->val_type = TEMP_VAL_CONST;
ots->val = ts->val;
if (IS_DEAD_ARG(1)) {
- temp_dead(s, args[1]);
+ temp_dead(s, ts);
}
} else {
/* The code in the first if block should have moved the
@@ -1921,7 +1919,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
s->reg_to_temp[ots->reg] = NULL;
}
ots->reg = ts->reg;
- temp_dead(s, args[1]);
+ temp_dead(s, ts);
} else {
if (ots->val_type != TEMP_VAL_REG) {
/* When allocating a new register, make sure to not spill the
@@ -2038,7 +2036,7 @@ static void tcg_reg_alloc_op(TCGContext *s,
/* mark dead temporaries and free the associated registers */
for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) {
if (IS_DEAD_ARG(i)) {
- temp_dead(s, args[i]);
+ temp_dead(s, &s->temps[args[i]]);
}
}
@@ -2109,7 +2107,7 @@ static void tcg_reg_alloc_op(TCGContext *s,
tcg_reg_sync(s, reg);
}
if (IS_DEAD_ARG(i)) {
- temp_dead(s, args[i]);
+ temp_dead(s, ts);
}
}
}
@@ -2211,7 +2209,7 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs,
/* mark dead temporaries and free the associated registers */
for(i = nb_oargs; i < nb_iargs + nb_oargs; i++) {
if (IS_DEAD_ARG(i)) {
- temp_dead(s, args[i]);
+ temp_dead(s, &s->temps[args[i]]);
}
}
@@ -2257,7 +2255,7 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs,
tcg_reg_sync(s, reg);
}
if (IS_DEAD_ARG(i)) {
- temp_dead(s, args[i]);
+ temp_dead(s, ts);
}
}
}
@@ -2387,7 +2385,7 @@ int tcg_gen_code(TCGContext *s, tcg_insn_unit *gen_code_buf)
}
break;
case INDEX_op_discard:
- temp_dead(s, args[0]);
+ temp_dead(s, &s->temps[args[0]]);
break;
case INDEX_op_set_label:
tcg_reg_alloc_bb_end(s, s->reserved_regs);
--
2.5.0
next prev parent reply other threads:[~2016-02-06 0:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-06 0:09 [Qemu-devel] [PULL 00/12] TCG patch queue Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 01/12] tcg: Respect highwater in tcg_out_tb_finalize Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 02/12] tcg: Remove lingering references to gen_opc_buf Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 03/12] tcg: Change tcg_global_mem_new_* to take a TCGv_ptr Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 04/12] tcg: Change ts->mem_reg to ts->mem_base Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 05/12] tcg: Tidy temporary allocation Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 06/12] tcg: More use of TCGReg where appropriate Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 07/12] tcg: Remove tcg_get_arg_str_i32/64 Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 08/12] tcg: Change reg_to_temp to TCGTemp pointer Richard Henderson
2016-02-06 0:09 ` Richard Henderson [this message]
2016-02-06 0:09 ` [Qemu-devel] [PULL 10/12] tcg: Change temp_sync argument to TCGTemp Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 11/12] tcg: Change temp_save " Richard Henderson
2016-02-06 0:09 ` [Qemu-devel] [PULL 12/12] tcg: Introduce temp_load Richard Henderson
2016-02-08 11:25 ` [Qemu-devel] [PULL 00/12] TCG patch queue Peter Maydell
2016-02-08 20:24 ` Richard Henderson
2016-02-08 23:25 ` Richard Henderson
2016-02-09 9:24 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454717370-17516-10-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).