From patchwork Sat Apr 18 16:18:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 185554 Delivered-To: patch@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp1900126ilf; Sat, 18 Apr 2020 09:19:46 -0700 (PDT) X-Google-Smtp-Source: APiQypJk2HQSKLVhYsBWB8844wkTK9cfpuZHxDHRt97nQ+h4k80nT8G/qcYBoF0Qf4jlLh+/vT3T X-Received: by 2002:ad4:4242:: with SMTP id l2mr7644145qvq.98.1587226786322; Sat, 18 Apr 2020 09:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587226786; cv=none; d=google.com; s=arc-20160816; b=OzC1BwAXqQCXxVmPAXlrfF6C/MUS5QepPjj/a2JYDX+YlPS2+EBRahIOwtHQd7NMeh KNtt3eGNwEq/MizE7JLq9CJwBLzzFuyX8oDzOTw4m7IczUrvEAHahfhAS+sqMSyGKfOR d+Cmbo58e3HUQT9nUY/68yGO/dQ9FsUx1trFGqM/4M+cbZydfEjGkY1ACmiFMNq8uIF1 txEyfAUOGUOGOrEdkW8sbf6hFI1AO0OIMySxsp0mVgS6OhyaIh7H1ABrc+CT1wLO/xgB uulQWiJ9Uht0Dw0RItF/9+oqHLX29g0xeo6lGSzkuqE9C3RAWICBZTQginL3UcSZLSkJ iJcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=hY9ypQA6lau+BCL7v0kFVd0b+GolnNEN+YdpYYAzLrU=; b=B52o2OZaJxQk8WEi90PbUhl/u1UuosqcTUpqXvIW4hFcC8fjzEdbUeZ+WQpUwl+cpT Jgj+DD9ia1kuced2brI3IOzGYXsyV/WsR+YuolmE9Dr1hYehIWhfvi65avm9if3/HoTR O7LlRKELx9XZr0sBncqVgyXYkgsQt0G4BprtBHNwTlJt2cOR5m608DBANhQLntna5VyR zw6fNgWjUswSN93DsgjYP+wXuyk7dxLLci+0mxxMhyJDqbAaJVgp85JUZomXglncwvRx mFCGrVbBJRfTM+KJECdLIgDv9vtaJw6vWD7HJOMmKShnJG6/jagJJXfYg/7Pae9rCu4a Eyig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Ns9/rZ3T"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.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. [209.51.188.17]) by mx.google.com with ESMTPS id a21si10300237qtc.162.2020.04.18.09.19.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Apr 2020 09:19:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Ns9/rZ3T"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.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]:59498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPqC1-00045P-H3 for patch@linaro.org; Sat, 18 Apr 2020 12:19:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48081) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPqBd-00044t-0B for qemu-devel@nongnu.org; Sat, 18 Apr 2020 12:19:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jPqBb-0004lt-NG for qemu-devel@nongnu.org; Sat, 18 Apr 2020 12:19:20 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:43003) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jPqBb-0004hR-Hi for qemu-devel@nongnu.org; Sat, 18 Apr 2020 12:19:19 -0400 Received: by mail-pl1-x642.google.com with SMTP id v2so2207976plp.9 for ; Sat, 18 Apr 2020 09:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=hY9ypQA6lau+BCL7v0kFVd0b+GolnNEN+YdpYYAzLrU=; b=Ns9/rZ3TDU/xSZmRtJpa8nhHuMwKisMjjwqCLgbyrUoBfc7w1fX7XsBfqTeDdlZ5JE N+cSduGL0b3enav7gRwr+cgoGJAnECW87tz3tvflm7CAh+b+Ubp4HJmnWNSpXjsIN1J2 NdruCgb+4bYOEbyUjd0pkBK/DvAMyr3/zA0IQH3B3oh9+a7J4KaY/S3hJaaOUgJr3DE9 q7kR1Nzl8JzRpPYnuK76YA6vXr/6VikeEKRkfNJI67AfmJZrMUeDwZOVLuCid+yNdvY8 z3ExR3gglCrJQM7zd82d8eUVh3IY5AjE7bKXi0QiiswsnVmGVvUuiSwKyBOSiX2DaAbi jqNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hY9ypQA6lau+BCL7v0kFVd0b+GolnNEN+YdpYYAzLrU=; b=qdwFg2FMvrfENasOoJKf41lvz6vJmeb1c5AuEPUSV8vU2IBXHhSFM4HXd3RN6O9YE7 LsxuK8c/0nNuDgD+th2RS0RPwuaUvGpat98CbvgusxvS/SVbL4JpwMun078hKODXV/G6 lbhNFExNl+l0fcWv8CwLnfuQIv0lUCAm5iRtI2Bwh4HvW5n04pOkfrkgC293h4P3ydAd xIDqcozwnCtP02ZFneSS/NKQurj4lDUa7ccugGJO+x9QEwLUVV8eLFC+WSuXZXtfjWYN Tx8f3gRtczpWaRfUOaZtO94j4ubILyW+ywSYFQRsCeSf6omIOgSqlQ8VutnPtNe6lEG/ 2sBg== X-Gm-Message-State: AGi0PuYLs2EUut8ngSGOQ5iYl/grnZ74Z6+1Dntlad+SKBXyZNgO2Mc5 Dt1uP7D2JBTiMaw7dXIMZ/EclCJET38= X-Received: by 2002:a17:90b:3598:: with SMTP id mm24mr11892407pjb.132.1587226758142; Sat, 18 Apr 2020 09:19:18 -0700 (PDT) Received: from localhost.localdomain (174-21-149-226.tukw.qwest.net. [174.21.149.226]) by smtp.gmail.com with ESMTPSA id i187sm22398382pfc.112.2020.04.18.09.19.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2020 09:19:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 01/16] tcg: Add temp_readonly Date: Sat, 18 Apr 2020 09:18:59 -0700 Message-Id: <20200418161914.4387-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200418161914.4387-1-richard.henderson@linaro.org> References: <20200418161914.4387-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 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: , 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. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 5 +++++ tcg/tcg.c | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 3534dce77f..27e1b509a6 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -678,6 +678,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 eaf81397a3..92b3767097 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3132,7 +3132,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) { @@ -3156,7 +3156,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) { @@ -3314,8 +3314,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 @@ -3373,7 +3372,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) { @@ -3413,7 +3412,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; @@ -3474,7 +3473,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); } @@ -3511,7 +3510,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); @@ -3742,7 +3741,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]) { @@ -3784,7 +3783,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)); @@ -3916,7 +3915,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);