From patchwork Thu Jan 14 02:16:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 362793 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp67143jap; Wed, 13 Jan 2021 18:22:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxm3YrcEX9cCe7Ri5dqxu1pCEwVjsnmhi4sujPwIx8C6po5QbNqOLe4S+LEzaQ7xDps/hSf X-Received: by 2002:a25:d452:: with SMTP id m79mr7315087ybf.417.1610590942911; Wed, 13 Jan 2021 18:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610590942; cv=none; d=google.com; s=arc-20160816; b=EDeGrzAT7yaL9On0tqOd1q4KQVX7b5oT5OPQkjmm6GYuP/4csFUTdDrWVa4vqrOgWA 4F59ZNXPcIu6J2i++bWks1ABNK4HkYsyoGA8rXT6J2wU3OaOYazz5S0HYlOlR7X3jchC 0dxCrUMUmeTXr9SdsPPYRgcAQtqZ+r4CsO1RjHb153Wg18wMO8BnFne6oYtxWbW+KYR6 XAWY8JPZ7jaRIZPgOQq7NwVZ0Nzj8xGP8gQkjUaFhomFLZT4llBdeDVYDB8yLvzo/XYI pNg9wgulFkAcvitWVpdCOoen839BtFA67e/BZoCV2ll1Gxk1V1n4FTY98A4JEd3P575j yhBA== 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=YpDNiHW+o2iNjUonn03i++LfISaZVtNqCD0CIRtryeM=; b=Hy6HWUHWuzEnI7i9Fsq8eVK49cQzlruNKV0mlcZuAYvnN9cAXwqeXsqr8BOWJVxIuI t7Ad+S9QImIYbVQ2KfMKH815TTRqGifirKl8sfOO+JrsWkWP4mOVmvQPF66nIgvcc/bs 9HC7i3EiTV7f3/ZCM7G7kJ6H4GIBKIrt/3dzHjQ/Y1i0YfTkt/J/4fHmamzzttKMyrJs kKa+450tHNGaVp/iyBEsxxBv1cRF3XAOF+pluICCVIQfNeHqHYPCbJNV5YMLy1/M1VSh uQya6hA4EUeF2xmShGByD3zSmB/12QsDY7oQ2SE6fn/VxNz5cjtAG5KFa9qnVn2Row0d zfzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hTCnrVLi; 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 z206si3709881ybz.48.2021.01.13.18.22.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jan 2021 18:22:22 -0800 (PST) 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=hTCnrVLi; 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]:49632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzsHG-0001bx-Bl for patch@linaro.org; Wed, 13 Jan 2021 21:22:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzsCC-0003Jk-IC for qemu-devel@nongnu.org; Wed, 13 Jan 2021 21:17:08 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:44603) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzsCA-0003OI-Nk for qemu-devel@nongnu.org; Wed, 13 Jan 2021 21:17:08 -0500 Received: by mail-pl1-x62c.google.com with SMTP id r4so2128983pls.11 for ; Wed, 13 Jan 2021 18:17:06 -0800 (PST) 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=YpDNiHW+o2iNjUonn03i++LfISaZVtNqCD0CIRtryeM=; b=hTCnrVLieh1AdfZur6mt7/4aqb2IYuq+A6eGXOMK8meNXUBTmDFJ+tgBH0QBRiTJBO c/FvApDpkI0fZhUq/7r7j2OuNpWlRdP/BoPUoOvqw0OeYfImO7XtnuOvGtNdV7opqNcw yvhg5z9v+GZs9CGo5KOnG9JnrevmeFCDDxbPG9/lfTMwOSEsWS5Kv8/GsTtLiQi6Q9/O sLG+XRTYsJIds8/eMt5w64mUdBNxMSKMbVlxMYd0FLXLUUd8ve1THWslmxSG3QRYyYrT dViuQxIfnqaayHgK+/frtZIOpmvGP0gXEUsgrGh2KPK5poxaYRNj+bavVu3CwckCWXKw Y5/A== 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=YpDNiHW+o2iNjUonn03i++LfISaZVtNqCD0CIRtryeM=; b=J7omKF5pUZer+EQQ9uDFEJijOp8O/e731N9v8lHlsIVrUxXaft+3SzfbfAGFqqffOi 0Y4ajhHoBAjcdhOf12FkeRtpzSk6e7Nw2w2MpClssVO5oibvPONS04TcXeTsTob+LV7f UjfpuSAyVnOFslrrqFm1tuvcbVHethoeuFO4D+ASnprKZs3u52RrXRdS7UlREmR2bKJM 9qVJSLxAC/Y01OF26UsaKjjVGo1OtfG7l8CVowyTcbeMdvjYiRQ342aWTSS/MOtojGdn NmlnHZfYTEG4Uo5R9I2ivzMmk63BrF28AeKUX/McK6Z0IOlsoFuyBKjFFvRSrhohFKzk bMIQ== X-Gm-Message-State: AOAM5324Dcj6mbwgRyL+jG8/KE6q1TSXkEvFTRhSUA0Vpbukt2vsQiIX 7Gt11cvon/JCvVRv6lJ226FvED0owmIfsQ== X-Received: by 2002:a17:90a:454e:: with SMTP id r14mr2501853pjm.194.1610590624956; Wed, 13 Jan 2021 18:17:04 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id i7sm3771687pfc.50.2021.01.13.18.17.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 18:17:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/24] tcg: Add temp_readonly Date: Wed, 13 Jan 2021 16:16:34 -1000 Message-Id: <20210114021654.647242-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210114021654.647242-1-richard.henderson@linaro.org> References: <20210114021654.647242-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?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: Alex Bennée 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.25.1 diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 571d4e0fa3..2bdaeaa69c 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -679,6 +679,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 const void *tcg_code_gen_epilogue; diff --git a/tcg/tcg.c b/tcg/tcg.c index 143794a585..e02bb71953 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3254,7 +3254,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) { @@ -3278,7 +3278,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) { @@ -3461,8 +3461,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 @@ -3542,7 +3541,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) { @@ -3582,7 +3581,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; @@ -3643,7 +3642,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); } @@ -3680,7 +3679,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); @@ -3912,7 +3911,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->oalias && !const_args[arg_ct->alias_index]) { reg = new_args[arg_ct->alias_index]; @@ -3953,7 +3952,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)); @@ -4085,7 +4084,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);