From nobody Mon Apr 7 18:45:09 2025 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=1678392900; cv=none; d=zohomail.com; s=zohoarc; b=Kq2Ym9q9vBVCoimrA5CIGKo4ctRlrhE6Rk4vqtHh1Ii79eL6W/DnPdzM7HKLK7nIycIkzFRmNCpsEJQDBLo5EgOL+lcSvkO/r+pOMeXEFcszNNA8Ls0x2W370LObQ0RsCJDHo3Gd+0fAde2f9ypWft1SgH0Lp/V22O/wH+Zk/Xc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678392900; 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=1sfAmm8DUWCsMwoqJJW8S4peQJjwhppHUIprJsaoZ0k=; b=aTtOkijY/0S1nDa9Fpe1PQyM9HiFy2adnago+opxZYbXzluWdM2vW2WQd5xQ3yu4E5sOjMzb95WApgb1USJo/VLw0JY5RKeX0UUriaXEgoX1zfqyLelt4ZyaUuXksath6MJVkO84nb8rCE6ClYatnetxDaXHzO1RA9aMVkcPVjQ= 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 1678392900910523.0367379321744; Thu, 9 Mar 2023 12:15:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paMad-0005tg-9k; Thu, 09 Mar 2023 15:10:15 -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 1paMaM-0005DY-GR for qemu-devel@nongnu.org; Thu, 09 Mar 2023 15:09:58 -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 1paMaK-0001YC-B9 for qemu-devel@nongnu.org; Thu, 09 Mar 2023 15:09:58 -0500 Received: by mail-pj1-x102e.google.com with SMTP id l1so3170967pjt.2 for ; Thu, 09 Mar 2023 12:09:55 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:bf7f:79a0:a976:bdaf]) by smtp.gmail.com with ESMTPSA id c2-20020a170902aa4200b001991e4e0bdcsm43797plr.233.2023.03.09.12.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 12:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678392595; 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=1sfAmm8DUWCsMwoqJJW8S4peQJjwhppHUIprJsaoZ0k=; b=RnAgYYTnhC00FyXrWS6ZgT6gIrsZhl7DFi2lnIPnsgvzkNTLu/eunSRwgLA3WaqO0n YfTVthHApQSw4rP7EvN2mfgaC4ylqY9QNIgr4/jtQ45hRJnkeeIpW2C3eCX4EeMj/23K yC2ka0THZ/KQtAdhzT5lKhviQN3fJpW24uU9xuqwnaffHuF1Euqy3t/lxPf1xe/mmU/1 clad7r1j8Kumwyc46gKN3pQewn0zoKIisIM30N4h1sjXvala+I3MqSugnubS2QI0QJAf l8SLW9n0a/6MvI/1yIxpz9Rww+SojhQwTZ2B5aCiXXaRBR/JbasSLj9uhirJ37r7ktf6 /rHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678392595; 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=1sfAmm8DUWCsMwoqJJW8S4peQJjwhppHUIprJsaoZ0k=; b=06oMBcrqQs0BuGb/CdViEX4GKNCthTYy7fhgK0oiUCTjjohXb6oQbrZxjPK7wH7piL +z4d4jO50KTZrliinMdZncygX6E7LPoKTlYYqFS+OePuYgeBVDmAhm8s1NHP4Gt57b6b VzKLx9R2wmzMeMpfUijrD6XxNxYiRWtttighYkadmEv/AY3Otcf10Y+sQX/ylG2jUpoB QxawIMQT/UwdqoSZ0wwYom3oDlOTeN1j9D6hg97za1YuvU1BJZbZpTcSKNf9f8qGufPk Zcjx+QDPS/u1FZ9yZOoX71O5uK69ihvLRfirSf0wIpi2enVtRi4N9SXwWfZVMUUyq8ZA EqTw== X-Gm-Message-State: AO0yUKVh2kOjWpqQZxE/ZTU9mavjwBGCoTPx15qeLf915yWUNoU05wSo dzrBqPqyl97wVaTgRTQxjUrtGYwBgzOmEbZj36I= X-Google-Smtp-Source: AK7set/WP/RjXvYh1YxsxAwPRyl6mm6IMBimsVzOEQCW6hW/7UrYkjZgkt0o6G37J1E2BCBraAXR/Q== X-Received: by 2002:a17:902:ea04:b0:19e:6e9d:4bd with SMTP id s4-20020a170902ea0400b0019e6e9d04bdmr28574192plg.43.1678392595506; Thu, 09 Mar 2023 12:09:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL v2 72/91] target/arm: Create gen_set_rmode, gen_restore_rmode Date: Thu, 9 Mar 2023 12:05:31 -0800 Message-Id: <20230309200550.3878088-73-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309200550.3878088-1-richard.henderson@linaro.org> References: <20230309200550.3878088-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: 1678392901224100001 Split out common subroutines for handing rounding mode changes during translation. Use tcg_constant_i32 and tcg_temp_new_i32 instead of tcg_const_i32. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/arm/tcg/translate.h | 17 ++++++++++++ target/arm/tcg/translate-a64.c | 47 ++++++++++++++-------------------- target/arm/tcg/translate-sve.c | 6 ++--- target/arm/tcg/translate-vfp.c | 26 ++++++++----------- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index 20f3ca7aca..f02d4685b4 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -616,6 +616,23 @@ static inline TCGv_ptr gen_lookup_cp_reg(uint32_t key) return ret; } =20 +/* + * Set and reset rounding mode around another operation. + */ +static inline TCGv_i32 gen_set_rmode(ARMFPRounding rmode, TCGv_ptr fpst) +{ + TCGv_i32 new =3D tcg_constant_i32(arm_rmode_to_sf(rmode)); + TCGv_i32 old =3D tcg_temp_new_i32(); + + gen_helper_set_rmode(old, new, fpst); + return old; +} + +static inline void gen_restore_rmode(TCGv_i32 old, TCGv_ptr fpst) +{ + gen_helper_set_rmode(old, old, fpst); +} + /* * Helpers for implementing sets of trans_* functions. * Defer the implementation of NAME to FUNC, with optional extra arguments. diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 210899ff79..989c958de6 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -6146,13 +6146,12 @@ static void handle_fp_1src_half(DisasContext *s, in= t opcode, int rd, int rn) case 0xb: /* FRINTZ */ case 0xc: /* FRINTA */ { - TCGv_i32 tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(opcode & 7)); + TCGv_i32 tcg_rmode; + fpst =3D fpstatus_ptr(FPST_FPCR_F16); - - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_rmode =3D gen_set_rmode(opcode & 7, fpst); gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst); - - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_restore_rmode(tcg_rmode, fpst); break; } case 0xe: /* FRINTX */ @@ -6231,10 +6230,9 @@ static void handle_fp_1src_single(DisasContext *s, i= nt opcode, int rd, int rn) =20 fpst =3D fpstatus_ptr(FPST_FPCR); if (rmode >=3D 0) { - TCGv_i32 tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(rmode)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + TCGv_i32 tcg_rmode =3D gen_set_rmode(rmode, fpst); gen_fpst(tcg_res, tcg_op, fpst); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_restore_rmode(tcg_rmode, fpst); } else { gen_fpst(tcg_res, tcg_op, fpst); } @@ -6304,10 +6302,9 @@ static void handle_fp_1src_double(DisasContext *s, i= nt opcode, int rd, int rn) =20 fpst =3D fpstatus_ptr(FPST_FPCR); if (rmode >=3D 0) { - TCGv_i32 tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(rmode)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + TCGv_i32 tcg_rmode =3D gen_set_rmode(rmode, fpst); gen_fpst(tcg_res, tcg_op, fpst); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_restore_rmode(tcg_rmode, fpst); } else { gen_fpst(tcg_res, tcg_op, fpst); } @@ -6944,9 +6941,7 @@ static void handle_fpfpcvt(DisasContext *s, int rd, i= nt rn, int opcode, rmode =3D FPROUNDING_TIEAWAY; } =20 - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(rmode)); - - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + tcg_rmode =3D gen_set_rmode(rmode, tcg_fpstatus); =20 switch (type) { case 1: /* float64 */ @@ -7023,7 +7018,7 @@ static void handle_fpfpcvt(DisasContext *s, int rd, i= nt rn, int opcode, g_assert_not_reached(); } =20 - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + gen_restore_rmode(tcg_rmode, tcg_fpstatus); } } =20 @@ -8771,9 +8766,8 @@ static void handle_simd_shift_fpint_conv(DisasContext= *s, bool is_scalar, =20 assert(!(is_scalar && is_q)); =20 - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO)); tcg_fpstatus =3D fpstatus_ptr(size =3D=3D MO_16 ? FPST_FPCR_F16 : FPST= _FPCR); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + tcg_rmode =3D gen_set_rmode(FPROUNDING_ZERO, tcg_fpstatus); fracbits =3D (16 << size) - immhb; tcg_shift =3D tcg_constant_i32(fracbits); =20 @@ -8831,7 +8825,7 @@ static void handle_simd_shift_fpint_conv(DisasContext= *s, bool is_scalar, } } =20 - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + gen_restore_rmode(tcg_rmode, tcg_fpstatus); } =20 /* AdvSIMD scalar shift by immediate @@ -10219,12 +10213,11 @@ static void disas_simd_scalar_two_reg_misc(DisasC= ontext *s, uint32_t insn) } =20 if (is_fcvt) { - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(rmode)); tcg_fpstatus =3D fpstatus_ptr(FPST_FPCR); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + tcg_rmode =3D gen_set_rmode(rmode, tcg_fpstatus); } else { - tcg_rmode =3D NULL; tcg_fpstatus =3D NULL; + tcg_rmode =3D NULL; } =20 if (size =3D=3D 3) { @@ -10276,7 +10269,7 @@ static void disas_simd_scalar_two_reg_misc(DisasCon= text *s, uint32_t insn) } =20 if (is_fcvt) { - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + gen_restore_rmode(tcg_rmode, tcg_fpstatus); } } =20 @@ -12406,8 +12399,7 @@ static void disas_simd_two_reg_misc(DisasContext *s= , uint32_t insn) tcg_fpstatus =3D NULL; } if (rmode >=3D 0) { - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(rmode)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + tcg_rmode =3D gen_set_rmode(rmode, tcg_fpstatus); } else { tcg_rmode =3D NULL; } @@ -12590,7 +12582,7 @@ static void disas_simd_two_reg_misc(DisasContext *s= , uint32_t insn) clear_vec_high(s, is_q, rd); =20 if (tcg_rmode) { - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + gen_restore_rmode(tcg_rmode, tcg_fpstatus); } } =20 @@ -12758,8 +12750,7 @@ static void disas_simd_two_reg_misc_fp16(DisasConte= xt *s, uint32_t insn) } =20 if (rmode >=3D 0) { - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(rmode)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + tcg_rmode =3D gen_set_rmode(rmode, tcg_fpstatus); } =20 if (is_scalar) { @@ -12859,7 +12850,7 @@ static void disas_simd_two_reg_misc_fp16(DisasConte= xt *s, uint32_t insn) } =20 if (tcg_rmode) { - gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + gen_restore_rmode(tcg_rmode, tcg_fpstatus); } } =20 diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c index 3c65dd1ff2..3ca60fb36b 100644 --- a/target/arm/tcg/translate-sve.c +++ b/target/arm/tcg/translate-sve.c @@ -4096,17 +4096,15 @@ static bool do_frint_mode(DisasContext *s, arg_rpr_= esz *a, } =20 vsz =3D vec_full_reg_size(s); - tmode =3D tcg_const_i32(arm_rmode_to_sf(mode)); status =3D fpstatus_ptr(a->esz =3D=3D MO_16 ? FPST_FPCR_F16 : FPST_FPC= R); - - gen_helper_set_rmode(tmode, tmode, status); + tmode =3D gen_set_rmode(mode, status); =20 tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, a->rd), vec_full_reg_offset(s, a->rn), pred_full_reg_offset(s, a->pg), status, vsz, vsz, 0, fn); =20 - gen_helper_set_rmode(tmode, tmode, status); + gen_restore_rmode(tmode, status); return true; } =20 diff --git a/target/arm/tcg/translate-vfp.c b/target/arm/tcg/translate-vfp.c index e7acfb3338..dd782aacf4 100644 --- a/target/arm/tcg/translate-vfp.c +++ b/target/arm/tcg/translate-vfp.c @@ -464,8 +464,7 @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) fpst =3D fpstatus_ptr(FPST_FPCR); } =20 - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(rounding)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_rmode =3D gen_set_rmode(rounding, fpst); =20 if (sz =3D=3D 3) { TCGv_i64 tcg_op; @@ -489,7 +488,7 @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) vfp_store_reg32(tcg_res, rd); } =20 - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_restore_rmode(tcg_rmode, fpst); return true; } =20 @@ -533,9 +532,7 @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) } =20 tcg_shift =3D tcg_constant_i32(0); - - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(rounding)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_rmode =3D gen_set_rmode(rounding, fpst); =20 if (sz =3D=3D 3) { TCGv_i64 tcg_double, tcg_res; @@ -572,7 +569,7 @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) vfp_store_reg32(tcg_res, rd); } =20 - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_restore_rmode(tcg_rmode, fpst); return true; } =20 @@ -2783,10 +2780,9 @@ static bool trans_VRINTZ_hp(DisasContext *s, arg_VRI= NTZ_sp *a) tmp =3D tcg_temp_new_i32(); vfp_load_reg32(tmp, a->vm); fpst =3D fpstatus_ptr(FPST_FPCR_F16); - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_rmode =3D gen_set_rmode(FPROUNDING_ZERO, fpst); gen_helper_rinth(tmp, tmp, fpst); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_restore_rmode(tcg_rmode, fpst); vfp_store_reg32(tmp, a->vd); return true; } @@ -2808,10 +2804,9 @@ static bool trans_VRINTZ_sp(DisasContext *s, arg_VRI= NTZ_sp *a) tmp =3D tcg_temp_new_i32(); vfp_load_reg32(tmp, a->vm); fpst =3D fpstatus_ptr(FPST_FPCR); - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_rmode =3D gen_set_rmode(FPROUNDING_ZERO, fpst); gen_helper_rints(tmp, tmp, fpst); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_restore_rmode(tcg_rmode, fpst); vfp_store_reg32(tmp, a->vd); return true; } @@ -2842,10 +2837,9 @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRI= NTZ_dp *a) tmp =3D tcg_temp_new_i64(); vfp_load_reg64(tmp, a->vm); fpst =3D fpstatus_ptr(FPST_FPCR); - tcg_rmode =3D tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_rmode =3D gen_set_rmode(FPROUNDING_ZERO, fpst); gen_helper_rintd(tmp, tmp, fpst); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_restore_rmode(tcg_rmode, fpst); vfp_store_reg64(tmp, a->vd); return true; } --=20 2.34.1