Received: from eggs.gnu.org ([2001:4830:134:3::10]:52640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c76Fb-0000j4-BW for qemu-devel@nongnu.org; Wed, 16 Nov 2016 14:52:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c76Fa-00075D-8m for qemu-devel@nongnu.org; Wed, 16 Nov 2016 14:52:07 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:36180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c76Fa-00074L-2G for qemu-devel@nongnu.org; Wed, 16 Nov 2016 14:52:06 -0500 Received: by mail-wm0-x241.google.com with SMTP id m203so14507075wma.3 for ; Wed, 16 Nov 2016 11:52:05 -0800 (PST) Sender: Richard Henderson From: Richard Henderson Date: Wed, 16 Nov 2016 20:51:40 +0100 Message-Id: <1479325910-9060-5-git-send-email-rth@twiddle.net> In-Reply-To: <1479325910-9060-1-git-send-email-rth@twiddle.net> References: <1479325910-9060-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [RFC 04/14] tcg: Add temp_global bit to TCGTemp List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aurelien@aurel32.net, peter.maydell@linaro.org This avoids needing to test the index of a temp against nb_globals. Signed-off-by: Richard Henderson --- tcg/tcg.c | 12 +++++++++--- tcg/tcg.h | 12 ++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 8ae41a6..b186b38 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -458,9 +458,14 @@ static inline TCGTemp *tcg_temp_alloc(TCGContext *s) static inline TCGTemp *tcg_global_alloc(TCGContext *s) { + TCGTemp *ts; + tcg_debug_assert(s->nb_globals == s->nb_temps); s->nb_globals++; - return tcg_temp_alloc(s); + ts = tcg_temp_alloc(s); + ts->temp_global = 1; + + return ts; } static TCGTemp *tcg_global_reg_new_internal(TCGContext *s, TCGType type, @@ -906,7 +911,7 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char *buf, int buf_size, { int idx = temp_idx(ts); - if (idx < s->nb_globals) { + if (ts->temp_global) { pstrcpy(buf, buf_size, ts->name); } else if (ts->temp_local) { snprintf(buf, buf_size, "loc%d", idx - s->nb_globals); @@ -1718,6 +1723,7 @@ static bool liveness_pass_2(TCGContext *s) so that we reload when needed. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { arg_idx = arg_index(args[i]); + /* Note this unsigned test catches TCG_CALL_ARG_DUMMY too. */ if (arg_idx < nb_globals) { arg_ts = arg_temp(args[i]); dir_ts = arg_ts->state_ptr; @@ -1900,7 +1906,7 @@ static void temp_free_or_dead(TCGContext *s, TCGTemp *ts, int free_or_dead) } ts->val_type = (free_or_dead < 0 || ts->temp_local - || temp_idx(ts) < s->nb_globals + || ts->temp_global ? TEMP_VAL_MEM : TEMP_VAL_DEAD); } diff --git a/tcg/tcg.h b/tcg/tcg.h index 723e06f..dbd6308 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -401,10 +401,14 @@ typedef struct TCGTemp { unsigned int indirect_base:1; unsigned int mem_coherent:1; unsigned int mem_allocated:1; - unsigned int temp_local:1; /* If true, the temp is saved across - basic blocks. Otherwise, it is not - preserved across basic blocks. */ - unsigned int temp_allocated:1; /* never used for code gen */ + /* If true, the temp is saved across both basic blocks and + translation blocks. */ + unsigned int temp_global:1; + /* If true, the temp is saved across basic blocks but dead + at the end of translation blocks. If false, the temp is + dead at the end of basic blocks. */ + unsigned int temp_local:1; + unsigned int temp_allocated:1; tcg_target_long val; struct TCGTemp *mem_base; -- 2.7.4