From patchwork Wed Apr 22 01:16:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 185636 Delivered-To: patch@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp169800ilf; Tue, 21 Apr 2020 18:31:12 -0700 (PDT) X-Google-Smtp-Source: APiQypIbbkGvvbej6U98LPnSlVBwCgsNHgo38NQLcg5h7eW40tW8gmAFEmKYHk8RK64VxAsFGimo X-Received: by 2002:a37:7906:: with SMTP id u6mr22846301qkc.489.1587519072241; Tue, 21 Apr 2020 18:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587519072; cv=none; d=google.com; s=arc-20160816; b=ajv/RVoXqN80h0LSm4M9nFhh3BIsLgxIdEasXzLYUmp64auCDN68TmcHhV/BZJsIDP V+eKQT6mJGAVCkNKEIewCEvk6HuzG0YVR+uANlobK74ybPvkC9zRiFFmwyiyWX9dViQo ZbMmMZp15XnDzsgygH6VL3+uCV6XFuaO9iB1x6O1CGy3SeIEOMn6JUAj3PD3YrIfZMHP RUuIn0YGsATPfP0tfsLkQArBw12YRQFd78/7618dhEtAbwmMv7Ur5PMNUnnY+BNiBmN4 zlFZodp2KXdiGTct30y3z9d5V8He6MGzBwRjsCzlEKmodoFFf1g2vGDxwbtQlnR1kJjb QS7w== 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=/FlEZqC+1flp7+XXS8i2pS5jBZSc3XV7jKgV0ZZ4cZs=; b=chL1oNw3u4EEZGM7YgEF6j3Ih+1LELW2pJt+U7rDbc3pXvZ+FQlehemZ4Y2mONcfxS vIGCGLRYyQY84JcOSslq8tiZP5izicI2Ri4gMwWoSqFfZWBMU4mTMCtaEgW0Dobls+wh JOfV6wAGG5+LhGCaCdx/5724BNfU3RaUAuXtNI0ADx8yE/aJxfA7wrZEdGSo8FBIEkqk S0+OMQ/fnGYvcBAojjx5+ClmtidnOuL6/7A/Qd1/X6mmYb7vd8gZxwJG5p6IqrAfD07b NnPtmhGlKEGOHuSrgKlgUX766Z8/7iyHc0e7Pwq8CLgT+VbrZC+HeXnnZba6jAWlEEiK zzew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NkW9SUgF; 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 u2si2308899qvy.210.2020.04.21.18.31.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Apr 2020 18:31:12 -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=NkW9SUgF; 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]:38900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jR4EJ-0006i1-NQ for patch@linaro.org; Tue, 21 Apr 2020 21:31:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34468) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jR41F-0001Nw-0u for qemu-devel@nongnu.org; Tue, 21 Apr 2020 21:17:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jR41D-0001bw-Q3 for qemu-devel@nongnu.org; Tue, 21 Apr 2020 21:17:40 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:35951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jR41D-0001Zg-BL for qemu-devel@nongnu.org; Tue, 21 Apr 2020 21:17:39 -0400 Received: by mail-pg1-x541.google.com with SMTP id o185so262056pgo.3 for ; Tue, 21 Apr 2020 18:17:38 -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=/FlEZqC+1flp7+XXS8i2pS5jBZSc3XV7jKgV0ZZ4cZs=; b=NkW9SUgFkVNkc8WAJS+HoA8OOVqnxrtr+8E/7I/ZMhwmFrYlGU0a+tganRSBIn5v7L D8Mbz/QNpM6x/ZO7GSEk1C12znlvUeHtyZjxMFVxz5dAxF0DnVWm5PUvllhzSaz2HLVU rX+MqauMLpumwW03VnpFCSUzW5nE4BitNZJAWG6rrgrjgqKbTuvMDUbFpKpeZaPw37Fv aJF880M64GdY48bBuEF2PHSUYOdlVQ+oP7DyOY3JIhq375PybEuqCYSQeBasRC/FM2pQ vUoab9yXKGGm7j7phfhFjMjeY84hqCSd9d+P8LtnxJS5aS5Khl4T3Z9ckd3m1Ewrsnqd aCaw== 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=/FlEZqC+1flp7+XXS8i2pS5jBZSc3XV7jKgV0ZZ4cZs=; b=Lj2zzoRtfRNrLF36hbie7n89bPVWejo2N1AgHQjAbSw+1GIGEUd1L2crq4D6vW+1T5 RJj+ncvus5BK0F8bv2Q4tVNxggmFao6BoDpjAF5bKISNXc66NFQC7ypifAxhxUy4Aj/m rnnZjW+DR3Az5z8Ud9nYn6oI89SGWOUGM1fPe1Q4GoSjtxK4yv6I+04U5wE1zuL8OipD 4K8gjpKjbit7+7HcchyAGoUHeinkfJNoSGqpu1gX4n8nRcqCEgQ+8GxoHLo1BDHd9EAC T+HD+k5UrS/aD4vf9arxsNnSfBfrJWSqcXdCOaGQlbREoSXfUheJFhvJaxNQpX4LWPf8 U0Bg== X-Gm-Message-State: AGi0PuZbvKCsZuHvdSENF1mYU27B/xJAx7vYCP0YtpaMuET4ireLCr5J S4MOtWA2B+KfcVbwZmNIOkSIJexvyTI= X-Received: by 2002:a63:1a16:: with SMTP id a22mr24742623pga.264.1587518257665; Tue, 21 Apr 2020 18:17:37 -0700 (PDT) Received: from localhost.localdomain (174-21-149-226.tukw.qwest.net. [174.21.149.226]) by smtp.gmail.com with ESMTPSA id m4sm3673561pfm.26.2020.04.21.18.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 18:17:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/36] tcg: Add temp_readonly Date: Tue, 21 Apr 2020 18:16:56 -0700 Message-Id: <20200422011722.13287-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200422011722.13287-1-richard.henderson@linaro.org> References: <20200422011722.13287-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::541 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 Reviewed-by: Alex Bennée 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);