From patchwork Thu Sep 19 21:25:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 276074 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C81972C00C3 for ; Fri, 20 Sep 2013 08:03:22 +1000 (EST) Received: from localhost ([::1]:53180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMlp2-0000xL-Q4 for incoming@patchwork.ozlabs.org; Thu, 19 Sep 2013 17:31:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMljs-0002uG-FX for qemu-devel@nongnu.org; Thu, 19 Sep 2013 17:26:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMljZ-0005Su-83 for qemu-devel@nongnu.org; Thu, 19 Sep 2013 17:26:16 -0400 Received: from mail-yh0-x231.google.com ([2607:f8b0:4002:c01::231]:57370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMljZ-0005Sd-2k for qemu-devel@nongnu.org; Thu, 19 Sep 2013 17:25:57 -0400 Received: by mail-yh0-f49.google.com with SMTP id i57so4327394yha.8 for ; Thu, 19 Sep 2013 14:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=w3+8OG2z1OxHhW8k3GGg2YRBeAdkyTbMSJolyI1hg6o=; b=dHEib/Kjxxa4uZzVj4ExQdGo7VMJrGrnCaLZU2wPdz9PJA+095sNeX6SEgrXswm4LK zc25kmUetqPMudDzK/7+oo5GTdTNHZw90cXe6rRvkYrbdsN1T2r6EKx6+7iIOq055cFW Xu/loAY9wWlci/mxePufDtnk0npUG7tmxCJTRrojdxaaS1TqBqsl6lrAAJi+HVFhkQ2s MAtlScxuF2vgLeBJhdQB6kj4PeEFLitGNnTkQneCSpq4qFJ4ub5zLOptgSqGXFQ6FG42 jY/QsFVMF6RLKeFX893zCs564MBhLEkHFLa5H8bTam21hhNPjQI4pYvygg2b7kcp6djK zw6w== X-Received: by 10.236.100.144 with SMTP id z16mr2980242yhf.9.1379625956711; Thu, 19 Sep 2013 14:25:56 -0700 (PDT) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id e65sm13556947yhc.18.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 19 Sep 2013 14:25:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Sep 2013 14:25:00 -0700 Message-Id: <1379625908-27964-9-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1379625908-27964-1-git-send-email-rth@twiddle.net> References: <1379625908-27964-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4002:c01::231 Cc: blauwirbel@gmail.com, aurelien@aurel32.net Subject: [Qemu-devel] [RFC 08/16] tcg: Change temp_dead argument to TCGTemp X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Richard Henderson --- tcg/tcg.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 35e0c7c..ee11c94 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1649,19 +1649,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) { + int idx = ts - s->temps; + 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; - } + ts->val_type = (idx < s->nb_globals || ts->temp_local + ? TEMP_VAL_MEM : TEMP_VAL_DEAD); } } @@ -1697,13 +1694,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); + 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 } @@ -1753,7 +1752,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 } } @@ -1789,7 +1788,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); } } @@ -1836,9 +1835,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, } tcg_out_st(s, ots->type, 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) { @@ -1856,7 +1855,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 @@ -1962,7 +1961,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]]); } } @@ -2033,7 +2032,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); } } } @@ -2174,7 +2173,7 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def, /* 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]]); } } @@ -2219,7 +2218,7 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def, tcg_reg_sync(s, reg); } if (IS_DEAD_ARG(i)) { - temp_dead(s, args[i]); + temp_dead(s, ts); } } } @@ -2330,7 +2329,7 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf, args += args[0]; goto next; 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);