From nobody Tue Feb 10 21:00:26 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=1661211522; cv=none; d=zohomail.com; s=zohoarc; b=Ug7103M1AgCFkjbOFcJ1uZpZ9JhKgXSajRPkXEm6p+27N6kCVagsEnCynjny7U6VZOm7wtHgoEAtSJBJuyocSRcoaRVkLYpyPgrCMogdRuMYUJhom+aas/Jx4RDCP36HkEy+5LQhsupIK+09Igpba6isD+7B7L7arKxoPwSIxCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661211522; h=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=RKoJ35vLYvCsMuP+JFswrPYXmhyjLc71nVTkFzG8E7k=; b=E43AXHCwd4agADJqY2X35lTJfHDOZm3l6542OzsRUOCNTB+Xz5YP6tHXa54IvkNKIdQoCyqq0gRAJT1xHU6Gbq9efX/4y9I2JUpVcAlHok/0evANEHrhpbszD1qZtG638QyxHLy1qEoSiMpvOBZqkq13jfH2UU6btDMLm1d91fQ= 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 1661211522934599.8267823887169; Mon, 22 Aug 2022 16:38:42 -0700 (PDT) Received: from localhost ([::1]:52338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQH0D-0003Dr-UY for importer@patchew.org; Mon, 22 Aug 2022 19:38:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQGlz-0005jT-7H for qemu-devel@nongnu.org; Mon, 22 Aug 2022 19:24:00 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:43673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQGlw-0005bY-TA for qemu-devel@nongnu.org; Mon, 22 Aug 2022 19:23:58 -0400 Received: by mail-pf1-x42f.google.com with SMTP id w138so9197402pfc.10 for ; Mon, 22 Aug 2022 16:23:56 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:c3f1:b74f:5edd:63af]) by smtp.gmail.com with ESMTPSA id k17-20020aa79731000000b0052d3899f8c2sm3809112pfg.4.2022.08.22.16.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 16:23:55 -0700 (PDT) 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; bh=RKoJ35vLYvCsMuP+JFswrPYXmhyjLc71nVTkFzG8E7k=; b=WLBGS1gAh6iSpNuimV6mUPfJcfa6fd14Rb5wi3pghWXNje53sSNiGEmTMgDpLElnLq 1D2PTil7WFabFFt9rGgd8mPIeMmjfV3pD14PDkaJ9deYVd3zXqgWF6avqF5T1z9L6HsZ 7Sit5f3uxi27Rt4vovhq4rvcnvn052LbYrJM9o4vSWovqPT1O5euAisry+g7nwKtsbXM z2FHfSC8NB14GEwBN/BaAntnCYYdLf5GQvGCnResfoK3AVwbD8egRD2qQRiSCONPW3IY crxY2fYoQwN5Sm/IgJE8/0gPZNyNSdEBTmf3uHOwCpw3PkCcrjEtYGb/x04mGLhiPO+z HAIQ== 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; bh=RKoJ35vLYvCsMuP+JFswrPYXmhyjLc71nVTkFzG8E7k=; b=MQ5cEtNSYIgyJFe0YuRicAfCznDs9b5TSOguq5ztPtTCzpVhq9zdnw4mXUK3RW+r9r DLxZ9pH94LdQYQ0SiUzfEikLrmyo57Db3EmvWNZpk7fue2Y7fuh4074+jAtcihcGmoau lLSLDlYKYZCcl8cSHP+Yz2ifcVYA9PMAPmygNAXz5bCzvb7dJWxAeqk6XA9SKFegiwO7 tOKcSUgKIPnjoac6tt+X/CWwNpHOJXMBp6LuSYbmGWNKdnldbvNVCyNoGIsrpKpr9uaA 4qOGoJ5fk9jL4NUlnIdt8ajvXceeeum/W4VlppIJqYb2pfCFJeOzhgA2CSYFM0EFR+7A 1Wrg== X-Gm-Message-State: ACgBeo0KGh41WwgdttDFNxn+aTP4dQifyctsXeoKJBDOtsYZzcuAKBYH KO0ZZbST7WkOlQdtU7GR+1uiCZ7c8XjywA== X-Google-Smtp-Source: AA6agR7h05kdZNzhDgq1OUmXQpnIC6zaHUhk1pbLp0ZjhzVVkuE+6upkwutOWdd2PrN81+mf9PRsbg== X-Received: by 2002:a63:6a48:0:b0:42a:3cab:cc36 with SMTP id f69-20020a636a48000000b0042a3cabcc36mr15265356pgc.135.1661210636093; Mon, 22 Aug 2022 16:23:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v3 14/17] target/arm: Change gen_jmp* to work on displacements Date: Mon, 22 Aug 2022 16:23:35 -0700 Message-Id: <20220822232338.1727934-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822232338.1727934-1-richard.henderson@linaro.org> References: <20220822232338.1727934-1-richard.henderson@linaro.org> 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1661211523588100001 Content-Type: text/plain; charset="utf-8" In preparation for TARGET_TB_PCREL, reduce reliance on absolute values. Signed-off-by: Richard Henderson --- target/arm/translate.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 63a41ed438..4d13e365e2 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -270,6 +270,12 @@ static uint32_t read_pc(DisasContext *s) return s->pc_curr + (s->thumb ? 4 : 8); } =20 +/* The pc_curr difference for an architectural jump. */ +static int jmp_diff(DisasContext *s, int diff) +{ + return diff + (s->thumb ? 4 : 8); +} + /* Set a variable to the value of a CPU register. */ void load_reg_var(DisasContext *s, TCGv_i32 var, int reg) { @@ -2614,10 +2620,8 @@ static void gen_goto_tb(DisasContext *s, int n, int = diff) } =20 /* Jump, specifying which TB number to use if we gen_goto_tb() */ -static inline void gen_jmp_tb(DisasContext *s, uint32_t dest, int tbno) +static void gen_jmp_tb(DisasContext *s, int diff, int tbno) { - int diff =3D dest - s->pc_curr; - if (unlikely(s->ss_active)) { /* An indirect jump so that we still trigger the debug exception. = */ gen_update_pc(s, diff); @@ -2659,9 +2663,9 @@ static inline void gen_jmp_tb(DisasContext *s, uint32= _t dest, int tbno) } } =20 -static inline void gen_jmp(DisasContext *s, uint32_t dest) +static inline void gen_jmp(DisasContext *s, int diff) { - gen_jmp_tb(s, dest, 0); + gen_jmp_tb(s, diff, 0); } =20 static inline void gen_mulxy(TCGv_i32 t0, TCGv_i32 t1, int x, int y) @@ -8331,7 +8335,7 @@ static bool trans_CLRM(DisasContext *s, arg_CLRM *a) =20 static bool trans_B(DisasContext *s, arg_i *a) { - gen_jmp(s, read_pc(s) + a->imm); + gen_jmp(s, jmp_diff(s, a->imm)); return true; } =20 @@ -8346,14 +8350,14 @@ static bool trans_B_cond_thumb(DisasContext *s, arg= _ci *a) return true; } arm_skip_unless(s, a->cond); - gen_jmp(s, read_pc(s) + a->imm); + gen_jmp(s, jmp_diff(s, a->imm)); return true; } =20 static bool trans_BL(DisasContext *s, arg_i *a) { tcg_gen_movi_i32(cpu_R[14], s->base.pc_next | s->thumb); - gen_jmp(s, read_pc(s) + a->imm); + gen_jmp(s, jmp_diff(s, a->imm)); return true; } =20 @@ -8373,7 +8377,8 @@ static bool trans_BLX_i(DisasContext *s, arg_BLX_i *a) } tcg_gen_movi_i32(cpu_R[14], s->base.pc_next | s->thumb); store_cpu_field_constant(!s->thumb, thumb); - gen_jmp(s, (read_pc(s) & ~3) + a->imm); + /* This difference computes a page offset so ok for TARGET_TB_PCREL. */ + gen_jmp(s, (read_pc(s) & ~3) - s->pc_curr + a->imm); return true; } =20 @@ -8534,10 +8539,10 @@ static bool trans_WLS(DisasContext *s, arg_WLS *a) * when we take this upcoming exit from this TB, so gen_jmp_tb() i= s OK. */ } - gen_jmp_tb(s, s->base.pc_next, 1); + gen_jmp_tb(s, curr_insn_len(s), 1); =20 gen_set_label(nextlabel); - gen_jmp(s, read_pc(s) + a->imm); + gen_jmp(s, jmp_diff(s, a->imm)); return true; } =20 @@ -8617,7 +8622,7 @@ static bool trans_LE(DisasContext *s, arg_LE *a) =20 if (a->f) { /* Loop-forever: just jump back to the loop start */ - gen_jmp(s, read_pc(s) - a->imm); + gen_jmp(s, jmp_diff(s, -a->imm)); return true; } =20 @@ -8648,7 +8653,7 @@ static bool trans_LE(DisasContext *s, arg_LE *a) tcg_temp_free_i32(decr); } /* Jump back to the loop start */ - gen_jmp(s, read_pc(s) - a->imm); + gen_jmp(s, jmp_diff(s, -a->imm)); =20 gen_set_label(loopend); if (a->tp) { @@ -8656,7 +8661,7 @@ static bool trans_LE(DisasContext *s, arg_LE *a) store_cpu_field(tcg_constant_i32(4), v7m.ltpsize); } /* End TB, continuing to following insn */ - gen_jmp_tb(s, s->base.pc_next, 1); + gen_jmp_tb(s, curr_insn_len(s), 1); return true; } =20 @@ -8755,7 +8760,7 @@ static bool trans_CBZ(DisasContext *s, arg_CBZ *a) tcg_gen_brcondi_i32(a->nz ? TCG_COND_EQ : TCG_COND_NE, tmp, 0, s->condlabel); tcg_temp_free_i32(tmp); - gen_jmp(s, read_pc(s) + a->imm); + gen_jmp(s, jmp_diff(s, a->imm)); return true; } =20 --=20 2.34.1