From patchwork Fri Oct 20 23:19:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116545 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2223535qgn; Fri, 20 Oct 2017 16:25:45 -0700 (PDT) X-Received: by 10.237.37.71 with SMTP id w7mr9883032qtc.299.1508541945113; Fri, 20 Oct 2017 16:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508541945; cv=none; d=google.com; s=arc-20160816; b=eHl2d1PoYVb5O713FPZf2C87XnHfFFTlm1RHDbV0R1WRumdTeAOkgEAhzihZlAHNe5 63iJqXTuQTWVZM9Wn4HLgy/S4mNa0FeAdNbRMbNG1ycPtyQH+nMuPXij/InIeW3jnip0 ty3Yyv+Sc896M2j13oxD5/fFM8VRykeBvMLRSqA2uvIiSFmkf8YXnNTgiWSBiwz2v1EK B8H8YUxizVz2BgpgOj3WC9XtNMRX7xbFsIvvHmA8vqOxAMui5VSDF2AKaHiZFOl0uV6B DS1KaXkfywYpBfmIYu5F28casUK7k+t52SsOA+15y0AORDS77spLeVT9gkjiTdh7OVLR S1VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=fIRTtJ8KEEDxZ+5LtR3lWFEsjs359DfjsAaCpaeriGc=; b=bmapaVF8PEUNKQSNk82oWVK3bByvpkMkV1TlPXuRffAFCYPX04sxOOw6ezRQdPEA/m oV7i51X82G02NTARBEfc49LVfAc1ztrTl4C8j/en/DjW/ZtcdFf7nSNYzulGZai5Hv7D ejWNH9/A4ecNYTSd4AuBbNJtw7yhnvb2xU0gUpoCwFmn7aJe4oRCD4I8RdwLrjih/DdE iQuODthozjqWEO7D8wy5NQfiCJUEXukkaRo+8H3HIKh6LRwVMvMrrKRcSaZPrBCc7rdn R8ef2Iq/89ARKtjzHb2cMloCqXgzDzfWp5qwKhk1IE2VyP95mIcsjXM1q7SJ/FlQxkPw ySUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c5HRvEJ2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f1si1262712qkh.400.2017.10.20.16.25.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 20 Oct 2017 16:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c5HRvEJ2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5gfe-0001W9-Qg for patch@linaro.org; Fri, 20 Oct 2017 19:25:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5gan-0005rN-3U for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:20:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5gaj-0007YB-3X for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:20:41 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:54400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5gai-0007Xv-U7 for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:20:37 -0400 Received: by mail-pf0-x243.google.com with SMTP id n89so13055357pfk.11 for ; Fri, 20 Oct 2017 16:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fIRTtJ8KEEDxZ+5LtR3lWFEsjs359DfjsAaCpaeriGc=; b=c5HRvEJ2+KTUrvb3b/IRxMgxjMk0DA/JetjM5JaSahCq3tcsEW4vOJiO+T9dh0yYpZ plp2T55kAiNQ31PFtVgAm7G4DldSIyuUW8dtb0ZLK1JNbBFnbMdOozooqh6Pubqw5zx4 tjGa3ujRjXfK5zyldT/QZMZMueWDR+0998A+w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fIRTtJ8KEEDxZ+5LtR3lWFEsjs359DfjsAaCpaeriGc=; b=ZtgG9TuYdb58+yxioNuxTnAVO+JY1QJnTgVX0zyMK6HnOgf7vEAvoQuSptet3cSJ8A eTZt5CT7qixNFk82Vfpg3CuVkGHAo368LONeEY5bFlBHFdrqkIZ0EEh87ScG/CEkQ3zO Bmul4XRSnT8aCUwdftkJtdQqIbcGEl0a+1t86LAOI3GlWpBpm/UxMuTwZkEuTj95CIET yhGX6F8iUHiBwonBWQ0EomDc8spU7rtz4P7QYf1lFHOcOUSY/6R2/f3/VGbipqtmoGO4 p20LgCGYWWo1oCpTzVc5zZFEiqb0iZfetYZ8YB06jlt8yj8/3RAh6kQQ7v98LVz6KVyh sZZQ== X-Gm-Message-State: AMCzsaXBsCgat7uMyz8ONdtlrqb4eTkryoJ98KoIF33RZb1cc1WYJf1E 4WB/SP3fSKRV99KaTao0UEdgzFlxBWE= X-Google-Smtp-Source: ABhQp+RES0KUp3S+cPN3wbWAx7GuQ4/MZb8wl5ySTwHlzbtOtfTDExNAMKKRScQ1csuLk+d6XDqy9A== X-Received: by 10.101.78.8 with SMTP id r8mr5761630pgt.306.1508541635743; Fri, 20 Oct 2017 16:20:35 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-165-104.tukw.qwest.net. [97.113.165.104]) by smtp.gmail.com with ESMTPSA id a17sm3532594pfk.173.2017.10.20.16.20.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 16:20:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 20 Oct 2017 16:19:37 -0700 Message-Id: <20171020232023.15010-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171020232023.15010-1-richard.henderson@linaro.org> References: <20171020232023.15010-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v7 06/52] tcg: Add temp_global bit to TCGTemp X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, cota@braap.org, f4bug@amsat.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This avoids needing to test the index of a temp against nb_globals. Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tcg/tcg.h | 12 ++++++++---- tcg/optimize.c | 15 ++++++++------- tcg/tcg.c | 11 ++++++++--- 3 files changed, 24 insertions(+), 14 deletions(-) -- 2.13.6 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/tcg.h b/tcg/tcg.h index f06187fd8e..fc4d1ed58b 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -579,10 +579,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; diff --git a/tcg/optimize.c b/tcg/optimize.c index d8c3a7ed56..55f9e83ce8 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -116,25 +116,26 @@ static TCGOpcode op_to_movi(TCGOpcode op) } } -static TCGArg find_better_copy(TCGContext *s, TCGArg temp) +static TCGArg find_better_copy(TCGContext *s, TCGArg arg) { + TCGTemp *ts = arg_temp(arg); TCGArg i; /* If this is already a global, we can't do better. */ - if (temp < s->nb_globals) { - return temp; + if (ts->temp_global) { + return arg; } /* Search for a global first. */ - for (i = temps[temp].next_copy ; i != temp ; i = temps[i].next_copy) { + for (i = temps[arg].next_copy ; i != arg; i = temps[i].next_copy) { if (i < s->nb_globals) { return i; } } /* If it is a temp, search for a temp local. */ - if (!arg_temp(temp)->temp_local) { - for (i = temps[temp].next_copy ; i != temp ; i = temps[i].next_copy) { + if (!ts->temp_local) { + for (i = temps[arg].next_copy ; i != arg; i = temps[i].next_copy) { if (s->temps[i].temp_local) { return i; } @@ -142,7 +143,7 @@ static TCGArg find_better_copy(TCGContext *s, TCGArg temp) } /* Failure to find a better representation, return the same temp. */ - return temp; + return arg; } static bool temps_are_copies(TCGArg arg1, TCGArg arg2) diff --git a/tcg/tcg.c b/tcg/tcg.c index 935f3da0a1..e2a5f3f4c2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -489,9 +489,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 int tcg_global_reg_new_internal(TCGContext *s, TCGType type, @@ -1190,7 +1195,7 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char *buf, int buf_size, { int idx = temp_idx(s, 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); @@ -2128,7 +2133,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(s, ts) < s->nb_globals + || ts->temp_global ? TEMP_VAL_MEM : TEMP_VAL_DEAD); }