From nobody Mon Nov 23 04:28:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1795012724; cv=none; d=zohomail.com; s=zohoarc; b=AS6bou+FhfXmfhDvU80PQdGx6wfUSMdwAFeAQ1Gpg4jvf8Wq8ETZG6OTSj+xs05wWstPOXHzvOrfWJlBjGcDmLs8dfep+lSFUOzkBxpfL9ST+QB2YxwkQX2a5XEN0xXaOb2uI2XrgMx+LGdzIZW7b7QqLVIC70f3Z0uV+59D5Ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795012724; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=xRKyD6YfUwdxfu1moGC7CiKwDJtwAXXPBQcvjyebL9Y=; b=V/RdmCEijP4IH7Ts5Jdj62kaAgxndjcKNJUT+WSHI7Nt/vmAXd3u1FroLc4RA5xS+GFt5jXYaFsBJJ8vInJkV1zfm2Mtkn4aXCZH5ASI/DoT+DHNbFQjKMwmjqbRaH3RVB8f9rOpYjyfMYK1kIMoJdvxeBLriltV3DmWACkBsBo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17950127241241011.918890922356; Wed, 18 Nov 2026 06:38:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTgnw-0007Ln-DW; Wed, 18 Nov 2026 09:38:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTgnu-0007LV-4u for qemu-devel@nongnu.org; Wed, 18 Nov 2026 09:38:30 -0500 Received: from rev.ng ([94.130.142.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTgns-00008C-Dj for qemu-devel@nongnu.org; Wed, 18 Nov 2026 09:38:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rev.ng; s=dkim; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc: To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive:List-Unsubscribe:List-Unsubscribe-Post: List-Help; bh=xRKyD6YfUwdxfu1moGC7CiKwDJtwAXXPBQcvjyebL9Y=; b=IpISDNOphRnA9Bq DTJnD8lpE0rd0oPbGBku+jdXv0/iP6rK0kPKbzS+jDyCNqK2xMFO3Fgk5pktuwusbSMg1/j9FKzd0 2H9Mv8wGGhP4IzELKNqkTdg1FENJwdiIVg6VG5pyGoATH3tEh7l0pk+cTgSFgk4hXICAg+Pq6Nol7 pE=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, brian.cain@oss.qualcomm.com, marco.liebel@oss.qualcomm.com, Anton Johansson Subject: [PATCH] target/hexagon: Explicitly pass GP to helpers Date: Wed, 18 Nov 2026 15:44:41 +0100 Message-ID: <20261118144441.27680-1-anjo@rev.ng> MIME-Version: 1.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=94.130.142.21; envelope-from=anjo@rev.ng; helo=rev.ng 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, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anton Johansson From: Anton Johansson via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1795012725687158500 Content-Type: text/plain; charset="utf-8" helpers using fREAD_GP() are broken and do not account for the presence of extenders which change the addressing mode from GP-relative to absolute. Explicitly pass GP to helpers and check for expanders at the call-site. Signed-off-by: Anton Johansson Reviewed-by: Brian Cain --- target/hexagon/macros.h | 8 +------- target/hexagon/attribs_def.h.inc | 1 + target/hexagon/hex_common.py | 11 +++++++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h index 2748e26d6c..9187b02e6c 100644 --- a/target/hexagon/macros.h +++ b/target/hexagon/macros.h @@ -347,13 +347,7 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val= , int shift) #define fREAD_SA0 (env->gpr[HEX_REG_SA0]) #define fREAD_SA1 (env->gpr[HEX_REG_SA1]) #define fREAD_FP() (env->gpr[HEX_REG_FP]) -#ifdef FIXME -/* Figure out how to get insn->extension_valid to helper */ -#define fREAD_GP() \ - (insn->extension_valid ? 0 : env->gpr[HEX_REG_GP]) -#else -#define fREAD_GP() (env->gpr[HEX_REG_GP]) -#endif +#define fREAD_GP() (GP) #define fREAD_PC() (PC) =20 #define fREAD_P0() (P0) diff --git a/target/hexagon/attribs_def.h.inc b/target/hexagon/attribs_def.= h.inc index 71c6f04912..bef7ff45d9 100644 --- a/target/hexagon/attribs_def.h.inc +++ b/target/hexagon/attribs_def.h.inc @@ -133,6 +133,7 @@ DEF_ATTRIB(IMPLICIT_WRITES_LR, "Writes the link registe= r", "", "UREG.LR") DEF_ATTRIB(IMPLICIT_READS_PC, "Reads the program counter", "UREG.PC", "") DEF_ATTRIB(IMPLICIT_WRITES_SP, "Writes the stack pointer", "", "UREG.SP") DEF_ATTRIB(IMPLICIT_READS_SP, "Reads the stack pointer", "UREG.SP", "") +DEF_ATTRIB(IMPLICIT_READS_GP, "Reads the global pointer", "UREG.GP", "") DEF_ATTRIB(IMPLICIT_WRITES_FP, "Writes the frame pointer", "", "UREG.FP") DEF_ATTRIB(IMPLICIT_WRITES_LC0, "Writes loop count for loop 0", "", "UREG.= LC0") DEF_ATTRIB(IMPLICIT_WRITES_LC1, "Writes loop count for loop 1", "", "UREG.= LC1") diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py index f85f063f52..24dcdb5ce1 100755 --- a/target/hexagon/hex_common.py +++ b/target/hexagon/hex_common.py @@ -142,6 +142,7 @@ def calculate_attribs(): add_qemu_macro_attrib('fLSBNEW1NOT', 'A_IMPLICIT_READS_P1') add_qemu_macro_attrib('fREAD_P3', 'A_IMPLICIT_READS_P3') add_qemu_macro_attrib('fREAD_SP', 'A_IMPLICIT_READS_SP') + add_qemu_macro_attrib('fREAD_GP', 'A_IMPLICIT_READS_GP') =20 # Recurse down macros, find attributes from sub-macros macroValues =3D list(macros.values()) @@ -246,6 +247,10 @@ def need_sp(tag): return "A_IMPLICIT_READS_SP" in attribdict[tag] =20 =20 +def need_gp(tag): + return "A_IMPLICIT_READS_GP" in attribdict[tag] + + def is_hvx_insn(tag): return "A_CVI" in attribdict[tag] =20 @@ -2210,6 +2215,12 @@ def helper_args(tag, regs, imms): "hex_gpr[HEX_REG_SP]", "uint32_t SP" )) + if need_gp(tag): + args.append(HelperArg( + "i32", + "insn->extension_valid ? tcg_constant_tl(0) : hex_gpr[HEX_REG_= GP]", + "uint32_t GP" + )) if need_slot(tag): args.append(HelperArg( "i32", --=20 2.52.0