From patchwork Fri May 8 15:17:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186361 Delivered-To: patch@linaro.org Received: by 2002:a92:8d81:0:0:0:0:0 with SMTP id w1csp81507ill; Fri, 8 May 2020 08:21:43 -0700 (PDT) X-Google-Smtp-Source: APiQypJqAghfr1wRSf9tiaQ4cdqUXRiikcpUPSawQOPSaC+ANfm+BIHFD6Y6ZxLmVSfq/VNgXBna X-Received: by 2002:a05:6214:12e4:: with SMTP id w4mr3178241qvv.190.1588951303895; Fri, 08 May 2020 08:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588951303; cv=none; d=google.com; s=arc-20160816; b=kqsNwDf0aJgYYkuzanxmt/bZw24enNtTGi1PqfkzT+ao4E5BRIiTGcn1nYRDQSJc39 ll9Sd1eOK71iWPWNZwDcayna0OOdEKoj/DfEGF2qgT4FvfP+3K8rEN5xPt/3aa36jCDM X150RY7ufM9AAMYoVcaS447LCfeZaZZxp62WN45Xq46RV6cdX/BT71Hf5+by1y+ImpEc KOHHiJ8/AkqLo4vmhoexkOvZjsXfyyqP1J20gVSnm+Smu94JAP1+ZV0kj9NmWEwqB4tD D5SpJMAlbKKiraiVq062oKSL4HgOMF6Bn6yLFOrXmEdgaxYaFff5/XreuueszZfY2Zkx krYA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=6U9k1uhyDn85vPSFrFIwM0ONxS2wD3t03ZIkgvfeY9w=; b=aev2yHp8gpkC5nrmPcRj0x4zY9MwJn6QYjIQ2TVSLOENXk3KtxXL+WkbYwiZxIXsfR L4tpWHlNx3T+2O1gM3NXC6oipjCOrWGkK+eZ7yOcacOYg7lZ7qdghpJeL7a0P2ws3lxj 5MbXfa4eL/nPvBrcBass3alxQ4PreY0r/Q4Gjgkku3Q+3Fi16H7OOfOWmg1Gh8hsc6lz HZElxFAaR8O1z50JWH79DzLIdzN2qpEO8qken831bnvU+KBkUe3NmWNRZ/RTciSqu823 NZXZeriif3r/0IUaIcmVhb4f567vq73UvdtO6IQ1YomUJroT19S0HE6UC6h/loDbNErh EuCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P5AtST/C"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:470:142::17]) by mx.google.com with ESMTPS id 14si1421311qtp.272.2020.05.08.08.21.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 08:21:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:470:142::17 as permitted sender) client-ip=2001:470:142::17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P5AtST/C"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX4op-0001I0-93 for patch@linaro.org; Fri, 08 May 2020 11:21:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX4l8-0005bf-Qd for qemu-devel@nongnu.org; Fri, 08 May 2020 11:17:54 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:36542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX4l7-0002pX-E5 for qemu-devel@nongnu.org; Fri, 08 May 2020 11:17:54 -0400 Received: by mail-pj1-x1042.google.com with SMTP id q24so4378818pjd.1 for ; Fri, 08 May 2020 08:17:53 -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 :mime-version:content-transfer-encoding; bh=6U9k1uhyDn85vPSFrFIwM0ONxS2wD3t03ZIkgvfeY9w=; b=P5AtST/CaUnao1jN/+vFah7CW94RcUhrNrJyLa1PMsUeZkO1uY2lIzjyRscf1I3wZF xLnH6CUKZAS23ilcTmjcqk0c2rD5uQl2BCiDkKRIynOQSesix+S40+cKy0vmdG43Esh1 YkMOyrhTcGQHNge/47Mk4CFjhS6MlQxMyIKzUEDQIgdlVUxEO6rflSAb0VwpK+XBFAUB MVy0Z2PhHrwuq/D16OpYiTDcVR1ss09Tj/CSVvW9vl2SfON0d0p44zpzMVRl3XXVa4DU fYTKuZo255/qMuTpGRixModKmwuFWbOVHUnzxBk35OECqSXJtzdlTB5vR/KD9t8iNrx3 EWdg== 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:mime-version:content-transfer-encoding; bh=6U9k1uhyDn85vPSFrFIwM0ONxS2wD3t03ZIkgvfeY9w=; b=cuU6T3Zyt9ccfiPE/9kLTVKkmfaxMTo3+yrNDHm/va2adKPLMI7kSr2r4oVpNFXUkP DdX1912pKambMfCPjlOLuft1yHEErUreU0lRJazfWOjM01pd3V/qXL+S2yOafeGSqerH w5d3JYZyX+YGM4MzMHeeUd7lqEohYgWdlKSkpibCP3UnH+sfn9W4pdXZXThiw18doInD HRA5gfzY0mSD867QzH1HWitgu8fS9pysuQ0jmsskZ6Xk5WYC5DcuhJ2BCGXekz1yreLP ZzuLqVowvGUJh73SDuTvfiL3bcCjgMxRrGOWR6yzye46TXZ47Egq36gr8I58DEWQB7iu IVNQ== X-Gm-Message-State: AGi0PuYvUu0JUpyAVedtYW2LdlI1pGF0TbR3NQ+kLO/KDY+XkhCh9yHk 4LKFYOzUnzkorLspzCt9BVe7xaUG6uk= X-Received: by 2002:a17:90a:24e6:: with SMTP id i93mr6657128pje.13.1588951071556; Fri, 08 May 2020 08:17:51 -0700 (PDT) Received: from localhost.localdomain (174-21-149-226.tukw.qwest.net. [174.21.149.226]) by smtp.gmail.com with ESMTPSA id b5sm2125933pfb.190.2020.05.08.08.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 08:17:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/19] tcg: Add temp_readonly Date: Fri, 8 May 2020 08:17:30 -0700 Message-Id: <20200508151747.6166-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200508151747.6166-1-richard.henderson@linaro.org> References: <20200508151747.6166-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1042.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In most, but not all, places that we check for TEMP_FIXED, we are really testing that we do not modify the temporary. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 5 +++++ tcg/tcg.c | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 06486635e6..0d09ea7822 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -681,6 +681,11 @@ struct TCGContext { target_ulong gen_insn_data[TCG_MAX_INSNS][TARGET_INSN_START_WORDS]; }; +static inline bool temp_readonly(TCGTemp *ts) +{ + return ts->kind == TEMP_FIXED; +} + extern TCGContext tcg_init_ctx; extern __thread TCGContext *tcg_ctx; extern TCGv_env cpu_env; diff --git a/tcg/tcg.c b/tcg/tcg.c index 2c022c9621..a529166026 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3173,7 +3173,7 @@ static void temp_load(TCGContext *, TCGTemp *, TCGRegSet, TCGRegSet, TCGRegSet); mark it free; otherwise mark it dead. */ static void temp_free_or_dead(TCGContext *s, TCGTemp *ts, int free_or_dead) { - if (ts->kind == TEMP_FIXED) { + if (temp_readonly(ts)) { return; } if (ts->val_type == TEMP_VAL_REG) { @@ -3197,7 +3197,7 @@ static inline void temp_dead(TCGContext *s, TCGTemp *ts) static void temp_sync(TCGContext *s, TCGTemp *ts, TCGRegSet allocated_regs, TCGRegSet preferred_regs, int free_or_dead) { - if (ts->kind == TEMP_FIXED) { + if (temp_readonly(ts)) { return; } if (!ts->mem_coherent) { @@ -3355,8 +3355,7 @@ static void temp_save(TCGContext *s, TCGTemp *ts, TCGRegSet allocated_regs) { /* The liveness analysis already ensures that globals are back in memory. Keep an tcg_debug_assert for safety. */ - tcg_debug_assert(ts->val_type == TEMP_VAL_MEM - || ts->kind == TEMP_FIXED); + tcg_debug_assert(ts->val_type == TEMP_VAL_MEM || temp_readonly(ts)); } /* save globals to their canonical location and assume they can be @@ -3414,7 +3413,7 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, TCGRegSet preferred_regs) { /* ENV should not be modified. */ - tcg_debug_assert(ots->kind != TEMP_FIXED); + tcg_debug_assert(!temp_readonly(ots)); /* The movi is not explicitly generated here. */ if (ots->val_type == TEMP_VAL_REG) { @@ -3454,7 +3453,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) ts = arg_temp(op->args[1]); /* ENV should not be modified. */ - tcg_debug_assert(ots->kind != TEMP_FIXED); + tcg_debug_assert(!temp_readonly(ots)); /* Note that otype != itype for no-op truncation. */ otype = ots->type; @@ -3515,7 +3514,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) * Store the source register into the destination slot * and leave the destination temp as TEMP_VAL_MEM. */ - assert(ots->kind != TEMP_FIXED); + assert(!temp_readonly(ots)); if (!ts->mem_allocated) { temp_allocate_frame(s, ots); } @@ -3552,7 +3551,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) its = arg_temp(op->args[1]); /* ENV should not be modified. */ - tcg_debug_assert(ots->kind != TEMP_FIXED); + tcg_debug_assert(!temp_readonly(ots)); itype = its->type; vece = TCGOP_VECE(op); @@ -3783,7 +3782,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) ts = arg_temp(arg); /* ENV should not be modified. */ - tcg_debug_assert(ts->kind != TEMP_FIXED); + tcg_debug_assert(!temp_readonly(ts)); if ((arg_ct->ct & TCG_CT_ALIAS) && !const_args[arg_ct->alias_index]) { @@ -3825,7 +3824,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) ts = arg_temp(op->args[i]); /* ENV should not be modified. */ - tcg_debug_assert(ts->kind != TEMP_FIXED); + tcg_debug_assert(!temp_readonly(ts)); if (NEED_SYNC_ARG(i)) { temp_sync(s, ts, o_allocated_regs, 0, IS_DEAD_ARG(i)); @@ -3957,7 +3956,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) ts = arg_temp(arg); /* ENV should not be modified. */ - tcg_debug_assert(ts->kind != TEMP_FIXED); + tcg_debug_assert(!temp_readonly(ts)); reg = tcg_target_call_oarg_regs[i]; tcg_debug_assert(s->reg_to_temp[reg] == NULL);