From nobody Tue Feb 10 18:54:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1669959696; cv=none; d=zohomail.com; s=zohoarc; b=JEUI6S489i2DzR9tT6hbio4R1CrGUAVRHb0a7jZE/ywk0PAYCUYwKNjTxaQKYvWQkOKOSMBm94cnENfYlREmGiF4JNadP+rmp7pAeSSmhmLlW7CvtQ4jHhzKQ4poxlqeWqKBZBcEbmJBXjrnYUZZFH2SqkAVbtPuQCZ8vhsEOEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669959696; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HrfsNyGJ4cFlPj1QXpR5FkACHHSum2rmLa4iU9J/XqE=; b=aCOET9gHFs4orfP9KxhWHMbNp+MgnuYah+DA8rqtS72miJPtyZCRQX8jv0O9GlO+j6PDqj6HufH/LWcD2iS65ZHdE9x3rrHqMBgXyb5U4w+6JmS5zUdk7Tt0qKYwdk+Gj23/m9L1gSFO/s7i31Wy2DeVynypRrL+4LrykglwA3A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669959696561225.8683519713088; Thu, 1 Dec 2022 21:41:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0ymn-0002jm-4n; Fri, 02 Dec 2022 00:40:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0yml-0002ij-3G for qemu-devel@nongnu.org; Fri, 02 Dec 2022 00:40:31 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0ymj-0003Pv-9w for qemu-devel@nongnu.org; Fri, 02 Dec 2022 00:40:30 -0500 Received: by mail-pj1-x102e.google.com with SMTP id o5-20020a17090a678500b00218cd5a21c9so4181753pjj.4 for ; Thu, 01 Dec 2022 21:40:28 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:e3cc:2e37:17d4:f1d5]) by smtp.gmail.com with ESMTPSA id d12-20020a170903230c00b00186f0f59c85sm4637075plh.235.2022.12.01.21.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 21:40:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HrfsNyGJ4cFlPj1QXpR5FkACHHSum2rmLa4iU9J/XqE=; b=L95YjzOzUsTvBe6U9ypgCou5ovF3hD1SRslQLfRn/aijLbh1w7g4OezhAlm/bXMJ2Q LdP7KEwzLnb9SnChrosGgUpMBFSO0oR/ebmcqNSNiVsvgNuUGD2JnK/gRY6nk3UBQf4c vKqNFZ0ShvavPBZpgjFK3JK5EUyISsCFWXJVdRZ6y5UZy0yGc7IkI4BCUM00TFgJdnXs 3rWpw25eMziAzZIrMA8Z1X9GFJY7DuCfBwgQxKm7zcbyWu6UCmBTJCZVwP5jvDuCiTOz 0w0h7uGCg7vIn1OAuXEQUfXJF7AMsmFTCLCrO4pdLYJWW/rcQtxUY0r1MHN6/8aJWIFF cT8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HrfsNyGJ4cFlPj1QXpR5FkACHHSum2rmLa4iU9J/XqE=; b=yFKDNocVqqT45Vq7m5yza6qMMteOZcg1gCvbYzLFMFN3M10Xb4CWshwRBV4NacVw13 zEN7lvFTXC4FoNJlO1ITpbjZm4e8vGfix+aanJImuBu/IeoofcW9vuoSc6Z2hGOF3VfC 6I9CkKors+q3EsBbJ5muA9SU+OHscCExAXvqe48e76Z/bzKLyrobu7e0B9ggY+74KJ6d zWOpPPMPGnAbG+TyuXOazw8gDZH/Fqr5f4Bm3m1xktu933EVC7DQDSBAKfHrPGbfTRKC +PQjyyWRzm6+6RPFp1TmNw9oPT9r8KdXMYbTxDM/9QevUR9KKN+3bA641b29WiRhB3dJ Ld+g== X-Gm-Message-State: ANoB5pmbU8wCMX8ISpel8Db3xKUKwKjJPsdWCpV6hampe8CFY/SdxkLS HdqR3nhLZNG4wjGjE/0l0zCkkjCUAMUzIh+U X-Google-Smtp-Source: AA0mqf5B27eqeYwdr3eJpoxPf4d6P4fBd1A+4CyT7T03nb7QnNB56qYioUj99oF1qd7s6Ycx/W83YA== X-Received: by 2002:a17:90b:3746:b0:219:7907:fc72 with SMTP id ne6-20020a17090b374600b002197907fc72mr7009370pjb.163.1669959627995; Thu, 01 Dec 2022 21:40:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 28/34] tcg: Use output_pref wrapper function Date: Thu, 1 Dec 2022 21:39:52 -0800 Message-Id: <20221202053958.223890-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221202053958.223890-1-richard.henderson@linaro.org> References: <20221202053958.223890-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1669959697432100001 We will shortly have the possibility of more that two outputs, though only for calls (for which preferences are moot). Avoid direct references to op->output_pref[] when possible. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 5 +++++ tcg/tcg.c | 34 ++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index d430ea10c8..a6310b898f 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -518,6 +518,11 @@ typedef struct TCGOp { /* Make sure operands fit in the bitfields above. */ QEMU_BUILD_BUG_ON(NB_OPS > (1 << 8)); =20 +static inline TCGRegSet output_pref(const TCGOp *op, unsigned i) +{ + return i < ARRAY_SIZE(op->output_pref) ? op->output_pref[i] : 0; +} + typedef struct TCGProfile { int64_t cpu_exec_time; int64_t tb_count1; diff --git a/tcg/tcg.c b/tcg/tcg.c index ccbe947222..d08323db49 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1966,7 +1966,7 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bool= have_prefs) =20 if (have_prefs) { for (i =3D 0; i < nb_oargs; ++i) { - TCGRegSet set =3D op->output_pref[i]; + TCGRegSet set =3D output_pref(op, i); =20 if (i =3D=3D 0) { ne_fprintf(f, " pref=3D"); @@ -2636,11 +2636,11 @@ static void liveness_pass_1(TCGContext *s) } ts->state =3D TS_DEAD; la_reset_pref(ts); - - /* Not used -- it will be tcg_target_call_oarg_regs[i]= . */ - op->output_pref[i] =3D 0; } =20 + /* Not used -- it will be tcg_target_call_oarg_reg(). */ + memset(op->output_pref, 0, sizeof(op->output_pref)); + if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | TCG_CALL_NO_READ_GLOBALS))) { la_global_kill(s, nb_globals); @@ -2802,7 +2802,9 @@ static void liveness_pass_1(TCGContext *s) ts =3D arg_temp(op->args[i]); =20 /* Remember the preference of the uses that followed. */ - op->output_pref[i] =3D *la_temp_pref(ts); + if (i < ARRAY_SIZE(op->output_pref)) { + op->output_pref[i] =3D *la_temp_pref(ts); + } =20 /* Output args are dead. */ if (ts->state & TS_DEAD) { @@ -2872,7 +2874,7 @@ static void liveness_pass_1(TCGContext *s) =20 set &=3D ct->regs; if (ct->ialias) { - set &=3D op->output_pref[ct->alias_index]; + set &=3D output_pref(op, ct->alias_index); } /* If the combination is not possible, restart. */ if (set =3D=3D 0) { @@ -3539,7 +3541,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *op) TCGReg oreg, ireg; =20 allocated_regs =3D s->reserved_regs; - preferred_regs =3D op->output_pref[0]; + preferred_regs =3D output_pref(op, 0); ots =3D arg_temp(op->args[0]); ts =3D arg_temp(op->args[1]); =20 @@ -3656,7 +3658,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TC= GOp *op) if (IS_DEAD_ARG(1)) { temp_dead(s, its); } - tcg_reg_alloc_do_movi(s, ots, val, arg_life, op->output_pref[0]); + tcg_reg_alloc_do_movi(s, ots, val, arg_life, output_pref(op, 0)); return; } =20 @@ -3673,7 +3675,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TC= GOp *op) tcg_regset_set_reg(allocated_regs, its->reg); } oreg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, - op->output_pref[0], ots->indirect_base); + output_pref(op, 0), ots->indirect_base); set_temp_val_reg(s, ots, oreg); } =20 @@ -3792,7 +3794,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) switch (arg_ct->pair) { case 0: /* not paired */ if (arg_ct->ialias) { - i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + i_preferred_regs =3D output_pref(op, arg_ct->alias_index); =20 /* * If the input is not dead after the instruction, @@ -3839,7 +3841,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) * and to identify a few cases where it's not required. */ if (arg_ct->ialias) { - i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + i_preferred_regs =3D output_pref(op, arg_ct->alias_index); if (IS_DEAD_ARG(i1) && IS_DEAD_ARG(i2) && ts->val_type =3D=3D TEMP_VAL_REG && @@ -3873,7 +3875,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) =20 case 3: /* ialias with second output, no first input */ tcg_debug_assert(arg_ct->ialias); - i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + i_preferred_regs =3D output_pref(op, arg_ct->alias_index); =20 if (IS_DEAD_ARG(i) && ts->val_type =3D=3D TEMP_VAL_REG && @@ -3993,10 +3995,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const T= CGOp *op) } else if (arg_ct->newreg) { reg =3D tcg_reg_alloc(s, arg_ct->regs, i_allocated_regs | o_allocated_reg= s, - op->output_pref[k], ts->indirect_b= ase); + output_pref(op, k), ts->indirect_b= ase); } else { reg =3D tcg_reg_alloc(s, arg_ct->regs, o_allocated_reg= s, - op->output_pref[k], ts->indirect_b= ase); + output_pref(op, k), ts->indirect_b= ase); } break; =20 @@ -4007,7 +4009,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) break; } reg =3D tcg_reg_alloc_pair(s, arg_ct->regs, o_allocated_re= gs, - op->output_pref[k], ts->indirect_= base); + output_pref(op, k), ts->indirect_= base); break; =20 case 2: /* second of pair */ @@ -4090,7 +4092,7 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const T= CGOp *op) } =20 oreg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, - op->output_pref[0], ots->indirect_base); + output_pref(op, 0), ots->indirect_base); set_temp_val_reg(s, ots, oreg); } =20 --=20 2.34.1