From patchwork Sat Feb 6 00:09:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 8240691 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ADFF8BEEE5 for ; Sat, 6 Feb 2016 00:13:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D5100203B4 for ; Sat, 6 Feb 2016 00:13:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 02694203B1 for ; Sat, 6 Feb 2016 00:13:12 +0000 (UTC) Received: from localhost ([::1]:50986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqUx-00043P-BH for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 Feb 2016 19:13:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqSI-000864-Sh for qemu-devel@nongnu.org; Fri, 05 Feb 2016 19:10:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRqSH-0006uK-KS for qemu-devel@nongnu.org; Fri, 05 Feb 2016 19:10:26 -0500 Received: from mail-qg0-x229.google.com ([2607:f8b0:400d:c04::229]:35656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqSH-0006u5-G9 for qemu-devel@nongnu.org; Fri, 05 Feb 2016 19:10:25 -0500 Received: by mail-qg0-x229.google.com with SMTP id y89so7203685qge.2 for ; Fri, 05 Feb 2016 16:10:25 -0800 (PST) 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=oICFIt2X7VZqC+y4/DgD0KVyL5FdSfQXe9H5DKZ5rsk=; b=KZfJriFwXBn+RyyPXf7zXOY7uljKViUK3czdvdlshs0546uWVkLisyZLKcsvUpyr9l A5a9hiz90bv8wdvtJsROG1EGGUKPWscsJzoSBsGpAgufzRNFZA7wHkCQ1FoForu4MBod urKYpGdd5dg8+duxqqOreYE5fblCSlXdQZVABJlZBGy0PcuxVGPqwHAa20sgwB/7N4L+ aHBH8NFF0tSNMDswYn7QGktMPbaz1dtJ7c1q3Qsxu1uhEJteoWqK1pHFBoZ/bLI+Q54g 5gCI1UFH46Q4UQ1SGSLFmGhja8i7aSzboRDnuTco5BNxFAWLoqAYqOCmZ9b6mGyNu6dB lDTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=oICFIt2X7VZqC+y4/DgD0KVyL5FdSfQXe9H5DKZ5rsk=; b=ZEA29qp354eboR944GIdF5JhLBHJtmU8KbhgOHzafyl1jxE08jR6rf2TIUhKxILRc6 1V7b+isKN0hRdOV1QkUufRwRQJE+SKIbWhVmkNZ4/zmKU9lfZgNRdV7FP9zgoYHgAl6J VgjSHhG+4nAOJJ7Vg4W9IqcNGKmiriLHi1wi+c2XxY2qUhCjLi7gHLXpi7FhGr313Sjm R3q9MKBetmSQYXNBn0ppwWu91ojum5jnYXo/PzlDEPxNzMuLhz4JBTYPACFj+OYmkdDF tRHLv4K9aO1Tuqdvzz+mS7DGfep/5clKZ1n7Cp5bopWfI5782XGCDvt2GswHwAZyk630 tLWw== X-Gm-Message-State: AG10YORDtW7q5oz9gCchyMMJw55oVXPJbl+ucVjEDeZwUbKmZwvFcAv437b0AeNd2jQfUw== X-Received: by 10.140.31.225 with SMTP id f88mr1106169qgf.52.1454717425225; Fri, 05 Feb 2016 16:10:25 -0800 (PST) Received: from bigtime.com ([1.129.57.172]) by smtp.gmail.com with ESMTPSA id w66sm9079564qhc.15.2016.02.05.16.10.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Feb 2016 16:10:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 6 Feb 2016 11:09:27 +1100 Message-Id: <1454717370-17516-10-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454717370-17516-1-git-send-email-rth@twiddle.net> References: <1454717370-17516-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::229 Cc: peter.maydell@linaro.org Subject: [Qemu-devel] [PULL 09/12] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- 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);