From patchwork Thu Jun 13 12:13:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166616 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp695112ilk; Thu, 13 Jun 2019 05:27:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqt9ku8Y0tJCARjygbdqwxlRaMFWRt6LZ7ANEXgnIefC8US8QMt8rxxZNjKvF7AiuB5Kcq X-Received: by 2002:a37:5d44:: with SMTP id r65mr10301352qkb.73.1560428851853; Thu, 13 Jun 2019 05:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560428851; cv=none; d=google.com; s=arc-20160816; b=NRUXZul35eZaKcqS2f2mUfi9HKbgimV4ddSYDB0dM1OkuknnG2w4gTZ9/TEtPum8M8 ehET/RJSiNXoZ6dVjYtQKkGr8Cqa6ZtF/Tv1A0UW6QOnnJFoSVIDcPTupuhiaJby5OLN Uh6Jy8J0nzIhqaSRa9Hn4ksRVU6kBVXtr541A8LH6sSZu+9pdO9Kgq14clejLJZ5oR0g Aj23MN0M3DhvVJkb2p8yAfeOhA+JfAFC7e7qYBMxtmAdsI1Sk3LzToeZdyIT4RSQXiQb HWldFm0WXc4WXws68dYYuqZWhMxXh3UuMhJ5hyWTyx0TXrrAiRkCIZrr8xoDlDrboGuk SnTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Dn7KxRgCvtYAfGaacJQP6WpAQ39HiMNEc3qaxDs7q9A=; b=WPJ4rDoKEkBCpNg67PrrWlgFc1F61lrpDs4yuk+B9F8CM3ByAcT/UqYSp1Ritv2UtT 6Nnhni75U2xz53XRmncIN+IjkhCrpweJRCA31O5wNcG6tYdG1wsgyhnLzlyznyj2PvvE fycalLF6khrM9y0H2pdCDPhTCZbzsf0Z9uM6k2ZHzq99R+kY2iNbnybdfXYNRGH7xKhK Itq9e6tXs+SS+nAUZl6+77phnAjrFPwTox4Pw7UnC1NAjK8/kwTr3lCfEA4w9zF/Q9cW yzXa42H/QcpTnAFFuN0OVrILLWieB0/M/fL3wJr1rYmlkhpy8yaqn4l4j63knzpAm6kI CC9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=w9USfq8S; 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=fail (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 s54si1812387qts.122.2019.06.13.05.27.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:27:31 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=w9USfq8S; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOpH-0005Zw-DC for patch@linaro.org; Thu, 13 Jun 2019 08:27:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58721) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOcr-0007tJ-Ih for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOco-0003sX-Ll for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:41 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:43657) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOco-0003rf-A1 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:38 -0400 Received: by mail-wr1-x42a.google.com with SMTP id p13so10425245wru.10 for ; Thu, 13 Jun 2019 05:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Dn7KxRgCvtYAfGaacJQP6WpAQ39HiMNEc3qaxDs7q9A=; b=w9USfq8SpZVDbWWHMlnVyLn2X7L7GT73hbIwUn2nCPulqc0YFhk+aaqCioCgMIGyal A8xqPKOsiom7UJN3VIIQ6BW66dF5ZC1z3WkugACyVpOLinv8gHteulBR824yIP0niOOc TDdcSs7o2+icBqC0SaztB90wd560tBpXz8jE74whsimDkhot/4nd3c6y+vp9LiLWl5Fa 4MrZ6TOcue/E+Yq3n5LTEzX6Esxl9/r3QDYDnl+LlgOeZJS6CtouWzUV+pgPhKfRgTV4 cd2y+/UxtYA9zRTA/2vkgPDuHYSaAaQLjK/KlZWFFngegBS4yVtNJCA5MFw20FLJXG01 4Uyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dn7KxRgCvtYAfGaacJQP6WpAQ39HiMNEc3qaxDs7q9A=; b=c0eXY6ChSooqdSXNGMUywJTXD3ci0bFRyk6AQ+Yk6gUQ0u+2ySdVd8wflueizduizj B2Y3/U6kLc8yl0EoZNnYSNCZ2Ose4LxUbFSyCwpmfViuY2JFJ2raY3IF7VKxQsE2GWRa NoDodtj61sGV56Aqn4rUTMJ2qLzWdTb5nllFzBDpucCTbyJrL3rP5pqmoTrFpGyNACy2 DUKQKSRnlb0WHl8CQPzT4lEhKH8hXvFM7SgsHSG34lOvcNeqk2RqQ193/zh6A2zBgDh7 hWCbP5FmKeXIGg7J5DRJy3RPeeM46KlhYWVU8Y/GNR2hWsk+CcLETOyE+TzXjnXZDMsv 2oaA== X-Gm-Message-State: APjAAAW6yWWHBgY9sNetvRUBpPJWL22AFHtBJLvU7RbRTAA/92mX0SYe P6BKR2b0AdsPATiDXpMnfqPS6+8Pev723Q== X-Received: by 2002:adf:f181:: with SMTP id h1mr1580777wro.86.1560428076670; Thu, 13 Jun 2019 05:14:36 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:46 +0100 Message-Id: <20190613121433.5246-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a Subject: [Qemu-devel] [PULL 01/48] target/arm: Vectorize USHL and SSHL 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson These instructions shift left or right depending on the sign of the input, and 7 bits are significant to the shift. This requires several masks and selects in addition to the actual shifts to form the complete answer. That said, the operation is still a small improvement even for two 64-bit elements -- 13 vector operations instead of 2 * 7 integer operations. Signed-off-by: Richard Henderson Message-id: 20190603232209.20704-1-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/helper.h | 11 +- target/arm/translate.h | 6 + target/arm/neon_helper.c | 33 ---- target/arm/translate-a64.c | 18 +-- target/arm/translate.c | 300 +++++++++++++++++++++++++++++++++++-- target/arm/vec_helper.c | 88 +++++++++++ 6 files changed, 390 insertions(+), 66 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.h b/target/arm/helper.h index 132aa1682e8..1ab0fe597a9 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -297,14 +297,8 @@ DEF_HELPER_2(neon_abd_s16, i32, i32, i32) DEF_HELPER_2(neon_abd_u32, i32, i32, i32) DEF_HELPER_2(neon_abd_s32, i32, i32, i32) -DEF_HELPER_2(neon_shl_u8, i32, i32, i32) -DEF_HELPER_2(neon_shl_s8, i32, i32, i32) DEF_HELPER_2(neon_shl_u16, i32, i32, i32) DEF_HELPER_2(neon_shl_s16, i32, i32, i32) -DEF_HELPER_2(neon_shl_u32, i32, i32, i32) -DEF_HELPER_2(neon_shl_s32, i32, i32, i32) -DEF_HELPER_2(neon_shl_u64, i64, i64, i64) -DEF_HELPER_2(neon_shl_s64, i64, i64, i64) DEF_HELPER_2(neon_rshl_u8, i32, i32, i32) DEF_HELPER_2(neon_rshl_s8, i32, i32, i32) DEF_HELPER_2(neon_rshl_u16, i32, i32, i32) @@ -691,6 +685,11 @@ DEF_HELPER_FLAGS_2(frint64_s, TCG_CALL_NO_RWG, f32, f32, ptr) DEF_HELPER_FLAGS_2(frint32_d, TCG_CALL_NO_RWG, f64, f64, ptr) DEF_HELPER_FLAGS_2(frint64_d, TCG_CALL_NO_RWG, f64, f64, ptr) +DEF_HELPER_FLAGS_4(gvec_sshl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_sshl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_ushl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_ushl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + #ifdef TARGET_AARCH64 #include "helper-a64.h" #include "helper-sve.h" diff --git a/target/arm/translate.h b/target/arm/translate.h index c2348def0d1..f357b767cb9 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -244,6 +244,8 @@ extern const GVecGen3 bif_op; extern const GVecGen3 mla_op[4]; extern const GVecGen3 mls_op[4]; extern const GVecGen3 cmtst_op[4]; +extern const GVecGen3 sshl_op[4]; +extern const GVecGen3 ushl_op[4]; extern const GVecGen2i ssra_op[4]; extern const GVecGen2i usra_op[4]; extern const GVecGen2i sri_op[4]; @@ -253,6 +255,10 @@ extern const GVecGen4 sqadd_op[4]; extern const GVecGen4 uqsub_op[4]; extern const GVecGen4 sqsub_op[4]; void gen_cmtst_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b); +void gen_ushl_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b); +void gen_sshl_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b); +void gen_ushl_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b); +void gen_sshl_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b); /* * Forward to the isar_feature_* tests given a DisasContext pointer. diff --git a/target/arm/neon_helper.c b/target/arm/neon_helper.c index 42590567236..c581ffb7d3c 100644 --- a/target/arm/neon_helper.c +++ b/target/arm/neon_helper.c @@ -615,24 +615,9 @@ NEON_VOP(abd_u32, neon_u32, 1) } else { \ dest = src1 << tmp; \ }} while (0) -NEON_VOP(shl_u8, neon_u8, 4) NEON_VOP(shl_u16, neon_u16, 2) -NEON_VOP(shl_u32, neon_u32, 1) #undef NEON_FN -uint64_t HELPER(neon_shl_u64)(uint64_t val, uint64_t shiftop) -{ - int8_t shift = (int8_t)shiftop; - if (shift >= 64 || shift <= -64) { - val = 0; - } else if (shift < 0) { - val >>= -shift; - } else { - val <<= shift; - } - return val; -} - #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp = (int8_t)src2; \ @@ -645,27 +630,9 @@ uint64_t HELPER(neon_shl_u64)(uint64_t val, uint64_t shiftop) } else { \ dest = src1 << tmp; \ }} while (0) -NEON_VOP(shl_s8, neon_s8, 4) NEON_VOP(shl_s16, neon_s16, 2) -NEON_VOP(shl_s32, neon_s32, 1) #undef NEON_FN -uint64_t HELPER(neon_shl_s64)(uint64_t valop, uint64_t shiftop) -{ - int8_t shift = (int8_t)shiftop; - int64_t val = valop; - if (shift >= 64) { - val = 0; - } else if (shift <= -64) { - val >>= 63; - } else if (shift < 0) { - val >>= -shift; - } else { - val <<= shift; - } - return val; -} - #define NEON_FN(dest, src1, src2) do { \ int8_t tmp; \ tmp = (int8_t)src2; \ diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 8a3bf204d3d..f53cd288158 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -8847,9 +8847,9 @@ static void handle_3same_64(DisasContext *s, int opcode, bool u, break; case 0x8: /* SSHL, USHL */ if (u) { - gen_helper_neon_shl_u64(tcg_rd, tcg_rn, tcg_rm); + gen_ushl_i64(tcg_rd, tcg_rn, tcg_rm); } else { - gen_helper_neon_shl_s64(tcg_rd, tcg_rn, tcg_rm); + gen_sshl_i64(tcg_rd, tcg_rn, tcg_rm); } break; case 0x9: /* SQSHL, UQSHL */ @@ -11244,6 +11244,10 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) is_q ? 16 : 8, vec_full_reg_size(s), (u ? uqsub_op : sqsub_op) + size); return; + case 0x08: /* SSHL, USHL */ + gen_gvec_op3(s, is_q, rd, rn, rm, + u ? &ushl_op[size] : &sshl_op[size]); + return; case 0x0c: /* SMAX, UMAX */ if (u) { gen_gvec_fn3(s, is_q, rd, rn, rm, tcg_gen_gvec_umax, size); @@ -11359,16 +11363,6 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) genfn = fns[size][u]; break; } - case 0x8: /* SSHL, USHL */ - { - static NeonGenTwoOpFn * const fns[3][2] = { - { gen_helper_neon_shl_s8, gen_helper_neon_shl_u8 }, - { gen_helper_neon_shl_s16, gen_helper_neon_shl_u16 }, - { gen_helper_neon_shl_s32, gen_helper_neon_shl_u32 }, - }; - genfn = fns[size][u]; - break; - } case 0x9: /* SQSHL, UQSHL */ { static NeonGenTwoOpEnvFn * const fns[3][2] = { diff --git a/target/arm/translate.c b/target/arm/translate.c index d25e19ef113..096e338bf06 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -5374,13 +5374,13 @@ static inline void gen_neon_shift_narrow(int size, TCGv_i32 var, TCGv_i32 shift, if (u) { switch (size) { case 1: gen_helper_neon_shl_u16(var, var, shift); break; - case 2: gen_helper_neon_shl_u32(var, var, shift); break; + case 2: gen_ushl_i32(var, var, shift); break; default: abort(); } } else { switch (size) { case 1: gen_helper_neon_shl_s16(var, var, shift); break; - case 2: gen_helper_neon_shl_s32(var, var, shift); break; + case 2: gen_sshl_i32(var, var, shift); break; default: abort(); } } @@ -6259,6 +6259,282 @@ const GVecGen3 cmtst_op[4] = { .vece = MO_64 }, }; +void gen_ushl_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) +{ + TCGv_i32 lval = tcg_temp_new_i32(); + TCGv_i32 rval = tcg_temp_new_i32(); + TCGv_i32 lsh = tcg_temp_new_i32(); + TCGv_i32 rsh = tcg_temp_new_i32(); + TCGv_i32 zero = tcg_const_i32(0); + TCGv_i32 max = tcg_const_i32(32); + + /* + * Rely on the TCG guarantee that out of range shifts produce + * unspecified results, not undefined behaviour (i.e. no trap). + * Discard out-of-range results after the fact. + */ + tcg_gen_ext8s_i32(lsh, b); + tcg_gen_neg_i32(rsh, lsh); + tcg_gen_shl_i32(lval, a, lsh); + tcg_gen_shr_i32(rval, a, rsh); + tcg_gen_movcond_i32(TCG_COND_LTU, d, lsh, max, lval, zero); + tcg_gen_movcond_i32(TCG_COND_LTU, d, rsh, max, rval, d); + + tcg_temp_free_i32(lval); + tcg_temp_free_i32(rval); + tcg_temp_free_i32(lsh); + tcg_temp_free_i32(rsh); + tcg_temp_free_i32(zero); + tcg_temp_free_i32(max); +} + +void gen_ushl_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) +{ + TCGv_i64 lval = tcg_temp_new_i64(); + TCGv_i64 rval = tcg_temp_new_i64(); + TCGv_i64 lsh = tcg_temp_new_i64(); + TCGv_i64 rsh = tcg_temp_new_i64(); + TCGv_i64 zero = tcg_const_i64(0); + TCGv_i64 max = tcg_const_i64(64); + + /* + * Rely on the TCG guarantee that out of range shifts produce + * unspecified results, not undefined behaviour (i.e. no trap). + * Discard out-of-range results after the fact. + */ + tcg_gen_ext8s_i64(lsh, b); + tcg_gen_neg_i64(rsh, lsh); + tcg_gen_shl_i64(lval, a, lsh); + tcg_gen_shr_i64(rval, a, rsh); + tcg_gen_movcond_i64(TCG_COND_LTU, d, lsh, max, lval, zero); + tcg_gen_movcond_i64(TCG_COND_LTU, d, rsh, max, rval, d); + + tcg_temp_free_i64(lval); + tcg_temp_free_i64(rval); + tcg_temp_free_i64(lsh); + tcg_temp_free_i64(rsh); + tcg_temp_free_i64(zero); + tcg_temp_free_i64(max); +} + +static void gen_ushl_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) +{ + TCGv_vec lval = tcg_temp_new_vec_matching(d); + TCGv_vec rval = tcg_temp_new_vec_matching(d); + TCGv_vec lsh = tcg_temp_new_vec_matching(d); + TCGv_vec rsh = tcg_temp_new_vec_matching(d); + TCGv_vec msk, max; + + /* + * Rely on the TCG guarantee that out of range shifts produce + * unspecified results, not undefined behaviour (i.e. no trap). + * Discard out-of-range results after the fact. + */ + tcg_gen_neg_vec(vece, rsh, b); + if (vece == MO_8) { + tcg_gen_mov_vec(lsh, b); + } else { + msk = tcg_temp_new_vec_matching(d); + tcg_gen_dupi_vec(vece, msk, 0xff); + tcg_gen_and_vec(vece, lsh, b, msk); + tcg_gen_and_vec(vece, rsh, rsh, msk); + tcg_temp_free_vec(msk); + } + + /* + * Perform possibly out of range shifts, trusting that the operation + * does not trap. Discard unused results after the fact. + */ + tcg_gen_shlv_vec(vece, lval, a, lsh); + tcg_gen_shrv_vec(vece, rval, a, rsh); + + max = tcg_temp_new_vec_matching(d); + tcg_gen_dupi_vec(vece, max, 8 << vece); + + /* + * The choice of LT (signed) and GEU (unsigned) are biased toward + * the instructions of the x86_64 host. For MO_8, the whole byte + * is significant so we must use an unsigned compare; otherwise we + * have already masked to a byte and so a signed compare works. + * Other tcg hosts have a full set of comparisons and do not care. + */ + if (vece == MO_8) { + tcg_gen_cmp_vec(TCG_COND_GEU, vece, lsh, lsh, max); + tcg_gen_cmp_vec(TCG_COND_GEU, vece, rsh, rsh, max); + tcg_gen_andc_vec(vece, lval, lval, lsh); + tcg_gen_andc_vec(vece, rval, rval, rsh); + } else { + tcg_gen_cmp_vec(TCG_COND_LT, vece, lsh, lsh, max); + tcg_gen_cmp_vec(TCG_COND_LT, vece, rsh, rsh, max); + tcg_gen_and_vec(vece, lval, lval, lsh); + tcg_gen_and_vec(vece, rval, rval, rsh); + } + tcg_gen_or_vec(vece, d, lval, rval); + + tcg_temp_free_vec(max); + tcg_temp_free_vec(lval); + tcg_temp_free_vec(rval); + tcg_temp_free_vec(lsh); + tcg_temp_free_vec(rsh); +} + +static const TCGOpcode ushl_list[] = { + INDEX_op_neg_vec, INDEX_op_shlv_vec, + INDEX_op_shrv_vec, INDEX_op_cmp_vec, 0 +}; + +const GVecGen3 ushl_op[4] = { + { .fniv = gen_ushl_vec, + .fno = gen_helper_gvec_ushl_b, + .opt_opc = ushl_list, + .vece = MO_8 }, + { .fniv = gen_ushl_vec, + .fno = gen_helper_gvec_ushl_h, + .opt_opc = ushl_list, + .vece = MO_16 }, + { .fni4 = gen_ushl_i32, + .fniv = gen_ushl_vec, + .opt_opc = ushl_list, + .vece = MO_32 }, + { .fni8 = gen_ushl_i64, + .fniv = gen_ushl_vec, + .opt_opc = ushl_list, + .vece = MO_64 }, +}; + +void gen_sshl_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) +{ + TCGv_i32 lval = tcg_temp_new_i32(); + TCGv_i32 rval = tcg_temp_new_i32(); + TCGv_i32 lsh = tcg_temp_new_i32(); + TCGv_i32 rsh = tcg_temp_new_i32(); + TCGv_i32 zero = tcg_const_i32(0); + TCGv_i32 max = tcg_const_i32(31); + + /* + * Rely on the TCG guarantee that out of range shifts produce + * unspecified results, not undefined behaviour (i.e. no trap). + * Discard out-of-range results after the fact. + */ + tcg_gen_ext8s_i32(lsh, b); + tcg_gen_neg_i32(rsh, lsh); + tcg_gen_shl_i32(lval, a, lsh); + tcg_gen_umin_i32(rsh, rsh, max); + tcg_gen_sar_i32(rval, a, rsh); + tcg_gen_movcond_i32(TCG_COND_LEU, lval, lsh, max, lval, zero); + tcg_gen_movcond_i32(TCG_COND_LT, d, lsh, zero, rval, lval); + + tcg_temp_free_i32(lval); + tcg_temp_free_i32(rval); + tcg_temp_free_i32(lsh); + tcg_temp_free_i32(rsh); + tcg_temp_free_i32(zero); + tcg_temp_free_i32(max); +} + +void gen_sshl_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) +{ + TCGv_i64 lval = tcg_temp_new_i64(); + TCGv_i64 rval = tcg_temp_new_i64(); + TCGv_i64 lsh = tcg_temp_new_i64(); + TCGv_i64 rsh = tcg_temp_new_i64(); + TCGv_i64 zero = tcg_const_i64(0); + TCGv_i64 max = tcg_const_i64(63); + + /* + * Rely on the TCG guarantee that out of range shifts produce + * unspecified results, not undefined behaviour (i.e. no trap). + * Discard out-of-range results after the fact. + */ + tcg_gen_ext8s_i64(lsh, b); + tcg_gen_neg_i64(rsh, lsh); + tcg_gen_shl_i64(lval, a, lsh); + tcg_gen_umin_i64(rsh, rsh, max); + tcg_gen_sar_i64(rval, a, rsh); + tcg_gen_movcond_i64(TCG_COND_LEU, lval, lsh, max, lval, zero); + tcg_gen_movcond_i64(TCG_COND_LT, d, lsh, zero, rval, lval); + + tcg_temp_free_i64(lval); + tcg_temp_free_i64(rval); + tcg_temp_free_i64(lsh); + tcg_temp_free_i64(rsh); + tcg_temp_free_i64(zero); + tcg_temp_free_i64(max); +} + +static void gen_sshl_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) +{ + TCGv_vec lval = tcg_temp_new_vec_matching(d); + TCGv_vec rval = tcg_temp_new_vec_matching(d); + TCGv_vec lsh = tcg_temp_new_vec_matching(d); + TCGv_vec rsh = tcg_temp_new_vec_matching(d); + TCGv_vec tmp = tcg_temp_new_vec_matching(d); + + /* + * Rely on the TCG guarantee that out of range shifts produce + * unspecified results, not undefined behaviour (i.e. no trap). + * Discard out-of-range results after the fact. + */ + tcg_gen_neg_vec(vece, rsh, b); + if (vece == MO_8) { + tcg_gen_mov_vec(lsh, b); + } else { + tcg_gen_dupi_vec(vece, tmp, 0xff); + tcg_gen_and_vec(vece, lsh, b, tmp); + tcg_gen_and_vec(vece, rsh, rsh, tmp); + } + + /* Bound rsh so out of bound right shift gets -1. */ + tcg_gen_dupi_vec(vece, tmp, (8 << vece) - 1); + tcg_gen_umin_vec(vece, rsh, rsh, tmp); + tcg_gen_cmp_vec(TCG_COND_GT, vece, tmp, lsh, tmp); + + tcg_gen_shlv_vec(vece, lval, a, lsh); + tcg_gen_sarv_vec(vece, rval, a, rsh); + + /* Select in-bound left shift. */ + tcg_gen_andc_vec(vece, lval, lval, tmp); + + /* Select between left and right shift. */ + if (vece == MO_8) { + tcg_gen_dupi_vec(vece, tmp, 0); + tcg_gen_cmpsel_vec(TCG_COND_LT, vece, d, lsh, tmp, rval, lval); + } else { + tcg_gen_dupi_vec(vece, tmp, 0x80); + tcg_gen_cmpsel_vec(TCG_COND_LT, vece, d, lsh, tmp, lval, rval); + } + + tcg_temp_free_vec(lval); + tcg_temp_free_vec(rval); + tcg_temp_free_vec(lsh); + tcg_temp_free_vec(rsh); + tcg_temp_free_vec(tmp); +} + +static const TCGOpcode sshl_list[] = { + INDEX_op_neg_vec, INDEX_op_umin_vec, INDEX_op_shlv_vec, + INDEX_op_sarv_vec, INDEX_op_cmp_vec, INDEX_op_cmpsel_vec, 0 +}; + +const GVecGen3 sshl_op[4] = { + { .fniv = gen_sshl_vec, + .fno = gen_helper_gvec_sshl_b, + .opt_opc = sshl_list, + .vece = MO_8 }, + { .fniv = gen_sshl_vec, + .fno = gen_helper_gvec_sshl_h, + .opt_opc = sshl_list, + .vece = MO_16 }, + { .fni4 = gen_sshl_i32, + .fniv = gen_sshl_vec, + .opt_opc = sshl_list, + .vece = MO_32 }, + { .fni8 = gen_sshl_i64, + .fniv = gen_sshl_vec, + .opt_opc = sshl_list, + .vece = MO_64 }, +}; + static void gen_uqadd_vec(unsigned vece, TCGv_vec t, TCGv_vec sat, TCGv_vec a, TCGv_vec b) { @@ -6662,6 +6938,11 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) vec_size, vec_size); } return 0; + + case NEON_3R_VSHL: + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size, + u ? &ushl_op[size] : &sshl_op[size]); + return 0; } if (size == 3) { @@ -6670,13 +6951,6 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) neon_load_reg64(cpu_V0, rn + pass); neon_load_reg64(cpu_V1, rm + pass); switch (op) { - case NEON_3R_VSHL: - if (u) { - gen_helper_neon_shl_u64(cpu_V0, cpu_V1, cpu_V0); - } else { - gen_helper_neon_shl_s64(cpu_V0, cpu_V1, cpu_V0); - } - break; case NEON_3R_VQSHL: if (u) { gen_helper_neon_qshl_u64(cpu_V0, cpu_env, @@ -6711,7 +6985,6 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) } pairwise = 0; switch (op) { - case NEON_3R_VSHL: case NEON_3R_VQSHL: case NEON_3R_VRSHL: case NEON_3R_VQRSHL: @@ -6791,9 +7064,6 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) case NEON_3R_VHSUB: GEN_NEON_INTEGER_OP(hsub); break; - case NEON_3R_VSHL: - GEN_NEON_INTEGER_OP(shl); - break; case NEON_3R_VQSHL: GEN_NEON_INTEGER_OP_ENV(qshl); break; @@ -7202,9 +7472,9 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) } } else { if (input_unsigned) { - gen_helper_neon_shl_u64(cpu_V0, in, tmp64); + gen_ushl_i64(cpu_V0, in, tmp64); } else { - gen_helper_neon_shl_s64(cpu_V0, in, tmp64); + gen_sshl_i64(cpu_V0, in, tmp64); } } tmp = tcg_temp_new_i32(); diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c index dedef62403a..fcb36639036 100644 --- a/target/arm/vec_helper.c +++ b/target/arm/vec_helper.c @@ -1046,3 +1046,91 @@ void HELPER(gvec_fmlal_idx_a64)(void *vd, void *vn, void *vm, do_fmlal_idx(vd, vn, vm, &env->vfp.fp_status, desc, get_flush_inputs_to_zero(&env->vfp.fp_status_f16)); } + +void HELPER(gvec_sshl_b)(void *vd, void *vn, void *vm, uint32_t desc) +{ + intptr_t i, opr_sz = simd_oprsz(desc); + int8_t *d = vd, *n = vn, *m = vm; + + for (i = 0; i < opr_sz; ++i) { + int8_t mm = m[i]; + int8_t nn = n[i]; + int8_t res = 0; + if (mm >= 0) { + if (mm < 8) { + res = nn << mm; + } + } else { + res = nn >> (mm > -8 ? -mm : 7); + } + d[i] = res; + } + clear_tail(d, opr_sz, simd_maxsz(desc)); +} + +void HELPER(gvec_sshl_h)(void *vd, void *vn, void *vm, uint32_t desc) +{ + intptr_t i, opr_sz = simd_oprsz(desc); + int16_t *d = vd, *n = vn, *m = vm; + + for (i = 0; i < opr_sz / 2; ++i) { + int8_t mm = m[i]; /* only 8 bits of shift are significant */ + int16_t nn = n[i]; + int16_t res = 0; + if (mm >= 0) { + if (mm < 16) { + res = nn << mm; + } + } else { + res = nn >> (mm > -16 ? -mm : 15); + } + d[i] = res; + } + clear_tail(d, opr_sz, simd_maxsz(desc)); +} + +void HELPER(gvec_ushl_b)(void *vd, void *vn, void *vm, uint32_t desc) +{ + intptr_t i, opr_sz = simd_oprsz(desc); + uint8_t *d = vd, *n = vn, *m = vm; + + for (i = 0; i < opr_sz; ++i) { + int8_t mm = m[i]; + uint8_t nn = n[i]; + uint8_t res = 0; + if (mm >= 0) { + if (mm < 8) { + res = nn << mm; + } + } else { + if (mm > -8) { + res = nn >> -mm; + } + } + d[i] = res; + } + clear_tail(d, opr_sz, simd_maxsz(desc)); +} + +void HELPER(gvec_ushl_h)(void *vd, void *vn, void *vm, uint32_t desc) +{ + intptr_t i, opr_sz = simd_oprsz(desc); + uint16_t *d = vd, *n = vn, *m = vm; + + for (i = 0; i < opr_sz / 2; ++i) { + int8_t mm = m[i]; /* only 8 bits of shift are significant */ + uint16_t nn = n[i]; + uint16_t res = 0; + if (mm >= 0) { + if (mm < 16) { + res = nn << mm; + } + } else { + if (mm > -16) { + res = nn >> -mm; + } + } + d[i] = res; + } + clear_tail(d, opr_sz, simd_maxsz(desc)); +} From patchwork Thu Jun 13 12:13:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166613 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp694403ilk; Thu, 13 Jun 2019 05:26:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7taTYOeW8Fy5Ycp7z6nrRvvPpSwL3NLlAtCdItXHv47Re9iTHycQAKAWVnSV8HR3iOTlw X-Received: by 2002:ac8:30a4:: with SMTP id v33mr76731835qta.249.1560428809705; Thu, 13 Jun 2019 05:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560428809; cv=none; d=google.com; s=arc-20160816; b=GdcO6+xtk86CWrG2puGCaNXSwylebgCS+ha8zk9KFYjFLy8x39o8XO3YE5Y7hlAm7f 4Wp1nQR5l4jauHllvgM7VKKxifGZwq9nW6SAu02+matuFPt+gcXw3CHXRo8c6HITtOHn Ml79Bn+SW7cFQzK5tOZzaPSHrjdrRy4rhQDwHvAxovy/PhvYeyzL9NuW8+fGUhIjH8kG wHdzDFa/NtdZr5rgaRHzDmTIZIOIYO/Fm7PaJPDcvDJjF/UDtBOn1/pChYHwVF805ckm 72m8xY6JsAJlQqOE1ZL9606+aBVbm3aNt+gyPHscvXKE3zsM60ruL+5LmM3/h+Dx6nxq w+8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=B6ZUgC//PSMrRR2oNuVHItj5SGKIBntukxvLi8+tvVc=; b=0TSgWWfKkGWmWPPXfHOqGqf05qaYtl9o/5d54CZGGU5TfI27gqlwL1/Bf7BMHyuHPm 1C03h+7ulFNHSZ9Eyy7bWF5JHvoAtjCFTjIdFt9dGnD5WqSCGfSVt7TXOBmc9SHTxGoB pgsvW7tIm1j9VSoaL8QsV5gvn1OJqtSSPMpXbi0zy4uth4x7TJ9aBrokASIkYGYzcKrt e2rRQXWFdRoru+lIaBpgGIdfLzgDCCuQZwHefRgJCVOAPh3Va+UX5xK62ILqWx023vkO yNb+HT+BqDO6rmYI87ucMWcLmaZyZIHlwhBmM/NFq6n9PYuspS0rxBdPbdpw+p/0VNBz IYfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XyNwwTlU; 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=fail (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 15si1460230qkl.59.2019.06.13.05.26.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:26:49 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=XyNwwTlU; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39380 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOoa-0005Az-8W for patch@linaro.org; Thu, 13 Jun 2019 08:26:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58751) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOcv-0007tg-5S for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOct-0003w8-Fy for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:45 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:32992) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcr-0003si-Ba for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:41 -0400 Received: by mail-wr1-x435.google.com with SMTP id n9so20572074wru.0 for ; Thu, 13 Jun 2019 05:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=B6ZUgC//PSMrRR2oNuVHItj5SGKIBntukxvLi8+tvVc=; b=XyNwwTlUVXrNSI2go6fXy7VC3+DEcfFLaHiuS8g/Xq8GRrROZLeHaf2uVs87x2z1jg Jqq7BoADWuDP+gLGLLrMKmdibxii/B5Xc4k5KrSEkJc+wRczAfXn0YTGf0buj+XixzUx OxAmqwynbEDkNZjJtOoVXi6zrgqRKefkIIzD/Hd6vqqPQZGDp34Zeyax5Ly89OBeyQVP Wm8cQkpbLlfWH0661BvdompUK3ZBCBo//cTy++oABOnZKp8FUxEqfmo+ExbYnuS2tQls eTgyHYKP0POMaK2B9q0GmlbQzUKYzhNUOE2wlV9kXEl/3nG8xVs2XJs3puD54dxvrmsK Yd/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B6ZUgC//PSMrRR2oNuVHItj5SGKIBntukxvLi8+tvVc=; b=MZP+AXoxPv2plTBYOMYpFVts9AZOzC7KcRLgqi6bNG9bF+lzyFPm72o7ZSMLDy35wL /gxg3vCf2lx07yczQO5k1FGfq9okU24A/8JezYN5kWNwrxqpTE23TgJ2ZEHaEjRjyx6j Cxa4GrRVD7zY64QQldh6KKffUseRSYw989jZEOeE1u6fI3gVV4Hom4dtLcxVb6HgCYOx 1RWa5YWafp+b2PJ4yL3pNjdEkKIY8AzbfRJm+dm/2/v2Dwb15qOx8J1iYBuGCpLxb7xb m4gI89yy1QuLIZoSOviwjE1vMh37QHP5whDhlxHdK9oqmM0E8nPrc36DN721XkAhAoNY d4cA== X-Gm-Message-State: APjAAAV+Sp+Vicbl/3A90qk6BkSZTngg6H7WGfztBzM1iu3/43LSKCZL Dwd/sBsK2t/uPzFKl0M/UGsADs9Fe9gm6g== X-Received: by 2002:adf:e8cb:: with SMTP id k11mr58138851wrn.244.1560428077939; Thu, 13 Jun 2019 05:14:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:47 +0100 Message-Id: <20190613121433.5246-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 Subject: [Qemu-devel] [PULL 02/48] target/arm: Use tcg_gen_gvec_bitsel 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This replaces 3 target-specific implementations for BIT, BIF, and BSL. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20190518191934.21887-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/translate-a64.h | 2 + target/arm/translate.h | 3 -- target/arm/translate-a64.c | 15 ++++++-- target/arm/translate.c | 78 +++----------------------------------- 4 files changed, 20 insertions(+), 78 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h index 63d958cf504..9569bc5963d 100644 --- a/target/arm/translate-a64.h +++ b/target/arm/translate-a64.h @@ -122,5 +122,7 @@ typedef void GVecGen2iFn(unsigned, uint32_t, uint32_t, int64_t, uint32_t, uint32_t); typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); +typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t, + uint32_t, uint32_t, uint32_t); #endif /* TARGET_ARM_TRANSLATE_A64_H */ diff --git a/target/arm/translate.h b/target/arm/translate.h index f357b767cb9..01ae454dcf1 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -238,9 +238,6 @@ static inline void gen_ss_advance(DisasContext *s) } /* Vector operations shared between ARM and AArch64. */ -extern const GVecGen3 bsl_op; -extern const GVecGen3 bit_op; -extern const GVecGen3 bif_op; extern const GVecGen3 mla_op[4]; extern const GVecGen3 mls_op[4]; extern const GVecGen3 cmtst_op[4]; diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index f53cd288158..e9954eb78f7 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -704,6 +704,15 @@ static void gen_gvec_fn3(DisasContext *s, bool is_q, int rd, int rn, int rm, vec_full_reg_offset(s, rm), is_q ? 16 : 8, vec_full_reg_size(s)); } +/* Expand a 4-operand AdvSIMD vector operation using an expander function. */ +static void gen_gvec_fn4(DisasContext *s, bool is_q, int rd, int rn, int rm, + int rx, GVecGen4Fn *gvec_fn, int vece) +{ + gvec_fn(vece, vec_full_reg_offset(s, rd), vec_full_reg_offset(s, rn), + vec_full_reg_offset(s, rm), vec_full_reg_offset(s, rx), + is_q ? 16 : 8, vec_full_reg_size(s)); +} + /* Expand a 2-operand + immediate AdvSIMD vector operation using * an op descriptor. */ @@ -10918,13 +10927,13 @@ static void disas_simd_3same_logic(DisasContext *s, uint32_t insn) return; case 5: /* BSL bitwise select */ - gen_gvec_op3(s, is_q, rd, rn, rm, &bsl_op); + gen_gvec_fn4(s, is_q, rd, rd, rn, rm, tcg_gen_gvec_bitsel, 0); return; case 6: /* BIT, bitwise insert if true */ - gen_gvec_op3(s, is_q, rd, rn, rm, &bit_op); + gen_gvec_fn4(s, is_q, rd, rm, rn, rd, tcg_gen_gvec_bitsel, 0); return; case 7: /* BIF, bitwise insert if false */ - gen_gvec_op3(s, is_q, rd, rn, rm, &bif_op); + gen_gvec_fn4(s, is_q, rd, rm, rd, rn, tcg_gen_gvec_bitsel, 0); return; default: diff --git a/target/arm/translate.c b/target/arm/translate.c index 096e338bf06..ab3026664af 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -5755,72 +5755,6 @@ static int do_v81_helper(DisasContext *s, gen_helper_gvec_3_ptr *fn, return 1; } -/* - * Expanders for VBitOps_VBIF, VBIT, VBSL. - */ -static void gen_bsl_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) -{ - tcg_gen_xor_i64(rn, rn, rm); - tcg_gen_and_i64(rn, rn, rd); - tcg_gen_xor_i64(rd, rm, rn); -} - -static void gen_bit_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) -{ - tcg_gen_xor_i64(rn, rn, rd); - tcg_gen_and_i64(rn, rn, rm); - tcg_gen_xor_i64(rd, rd, rn); -} - -static void gen_bif_i64(TCGv_i64 rd, TCGv_i64 rn, TCGv_i64 rm) -{ - tcg_gen_xor_i64(rn, rn, rd); - tcg_gen_andc_i64(rn, rn, rm); - tcg_gen_xor_i64(rd, rd, rn); -} - -static void gen_bsl_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) -{ - tcg_gen_xor_vec(vece, rn, rn, rm); - tcg_gen_and_vec(vece, rn, rn, rd); - tcg_gen_xor_vec(vece, rd, rm, rn); -} - -static void gen_bit_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) -{ - tcg_gen_xor_vec(vece, rn, rn, rd); - tcg_gen_and_vec(vece, rn, rn, rm); - tcg_gen_xor_vec(vece, rd, rd, rn); -} - -static void gen_bif_vec(unsigned vece, TCGv_vec rd, TCGv_vec rn, TCGv_vec rm) -{ - tcg_gen_xor_vec(vece, rn, rn, rd); - tcg_gen_andc_vec(vece, rn, rn, rm); - tcg_gen_xor_vec(vece, rd, rd, rn); -} - -const GVecGen3 bsl_op = { - .fni8 = gen_bsl_i64, - .fniv = gen_bsl_vec, - .prefer_i64 = TCG_TARGET_REG_BITS == 64, - .load_dest = true -}; - -const GVecGen3 bit_op = { - .fni8 = gen_bit_i64, - .fniv = gen_bit_vec, - .prefer_i64 = TCG_TARGET_REG_BITS == 64, - .load_dest = true -}; - -const GVecGen3 bif_op = { - .fni8 = gen_bif_i64, - .fniv = gen_bif_vec, - .prefer_i64 = TCG_TARGET_REG_BITS == 64, - .load_dest = true -}; - static void gen_ssra8_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) { tcg_gen_vec_sar8i_i64(a, a, shift); @@ -6846,16 +6780,16 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) vec_size, vec_size); break; case 5: /* VBSL */ - tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, - vec_size, vec_size, &bsl_op); + tcg_gen_gvec_bitsel(MO_8, rd_ofs, rd_ofs, rn_ofs, rm_ofs, + vec_size, vec_size); break; case 6: /* VBIT */ - tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, - vec_size, vec_size, &bit_op); + tcg_gen_gvec_bitsel(MO_8, rd_ofs, rm_ofs, rn_ofs, rd_ofs, + vec_size, vec_size); break; case 7: /* VBIF */ - tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, - vec_size, vec_size, &bif_op); + tcg_gen_gvec_bitsel(MO_8, rd_ofs, rm_ofs, rd_ofs, rn_ofs, + vec_size, vec_size); break; } return 0; From patchwork Thu Jun 13 12:13:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166618 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp701584ilk; Thu, 13 Jun 2019 05:33:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgWpN6r8vf+ksZezfiEXi9YuXkM8kRCbWx0RVLSaB+qNeywzosGquENTP707MO3CHrJyJV X-Received: by 2002:a0c:879d:: with SMTP id 29mr3275528qvj.91.1560429215832; Thu, 13 Jun 2019 05:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429215; cv=none; d=google.com; s=arc-20160816; b=NGm6m2Yc/9PqVpolNZaypai+N28+5koLrsrUoTt7dLvXzgNjOItQlLa1thrL7aqMNr 8R2apWeC1BmWpnuwjSisLY12ZnQY2FbtIA0nM8IwcNrQcpzr2eFLfS38/bDonitYEFgB DJUwGfUqYODQ0kXgV9TC9d6mNYU870lyCbD+0u5TVUgjgQ/9OFPzXjYRvfxFRbiviSVW 0MmXaSrIFW28sKCE7sYPzvXq1AJtE7OHAcrVpD+kSOUVqvLUE5PwaOPxW5FuDMGCiQj1 wh8pb71LbkI2dxRV6XAFJmXiWXY6ccm+lOzTpQUHI3q7sdLC2ZXCXQBerON8ES/iPSaU GuwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=FgrJRA7j7aTJ3DWKdfLXQg9RBsbyTXhKrH5Enhs39X4=; b=x3aG4+o42TGtMmCVFrf9c8bYzKDWC3xb1/250gFn5FgcmZcGze7P23jgNYmqFz9p8x qbiPuKN+ewcdJW7Ktt1+miSmPuJfkwhkARvlH+vpK2GG3IzPpTL4NKnbtmK8s/NROTrF /3XH7HHZwjVMAkYK+pTBAxdrazWbdhwW7RBsGxQowVIdlv6h5jgvM+UNtgEliCTWqOaa w/bk5agmji7OSjpFPKMKcMxCL2D21BP4+gPpFynhC67l7undgd+enPIMsQtS3+iC82Si 8DJeLgof4hGgl98IiEqpoByqoBqe6bey0Sf5Z2A+7CMD6OIsTxeqLUpKVSUpz3sevoQq FjfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mo6vMRnX; 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=fail (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 v124si1559958qkc.264.2019.06.13.05.33.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:33:35 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=mo6vMRnX; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOv8-0001Pr-WB for patch@linaro.org; Thu, 13 Jun 2019 08:33:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58775) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOcx-0007tk-HY for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOcu-0003wy-B0 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:47 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:39408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcr-0003tS-DB for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:41 -0400 Received: by mail-wr1-x443.google.com with SMTP id x4so17872241wrt.6 for ; Thu, 13 Jun 2019 05:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FgrJRA7j7aTJ3DWKdfLXQg9RBsbyTXhKrH5Enhs39X4=; b=mo6vMRnX3ZrwUK7W+GWxyPfZUPDHrhoAbLvdB199iH+Xt2Q+QkRNiGo9aZ1ifX/SQW 3Nw/Yxb7lVSchyLOW7nI6RIhRE3RWy6rmOtdR3SDS6Uz7xUKOobBg+IhY/2ALLBoMSFy 5vScqnSoOf9ndo639W6Yved1gARN5PANXXd73KrcanxIYOWajgS35AVZM6s1tVcKC+jk B5nKS5PSBwE1TneM4TBaQwzxORX+3BE8Xl/xKqf0xVxicjbMIpAr8+J2LiLE9WJzVMoi WtTe6xfKZKss6icO3EX8Mn2DvAWd0Ze9GFibtr/k4cR/AxCxLMRukO4IVBY5kAw9WDqY P6mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FgrJRA7j7aTJ3DWKdfLXQg9RBsbyTXhKrH5Enhs39X4=; b=oVy1e6Wmvftw9Ch8QulPJnV31CkehUezGEzydDUa2OUJlK/+kfGUxMbyJT8MBj6QZE q82mATgehoFIZvBDb3cnA7XLeXW0KD0C3twbFUXDUErvqULZw0Pb/isRhUd85nF7InBM m7el1vAyVbfRPXlioqAXOQVnL/KMYARE3XwcIkIXytnbc1dTR8oIJvL2OaF7x+pV9OmF day+7pAF7CLemw9T5DXJ+OrxidRIYc4/8NcLo8lhgeLbFE81FrvIlG4hX//UZ5ctwJEB CozsqLV6VNtXE3NUjM3MZ6sqmWmZIgPWvj6+qEBlkKFwzhTFIxj6DTYN/SCF5jBSNwyK WUXg== X-Gm-Message-State: APjAAAX7TrvxiP10b0Uf6/Ay0RGJ/40WRM3ijCXv890wSoGuzct8Jucf PgLaiNe8lW6Ug1j7Ym/s+Jmk+Al0UMlJ5g== X-Received: by 2002:adf:e8d0:: with SMTP id k16mr46597951wrn.31.1560428079139; Thu, 13 Jun 2019 05:14:39 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:48 +0100 Message-Id: <20190613121433.5246-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 03/48] target/arm: Implement NSACR gating of floating point 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The NSACR register allows secure code to configure the FPU to be inaccessible to non-secure code. If the NSACR.CP10 bit is set then: * NS accesses to the FPU trap as UNDEF (ie to NS EL1 or EL2) * CPACR.{CP10,CP11} behave as if RAZ/WI * HCPTR.{TCP11,TCP10} behave as if RAO/WI Note that we do not implement the NSACR.NSASEDIS bit which gates only access to Advanced SIMD, in the same way that we don't implement the equivalent CPACR.ASEDIS and HCPTR.TASE. Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-id: 20190510110357.18825-1-peter.maydell@linaro.org --- target/arm/helper.c | 75 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 188fb1950ef..df4276f5f6c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -930,9 +930,36 @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, } value &= mask; } + + /* + * For A-profile AArch32 EL3 (but not M-profile secure mode), if NSACR.CP10 + * is 0 then CPACR.{CP11,CP10} ignore writes and read as 0b00. + */ + if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) && + !arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) { + value &= ~(0xf << 20); + value |= env->cp15.cpacr_el1 & (0xf << 20); + } + env->cp15.cpacr_el1 = value; } +static uint64_t cpacr_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + /* + * For A-profile AArch32 EL3 (but not M-profile secure mode), if NSACR.CP10 + * is 0 then CPACR.{CP11,CP10} ignore writes and read as 0b00. + */ + uint64_t value = env->cp15.cpacr_el1; + + if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) && + !arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) { + value &= ~(0xf << 20); + } + return value; +} + + static void cpacr_reset(CPUARMState *env, const ARMCPRegInfo *ri) { /* Call cpacr_write() so that we reset with the correct RAO bits set @@ -998,7 +1025,7 @@ static const ARMCPRegInfo v6_cp_reginfo[] = { { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), - .resetfn = cpacr_reset, .writefn = cpacr_write }, + .resetfn = cpacr_reset, .writefn = cpacr_write, .readfn = cpacr_read }, REGINFO_SENTINEL }; @@ -4683,6 +4710,36 @@ uint64_t arm_hcr_el2_eff(CPUARMState *env) return ret; } +static void cptr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* + * For A-profile AArch32 EL3, if NSACR.CP10 + * is 0 then HCPTR.{TCP11,TCP10} ignore writes and read as 1. + */ + if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) && + !arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) { + value &= ~(0x3 << 10); + value |= env->cp15.cptr_el[2] & (0x3 << 10); + } + env->cp15.cptr_el[2] = value; +} + +static uint64_t cptr_el2_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + /* + * For A-profile AArch32 EL3, if NSACR.CP10 + * is 0 then HCPTR.{TCP11,TCP10} ignore writes and read as 1. + */ + uint64_t value = env->cp15.cptr_el[2]; + + if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) && + !arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) { + value |= 0x3 << 10; + } + return value; +} + static const ARMCPRegInfo el2_cp_reginfo[] = { { .name = "HCR_EL2", .state = ARM_CP_STATE_AA64, .type = ARM_CP_IO, @@ -4730,7 +4787,8 @@ static const ARMCPRegInfo el2_cp_reginfo[] = { { .name = "CPTR_EL2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 2, .access = PL2_RW, .accessfn = cptr_access, .resetvalue = 0, - .fieldoffset = offsetof(CPUARMState, cp15.cptr_el[2]) }, + .fieldoffset = offsetof(CPUARMState, cp15.cptr_el[2]), + .readfn = cptr_el2_read, .writefn = cptr_el2_write }, { .name = "MAIR_EL2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 4, .crn = 10, .crm = 2, .opc2 = 0, .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.mair_el[2]), @@ -13587,6 +13645,19 @@ int fp_exception_el(CPUARMState *env, int cur_el) break; } + /* + * The NSACR allows A-profile AArch32 EL3 and M-profile secure mode + * to control non-secure access to the FPU. It doesn't have any + * effect if EL3 is AArch64 or if EL3 doesn't exist at all. + */ + if ((arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) && + cur_el <= 2 && !arm_is_secure_below_el3(env))) { + if (!extract32(env->cp15.nsacr, 10, 1)) { + /* FP insns act as UNDEF */ + return cur_el == 2 ? 2 : 1; + } + } + /* For the CPTR registers we don't need to guard with an ARM_FEATURE * check because zero bits in the registers mean "don't trap". */ From patchwork Thu Jun 13 12:13:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166615 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp695018ilk; Thu, 13 Jun 2019 05:27:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXOVBruMJ8za5ZB7X58UdQra0p8QzLhL3T5HSCIZ+S0xGjzeIYf1rn9ltWMULtOKT5ed4D X-Received: by 2002:a37:9b01:: with SMTP id d1mr67423266qke.46.1560428846270; Thu, 13 Jun 2019 05:27:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560428846; cv=none; d=google.com; s=arc-20160816; b=FJ/4nrha297j02K6m8p/Pd1khpzD0WwemtBMo7MLZ/sUp3NlkCF3p3SdIdu8Yoh8PM SWZ7CCbbYr+Iu+aXXE8anCqueRSpCY2EYCq1mmC9lAyMk3ByLC9aECCsXCE0U2ERHNWj eIAAz1GcYMnDEanBGPV5d7AtNlWEJvSTn44RuhPq/wXQV5P/inVyzL7Jj/o8jwoWI+w4 OVPwUz1tP7p6FIAZ8xsB1NEWK4h40h3i5t1e1ruAo8cqtX1ofAaXpoHvA6Rp4esDTi0I DujGvWL8POfgHnMJNWVuZ8M3PgiIccwr6zSHLAhzceLdr01/OOVpW9VEGngpfvJDySco O9mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZUooYRNQgmkNG0e2yEBeTuMYF1MRR7xam1XkALvG320=; b=alu4xWA9pbbc2yOjWBvwL2kZt0Lp5muEY3bGzm52gIqCnrzthdR82wQQ14cLdp+lmJ bm7SeXUUVLZTv/jALL0VVOYYhkC57ZLzrCLKluPJ/JspLgS99nX5u7lNN1eCXg0CxHMP YyrbPwzF6e6sYHOYF2FOSfVStMWgCehEFsVk7RZgUWqTJY4hXOs2lHW+tQ+jdb6hxHen GOkNSan2pstAXMhJMNSE7RgFPJxKAOWNOaUS+SDByuaT+pT0r94TMSRis4/+7nhxHOqF 7+2XTJkgKydEQYaNtr0sJ7XnEF7pQVh3DsvYDhZ/Pg4YyJ1npk54fXxt19nhbdKchmJP 07IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oYdT9Uiv; 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=fail (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 x189si1654935qkb.163.2019.06.13.05.27.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:27:26 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=oYdT9Uiv; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOpB-0005ML-Ti for patch@linaro.org; Thu, 13 Jun 2019 08:27:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58769) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOcx-0007tj-BD for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOcu-0003wx-B0 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:45 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:42885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcr-0003tu-ED for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:41 -0400 Received: by mail-wr1-x42c.google.com with SMTP id x17so5233198wrl.9 for ; Thu, 13 Jun 2019 05:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZUooYRNQgmkNG0e2yEBeTuMYF1MRR7xam1XkALvG320=; b=oYdT9UivNs+OPvJezs7OUA8WLYiud+InyFfN2ZNe525ESXhsF6vWC8/S/qATRDZBMK bmdvZASWVSiNvD44mWNvFtZ8lt4CctQ5cA67KYQvP7m/xHAOVNytBXnk/9bk4t+6dcEg X9Vd1x1Eoz2+mg7MfoCtZfPdqbie+gYZkd3ddvsgZx3HJlCp7S07uVNkXPIWXXNX7+dg fc8PmajTVs9u0E3iKKo4DA6vnbeP1w9x0KNqYwhihK/Hm6hZGu1VmhGTQskko/dgpoXy 4htWSOJ0xArlcuMup7097n5MpUA9Hs2MSpyuQbGDpTEN6YuwfOPVktGMX0XHao0MI++C RnxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZUooYRNQgmkNG0e2yEBeTuMYF1MRR7xam1XkALvG320=; b=JTXTq8UpSEk2z7INEAyZw0JnstnoS1pW5UJNyCLNdq8ju8xPNQqyK9C3DjIPDJb8ru gJNaXPYNLShcs6vmzOKXEAFeIKaEYlh9Xr1GA7Dw1VJ3YrI/BD3mLvf3isgNUQWXiWtb 0kq7lpNuilCl+Ah7zqHoCO0tvzAOmwz4sEoEQO46jhM8vj9E0acX7jFE8qgutJCDsz3Y 3ULWrs4cZ5BQwPsHlxP1Jx3j3hdVNplXWaZkMxN26tOB3Gbgk4HJ3yoXLOAIGFlARtpm mt2icdAf5nr2UYMv89afcB+NLxrA2WAJam6wc40dOv1D/MAu6hepMHWHCpX4JqRoNj6s FdSg== X-Gm-Message-State: APjAAAV42yAuh0w9HvMKBV3JHEv3IaXMjLARfWIxRmGXGnXZr9e3/kGE GqgA2/HeIbttLRrs/frSmKS4LuBsMaDOIg== X-Received: by 2002:adf:e8c8:: with SMTP id k8mr31275776wrn.285.1560428080053; Thu, 13 Jun 2019 05:14:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:39 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:49 +0100 Message-Id: <20190613121433.5246-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PULL 04/48] hw/arm/smmuv3: Fix decoding of ID register range 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The SMMUv3 ID registers cover an area 0x30 bytes in size (12 registers, 4 bytes each). We were incorrectly decoding only the first 0x20 bytes. Signed-off-by: Peter Maydell Reviewed-by: Eric Auger Message-id: 20190524124829.2589-1-peter.maydell@linaro.org --- hw/arm/smmuv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index fd8ec7860ee..e96d5beb9a8 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1232,7 +1232,7 @@ static MemTxResult smmu_readl(SMMUv3State *s, hwaddr offset, uint64_t *data, MemTxAttrs attrs) { switch (offset) { - case A_IDREGS ... A_IDREGS + 0x1f: + case A_IDREGS ... A_IDREGS + 0x2f: *data = smmuv3_idreg(offset - A_IDREGS); return MEMTX_OK; case A_IDR0 ... A_IDR5: From patchwork Thu Jun 13 12:13:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166617 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp700830ilk; Thu, 13 Jun 2019 05:32:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzanaZWyjF8uPFCO7BtY53MSmytQgcKvotrN+ZZjcKVCms8+wKAu3xB7sbLZ27ixBeVdS5m X-Received: by 2002:a0c:8722:: with SMTP id 31mr3285704qvh.164.1560429177995; Thu, 13 Jun 2019 05:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429177; cv=none; d=google.com; s=arc-20160816; b=YedWbRtMMY2CgHrsUTHtlZho0ELzc6+ew4WMDnFjh53hvhFxPLCkUl65i8RhZDJYd1 8DXMUZyHi1hOWjQJrJwHAnq+aIrQcUdrMcVO+RoAnTT+7O0m7kh1whouq6NvXgoyHWcB 4dB2nyn7fB+oTSUl+Z4RptnSoNgJ88Z3/L2WCU/vNUpfAWHx++skNVTIUpQFW2SJHsgv oR8N+AcbtgaR/3GgS3cfyqaHh35o2oev3aiKF+vjJW3X1elxUFOEI9rwNOubPvkVN0i6 /znkKEtkcy1BMTiQItk4RAWTc7wqw1Fprtx6jPDc6tTvoNUA4x+24Vn3Rc+oFNg3wHLO c4eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=bX4hRH4lVhTWXUt9Xxv5/AT7FDCVaSNWnYXS84dsZh8=; b=uHnVAD297qOVNIRmaTIUtSewYjAQj0IWhS9iuaW4JWblypvPL4yGVOglhwDzWgqLgu M/ECotUOfQYj+inBDcMKjD/j63sXmx+mAQ2gima9k42SpHZ5hLBPDQrVnaI19ewnzJ4Z QlecTmp+1a+KbOQZV4UR2yq84gVfk9dMtz69LebaGvejQu3scdcrjjyqP59GvLL+kxig DwzYN+blL6Vj5iljkp7FRkENiMrD/2DU52hrDWG6auypk5ZY+BlmxOxHn7B80UYXeTt7 l8Kc2s/j0JAMAeb4fRz2+00pDx0NP50n42MZP+slpH1uP/bC/p9/4BiM+G5brO3x5x3X U/gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WvAXgAMk; 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=fail (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 w2si1486285qkf.216.2019.06.13.05.32.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:32:57 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=WvAXgAMk; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOuX-0001E1-IK for patch@linaro.org; Thu, 13 Jun 2019 08:32:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58813) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOcz-0007uG-Rg for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOcx-0003zA-Dc for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:49 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:52231) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcv-0003ub-5m for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:45 -0400 Received: by mail-wm1-x343.google.com with SMTP id s3so9965488wms.2 for ; Thu, 13 Jun 2019 05:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bX4hRH4lVhTWXUt9Xxv5/AT7FDCVaSNWnYXS84dsZh8=; b=WvAXgAMkHfkAb0RVlgzGELM/5iiBMiC4eT16/axY8wTQ+6tmguvh7HbrWvUL0i5CQl qlmYHWLcvOr76KlMxLZ1wcp3INz3C6i7dZanzkyxK6rh7neJ+rFMjeKLXXiayElItj7P MvsKe8sXqgdpqkK/oHjTwsDXmB/yYTBtkgey5P5b4Vecyk/fml2UF7ZIS0qWy5zjj118 MP7XnamQ2bYVeTqPfge2/tMtYmwJdXtE3K0xqt6oO0pnnVyNrgp16+7qVlZVmfIVjxDz G85poM9KHZjsW//0VYJRBqhLU3zxBOfE1I9TtwbNbu6VBT/Rhu8736TiB7DQcUZQnXil haqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bX4hRH4lVhTWXUt9Xxv5/AT7FDCVaSNWnYXS84dsZh8=; b=SSxxPFM7mw9zkcbmgzpJHCBvn4LWRF6XFiVK+gPmEqWk80tDUYQKdTP/xNHYRdT/nt jdjmhnjwUFvspzn6i62JmpyUq5Nfpi18Fqo71Qrg2FK7cYBsKa4GPIZR5R2DU6QTgOeK ERWnd/Y81XQj1IkCZHUF2JZMY9Rtsz902hIk7OKhoMfleO7fbV8tjALS+d9NmoLBDbBR h37K5Wgm7haniVsiuuQxgm4pT2G4CrdOCpKKn3VEGN4tr6bpB7da4md4FcotOr6zIwM4 OUratHoIF+cI8jXN4LBibECnsfEgwm6lmN2cYUqDNeVIWvFDBfV89Qs08wky+SxSPaQ8 1ODA== X-Gm-Message-State: APjAAAXwgLaCAnqcfuRrorCMPu8qoE/0DOKJKrgNPQIA70sLJaNzW+Gq Z0IBLimAseUMxMK6cPKbd2evl1sPFSQh/g== X-Received: by 2002:a1c:c907:: with SMTP id f7mr3639072wmb.142.1560428081281; Thu, 13 Jun 2019 05:14:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:50 +0100 Message-Id: <20190613121433.5246-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 05/48] hw/core/bus.c: Only the main system bus can have no parent 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In commit 80376c3fc2c38fdd453 in 2010 we added a workaround for some qbus buses not being connected to qdev devices -- if the bus has no parent object then we register a reset function which resets the bus on system reset (and unregister it when the bus is unparented). Nearly a decade later, we have now no buses in the tree which are created with non-NULL parents, so we can remove the workaround and instead just assert that if the bus has a NULL parent then it is the main system bus. (The absence of other parentless buses was confirmed by code inspection of all the callsites of qbus_create() and qbus_create_inplace() and cross-checked by 'make check'.) Signed-off-by: Peter Maydell Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Damien Hedde Tested-by: Philippe Mathieu-Daudé Message-id: 20190523150543.22676-1-peter.maydell@linaro.org --- hw/core/bus.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) -- 2.20.1 diff --git a/hw/core/bus.c b/hw/core/bus.c index e6baa04e52b..17bc1edcde6 100644 --- a/hw/core/bus.c +++ b/hw/core/bus.c @@ -97,10 +97,9 @@ static void qbus_realize(BusState *bus, DeviceState *parent, const char *name) bus->parent->num_child_bus++; object_property_add_child(OBJECT(bus->parent), bus->name, OBJECT(bus), NULL); object_unref(OBJECT(bus)); - } else if (bus != sysbus_get_default()) { - /* TODO: once all bus devices are qdevified, - only reset handler for main_system_bus should be registered here. */ - qemu_register_reset(qbus_reset_all_fn, bus); + } else { + /* The only bus without a parent is the main system bus */ + assert(bus == sysbus_get_default()); } } @@ -109,18 +108,16 @@ static void bus_unparent(Object *obj) BusState *bus = BUS(obj); BusChild *kid; + /* Only the main system bus has no parent, and that bus is never freed */ + assert(bus->parent); + while ((kid = QTAILQ_FIRST(&bus->children)) != NULL) { DeviceState *dev = kid->child; object_unparent(OBJECT(dev)); } - if (bus->parent) { - QLIST_REMOVE(bus, sibling); - bus->parent->num_child_bus--; - bus->parent = NULL; - } else { - assert(bus != sysbus_get_default()); /* main_system_bus is never freed */ - qemu_unregister_reset(qbus_reset_all_fn, bus); - } + QLIST_REMOVE(bus, sibling); + bus->parent->num_child_bus--; + bus->parent = NULL; } void qbus_create_inplace(void *bus, size_t size, const char *typename, From patchwork Thu Jun 13 12:13:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166610 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp685721ilk; Thu, 13 Jun 2019 05:18:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPDJedrQbr72bLMOmn+bu6ffdTap9y3EQy8DFD5pSod6VukMZaQMSS8fLMhARw9+UgHWB0 X-Received: by 2002:a37:8fc4:: with SMTP id r187mr11978594qkd.113.1560428305022; Thu, 13 Jun 2019 05:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560428305; cv=none; d=google.com; s=arc-20160816; b=ip9H6zWq4eF4W9AT7Kt/pLeO+eB2Sdsv0z9RRWoXNsJW1TV+wwfDypI/nkntDE4dFs IE0PCA8LsJgzQ2xDz8ulNMTNm2JjnwCnyEdFuvl7B4UJ8CDXQfABXZfTyOUSWyJu2Neq 80zhS5zRUCoj9M5QtloH6cbJ7Tp6biXjqxXRHWrAuo40GHKSi2Yt2j2MMYg4idQYdMTa VhAMmg26ZrpDbip1dEjOv/NfCP3omBTMDYOXfjNBw34xReTHekSYkIcdEu7EGSn7MbQ4 Gput8hqY+uf0OZh56GRlpgRpUkWVgi/r0++L/yokQD6prU7gwdACgGQAo5Z4btLXBYe8 6Utg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=jlXFJdoAtBcsrDt+RzPH/+cxhZKjIl45SfiQerQen7Q=; b=ZEgyecCiGZp9Oel1qCjI+Ly2shCTBDvWtruuxuJ2T3QPUAtFQ93yXRFGdDNkz5FpAg dxdfl7u+tzP3Kxjc1IbAr19KCt5HuR019zTrCN8nR2QpA0jYAJU9wEdqFKTcxQ7hc+fe wjHYc2n7P/YpuDnWbRZ8a0563smzWja2TMJJIH2yJXNBV2NQwcYuWO2d13JqFenDGZbW 0Zi0Jgdq8mlutop7/7/svvoOKY6uP4tIRzhZaUyv8uBgKMYfWoxV8c42tOlTTIiXyMCZ Tx3yYZCGw5sjd9NkgmZscwJq7FZviGMotOVOwtjxR0JDhJqzVV1zB/SrOqGIe35C/7eQ 9Uvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bz3uCyd+; 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=fail (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 f6si1526026qkm.111.2019.06.13.05.18.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:18:25 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=bz3uCyd+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39352 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOgS-0007uq-Cn for patch@linaro.org; Thu, 13 Jun 2019 08:18:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58777) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOcx-0007tl-I3 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOcv-0003xm-B7 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:47 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:38642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcv-0003v1-39 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:45 -0400 Received: by mail-wr1-x443.google.com with SMTP id d18so20520750wrs.5 for ; Thu, 13 Jun 2019 05:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=jlXFJdoAtBcsrDt+RzPH/+cxhZKjIl45SfiQerQen7Q=; b=bz3uCyd+MZGkEPqrwRWvQ7NPvDO1qqBasx/hS1DLa4Oy3XxwuNOZdEhqgq8V9SugnN W0M9psU3QZNedPZ9B3Ga8Ytar4fQnNoHawResRMyfVvpabH/j5xOjp6nQYqIG0iTJfOc nd4Gy2v2EWWwbFpa3sLOX8d7ZCq0afwfwsmpjhkquTkm5a3lKXk3QDaipz0OkfTjaoLR m7YdkmKU8CacDmd2UskiqcB0MyDj54CYrWtb5T4fzgtafPMVU6Av7fA47mbZsDeUQWU+ bZLTdwkoCytsxQiPJjeg1E61ryxozTh3hfmI9/51c3xu6l6z9JnwhmVopthku/sbEM30 gX7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jlXFJdoAtBcsrDt+RzPH/+cxhZKjIl45SfiQerQen7Q=; b=pNr93u7MXrBJVH+hJZDVtb9FbLrSptkneP6zQaDMGdMZnBLFkqbR1HXUaVumRpmmbn O3qJKPHQDUducNmM2lM52+yGqBjFDAqfSAU3KSZSn6J0u4rOUnN3XgNoZV0dwk/8aMxv 1fVPxd8NPybObEUaJoJMBzW1DCL5y+Xv/PA+zC5ILX6LacarpuHOWEzBO0kiq05IYztu 1cusYk+BR+IzbNscZlZPLKhLx0dDJ3Dz0UB/SLnTrn0Ee1PE03KOjqQvN61A5VaELLMn uz9Q+RUF0P4G6MG/lFkztQerN7TJz3RPg/WzPBkTPg5bRsA5s8s6fd5xjkBFM5tweGKw g9Ig== X-Gm-Message-State: APjAAAUdlAsQJ2RReHfPLwQy9nxnpq9HMKSZqDXqimL9qrWCAfj78HEO Cb0/M7cvEuxMKgfbjhpPuVvjWtSuKtZ8LQ== X-Received: by 2002:a5d:5089:: with SMTP id a9mr2459600wrt.290.1560428082247; Thu, 13 Jun 2019 05:14:42 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:41 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:51 +0100 Message-Id: <20190613121433.5246-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 06/48] target/arm: Fix output of PAuth Auth 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The ARM pseudocode installs the error_code into the original pointer, not the encrypted pointer. The difference applies within the 7 bits of pac data; the result should be the sign extension of bit 55. Add a testcase to that effect. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- tests/tcg/aarch64/Makefile.target | 2 +- target/arm/pauth_helper.c | 4 +- tests/tcg/aarch64/pauth-2.c | 61 +++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tests/tcg/aarch64/pauth-2.c -- 2.20.1 diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 2bb914975be..31ba9cfcaa1 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -15,7 +15,7 @@ run-fcvt: fcvt $(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)") $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref) -AARCH64_TESTS += pauth-1 +AARCH64_TESTS += pauth-1 pauth-2 run-pauth-%: QEMU += -cpu max TESTS:=$(AARCH64_TESTS) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index 7f30ae7395e..d3194f20437 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -344,9 +344,9 @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { int error_code = (keynumber << 1) | (keynumber ^ 1); if (param.tbi) { - return deposit64(ptr, 53, 2, error_code); + return deposit64(orig_ptr, 53, 2, error_code); } else { - return deposit64(ptr, 61, 2, error_code); + return deposit64(orig_ptr, 61, 2, error_code); } } return orig_ptr; diff --git a/tests/tcg/aarch64/pauth-2.c b/tests/tcg/aarch64/pauth-2.c new file mode 100644 index 00000000000..2fe030ba3da --- /dev/null +++ b/tests/tcg/aarch64/pauth-2.c @@ -0,0 +1,61 @@ +#include +#include + +asm(".arch armv8.4-a"); + +void do_test(uint64_t value) +{ + uint64_t salt1, salt2; + uint64_t encode, decode; + + /* + * With TBI enabled and a 48-bit VA, there are 7 bits of auth, + * and so a 1/128 chance of encode = pac(value,key,salt) producing + * an auth for which leaves value unchanged. + * Iterate until we find a salt for which encode != value. + */ + for (salt1 = 1; ; salt1++) { + asm volatile("pacda %0, %2" : "=r"(encode) : "0"(value), "r"(salt1)); + if (encode != value) { + break; + } + } + + /* A valid salt must produce a valid authorization. */ + asm volatile("autda %0, %2" : "=r"(decode) : "0"(encode), "r"(salt1)); + assert(decode == value); + + /* + * An invalid salt usually fails authorization, but again there + * is a chance of choosing another salt that works. + * Iterate until we find another salt which does fail. + */ + for (salt2 = salt1 + 1; ; salt2++) { + asm volatile("autda %0, %2" : "=r"(decode) : "0"(encode), "r"(salt2)); + if (decode != value) { + break; + } + } + + /* The VA bits, bit 55, and the TBI bits, should be unchanged. */ + assert(((decode ^ value) & 0xff80ffffffffffffull) == 0); + + /* + * Bits [54:53] are an error indicator based on the key used; + * the DA key above is keynumber 0, so error == 0b01. Otherwise + * bit 55 of the original is sign-extended into the rest of the auth. + */ + if ((value >> 55) & 1) { + assert(((decode >> 48) & 0xff) == 0b10111111); + } else { + assert(((decode >> 48) & 0xff) == 0b00100000); + } +} + +int main() +{ + do_test(0); + do_test(-1); + do_test(0xda004acedeadbeefull); + return 0; +} From patchwork Thu Jun 13 12:13:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166614 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp695006ilk; Thu, 13 Jun 2019 05:27:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqybU3HtSDL72mW/6vAlI1qU8fHK5KpbdCSv/UNS4hyX84z2MILfucxaAmAtgvfb7pgqV2t8 X-Received: by 2002:a0c:bd18:: with SMTP id m24mr3326594qvg.118.1560428845325; Thu, 13 Jun 2019 05:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560428845; cv=none; d=google.com; s=arc-20160816; b=G5kqZLIhBR8xtLQwugmve7+rpPXo0TBvVZWF/omagZWuZDNpky3VJZKLx73FN+eLSU 0DUMKE809jKoUsLE5giRMM9LkX/16FGPPDv/Ud+6bxEKv6pQh3OyZIiL/JkVuDiLE6+r oRHB6d53k1jgBobTzRKtRCJQ+Zavl29aQAVKH5K8WSR+xqB6jvl03UArkqnJBPIxL0fd vP0QM+HgTKTKaETcosxB5RpZJnMscXd9jPMKWqvLwMASpTKcZtwvbiZSQmngoHfDSsKM TDBaAz8PE1MMonsf0Kjlv3b4KaVBk5DSMexuJ70HA5fejJFy8Al61MJvwg0dB/HgcnFq JiVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=A6zB6s48Mdps2LC1th7zZyg8f6vSOggdH9q3F9SoDps=; b=rBAL5D3mepYaqFjrTgItmIfZHwMrnqJ5bkth4HfWPwxexxM64+cC8SeQofm+l94VcF zVHiMBi8XDX/TSvCPfS9BPsox7Ii5qmjyCkTs6XL3z86emVljpWyM4BVYXS47LO6PmcB E1scQEmkUW2oMtegZuH47nd0Gc0c+QSd2Cc2agRnD+Xse/lFm0ObtZKete0thuQczHnw WVruZDcMFMHCcy2/Kjg1TP4sdhIYaCJx3XE0WopVAaFRjtsTRvLhkGQ8k76Sq3BKz0Dl IokdCj5JS5wujQyUn8FOk28dMSghj4y27qMko6gj7DCvQ0PW3TyR1oGZ2zY8zmpC3oqP gb8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GqddfPVK; 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=fail (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 53si1779500qtx.195.2019.06.13.05.27.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:27:25 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=GqddfPVK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOpA-0005KE-Sg for patch@linaro.org; Thu, 13 Jun 2019 08:27:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58811) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOcz-0007uF-RP for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOcx-0003zF-Do for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:49 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:32989) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcv-0003wG-63 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:45 -0400 Received: by mail-wr1-x431.google.com with SMTP id n9so20572366wru.0 for ; Thu, 13 Jun 2019 05:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=A6zB6s48Mdps2LC1th7zZyg8f6vSOggdH9q3F9SoDps=; b=GqddfPVKPAImuE+nN8zpYvXcatzOSLgJqFUAadSshC0ahGORjGzEM1fSizt+Hp629B eoN/4Wu26fgJmYlJ8ZnngfduwZOp1EKPafuiJO5uc3GxHQLwc9P9bAwCf6Da2ntuXA9V 2KAkuj4ymP9ivFVJ3PE9aw8a/EwGJTYS1NxJfyhMjR+nKttessRpBZEYOza/byEb2W4A TMogiNOLHQftGc0c5H+djmRndyVhHOu2w0ZBwuT1LOoI+fP6LQb2oppPnPKAxHJJ4BM+ DByE+Fa3b0cpnljXUbc5uJBjXZ0vA59z3881W06dFSW6aUWZ0vkMVgL5kT3MQ8CPoboK sxQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A6zB6s48Mdps2LC1th7zZyg8f6vSOggdH9q3F9SoDps=; b=WmKeiDbm9i7n/iUNM2F+fF8WLoASW8yB9Pn/rFq7viBTJDDD+s6BDSzrW1hZHB+fvJ dAvFICnqhyHfbLLNrDXQ1NDEL0ETkPhBD6cCCOzN3VGV/u8pjDbBE/YioboHTnizbTc9 wdSHT5NUcnTP90CVSooyBbQxUPjvN9LbQMPGyAYRNtF1xU/87wx4MM89zpQSm3fB47se eJJo2Ar0hydtZRmmjTDUO7XJ1Vi2/B8xI0tt7nuoFnQOnxMAv9hXLVCIiTwbMLjjWAn7 nkJgl15bf0jZFeof1zL5pxk8fBfnvaGxthT77ObQKDC2iU+cBO2oj8k8JGZXJhI0xR2y 142A== X-Gm-Message-State: APjAAAXD5WzUmFqmERYbZpZrozlkQyeVrYV29Rij6WQwwtRFQa848f15 hhoS25zK1VO5Ry3cSmT2FTKgjoVe3x8pTw== X-Received: by 2002:adf:9cd0:: with SMTP id h16mr42664147wre.211.1560428083050; Thu, 13 Jun 2019 05:14:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:52 +0100 Message-Id: <20190613121433.5246-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 Subject: [Qemu-devel] [PULL 07/48] decodetree: Fix comparison of Field 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Typo comparing the sign of the field, twice, instead of also comparing the mask of the field (which itself encodes both position and length). Reported-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20190604154225.26992-1-richard.henderson@linaro.org Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Peter Maydell --- scripts/decodetree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 81874e22cc7..d7a59d63ac3 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -184,7 +184,7 @@ class Field: return '{0}(insn, {1}, {2})'.format(extr, self.pos, self.len) def __eq__(self, other): - return self.sign == other.sign and self.sign == other.sign + return self.sign == other.sign and self.mask == other.mask def __ne__(self, other): return not self.__eq__(other) From patchwork Thu Jun 13 12:13:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166611 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp685791ilk; Thu, 13 Jun 2019 05:18:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOXfq9gGZ5kUa+2YPFH9XbL/COeWRlMHxoMNXJ+5qPcNWRKqUdwjegZdy4M2cE70U4fEjZ X-Received: by 2002:ae9:ebd1:: with SMTP id b200mr71389108qkg.152.1560428308275; Thu, 13 Jun 2019 05:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560428308; cv=none; d=google.com; s=arc-20160816; b=FU/uzRLfQlANxCjREoK13txAtdKX/o7gBU6+ej9RPEL4xP/nNn5oTvCzmOoHy6y9aY R4Kpg4yUFj0k2TYIpic1qDaBKKnLnn1T2vDaDfhhrM3ZNIy6jOsbAxR8SJE8LuITU7+A i8XBj6e+dHsA62FAOSj4xFy+zrk8zUc8stDjNBN0duDpQG1tzBox+xkD1wdUsVAFtrKC WiK8zv5WI/eDxYHcrCG5eAEr31YzVyVZWIUsmMzAS9LwYAqLkLK6x2hdeR7IaAqQthzH dwhcKFkIzo5+gAmhBTQk6K8Y+a3tnBukl1ivC/bmgzM2UHOxhFZyiyMSe6Cakok4B2ll ya3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=k2MYwgAzYIN1OzgZk9hyeAfnDdny0N8Q/YN/4clJftg=; b=a7o/pyINbJUMk0Hk4YnSfj5cvPZOWJxq61GZty25BrzKrv03t3R/AnAwWSsNrlRuWK zLMmqpRHTjfYYAJN3+yVLijvtJiBIQslUqoIrm5LxA20okMDfkDo86YT5/241tkdX3Bo OGdhEPqFx4fK/sgIVb6GYziLmzwM9JwfFQQZzLC+Jyis3z8iSOaIl+Bx4Dj7ao0lEwHG vwWECVMcaIjYeg1vkX1budALA7CTAZ5ZSL7W5DvSR66vkFeNBQReLa4dHTS9JtV1g17f /S5TuKKqQKB1MK01B657waSKWe8SvQslbVJ24g5TahLcTK7KUCJQ7dpPJe8VZD369s0P bxLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d7FshUkm; 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=fail (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 q71si1623485qke.210.2019.06.13.05.18.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:18:28 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=d7FshUkm; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOgV-00083a-Nj for patch@linaro.org; Thu, 13 Jun 2019 08:18:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58863) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOd8-0007ur-8b for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOcz-00041A-RM for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:53 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:51222) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcx-0003xN-JU for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:49 -0400 Received: by mail-wm1-x343.google.com with SMTP id 207so2080614wma.1 for ; Thu, 13 Jun 2019 05:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=k2MYwgAzYIN1OzgZk9hyeAfnDdny0N8Q/YN/4clJftg=; b=d7FshUkmQoCrAlSRIpEl0eFJ9KgiHL/fMYGUuovmwrRXkgGDSFvhBu2/Lxqgrfjymo G2UiTmnHJ2ClAssTWvLB+TL6jnlLRhs6SBcuuF+1Ug3ZfjoRDCdCOYwrPja+/T857mvT LLLj50qAKe/ma2aPyXsm9bbgpZdo053+b7WgF0hxMrjumdwqen18wTicUaVP8ZjMm3b2 TvloV3RYOYyTQO1sagKy1UWHziYbQ7G/BIT3aDtCBrrqaJg4BTetIHaExZCUTYkWwGOB AHNXLJjtcSJsmqykUG9rnULVgIbKld3p7JQ4HMWgPQIu1v7vxBptvUWYZ5R8Q6rYi8ZB m7RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k2MYwgAzYIN1OzgZk9hyeAfnDdny0N8Q/YN/4clJftg=; b=DrcuAhSoOtcWI3TfwOE5i/jou97pJbzg7B/HeWcch2/5dcwxuYOpyRbTF+T6euQ7ex THxh5DIghfhLPm59K35l9xIyz1LoyaITSL/9ZVtcaOmB2iwtz7hu6IOruneY0Atj2QXt FFMlCpYfC7Vzw2K4dECv+jF1rRvw78FvAQ4WnFzDxsxMkUaaCmRtDRqrpSb7c7iOx/xi QVcajKuJZ4mK8e8KnTx5Wjnx1ojuef4Kp3rFJn5BiwFqqs3SKoP2mP5zCxmdnZ3i7P// Uyp5kephO06WZGTiO5nb+Agr2F/faT7H93dVkC6bOWfLuHJ5ViSbE8lv5BIT0vTC91fM txTQ== X-Gm-Message-State: APjAAAWzLE7uyhzZHueMVD4pPiBTs0H6/GzVcJ1DJa9NNM4BSa1pZwqm abXQlaXZzGkn4pd72b9nODM6IP2uU6wZVw== X-Received: by 2002:a7b:cbc6:: with SMTP id n6mr3751356wmi.14.1560428084082; Thu, 13 Jun 2019 05:14:44 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:43 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:53 +0100 Message-Id: <20190613121433.5246-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 08/48] target/arm: Add stubs for AArch32 VFP decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add the infrastructure for building and invoking a decodetree decoder for the AArch32 VFP encodings. At the moment the new decoder covers nothing, so we always fall back to the existing hand-written decode. We need to have one decoder for the unconditional insns and one for the conditional insns, as otherwise the patterns for conditional insns would incorrectly match against the unconditional ones too. Since translate.c is over 14,000 lines long and we're going to be touching pretty much every line of the VFP code as part of the decodetree conversion, we create a new translate-vfp.inc.c to hold the code which deals with VFP in the new scheme. It should be possible to convert this into a standalone translation unit eventually, but the conversion process will be much simpler if we simply #include it midway through translate.c to start with. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/Makefile.objs | 13 +++++++++++++ target/arm/translate-vfp.inc.c | 31 +++++++++++++++++++++++++++++++ target/arm/translate.c | 19 +++++++++++++++++++ target/arm/vfp-uncond.decode | 28 ++++++++++++++++++++++++++++ target/arm/vfp.decode | 28 ++++++++++++++++++++++++++++ 5 files changed, 119 insertions(+) create mode 100644 target/arm/translate-vfp.inc.c create mode 100644 target/arm/vfp-uncond.decode create mode 100644 target/arm/vfp.decode -- 2.20.1 diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs index 6bdcc65c2c8..dfa736a3752 100644 --- a/target/arm/Makefile.objs +++ b/target/arm/Makefile.objs @@ -19,5 +19,18 @@ target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE) $(PYTHON) $(DECODETREE) --decode disas_sve -o $@ $<,\ "GEN", $(TARGET_DIR)$@) +target/arm/decode-vfp.inc.c: $(SRC_PATH)/target/arm/vfp.decode $(DECODETREE) + $(call quiet-command,\ + $(PYTHON) $(DECODETREE) --static-decode disas_vfp -o $@ $<,\ + "GEN", $(TARGET_DIR)$@) + +target/arm/decode-vfp-uncond.inc.c: $(SRC_PATH)/target/arm/vfp-uncond.decode $(DECODETREE) + $(call quiet-command,\ + $(PYTHON) $(DECODETREE) --static-decode disas_vfp_uncond -o $@ $<,\ + "GEN", $(TARGET_DIR)$@) + target/arm/translate-sve.o: target/arm/decode-sve.inc.c +target/arm/translate.o: target/arm/decode-vfp.inc.c +target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c + obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c new file mode 100644 index 00000000000..3447b3e6466 --- /dev/null +++ b/target/arm/translate-vfp.inc.c @@ -0,0 +1,31 @@ +/* + * ARM translation: AArch32 VFP instructions + * + * Copyright (c) 2003 Fabrice Bellard + * Copyright (c) 2005-2007 CodeSourcery + * Copyright (c) 2007 OpenedHand, Ltd. + * Copyright (c) 2019 Linaro, Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * This file is intended to be included from translate.c; it uses + * some macros and definitions provided by that file. + * It might be possible to convert it to a standalone .c file eventually. + */ + +/* Include the generated VFP decoder */ +#include "decode-vfp.inc.c" +#include "decode-vfp-uncond.inc.c" diff --git a/target/arm/translate.c b/target/arm/translate.c index ab3026664af..c97e6c8238c 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1727,6 +1727,9 @@ static inline void gen_mov_vreg_F0(int dp, int reg) #define ARM_CP_RW_BIT (1 << 20) +/* Include the VFP decoder */ +#include "translate-vfp.inc.c" + static inline void iwmmxt_load_reg(TCGv_i64 var, int reg) { tcg_gen_ld_i64(var, cpu_env, offsetof(CPUARMState, iwmmxt.regs[reg])); @@ -3384,6 +3387,22 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; } + /* + * If the decodetree decoder handles this insn it will always + * emit code to either execute the insn or generate an appropriate + * exception; so we don't need to ever return non-zero to tell + * the calling code to emit an UNDEF exception. + */ + if (extract32(insn, 28, 4) == 0xf) { + if (disas_vfp_uncond(s, insn)) { + return 0; + } + } else { + if (disas_vfp(s, insn)) { + return 0; + } + } + /* FIXME: this access check should not take precedence over UNDEF * for invalid encodings; we will generate incorrect syndrome information * for attempts to execute invalid vfp/neon encodings with FP disabled. diff --git a/target/arm/vfp-uncond.decode b/target/arm/vfp-uncond.decode new file mode 100644 index 00000000000..b1d9dc507c2 --- /dev/null +++ b/target/arm/vfp-uncond.decode @@ -0,0 +1,28 @@ +# AArch32 VFP instruction descriptions (unconditional insns) +# +# Copyright (c) 2019 Linaro, Ltd +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see . + +# +# This file is processed by scripts/decodetree.py +# +# Encodings for the unconditional VFP instructions are here: +# generally anything matching A32 +# 1111 1110 .... .... .... 101. ...0 .... +# and T32 +# 1111 110. .... .... .... 101. .... .... +# 1111 1110 .... .... .... 101. .... .... +# (but those patterns might also cover some Neon instructions, +# which do not live in this file.) diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode new file mode 100644 index 00000000000..28ee664d8c3 --- /dev/null +++ b/target/arm/vfp.decode @@ -0,0 +1,28 @@ +# AArch32 VFP instruction descriptions (conditional insns) +# +# Copyright (c) 2019 Linaro, Ltd +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see . + +# +# This file is processed by scripts/decodetree.py +# +# Encodings for the conditional VFP instructions are here: +# generally anything matching A32 +# cccc 11.. .... .... .... 101. .... .... +# and T32 +# 1110 110. .... .... .... 101. .... .... +# 1110 1110 .... .... .... 101. .... .... +# (but those patterns might also cover some Neon instructions, +# which do not live in this file.) From patchwork Thu Jun 13 12:13:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166621 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp705636ilk; Thu, 13 Jun 2019 05:37:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJLZEJgvh3bWMCGHFDoQFn/PPdOhQPyGNiUNpMU+VaZ03sRyXzV4KudyWiEuRang+HlXXq X-Received: by 2002:ac8:3014:: with SMTP id f20mr75580041qte.69.1560429442409; Thu, 13 Jun 2019 05:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429442; cv=none; d=google.com; s=arc-20160816; b=VTqV3Y9QGLvY9TPSwXEKDL7p8KfEFvX/ocB9BU7g+HnudJzw+VvqZReYSG9PJP7UiS oFLhSYbpvi72gA8cXO+jcaPPznIfGGPWZmltMEZp259RQ1zOhayyLEJIyV1Bfv9SVkPh 1aP6aZo/D8f7wmM1g6eQcYHDqySfWuNNgiyIqcLji95YdflLQeo50r3ESjUg46LhJ6bF nSkv0nBlj+WxEeFWIBjWMtPnGZZs3yVTc2ITF7QB+CAQ6KSSzsFXUZhEuyC+hYSwsrB6 /JzkpgG6/bLvUPimGPvbNgDPd2qnDi0BlfjgeU3rJ0/7kEnpFMltebBn0gjLq7sgw6oN SiRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=xm/iU+FgN2/ONIM2BO5fUGTM2YKGKHisYFdgV1PLSxQ=; b=tVNKf0zhXXzGq4ypTRX4t6zZtI+jKv//3PMOSBaoheVQconZrDEmC90irr60iX4cHY rH1SK67kbZDtaPGDVCcj9SISt1DyO9MsQ6Aj/Ak1fUywlfQu2Urizjl16JN1vJSKTS5E XnGJuO79WcWxo7BOaQwWWWSLjr65fgYy4r0mymF4QEoYMMw8kFy5huOwygSviV9AOYvl ChjJwTsCt2hjCHXvf1FbGj47Zun/WUQ6JQJnkEjPhsmmhdSE3Lhe2X5x7oXpPtkAWnrC z8E6pC+RVKuDCIl8ABUEiUF57i7qUtTCQpkC/9u1GT4v6EX963G80uHRnQaK3h68i8y/ YC0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=plQQM5AM; 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=fail (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 z53si1766591qtz.218.2019.06.13.05.37.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:37:22 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=plQQM5AM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOyn-0005IT-Vm for patch@linaro.org; Thu, 13 Jun 2019 08:37:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58882) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOd9-0007uw-Vf for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOd6-00048w-1f for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:59 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:41389) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcz-0003xx-Rz for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:51 -0400 Received: by mail-wr1-x42e.google.com with SMTP id c2so20519541wrm.8 for ; Thu, 13 Jun 2019 05:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xm/iU+FgN2/ONIM2BO5fUGTM2YKGKHisYFdgV1PLSxQ=; b=plQQM5AMHPTB2i5WNwtYosR6gEn3bHIZ20VeQWe6OdZojn5NmaefqLb6JgfK9otf69 0hccDmcn/HRTIMKvnTojtwKdCgU3EvOIijBaC+Stc20ilIsH2aLue3jsXWQ9XGHlaVUN d81hmtWWCQdgYXJcrLoQp88hHKzJ3JQmp8DBlVR68jzlWEOBxApDPuZ98jw0kpvWLD1X 4+9U1ZGMz5xSbIFeou8IOBZ9k8BbYEYMsureBp8Qpdq5TMdYdPAA7Npe1cusy3k33bD7 sHKA4P9XVnOSuthxVPQSbOtLTrW4LvUmSsE0j2AHbyungjDNKFBLDM6bx8pN+guSTHiR 4ByQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xm/iU+FgN2/ONIM2BO5fUGTM2YKGKHisYFdgV1PLSxQ=; b=qLaZIn4T2K1Qez/8UZhiDYfLz5xGLdjPUfLU+VvPz84tAViaEPTtiuoOaJUZIcTMAS BppGyYBwhNEe4XT2D0VDo9rV5gjsOgvA2BodCkgDdZjSew8I6EMFDDehWZ3RFV7bqPbk GRRQtt756PkzygasGJmIXau8CX421HWPtolO2nX151Ct3OfIl3RY+VINof1DWMLUcGV4 Oa6BEB3oXJBC42od0BkWppOhRwPNGCs7TXcaM1DPlu1l4eQQMlUqB6lpvXqAANZfvQiA HPMfaZ1dEAW0u1SnzYuPxUhU7yTaZG4EI85Tx18o41vy+hLXDoGI/oa9OJ5lB8bJoKjC R4Pg== X-Gm-Message-State: APjAAAXiYr3kdoWdtiaN6Z3DoZmXCuNzzSU1JiHqUz9PAl/7SiDK9nuH VN4ps6SeDaquuKS95aiPD0dBPyOHhmUwHA== X-Received: by 2002:a5d:5186:: with SMTP id k6mr45556426wrv.30.1560428085052; Thu, 13 Jun 2019 05:14:45 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:44 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:54 +0100 Message-Id: <20190613121433.5246-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e Subject: [Qemu-devel] [PULL 09/48] target/arm: Factor out VFP access checking code 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Factor out the VFP access checking code so that we can use it in the leaf functions of the decodetree decoder. We call the function full_vfp_access_check() so we can keep the more natural vfp_access_check() for a version which doesn't have the 'ignore_vfp_enabled' flag -- that way almost all VFP insns will be able to use vfp_access_check(s) and only the special-register access function will have to use full_vfp_access_check(s, ignore_vfp_enabled). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 100 ++++++++++++++++++++++++++++++++ target/arm/translate.c | 101 +++++---------------------------- 2 files changed, 113 insertions(+), 88 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 3447b3e6466..cf3d7febaa7 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -29,3 +29,103 @@ /* Include the generated VFP decoder */ #include "decode-vfp.inc.c" #include "decode-vfp-uncond.inc.c" + +/* + * Check that VFP access is enabled. If it is, do the necessary + * M-profile lazy-FP handling and then return true. + * If not, emit code to generate an appropriate exception and + * return false. + * The ignore_vfp_enabled argument specifies that we should ignore + * whether VFP is enabled via FPEXC[EN]: this should be true for FMXR/FMRX + * accesses to FPSID, FPEXC, MVFR0, MVFR1, MVFR2, and false for all other insns. + */ +static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) +{ + if (s->fp_excp_el) { + if (arm_dc_feature(s, ARM_FEATURE_M)) { + gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), + s->fp_excp_el); + } else { + gen_exception_insn(s, 4, EXCP_UDEF, + syn_fp_access_trap(1, 0xe, false), + s->fp_excp_el); + } + return false; + } + + if (!s->vfp_enabled && !ignore_vfp_enabled) { + assert(!arm_dc_feature(s, ARM_FEATURE_M)); + gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), + default_exception_el(s)); + return false; + } + + if (arm_dc_feature(s, ARM_FEATURE_M)) { + /* Handle M-profile lazy FP state mechanics */ + + /* Trigger lazy-state preservation if necessary */ + if (s->v7m_lspact) { + /* + * Lazy state saving affects external memory and also the NVIC, + * so we must mark it as an IO operation for icount. + */ + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { + gen_io_start(); + } + gen_helper_v7m_preserve_fp_state(cpu_env); + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { + gen_io_end(); + } + /* + * If the preserve_fp_state helper doesn't throw an exception + * then it will clear LSPACT; we don't need to repeat this for + * any further FP insns in this TB. + */ + s->v7m_lspact = false; + } + + /* Update ownership of FP context: set FPCCR.S to match current state */ + if (s->v8m_fpccr_s_wrong) { + TCGv_i32 tmp; + + tmp = load_cpu_field(v7m.fpccr[M_REG_S]); + if (s->v8m_secure) { + tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK); + } else { + tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK); + } + store_cpu_field(tmp, v7m.fpccr[M_REG_S]); + /* Don't need to do this for any further FP insns in this TB */ + s->v8m_fpccr_s_wrong = false; + } + + if (s->v7m_new_fp_ctxt_needed) { + /* + * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA + * and the FPSCR. + */ + TCGv_i32 control, fpscr; + uint32_t bits = R_V7M_CONTROL_FPCA_MASK; + + fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]); + gen_helper_vfp_set_fpscr(cpu_env, fpscr); + tcg_temp_free_i32(fpscr); + /* + * We don't need to arrange to end the TB, because the only + * parts of FPSCR which we cache in the TB flags are the VECLEN + * and VECSTRIDE, and those don't exist for M-profile. + */ + + if (s->v8m_secure) { + bits |= R_V7M_CONTROL_SFPA_MASK; + } + control = load_cpu_field(v7m.control[M_REG_S]); + tcg_gen_ori_i32(control, control, bits); + store_cpu_field(control, v7m.control[M_REG_S]); + /* Don't need to do this for any further FP insns in this TB */ + s->v7m_new_fp_ctxt_needed = false; + } + } + + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index c97e6c8238c..f7720922c75 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3373,8 +3373,10 @@ static int disas_vfp_misc_insn(DisasContext *s, uint32_t insn) return 1; } -/* Disassemble a VFP instruction. Returns nonzero if an error occurred - (ie. an undefined instruction). */ +/* + * Disassemble a VFP instruction. Returns nonzero if an error occurred + * (ie. an undefined instruction). + */ static int disas_vfp_insn(DisasContext *s, uint32_t insn) { uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask; @@ -3382,6 +3384,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) TCGv_i32 addr; TCGv_i32 tmp; TCGv_i32 tmp2; + bool ignore_vfp_enabled = false; if (!arm_dc_feature(s, ARM_FEATURE_VFP)) { return 1; @@ -3403,98 +3406,20 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) } } - /* FIXME: this access check should not take precedence over UNDEF + /* + * FIXME: this access check should not take precedence over UNDEF * for invalid encodings; we will generate incorrect syndrome information * for attempts to execute invalid vfp/neon encodings with FP disabled. */ - if (s->fp_excp_el) { - if (arm_dc_feature(s, ARM_FEATURE_M)) { - gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), - s->fp_excp_el); - } else { - gen_exception_insn(s, 4, EXCP_UDEF, - syn_fp_access_trap(1, 0xe, false), - s->fp_excp_el); - } - return 0; - } - - if (!s->vfp_enabled) { - /* VFP disabled. Only allow fmxr/fmrx to/from some control regs. */ - if ((insn & 0x0fe00fff) != 0x0ee00a10) - return 1; + if ((insn & 0x0fe00fff) == 0x0ee00a10) { rn = (insn >> 16) & 0xf; - if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC && rn != ARM_VFP_MVFR2 - && rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0) { - return 1; + if (rn == ARM_VFP_FPSID || rn == ARM_VFP_FPEXC || rn == ARM_VFP_MVFR2 + || rn == ARM_VFP_MVFR1 || rn == ARM_VFP_MVFR0) { + ignore_vfp_enabled = true; } } - - if (arm_dc_feature(s, ARM_FEATURE_M)) { - /* Handle M-profile lazy FP state mechanics */ - - /* Trigger lazy-state preservation if necessary */ - if (s->v7m_lspact) { - /* - * Lazy state saving affects external memory and also the NVIC, - * so we must mark it as an IO operation for icount. - */ - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_start(); - } - gen_helper_v7m_preserve_fp_state(cpu_env); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } - /* - * If the preserve_fp_state helper doesn't throw an exception - * then it will clear LSPACT; we don't need to repeat this for - * any further FP insns in this TB. - */ - s->v7m_lspact = false; - } - - /* Update ownership of FP context: set FPCCR.S to match current state */ - if (s->v8m_fpccr_s_wrong) { - TCGv_i32 tmp; - - tmp = load_cpu_field(v7m.fpccr[M_REG_S]); - if (s->v8m_secure) { - tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK); - } else { - tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK); - } - store_cpu_field(tmp, v7m.fpccr[M_REG_S]); - /* Don't need to do this for any further FP insns in this TB */ - s->v8m_fpccr_s_wrong = false; - } - - if (s->v7m_new_fp_ctxt_needed) { - /* - * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA - * and the FPSCR. - */ - TCGv_i32 control, fpscr; - uint32_t bits = R_V7M_CONTROL_FPCA_MASK; - - fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]); - gen_helper_vfp_set_fpscr(cpu_env, fpscr); - tcg_temp_free_i32(fpscr); - /* - * We don't need to arrange to end the TB, because the only - * parts of FPSCR which we cache in the TB flags are the VECLEN - * and VECSTRIDE, and those don't exist for M-profile. - */ - - if (s->v8m_secure) { - bits |= R_V7M_CONTROL_SFPA_MASK; - } - control = load_cpu_field(v7m.control[M_REG_S]); - tcg_gen_ori_i32(control, control, bits); - store_cpu_field(control, v7m.control[M_REG_S]); - /* Don't need to do this for any further FP insns in this TB */ - s->v7m_new_fp_ctxt_needed = false; - } + if (!full_vfp_access_check(s, ignore_vfp_enabled)) { + return 0; } if (extract32(insn, 28, 4) == 0xf) { From patchwork Thu Jun 13 12:13:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166623 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp711902ilk; Thu, 13 Jun 2019 05:43:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkygC8rGJtoD+oUNEDwcAvxR1KYoo0hqcVkOc8v/ZmS3m502+ZvxefPBE9cbXPHsxwI2zN X-Received: by 2002:aed:3b33:: with SMTP id p48mr68499508qte.143.1560429823067; Thu, 13 Jun 2019 05:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429823; cv=none; d=google.com; s=arc-20160816; b=M5naKpx7bK5w2zIPjHlOsG7g2aYDvE53dB2hPHfNaXFrMQwf6uiFWOrBNmGZaPHSzt Ul+GsRuwmQNhVK8vTdtokmyiJwTzrhSHjGsHBcuz23cTmLPabMuIj7DtwMeuuGC488Y4 yhbxjEzSra8UQum7UCKDnBMvU/z/zcBdhjSvxeJQHimSHx75Bf613e4ZGtVt0i+1k0bf vKWpGp41r1fwUtWrbiP0iaHQA70uriREIT6DL/nKiQUBf/ne/sKQKHoRrtd0VP36UZdZ zBbYUAFhE9fnJNycjl8CA+rHn5zFhsHn3q4XDX+J03suDcN5HqPJzQj9JudTaI6YlO3u I5cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZhjXNJSJoB8D/a7FDJ2SYoWWjcFDVf6Du9Vt4AtT2SM=; b=CXKFM1u8ZjDCMdHLUu/pWD1WX+K3PNStdTQwlWriThZRh+/+QdYj363HDzeBcEsCqV ge7ouxwi3/hlLU+LZiRqrbHG5hrCI3aCjW45iUiym3qn9/A5+nW/MbwKX2wepbi7Hemi RtsqKNv0yPSTPr0nh48VryG6dzjBEkjFbusKgW3uQlBmvucAipaOMVMpoVvJaTiGVVKC dDPKNcVvlazZ7wGXwEzSb1mKGL909AdP5Vzfz1+MzH8nRT4DTjv2rghg6wjLmbirt0EX MzGeDRdJwyasOMjoJlIbHfdaTucd45vVYw9c1Gc7Aa6BGt+FemBATSzmQi4/SY9dQbfq Bhsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pBBy6Nq4; 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=fail (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 u188si1599423qka.94.2019.06.13.05.43.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:43:43 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=pBBy6Nq4; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbP4w-0000wF-KU for patch@linaro.org; Thu, 13 Jun 2019 08:43:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58875) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOd9-0007ut-TA for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOd4-00046q-Vq for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:58 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:47016) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcz-0003yc-Pm for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:50 -0400 Received: by mail-wr1-x444.google.com with SMTP id n4so20482716wrw.13 for ; Thu, 13 Jun 2019 05:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZhjXNJSJoB8D/a7FDJ2SYoWWjcFDVf6Du9Vt4AtT2SM=; b=pBBy6Nq4jA6qSsB0H+Z5oLcxsqrI+1BxbnePD41XiExzkxOFtplE9kTOigpI2FRTk8 dN8m2Qn9LKY2RQ1Q6CVkxTCJbjPtb3Xm2rDrbyhEVj5fUQu8yLtJN2FNfYl0kxROskyS omwEBV7bTVU6ZcvI/0I93yqEDULMAaRPwsDhNtz/beFS/CYPALjLx44hUXWnPYrRipLF wpFeBDJBSMO1MSBBQ1lHKqMRB78hE+k/DnP1RMJKWmSgnm423AVx2fI+ne372iXR7oav 7L63uWbx1h1Acube7Q324lb0lTTiZCJFORcv9sThE1F18CbR2qaUzfbVPhz8MUidjNtL UGVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZhjXNJSJoB8D/a7FDJ2SYoWWjcFDVf6Du9Vt4AtT2SM=; b=rB36LrbhRkqHcadjHTZ0lnxub5OfMbvBM9SPNRJwDOGDVcMX6w6DCqT0Yu6W+1hljt YUn2yNF1PV5Jry9JRrGldiJeOtpwRKu941Ee7MCPdenx9bOyGn6Ykk6IW4An42LAzM1q 6/xT64rXmssaqudPv0Bq49w0cxk/sJ6Qa3zO1BhoV9ig7BveLRX91IOWe7WMaXG/cFEp ZkC/SKWEsrwh0dn38uh/tiCCihzi5ExC4hRV41PRkSe67gbAKSdWpiXJVP8eOgLThbey jz+PC3VzZRKrx58ECO1fUZvwYq1vce6HKhfOsLPR1Xm5E9LOed2DtsnWm1OxdhfEk9Ub ueIw== X-Gm-Message-State: APjAAAVw3hH0XXHp7DTvkzFHx5Lrue1HGwyCXJ6ReAYkG3LzJQpwP83D T8iVEJvL0yD1a116JfVNdDbC+UxlunC8/A== X-Received: by 2002:a5d:6b12:: with SMTP id v18mr60392889wrw.306.1560428086167; Thu, 13 Jun 2019 05:14:46 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:45 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:55 +0100 Message-Id: <20190613121433.5246-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 10/48] target/arm: Fix Cortex-R5F MVFR values 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The Cortex-R5F initfn was not correctly setting up the MVFR ID register values. Fill these in, since some subsequent patches will use ID register checks rather than CPU feature bit checks. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/cpu.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.1 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 4d5d46db7f0..c8441fc07b7 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1609,6 +1609,8 @@ static void cortex_r5f_initfn(Object *obj) cortex_r5_initfn(obj); set_feature(&cpu->env, ARM_FEATURE_VFP3); + cpu->isar.mvfr0 = 0x10110221; + cpu->isar.mvfr1 = 0x00000011; } static const ARMCPRegInfo cortexa8_cp_reginfo[] = { From patchwork Thu Jun 13 12:13:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166620 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp705607ilk; Thu, 13 Jun 2019 05:37:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhfpNsKCfy4oe3Oh548wzhJE7EIRKelJtsgYM+Y10rzXqMUAa0YwlJO+GvmIYYypckWZHP X-Received: by 2002:a37:68d2:: with SMTP id d201mr71855379qkc.65.1560429441328; Thu, 13 Jun 2019 05:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429441; cv=none; d=google.com; s=arc-20160816; b=zv8du+rN5II5fRmoF/uTujgWVGlWYTQYsdPaCjcX6rKc2Z2fCJSlDUAU/9jgWcAnKY W6lWShT/bjA7FqJP2of9e6S08gxrEvi4re6PD07vdxbn7Lqf+MGQPDx3cGlZk8utPnW9 evOMIrOBX1Sv2JJrnsr5yzIcpVLrpxmJwdg3THQDBZTSSdMt4Kmq9BUTWhYhRumQoR9G z7zu3aVr7GiPq2B+6mZSm28TiK/MNXKwXMLqpDkvTC4qGdohRtm9YCsWe7qN9jspxo+s EmByjDHwhC1a0mZ3xpftW1EJSYU7CoSzWvS2fFJAgGF9cPAlVUXYZ+CiwYMVkTGo4T3l KXKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=xzAVSfrVvqiX6ekYDb41MECWbYD3g8yVOK49nEoLOVo=; b=Xp+820rTijduZXs7ZFPU+Olm3EELFzpZgQ5SVTyGjZxER4Y0wwQTKuDwKZCT2gZUO9 r9O3/zrN9r3rZYuVfeo/VzdWw5KNfqTCkXgRhw6BRkrGuqE1L6/4yhL+craJ2aUwfEPi LbzvP60KsH1TxQ/+rH5rx30JiuRRJgn+w7lSG8y02VFXHVdVivHAOlYjYAmOG6wYqrA4 C+a1L/IP/4Z0FBHB1Nk24z3q3ToTzOGGTswXqWFmCMvZvDRkWyqMqfj8rooMcRVonkGL m8zc11rSeFQJD49f3dt6Q1RTyDvFIMtrANXRNZXw/G0Pii5C4uohDaQDKt6tb+0q23Oi fbJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="mnyNbH/S"; 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=fail (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 i42si1809989qta.108.2019.06.13.05.37.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:37:21 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b="mnyNbH/S"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOym-0005G4-UL for patch@linaro.org; Thu, 13 Jun 2019 08:37:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58880) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOd9-0007uu-Va for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOd6-00048x-1m for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:59 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:40295) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcz-0003zq-RL for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:51 -0400 Received: by mail-wm1-x341.google.com with SMTP id v19so9867924wmj.5 for ; Thu, 13 Jun 2019 05:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xzAVSfrVvqiX6ekYDb41MECWbYD3g8yVOK49nEoLOVo=; b=mnyNbH/ScqCopaOa5U/yB7M2FwK5+19T2DjqQMZv+EUVTo404O72KPHrAWlRooiTuq ugQsyUjg8QpJn/OuJTC+G0DlwLzJh+ejJpBHPF2M0x7bgf4lwUAbV+3dlAQu6857wbyf 0sXTGVQ9qLur7vf8f1YxSzE9FvI8pTtwcs4cJ4KiSDSVAB559FoH9/zh6/XJplq6Xbfl Lx78YLn/hcDp9R1zNQbJdVTvgMRQZxHFeKuD84iqk8V2idVlvL9HQFw5mL3ezR3LKOOG GXDTnoMZxfYBAeXzcr5a3aZTkHochqark9YE9Wf81DkWCSZXkT02B3RzFdCB1+1g9Acc S9ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xzAVSfrVvqiX6ekYDb41MECWbYD3g8yVOK49nEoLOVo=; b=SpG3IoMVrTPDwlXtaYYg/mnpurpCOp82fUoEVkwX4CeDB1e8QSRMX1P0TRYX6yzBbZ SfWbzkhWGDUNHrQieVq2ipW3OVuLLGGy+8tmu35bVfz5ixqEWjiWwRXTbMfSEIhTEY8N 2Z/EUfYMs5NMnqJIBml2W0mQUBeKhpKfHQQW8TrOfRzGdbe8iUdPAnlyw7Y7DCbqIW6U pfnQrT7udSLG7xfFZJ87tRCYM7qTIaH/SUPVnU7fsgyXnHT35pvUtXd6FYlbL/JXJM4i NYhjTKgRqCxdGCIJXKN4Avb6hikNzqN6Z/e9nmZ44l3WFhZzh+jM260Laky8ven8FSNv wEwA== X-Gm-Message-State: APjAAAWOnIERp9CakqypXi2RF/uG+m3nsQvCMSMizSLGL8zT9GvM7RtZ Rv0J1Hj08UYh6Uqz8wj+gCxLnV/wmRhXZw== X-Received: by 2002:a1c:3:: with SMTP id 3mr3727207wma.44.1560428087314; Thu, 13 Jun 2019 05:14:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:46 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:56 +0100 Message-Id: <20190613121433.5246-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PULL 11/48] target/arm: Explicitly enable VFP short-vectors for aarch32 -cpu max 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" At the moment our -cpu max for AArch32 supports VFP short-vectors because we always implement them, even for CPUs which should not have them. The following commits are going to switch to using the correct ID-register-check to enable or disable short vector support, so we need to turn it on explicitly for -cpu max, because Cortex-A15 doesn't implement it. We don't enable this for the AArch64 -cpu max, because the v8A architecture never supports short-vectors. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.20.1 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index c8441fc07b7..2335659a852 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2023,6 +2023,10 @@ static void arm_max_initfn(Object *obj) kvm_arm_set_cpu_features_from_host(cpu); } else { cortex_a15_initfn(obj); + + /* old-style VFP short-vector support */ + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); + #ifdef CONFIG_USER_ONLY /* We don't set these in system emulation mode for the moment, * since we don't correctly set (all of) the ID registers to From patchwork Thu Jun 13 12:13:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166619 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp702109ilk; Thu, 13 Jun 2019 05:34:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwX92rqK/0EPcoFQgCmfAM5MpuktEjegDghoqqaLLJOukBKP6NLMT/t3l0IdFuu2JZ5/fYJ X-Received: by 2002:aed:3b25:: with SMTP id p34mr74695527qte.289.1560429244363; Thu, 13 Jun 2019 05:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429244; cv=none; d=google.com; s=arc-20160816; b=bjI6xJUAm/kFg91oJEE0IvAdbCo72j59AOMztojm0vpMFSYT51D9Gu4VrTZUfHlPz3 vz87xniPGTnnosJEelEVplFFSD4oO4ugKDS1+ASJZBci8tNsF7lDjmDmmkCUpyKW6LNh mBowN/8f9Olbcov9HhkND71ClEQk/soGAgeg5ro6hhwxN1+rP/Tolt6LvmFPvtaFtfVz NaCe7MAYGVpswZ2Pp80icnHGYGFNddmx5zaN4BUThIZ5BJT98l7RAOsn+Fo9fgJPlCtm PpWfs7h2oDR71KYC60HIIoJqKINt4ZPORRyLVhFeZWbaOELuvjiPChJQHSs0O9KGqqqi aLaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ntwaaBg1kutCMaFMzBy7jmCm0WsN7rKH75PfJlZe0jU=; b=Cn1blo6KPjJ+ps9WhW4J+8x79C/CgUcK/3nJka2TP/52EFciKRWvap1RQ8thsDaYZL G1FsSt4p4RLxP3FkgKEYWtpEFZ+DNrRFxpkTFDErpl3jcKgi5+vsqdDa/S1mb1lJSAu4 xdinWuWSx753Xmwoj4IoxK0ha6qDUJWw9LQrUTvnA2XQx4mv+bCDKd/Zr1YDEYat9xCs ACts4aEndA/q5yAd270770tHnE2asVda47yrE6WjPU5JLAFWAXbe15N27pjqmrzK0aK3 XsM5mqNMmBOkCKhQeIB/OcMQILMyZ4+hjabTUBZZGlXY8rgRLsWX9Z6+WTapHUVNK8UF OMXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XqK+Namr; 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=fail (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 o3si1857489qtb.21.2019.06.13.05.34.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:34:04 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=XqK+Namr; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOvb-0001jM-So for patch@linaro.org; Thu, 13 Jun 2019 08:34:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58881) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOd9-0007uv-Vb for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOd6-000495-25 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:59 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:32984) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcz-00040R-TC for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:51 -0400 Received: by mail-wr1-x42b.google.com with SMTP id n9so20572667wru.0 for ; Thu, 13 Jun 2019 05:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ntwaaBg1kutCMaFMzBy7jmCm0WsN7rKH75PfJlZe0jU=; b=XqK+NamrtJtp2h19ewArAQVA0WuJYb8JYKED55BG9WXwjcxCVJa5GNYs8TfUhKDFHp WGUa+RJJnfIdfz+Cl8TwMEjcvzoib6MYBuKJiOtq5z7gnXEOXKaLp6/Whn5lASReW4Ou c4hv+M0Yi3/EvhVrUDOXzEaiOwOPr44mfjNa63erZWAbMvYrHDSZLiJs3CzWDHNxm/oW 7t8nexjUo8yR4/bdvEqmTM4RgaswFaKOVdapL4rOREltYwNVt/fDj0Yvjc4ylzDmzWSt eBOYaqSznt+a1O3OeXZySZUFBy0FMvdhx9X/UrAIJT1BlFyuNlgsr9+gbZMwaVoUfOxC dj7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ntwaaBg1kutCMaFMzBy7jmCm0WsN7rKH75PfJlZe0jU=; b=hvU9cfxeQAGxgIEkj7Q6Df5fhst0kgsCTDvxDWPpOtqkqyAQxhWpz7M51LuZidSh7V DnbstCQyuGKKPJKYvfw1s3LyurkTCWUpxXsHkl5L3+SCr6Jc1CmJ/55OIvTDjHvVFUGl OgDTxVYcTzRU3XsCnTRcI9sH6AUjq26X2ISlMd1gqKdYRtID/ouSCVdZRWQnNEie2V8Q 7rc3OdLnaNQGyFEL32jEJkBugOVYC1plGw5c2+jyD++GGM2tmGqPyjCLWzAnopciLAND KsmmKw61kPQ9Im5CtXPKIc3p7aHOnPtULpN4RF9WCX9GbpIsc3cXg6oMmmDFjCnfQLI3 i6jQ== X-Gm-Message-State: APjAAAX4LqX1LTVdy7oTGqu0UjPRiGxTBrWRytdhsuCztZ7xjSnv2aQT p9IokU/a/X3LD0K37YOhO8fDfrFih3mGng== X-Received: by 2002:adf:fb81:: with SMTP id a1mr19212708wrr.329.1560428088237; Thu, 13 Jun 2019 05:14:48 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:57 +0100 Message-Id: <20190613121433.5246-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [PULL 12/48] target/arm: Convert the VSEL instructions to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VSEL instructions to decodetree. We leave trans_VSEL() in translate.c for now as this allows the patch to show just the changes from the old handle_vsel(). In the old code the check for "do D16-D31 exist" was hidden in the VFP_DREG macro, and assumed that VFPv3 always implied that D16-D31 exist. In the new code we do the correct ID register test. This gives identical behaviour for most of our CPUs, and fixes previously incorrect handling for Cortex-R5F, Cortex-M4 and Cortex-M33, which all implement VFPv3 or better with only 16 double-precision registers. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/cpu.h | 6 ++++++ target/arm/translate-vfp.inc.c | 9 +++++++++ target/arm/translate.c | 35 ++++++++++++++++++++++++---------- target/arm/vfp-uncond.decode | 19 ++++++++++++++++++ 4 files changed, 59 insertions(+), 10 deletions(-) -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 06ddc49eb6c..dc50c86e318 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3371,6 +3371,12 @@ static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; } +static inline bool isar_feature_aa32_fp_d32(const ARMISARegisters *id) +{ + /* Return true if D16-D31 are implemented */ + return FIELD_EX64(id->mvfr0, MVFR0, SIMDREG) >= 2; +} + /* * We always set the FP and SIMD FP16 fields to indicate identical * levels of support (assuming SIMD is implemented at all), so diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index cf3d7febaa7..f7535138d0f 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -129,3 +129,12 @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) return true; } + +/* + * The most usual kind of VFP access check, for everything except + * FMXR/FMRX to the always-available special registers. + */ +static bool vfp_access_check(DisasContext *s) +{ + return full_vfp_access_check(s, false); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index f7720922c75..997cafdbe5c 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3076,10 +3076,27 @@ static void gen_neon_dup_high16(TCGv_i32 var) tcg_temp_free_i32(tmp); } -static int handle_vsel(uint32_t insn, uint32_t rd, uint32_t rn, uint32_t rm, - uint32_t dp) +static bool trans_VSEL(DisasContext *s, arg_VSEL *a) { - uint32_t cc = extract32(insn, 20, 2); + uint32_t rd, rn, rm; + bool dp = a->dp; + + if (!dc_isar_feature(aa32_vsel, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (dp && !dc_isar_feature(aa32_fp_d32, s) && + ((a->vm | a->vn | a->vd) & 0x10)) { + return false; + } + rd = a->vd; + rn = a->vn; + rm = a->vm; + + if (!vfp_access_check(s)) { + return true; + } if (dp) { TCGv_i64 frn, frm, dest; @@ -3101,7 +3118,7 @@ static int handle_vsel(uint32_t insn, uint32_t rd, uint32_t rn, uint32_t rm, tcg_gen_ld_f64(frn, cpu_env, vfp_reg_offset(dp, rn)); tcg_gen_ld_f64(frm, cpu_env, vfp_reg_offset(dp, rm)); - switch (cc) { + switch (a->cc) { case 0: /* eq: Z */ tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero, frn, frm); @@ -3148,7 +3165,7 @@ static int handle_vsel(uint32_t insn, uint32_t rd, uint32_t rn, uint32_t rm, dest = tcg_temp_new_i32(); tcg_gen_ld_f32(frn, cpu_env, vfp_reg_offset(dp, rn)); tcg_gen_ld_f32(frm, cpu_env, vfp_reg_offset(dp, rm)); - switch (cc) { + switch (a->cc) { case 0: /* eq: Z */ tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero, frn, frm); @@ -3182,7 +3199,7 @@ static int handle_vsel(uint32_t insn, uint32_t rd, uint32_t rn, uint32_t rm, tcg_temp_free_i32(zero); } - return 0; + return true; } static int handle_vminmaxnm(uint32_t insn, uint32_t rd, uint32_t rn, @@ -3354,10 +3371,8 @@ static int disas_vfp_misc_insn(DisasContext *s, uint32_t insn) rm = VFP_SREG_M(insn); } - if ((insn & 0x0f800e50) == 0x0e000a00 && dc_isar_feature(aa32_vsel, s)) { - return handle_vsel(insn, rd, rn, rm, dp); - } else if ((insn & 0x0fb00e10) == 0x0e800a00 && - dc_isar_feature(aa32_vminmaxnm, s)) { + if ((insn & 0x0fb00e10) == 0x0e800a00 && + dc_isar_feature(aa32_vminmaxnm, s)) { return handle_vminmaxnm(insn, rd, rn, rm, dp); } else if ((insn & 0x0fbc0ed0) == 0x0eb80a40 && dc_isar_feature(aa32_vrint, s)) { diff --git a/target/arm/vfp-uncond.decode b/target/arm/vfp-uncond.decode index b1d9dc507c2..b7f7c27fe86 100644 --- a/target/arm/vfp-uncond.decode +++ b/target/arm/vfp-uncond.decode @@ -26,3 +26,22 @@ # 1111 1110 .... .... .... 101. .... .... # (but those patterns might also cover some Neon instructions, # which do not live in this file.) + +# VFP registers have an odd encoding with a four-bit field +# and a one-bit field which are assembled in different orders +# depending on whether the register is double or single precision. +# Each individual instruction function must do the checks for +# "double register selected but CPU does not have double support" +# and "double register number has bit 4 set but CPU does not +# support D16-D31" (which should UNDEF). +%vm_dp 5:1 0:4 +%vm_sp 0:4 5:1 +%vn_dp 7:1 16:4 +%vn_sp 16:4 7:1 +%vd_dp 22:1 12:4 +%vd_sp 12:4 22:1 + +VSEL 1111 1110 0. cc:2 .... .... 1010 .0.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp dp=0 +VSEL 1111 1110 0. cc:2 .... .... 1011 .0.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp dp=1 From patchwork Thu Jun 13 12:13:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166632 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp722106ilk; Thu, 13 Jun 2019 05:54:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPCcZj/l5Wmu2kKkfYqBtY6f4WO1PepmddrOWUubVHCJvTT37Q92ItlB/tOHu47Ie+EcKK X-Received: by 2002:ac8:4982:: with SMTP id f2mr68718180qtq.213.1560430459887; Thu, 13 Jun 2019 05:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430459; cv=none; d=google.com; s=arc-20160816; b=BJ6kXLNozygQC89y+MjROmNTS6f6dBWcd6CA+I+mn6hxWRjVH3Ty/JHMf+9aPTU3LF aYyHfyliQs3XVO7TULx1uPHpjEhhstEZUj6UZj9ZnRoW1JrCyHZfCMfvLq2Dtp85fKW6 G6vXsQXBZuvq41WEJwBR1QS0X0CjfXDs4Q0UmeZKPNN9kGog3uVEV59aGI/aYzGy9xV7 EletyiK/1rsqvLFaEljUTBbEpOPbgidqc3UVxmUkNO1dqX2AeTO3k7BL7b0m/KF7Hruo Hf7fgzvUsMQD7U/Ej63aPvfEFpiByQnImDMecNZt5959QFVd601gMxs/R7Gb4MQHTNR+ Ebzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=DxkVuYTzDW0ZPX4NRM71Po/auhPBMIBC698b0Rvas5w=; b=okDzhkAAUfdiERn6vGmEnDrOTYfWHpd/tChAwlxGy1ry+FU71FnAF2wiamWpGhkuZ2 8J6wbcnPK9cPQIBD8jaRlEgNycMy2kdoSufrCEu0Io3I1WTLkBzqH9LRzcRhO7GTQtas 50j+HqvNE38vQdixfeff4SiKO4zfPEY1uLYAou07yy0CfyBCH/N+0+Ow4PS0HCE08EJ1 XR6Vv88ULLvHpZ3kLu0k35gB4ufSvsJ7sS13nKZAz3tqKuOZmrpWjz4EQwQ7q3Us/ezt Cx+e1rpXYqUr/SWuwJkM3S2t+M0BTXXablUlpECVnlr7+9wy6xbQtFUy6R4pxDv0jisp Sowg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="IkNyyD/i"; 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=fail (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 m5si1356523qvi.61.2019.06.13.05.54.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:54:19 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b="IkNyyD/i"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPFD-0001Dv-Dk for patch@linaro.org; Thu, 13 Jun 2019 08:54:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59132) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdR-00085d-JL for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdN-0004Q4-7u for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:15 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:45252) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdK-00040o-B2 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:11 -0400 Received: by mail-wr1-x42c.google.com with SMTP id f9so20487065wre.12 for ; Thu, 13 Jun 2019 05:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DxkVuYTzDW0ZPX4NRM71Po/auhPBMIBC698b0Rvas5w=; b=IkNyyD/ioq3HBl8rjXSUxwSJ/beY503oJR4gZZmhJt6hIXQT/NUlxzWiLnU4HDwvvL Ss/Dh+tfyvNpWdi3qg8B5R0qbe3UDkwxnEi8PojYLbYKy/istdudSMat9782Jf/qd/0O zQvZrkg3m+04OxCpYRykGkGNtKXZ6zfhmIDi+ZytVy7lF50Ynll2H69kurZ08rUnRHEE tT627+eza/1kRJIpG5K1294T6MMqGM1Wqu2GYuoLMsUslJ8snOvUQFGdjIdnvJFhRbjK lo7x0KNFhM3G2RdBlJXxOTPEiwAGnUy8O7162NELhcpDGtoh/1lehTYUCq+lC4URfipc SHHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DxkVuYTzDW0ZPX4NRM71Po/auhPBMIBC698b0Rvas5w=; b=kV//gziXyQOIiAOMN5JIZ0LY/+sV5IsS7JEXuRcibpI+cOsjNKdIQ+0rySH9emBAsW lU/+KHd+fIIEMpairwpt1ENlpv73aY4hK/MaBFUiRytzUlml7RNmZKAsnTGVWQoGxnVm w9ON9roo8KpQ1b62WBuDJlU93hrraBFH72c4++St/CoNk7n2AWxoSkxiWdfs7+mDsJfK luPXncY+EBJ0JHbdSOuKZzmZT0Yv/8J2GmqKL1QXtocAT7c5Rz/917jRr7Zcd+zpPLZs +rdjTHCdDgE9EKOGNsUzd0Uqe9jrXiu+ACz/3IOfhbBV2LC8v11wnCZS3O6NCiELDhuN waBA== X-Gm-Message-State: APjAAAWB5o5sPhM7jHpBGCNorfsFH9nnPRr60tE6PYjI1xv6MXS4217a EuU/8f3MU4DgOL5tj8WFH4c/s9RBkxjOBA== X-Received: by 2002:adf:dcc2:: with SMTP id x2mr19241815wrm.55.1560428089145; Thu, 13 Jun 2019 05:14:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:48 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:58 +0100 Message-Id: <20190613121433.5246-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PULL 13/48] target/arm: Convert VMINNM, VMAXNM to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VMINNM and VMAXNM instructions to decodetree. As with VSEL, we leave the trans_VMINMAXNM() function in translate.c for the moment. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate.c | 41 ++++++++++++++++++++++++------------ target/arm/vfp-uncond.decode | 5 +++++ 2 files changed, 33 insertions(+), 13 deletions(-) -- 2.20.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 997cafdbe5c..6cbdf4307a4 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3202,11 +3202,31 @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) return true; } -static int handle_vminmaxnm(uint32_t insn, uint32_t rd, uint32_t rn, - uint32_t rm, uint32_t dp) +static bool trans_VMINMAXNM(DisasContext *s, arg_VMINMAXNM *a) { - uint32_t vmin = extract32(insn, 6, 1); - TCGv_ptr fpst = get_fpstatus_ptr(0); + uint32_t rd, rn, rm; + bool dp = a->dp; + bool vmin = a->op; + TCGv_ptr fpst; + + if (!dc_isar_feature(aa32_vminmaxnm, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (dp && !dc_isar_feature(aa32_fp_d32, s) && + ((a->vm | a->vn | a->vd) & 0x10)) { + return false; + } + rd = a->vd; + rn = a->vn; + rm = a->vm; + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(0); if (dp) { TCGv_i64 frn, frm, dest; @@ -3247,7 +3267,7 @@ static int handle_vminmaxnm(uint32_t insn, uint32_t rd, uint32_t rn, } tcg_temp_free_ptr(fpst); - return 0; + return true; } static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, @@ -3359,23 +3379,18 @@ static const uint8_t fp_decode_rm[] = { static int disas_vfp_misc_insn(DisasContext *s, uint32_t insn) { - uint32_t rd, rn, rm, dp = extract32(insn, 8, 1); + uint32_t rd, rm, dp = extract32(insn, 8, 1); if (dp) { VFP_DREG_D(rd, insn); - VFP_DREG_N(rn, insn); VFP_DREG_M(rm, insn); } else { rd = VFP_SREG_D(insn); - rn = VFP_SREG_N(insn); rm = VFP_SREG_M(insn); } - if ((insn & 0x0fb00e10) == 0x0e800a00 && - dc_isar_feature(aa32_vminmaxnm, s)) { - return handle_vminmaxnm(insn, rd, rn, rm, dp); - } else if ((insn & 0x0fbc0ed0) == 0x0eb80a40 && - dc_isar_feature(aa32_vrint, s)) { + if ((insn & 0x0fbc0ed0) == 0x0eb80a40 && + dc_isar_feature(aa32_vrint, s)) { /* VRINTA, VRINTN, VRINTP, VRINTM */ int rounding = fp_decode_rm[extract32(insn, 16, 2)]; return handle_vrint(insn, rd, rm, dp, rounding); diff --git a/target/arm/vfp-uncond.decode b/target/arm/vfp-uncond.decode index b7f7c27fe86..8ab201fa058 100644 --- a/target/arm/vfp-uncond.decode +++ b/target/arm/vfp-uncond.decode @@ -45,3 +45,8 @@ VSEL 1111 1110 0. cc:2 .... .... 1010 .0.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp dp=0 VSEL 1111 1110 0. cc:2 .... .... 1011 .0.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp dp=1 + +VMINMAXNM 1111 1110 1.00 .... .... 1010 . op:1 .0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp dp=0 +VMINMAXNM 1111 1110 1.00 .... .... 1011 . op:1 .0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp dp=1 From patchwork Thu Jun 13 12:13:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166631 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp721155ilk; Thu, 13 Jun 2019 05:53:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwfCAunicEOKJ17k6RZMKzlOYQJttco1c/aGtnFgG3+RWeGFZ5sz+4AKB7bYc7U/B4xGXE X-Received: by 2002:ac8:2f90:: with SMTP id l16mr59956118qta.12.1560430397452; Thu, 13 Jun 2019 05:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430397; cv=none; d=google.com; s=arc-20160816; b=z54s8EhfeN9ERrEohlWdb+7UGtuqyZtvX7qVSvELWwkED5vGiAn+NWYATxrqIGgvsR TK9U7sna9CxZP95XpgWtWlchpGA+izmJKWyMdbbcFpLiF+Z8aypxzt1cVA/U8hpqnlxh XbGfmvOOWxKei7dL+vXeRIWoXX445E4T5prUu6+Mi7J9RFHnMKvkdqExO6cmL459W8ST MgGbUrW5+pn5auRH4C0IYmDl7FG1tv25JIbyMFcxK97pCgcsrOPewjUnPQKdwnEKC5Yv dfHccBWt7U3H+NuFLe8XoPr5EMTt7FiyJQD7HvXkOHtwksB9p+Z045jtjukhVhkHFBRO aIzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=G9EplEWWeY2rBD/O9y6VR49Hh5Zd3BPbLcO7Af3KvXA=; b=BdLxs7wRv8z9IL4K3maIcGf+WcoTLyZkkmdWhuQT/3BPt9w0mBTNeFG6Et4QkcVKV2 QVZDQ2Og4pTntQ7XEq2mOdRo0TrlrniaL/OkdmxAnmr+9rHBK4Iuzd1QJqzjrz3ZELkM t2SSMkvEWEERSfxh/681z1K/o+/QkVZ9ldJyz8mVkTsOE44k20RCSD/EhVgtWR7flsYb Op5ME0oQA7Ebq7H4SD3a+dYY0dcZj2BRv1wg8RXiEAkTrHq5zWc/1EC5kcPCCAybcDj7 UwRHisfYDUMwmpsGMqGPCTwWv0254vdQhy/KYVGa4qfc3JhDZxzv8cbMOs0YUSU0gGzo CK3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=s0Q3kV87; 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=fail (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 b7si1423533qvh.206.2019.06.13.05.53.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:53:17 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=s0Q3kV87; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPEC-0007p9-Rf for patch@linaro.org; Thu, 13 Jun 2019 08:53:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59078) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdN-000829-9B for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdL-0004O0-9N for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:13 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:38236) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdH-00041p-DC for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:09 -0400 Received: by mail-wr1-x431.google.com with SMTP id d18so20521232wrs.5 for ; Thu, 13 Jun 2019 05:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=G9EplEWWeY2rBD/O9y6VR49Hh5Zd3BPbLcO7Af3KvXA=; b=s0Q3kV877QBrAfKHztkhpWg3t5LVgArMsU0D0QE4mzGHdRHd6f3e7+3w2Ix8Qy6HVf 3yTuTh5xdBDn5fMfUvAY5GsjXKQEbrkhNx7kStY/pkUXsP1AOULjQoeXWOmOVlAeB+XV rS3b/pFZDmueCiHraaPUtD1KaqL/rZGknDQl7t7uxjNXz5t+PtQleJJhZI7dpih46B1r +Fb0vFNK4QxF6BHE4dW5ZXsKMS2DK/y3C4gfolXtovUe1vA9LFKL2GSJjSl9MZTCTmEk Pbk3r2560uoKZ9p5aLgS6rEURFqJKw/3BCQEh31Lwm2aGSZumnP0EV1onvrqKiroKlQX vgTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G9EplEWWeY2rBD/O9y6VR49Hh5Zd3BPbLcO7Af3KvXA=; b=aXH1546kui1Mb9NpIdQ00DoSRLxlUoHQJzmuEDMXBpzTwrkJjYWoYFyhIGLWZ7s2s1 +UopRTeSsjkNfM79kBH8rtTWUQut2O/KZueb2So57T7/H9JQWPifuVYpQZ7qhTLX+wcP 7+h9w1HNw58JwGtnjZrkYd15TS+fcWhUADKGZvArGoqtFfknK+ks8FrWPooJlsZ5CINg yaSaX2O7ZZSYcdOcPiW8fxA6Ll3KlyX00N6TfsJYvyJeMwagkD8vHUFTbQX0YUNKF6/u lCF6NkL/Ng6Ku3Iqnc4H2xls10FNzmqcBUAIJUcGawZm49gGeYpUrlTH4Ia22A70wT8H 3faw== X-Gm-Message-State: APjAAAUODI7QafTlm/mRBbTSVUjLHIwTKkq8db+uMIqr3R6OliCJ4fcG 1A7NDuyi+5v90X7504TmkVSxd39V2wL1qA== X-Received: by 2002:a5d:6709:: with SMTP id o9mr46293015wru.301.1560428090323; Thu, 13 Jun 2019 05:14:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:59 +0100 Message-Id: <20190613121433.5246-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 Subject: [Qemu-devel] [PULL 14/48] target/arm: Convert VRINTA/VRINTN/VRINTP/VRINTM to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VRINTA/VRINTN/VRINTP/VRINTM instructions to decodetree. Again, trans_VRINT() is temporarily left in translate.c. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate.c | 60 +++++++++++++++++++++++------------- target/arm/vfp-uncond.decode | 5 +++ 2 files changed, 43 insertions(+), 22 deletions(-) -- 2.20.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 6cbdf4307a4..1da683820ab 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3270,11 +3270,43 @@ static bool trans_VMINMAXNM(DisasContext *s, arg_VMINMAXNM *a) return true; } -static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, - int rounding) +/* + * Table for converting the most common AArch32 encoding of + * rounding mode to arm_fprounding order (which matches the + * common AArch64 order); see ARM ARM pseudocode FPDecodeRM(). + */ +static const uint8_t fp_decode_rm[] = { + FPROUNDING_TIEAWAY, + FPROUNDING_TIEEVEN, + FPROUNDING_POSINF, + FPROUNDING_NEGINF, +}; + +static bool trans_VRINT(DisasContext *s, arg_VRINT *a) { - TCGv_ptr fpst = get_fpstatus_ptr(0); + uint32_t rd, rm; + bool dp = a->dp; + TCGv_ptr fpst; TCGv_i32 tcg_rmode; + int rounding = fp_decode_rm[a->rm]; + + if (!dc_isar_feature(aa32_vrint, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (dp && !dc_isar_feature(aa32_fp_d32, s) && + ((a->vm | a->vd) & 0x10)) { + return false; + } + rd = a->vd; + rm = a->vm; + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(0); tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding)); gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); @@ -3305,7 +3337,7 @@ static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, tcg_temp_free_i32(tcg_rmode); tcg_temp_free_ptr(fpst); - return 0; + return true; } static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, @@ -3366,17 +3398,6 @@ static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, return 0; } -/* Table for converting the most common AArch32 encoding of - * rounding mode to arm_fprounding order (which matches the - * common AArch64 order); see ARM ARM pseudocode FPDecodeRM(). - */ -static const uint8_t fp_decode_rm[] = { - FPROUNDING_TIEAWAY, - FPROUNDING_TIEEVEN, - FPROUNDING_POSINF, - FPROUNDING_NEGINF, -}; - static int disas_vfp_misc_insn(DisasContext *s, uint32_t insn) { uint32_t rd, rm, dp = extract32(insn, 8, 1); @@ -3389,13 +3410,8 @@ static int disas_vfp_misc_insn(DisasContext *s, uint32_t insn) rm = VFP_SREG_M(insn); } - if ((insn & 0x0fbc0ed0) == 0x0eb80a40 && - dc_isar_feature(aa32_vrint, s)) { - /* VRINTA, VRINTN, VRINTP, VRINTM */ - int rounding = fp_decode_rm[extract32(insn, 16, 2)]; - return handle_vrint(insn, rd, rm, dp, rounding); - } else if ((insn & 0x0fbc0e50) == 0x0ebc0a40 && - dc_isar_feature(aa32_vcvt_dr, s)) { + if ((insn & 0x0fbc0e50) == 0x0ebc0a40 && + dc_isar_feature(aa32_vcvt_dr, s)) { /* VCVTA, VCVTN, VCVTP, VCVTM */ int rounding = fp_decode_rm[extract32(insn, 16, 2)]; return handle_vcvt(insn, rd, rm, dp, rounding); diff --git a/target/arm/vfp-uncond.decode b/target/arm/vfp-uncond.decode index 8ab201fa058..0aa83285de2 100644 --- a/target/arm/vfp-uncond.decode +++ b/target/arm/vfp-uncond.decode @@ -50,3 +50,8 @@ VMINMAXNM 1111 1110 1.00 .... .... 1010 . op:1 .0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp dp=0 VMINMAXNM 1111 1110 1.00 .... .... 1011 . op:1 .0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp dp=1 + +VRINT 1111 1110 1.11 10 rm:2 .... 1010 01.0 .... \ + vm=%vm_sp vd=%vd_sp dp=0 +VRINT 1111 1110 1.11 10 rm:2 .... 1011 01.0 .... \ + vm=%vm_dp vd=%vd_dp dp=1 From patchwork Thu Jun 13 12:14:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166630 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp720958ilk; Thu, 13 Jun 2019 05:53:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyc1j6YCw2+ZcueMfXIXjcERuElzlJRtTfIZLydRqTkMBBVvVf9kKu6FACNzUN8Jy/mLJhU X-Received: by 2002:ac8:68e:: with SMTP id f14mr7380744qth.366.1560430383758; Thu, 13 Jun 2019 05:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430383; cv=none; d=google.com; s=arc-20160816; b=dy1vXd+zLGihMsOv7bYUK522S9WYjAsAdajs3FIDTgG0ye/H8ijCoXX065xqwO4ui3 IX58ZOBfKNr0+nhkDGpgbu8tPO6sYxV0uB9G0oyCeMoRrm3ep/BEmCO8MfihptSMbzsv yQjbqwlIbo1stFQjSPpJdP7ZsuuGxX8c7Rk6ZUtor0208zZJmSTQgWFgcr/t6yWEd2Th kEyKVZtpuQnnV0bVz2VHkFcIuq7yjFREzTLA6mXeLga27x+kIBHqWwIXvKbOhLv60q3v D4aejJNlDCBOvfYOGGGACrXDMkCM0xZB1W+uboiGM3de3NHB7D0/XY2gIYDqWqeIYXZG hHzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=i8xZRS9V37an5mkOlNCXHCAwIm1/t9dfCuxOwyhXLds=; b=MxN4F9SLZn8lA1oyMyrXiqdWtZDOmBYt0sSTtbJ77niaEq2WGYGX8LbreChwLwdloL nTZ5ENS/3kphhG5KvTvFU9S3u5rL7+1e+0W05ekPmToDWD5y187SffiiCZ4kFrpc6QqQ D1ZgEPS1Go2IaNLQplnRjUckR1Z9PhpXk/7ImPIZiGRJ/1th1EqOQ3BQfac1yTot2+22 iRZ7j3zg//JeS6/QgP6Qd7+c5VfMm9ILjShAPQfgpLw+l4/fLkrK0SX46vVbblp0/QB9 EK1KxL89vYEDWE/HvmcIhzVD0AvK7dZz2g8Ala/IBAMxbF5/SewFqD13tvRqqmgKnOKC g/NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WhvCEeiJ; 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=fail (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 p7si1359044qvo.115.2019.06.13.05.53.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:53:03 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=WhvCEeiJ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPDz-0007gA-Bs for patch@linaro.org; Thu, 13 Jun 2019 08:53:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59017) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdL-00080U-9w for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdH-0004Kc-D9 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:10 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:37118) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdF-00042O-A8 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:05 -0400 Received: by mail-wr1-x443.google.com with SMTP id v14so20515036wrr.4 for ; Thu, 13 Jun 2019 05:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=i8xZRS9V37an5mkOlNCXHCAwIm1/t9dfCuxOwyhXLds=; b=WhvCEeiJ4qDz6f2XhTdPDI2rPJoTHYpB9dyq2Oh/x7IJ0U3QhYkcjKy0oPT8TLLkl2 DrcOAc+tbhXYXG9minu1PjDp4furjVg9SGEH246qWjyZN8Z37XC9s/Czo6onn0hoU4Eb +KcqBBQgsK1i29/sEMYV+ICRoieIdUTpmjkk5ZKjzS4uKxJAinH74CO1VDSGy7zwInHU PxOCmeuZ9WQQcQl+C5WQYoBTiVEoa07uC7BN28h13ixSWLC83+pSldj23LnxILf6ye2l vDUQwqoR45xVuz3XKK2frk7uXltij66wRe2C7OKkeWzpNvkOiGw47Hp6HKFcFLcpIHRb gOLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i8xZRS9V37an5mkOlNCXHCAwIm1/t9dfCuxOwyhXLds=; b=jpp+Klz9haFe9ofShXE5eqgINFM6pL0tW1sNjD42xQM3u7PlIjgUllK7bYaHMGAe/L K0cs+jT43f8MPNPH769YdxWU7KCzTndqWbuSrqydYnhrlzKBDk7oEpu8fhPdBvMV6cSt 6pMeP7j4vaMpYygGaMKZAuQ5XWAaQCtbXJ/vcDFtpGM5Zbfgn7Wu1VIcIGLS+F/oZs8U oHBOBs0QAVRDuidSlxUYoZOa+QqwOJNDpiLxeCVXcT9TUpQh75ECCwcbM2uxEIqo9Kol 1otKb1rSPPH2m6BC08gXFxJC+1R6R8eDmfeCftn6a8Bh2HChMkmtJ1NxKvuKfuudgK2b I5NA== X-Gm-Message-State: APjAAAUfZh1JhaYLXkcXVyY1i460mLoXgWXllOOPIrTNMQ47hB8/2vQ1 PFvzYX1BVQ47nCfIdVdxYUNCkGVKkT3y8A== X-Received: by 2002:adf:e301:: with SMTP id b1mr8052440wrj.304.1560428091209; Thu, 13 Jun 2019 05:14:51 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:50 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:00 +0100 Message-Id: <20190613121433.5246-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 15/48] target/arm: Convert VCVTA/VCVTN/VCVTP/VCVTM to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VCVTA/VCVTN/VCVTP/VCVTM instructions to decodetree. trans_VCVT() is temporarily left in translate.c. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate.c | 72 +++++++++++++++++------------------- target/arm/vfp-uncond.decode | 6 +++ 2 files changed, 39 insertions(+), 39 deletions(-) -- 2.20.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 1da683820ab..d59fadc8fbe 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3340,12 +3340,31 @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) return true; } -static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, - int rounding) +static bool trans_VCVT(DisasContext *s, arg_VCVT *a) { - bool is_signed = extract32(insn, 7, 1); - TCGv_ptr fpst = get_fpstatus_ptr(0); + uint32_t rd, rm; + bool dp = a->dp; + TCGv_ptr fpst; TCGv_i32 tcg_rmode, tcg_shift; + int rounding = fp_decode_rm[a->rm]; + bool is_signed = a->op; + + if (!dc_isar_feature(aa32_vcvt_dr, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (dp && !dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { + return false; + } + rd = a->vd; + rm = a->vm; + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(0); tcg_shift = tcg_const_i32(0); @@ -3355,10 +3374,6 @@ static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, if (dp) { TCGv_i64 tcg_double, tcg_res; TCGv_i32 tcg_tmp; - /* Rd is encoded as a single precision register even when the source - * is double precision. - */ - rd = ((rd << 1) & 0x1e) | ((rd >> 4) & 0x1); tcg_double = tcg_temp_new_i64(); tcg_res = tcg_temp_new_i64(); tcg_tmp = tcg_temp_new_i32(); @@ -3395,28 +3410,7 @@ static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, tcg_temp_free_ptr(fpst); - return 0; -} - -static int disas_vfp_misc_insn(DisasContext *s, uint32_t insn) -{ - uint32_t rd, rm, dp = extract32(insn, 8, 1); - - if (dp) { - VFP_DREG_D(rd, insn); - VFP_DREG_M(rm, insn); - } else { - rd = VFP_SREG_D(insn); - rm = VFP_SREG_M(insn); - } - - if ((insn & 0x0fbc0e50) == 0x0ebc0a40 && - dc_isar_feature(aa32_vcvt_dr, s)) { - /* VCVTA, VCVTN, VCVTP, VCVTM */ - int rounding = fp_decode_rm[extract32(insn, 16, 2)]; - return handle_vcvt(insn, rd, rm, dp, rounding); - } - return 1; + return true; } /* @@ -3452,6 +3446,15 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) } } + if (extract32(insn, 28, 4) == 0xf) { + /* + * Encodings with T=1 (Thumb) or unconditional (ARM): these + * were all handled by the decodetree decoder, so any insn + * patterns which get here must be UNDEF. + */ + return 1; + } + /* * FIXME: this access check should not take precedence over UNDEF * for invalid encodings; we will generate incorrect syndrome information @@ -3468,15 +3471,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 0; } - if (extract32(insn, 28, 4) == 0xf) { - /* - * Encodings with T=1 (Thumb) or unconditional (ARM): - * only used for the "miscellaneous VFP features" added in v8A - * and v7M (and gated on the MVFR2.FPMisc field). - */ - return disas_vfp_misc_insn(s, insn); - } - dp = ((insn & 0xf00) == 0xb00); switch ((insn >> 24) & 0xf) { case 0xe: diff --git a/target/arm/vfp-uncond.decode b/target/arm/vfp-uncond.decode index 0aa83285de2..5af1f2ee664 100644 --- a/target/arm/vfp-uncond.decode +++ b/target/arm/vfp-uncond.decode @@ -55,3 +55,9 @@ VRINT 1111 1110 1.11 10 rm:2 .... 1010 01.0 .... \ vm=%vm_sp vd=%vd_sp dp=0 VRINT 1111 1110 1.11 10 rm:2 .... 1011 01.0 .... \ vm=%vm_dp vd=%vd_dp dp=1 + +# VCVT float to int with specified rounding mode; Vd is always single-precision +VCVT 1111 1110 1.11 11 rm:2 .... 1010 op:1 1.0 .... \ + vm=%vm_sp vd=%vd_sp dp=0 +VCVT 1111 1110 1.11 11 rm:2 .... 1011 op:1 1.0 .... \ + vm=%vm_dp vd=%vd_sp dp=1 From patchwork Thu Jun 13 12:14:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166647 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp751953ilk; Thu, 13 Jun 2019 06:17:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqx07uS/kiwny6oKQoxtNO5rWLXN6cntN7/XmcaOcXgzisO3qXFNtA9uN80pCfKSpfLQq75s X-Received: by 2002:a0c:eecd:: with SMTP id h13mr3529751qvs.46.1560431856232; Thu, 13 Jun 2019 06:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560431856; cv=none; d=google.com; s=arc-20160816; b=elpCwx4t1Ce0GT+fhJRlz8HXQHsAxk/FWrKgjnEV2F1ROnFQAFD+QTXe71RQ4NCDSf XdVoD6ejZ3dlwqPIwIPZvdYdk+PvKUPUpnSR32BtMQJm1dZqfpZncIwv/3RDilLV28/W tlHD6o8vvVu52wzeOraxi5kAb2P0LcQVHe4MQpwaxPqSkb+hpMnLpspcjD5Yof+8ByO8 yRldCVLYDfmBAoLZgxsj0DIfyweOwbXUIyeqUkx6W2byCoBb2biqUrcM6Yd6d4aqmdNO CezTqTgJdqaISugAq7HWFlhGS9b/jBMFKceP5IK8UTP+027BjkCn4mdRXP7w1k6Ly7Oz a+nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=/aAqlk8oYj8ZyZ64S2GTvSQ7Is5HR1SWh30tE9pTHjM=; b=CIGE2LlXJFrZ0L7D09lAHhKj+nx6jcgea31IEgpILvY1rej3vUTFI+K9tfZD63Dsx5 MImbg0/Za2iB7+1qx2EnZXuKG9TyyBADGrLRb4QcytiOgfn8DMOq2x81LcVtq7xUPVch oMS1ZjXP8TTjDp5QMxGT/52og1VATP/uuvUxclprX5mpKWdu/DGgNdGnB5M373oBax7z d8NUo0cy/38h/n6nbieVL+/bLXNPx75CSuoJgQce2OurF2QlLH4E3QMb802ClhwAPQyH bGXf2dQhxpYrnNlcjV7TgmXjXuojgePpnWuYChY0p7ELeQO+i0FwJ7CcEICDVJOpxi4Z ycYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pm9B8KrQ; 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=fail (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 52si1463197qvu.18.2019.06.13.06.17.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:17:36 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=pm9B8KrQ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPbj-0001oE-Pa for patch@linaro.org; Thu, 13 Jun 2019 09:17:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59242) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdV-0008Au-Kc for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdR-0004Ua-Ky for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:21 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:38241) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdQ-000438-Db for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:17 -0400 Received: by mail-wr1-x436.google.com with SMTP id d18so20521369wrs.5 for ; Thu, 13 Jun 2019 05:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/aAqlk8oYj8ZyZ64S2GTvSQ7Is5HR1SWh30tE9pTHjM=; b=pm9B8KrQ8jxtuHZpJuvsKTlDlPBHTAWGm++ocVsgMyfocOet7MYwkURzxcb6SAOrCa pUBRb8qDPd+YlrdDoY99ijs5diuyhvvWTSCTqDivxtZlW9l0CSUqQ8W4om/GrrRv1oIO PLSZjMId+Qe6CpmlkGQEhrSa8sOwK3k/HjAUKfiVmMqGsFSZgiSbN9sUm1n7TqMLx+LE 9kmVvRyr2LwydDBXg5uTQOmxgPqvUY0oQJxipO9cgsvsfNoVFe0hFfyfHaTehxrNJLq+ 9j27GcWM9QtFt4ALAzaU4nr/cFZLUXh0eHddRE+6ibdqcH+2YsXIqVxjuMY1L19d4t/y cBww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/aAqlk8oYj8ZyZ64S2GTvSQ7Is5HR1SWh30tE9pTHjM=; b=P0HZ7knD4RYVxTG+WdP/ft7ycmsoKfJDtc0EGtDEobxDdqX7Ko7G0XOxoGoQX3On4X 9CPvsNv73F6YKyBzD3ZDOpzwg5Qiog/ZvNIHfJWMQvMMC+nZHBZw4TQ0FAk3l5KEmME2 vGFiYCe2X7Mg3SwLXuzrya7dSjZ1Hai78y/vKHF6PaeVL2zxmSEwuVVJnarF7ST28dDL MdmTZj2Cxgs5pd/rORfEUqijmQVfHvW01aSS0PSPRW/PAbw4Wmy+6XdR1che721wZy3o JKwOcF9i2ZN+8tZlubqZQ0TK0d4dzHaSkVaLoxcBitcR3pQBauKaJhCbAvdaogdCnPc2 LcVw== X-Gm-Message-State: APjAAAViB1Q7gDHbSsxoe3SipWVw0hn9eRnGvrEwPdWpaxaVRx1F7aXT oQk/ckyVTKrvJLdW2XhW1VloEHQrQ+1eCw== X-Received: by 2002:a5d:5607:: with SMTP id l7mr29007052wrv.228.1560428092511; Thu, 13 Jun 2019 05:14:52 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:51 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:01 +0100 Message-Id: <20190613121433.5246-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 Subject: [Qemu-devel] [PULL 16/48] target/arm: Move the VFP trans_* functions to translate-vfp.inc.c 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move the trans_*() functions we've just created from translate.c to translate-vfp.inc.c. This is pure code motion with no textual changes (this can be checked with 'git show --color-moved'). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 337 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 337 --------------------------------- 2 files changed, 337 insertions(+), 337 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index f7535138d0f..2f070a6e0d9 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -138,3 +138,340 @@ static bool vfp_access_check(DisasContext *s) { return full_vfp_access_check(s, false); } + +static bool trans_VSEL(DisasContext *s, arg_VSEL *a) +{ + uint32_t rd, rn, rm; + bool dp = a->dp; + + if (!dc_isar_feature(aa32_vsel, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (dp && !dc_isar_feature(aa32_fp_d32, s) && + ((a->vm | a->vn | a->vd) & 0x10)) { + return false; + } + rd = a->vd; + rn = a->vn; + rm = a->vm; + + if (!vfp_access_check(s)) { + return true; + } + + if (dp) { + TCGv_i64 frn, frm, dest; + TCGv_i64 tmp, zero, zf, nf, vf; + + zero = tcg_const_i64(0); + + frn = tcg_temp_new_i64(); + frm = tcg_temp_new_i64(); + dest = tcg_temp_new_i64(); + + zf = tcg_temp_new_i64(); + nf = tcg_temp_new_i64(); + vf = tcg_temp_new_i64(); + + tcg_gen_extu_i32_i64(zf, cpu_ZF); + tcg_gen_ext_i32_i64(nf, cpu_NF); + tcg_gen_ext_i32_i64(vf, cpu_VF); + + tcg_gen_ld_f64(frn, cpu_env, vfp_reg_offset(dp, rn)); + tcg_gen_ld_f64(frm, cpu_env, vfp_reg_offset(dp, rm)); + switch (a->cc) { + case 0: /* eq: Z */ + tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero, + frn, frm); + break; + case 1: /* vs: V */ + tcg_gen_movcond_i64(TCG_COND_LT, dest, vf, zero, + frn, frm); + break; + case 2: /* ge: N == V -> N ^ V == 0 */ + tmp = tcg_temp_new_i64(); + tcg_gen_xor_i64(tmp, vf, nf); + tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero, + frn, frm); + tcg_temp_free_i64(tmp); + break; + case 3: /* gt: !Z && N == V */ + tcg_gen_movcond_i64(TCG_COND_NE, dest, zf, zero, + frn, frm); + tmp = tcg_temp_new_i64(); + tcg_gen_xor_i64(tmp, vf, nf); + tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero, + dest, frm); + tcg_temp_free_i64(tmp); + break; + } + tcg_gen_st_f64(dest, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i64(frn); + tcg_temp_free_i64(frm); + tcg_temp_free_i64(dest); + + tcg_temp_free_i64(zf); + tcg_temp_free_i64(nf); + tcg_temp_free_i64(vf); + + tcg_temp_free_i64(zero); + } else { + TCGv_i32 frn, frm, dest; + TCGv_i32 tmp, zero; + + zero = tcg_const_i32(0); + + frn = tcg_temp_new_i32(); + frm = tcg_temp_new_i32(); + dest = tcg_temp_new_i32(); + tcg_gen_ld_f32(frn, cpu_env, vfp_reg_offset(dp, rn)); + tcg_gen_ld_f32(frm, cpu_env, vfp_reg_offset(dp, rm)); + switch (a->cc) { + case 0: /* eq: Z */ + tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero, + frn, frm); + break; + case 1: /* vs: V */ + tcg_gen_movcond_i32(TCG_COND_LT, dest, cpu_VF, zero, + frn, frm); + break; + case 2: /* ge: N == V -> N ^ V == 0 */ + tmp = tcg_temp_new_i32(); + tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); + tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero, + frn, frm); + tcg_temp_free_i32(tmp); + break; + case 3: /* gt: !Z && N == V */ + tcg_gen_movcond_i32(TCG_COND_NE, dest, cpu_ZF, zero, + frn, frm); + tmp = tcg_temp_new_i32(); + tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); + tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero, + dest, frm); + tcg_temp_free_i32(tmp); + break; + } + tcg_gen_st_f32(dest, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i32(frn); + tcg_temp_free_i32(frm); + tcg_temp_free_i32(dest); + + tcg_temp_free_i32(zero); + } + + return true; +} + +static bool trans_VMINMAXNM(DisasContext *s, arg_VMINMAXNM *a) +{ + uint32_t rd, rn, rm; + bool dp = a->dp; + bool vmin = a->op; + TCGv_ptr fpst; + + if (!dc_isar_feature(aa32_vminmaxnm, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (dp && !dc_isar_feature(aa32_fp_d32, s) && + ((a->vm | a->vn | a->vd) & 0x10)) { + return false; + } + rd = a->vd; + rn = a->vn; + rm = a->vm; + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(0); + + if (dp) { + TCGv_i64 frn, frm, dest; + + frn = tcg_temp_new_i64(); + frm = tcg_temp_new_i64(); + dest = tcg_temp_new_i64(); + + tcg_gen_ld_f64(frn, cpu_env, vfp_reg_offset(dp, rn)); + tcg_gen_ld_f64(frm, cpu_env, vfp_reg_offset(dp, rm)); + if (vmin) { + gen_helper_vfp_minnumd(dest, frn, frm, fpst); + } else { + gen_helper_vfp_maxnumd(dest, frn, frm, fpst); + } + tcg_gen_st_f64(dest, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i64(frn); + tcg_temp_free_i64(frm); + tcg_temp_free_i64(dest); + } else { + TCGv_i32 frn, frm, dest; + + frn = tcg_temp_new_i32(); + frm = tcg_temp_new_i32(); + dest = tcg_temp_new_i32(); + + tcg_gen_ld_f32(frn, cpu_env, vfp_reg_offset(dp, rn)); + tcg_gen_ld_f32(frm, cpu_env, vfp_reg_offset(dp, rm)); + if (vmin) { + gen_helper_vfp_minnums(dest, frn, frm, fpst); + } else { + gen_helper_vfp_maxnums(dest, frn, frm, fpst); + } + tcg_gen_st_f32(dest, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i32(frn); + tcg_temp_free_i32(frm); + tcg_temp_free_i32(dest); + } + + tcg_temp_free_ptr(fpst); + return true; +} + +/* + * Table for converting the most common AArch32 encoding of + * rounding mode to arm_fprounding order (which matches the + * common AArch64 order); see ARM ARM pseudocode FPDecodeRM(). + */ +static const uint8_t fp_decode_rm[] = { + FPROUNDING_TIEAWAY, + FPROUNDING_TIEEVEN, + FPROUNDING_POSINF, + FPROUNDING_NEGINF, +}; + +static bool trans_VRINT(DisasContext *s, arg_VRINT *a) +{ + uint32_t rd, rm; + bool dp = a->dp; + TCGv_ptr fpst; + TCGv_i32 tcg_rmode; + int rounding = fp_decode_rm[a->rm]; + + if (!dc_isar_feature(aa32_vrint, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (dp && !dc_isar_feature(aa32_fp_d32, s) && + ((a->vm | a->vd) & 0x10)) { + return false; + } + rd = a->vd; + rm = a->vm; + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(0); + + tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding)); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + + if (dp) { + TCGv_i64 tcg_op; + TCGv_i64 tcg_res; + tcg_op = tcg_temp_new_i64(); + tcg_res = tcg_temp_new_i64(); + tcg_gen_ld_f64(tcg_op, cpu_env, vfp_reg_offset(dp, rm)); + gen_helper_rintd(tcg_res, tcg_op, fpst); + tcg_gen_st_f64(tcg_res, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i64(tcg_op); + tcg_temp_free_i64(tcg_res); + } else { + TCGv_i32 tcg_op; + TCGv_i32 tcg_res; + tcg_op = tcg_temp_new_i32(); + tcg_res = tcg_temp_new_i32(); + tcg_gen_ld_f32(tcg_op, cpu_env, vfp_reg_offset(dp, rm)); + gen_helper_rints(tcg_res, tcg_op, fpst); + tcg_gen_st_f32(tcg_res, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i32(tcg_op); + tcg_temp_free_i32(tcg_res); + } + + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_temp_free_i32(tcg_rmode); + + tcg_temp_free_ptr(fpst); + return true; +} + +static bool trans_VCVT(DisasContext *s, arg_VCVT *a) +{ + uint32_t rd, rm; + bool dp = a->dp; + TCGv_ptr fpst; + TCGv_i32 tcg_rmode, tcg_shift; + int rounding = fp_decode_rm[a->rm]; + bool is_signed = a->op; + + if (!dc_isar_feature(aa32_vcvt_dr, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (dp && !dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { + return false; + } + rd = a->vd; + rm = a->vm; + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(0); + + tcg_shift = tcg_const_i32(0); + + tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding)); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + + if (dp) { + TCGv_i64 tcg_double, tcg_res; + TCGv_i32 tcg_tmp; + tcg_double = tcg_temp_new_i64(); + tcg_res = tcg_temp_new_i64(); + tcg_tmp = tcg_temp_new_i32(); + tcg_gen_ld_f64(tcg_double, cpu_env, vfp_reg_offset(1, rm)); + if (is_signed) { + gen_helper_vfp_tosld(tcg_res, tcg_double, tcg_shift, fpst); + } else { + gen_helper_vfp_tould(tcg_res, tcg_double, tcg_shift, fpst); + } + tcg_gen_extrl_i64_i32(tcg_tmp, tcg_res); + tcg_gen_st_f32(tcg_tmp, cpu_env, vfp_reg_offset(0, rd)); + tcg_temp_free_i32(tcg_tmp); + tcg_temp_free_i64(tcg_res); + tcg_temp_free_i64(tcg_double); + } else { + TCGv_i32 tcg_single, tcg_res; + tcg_single = tcg_temp_new_i32(); + tcg_res = tcg_temp_new_i32(); + tcg_gen_ld_f32(tcg_single, cpu_env, vfp_reg_offset(0, rm)); + if (is_signed) { + gen_helper_vfp_tosls(tcg_res, tcg_single, tcg_shift, fpst); + } else { + gen_helper_vfp_touls(tcg_res, tcg_single, tcg_shift, fpst); + } + tcg_gen_st_f32(tcg_res, cpu_env, vfp_reg_offset(0, rd)); + tcg_temp_free_i32(tcg_res); + tcg_temp_free_i32(tcg_single); + } + + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_temp_free_i32(tcg_rmode); + + tcg_temp_free_i32(tcg_shift); + + tcg_temp_free_ptr(fpst); + + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index d59fadc8fbe..62a6c860d8a 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3076,343 +3076,6 @@ static void gen_neon_dup_high16(TCGv_i32 var) tcg_temp_free_i32(tmp); } -static bool trans_VSEL(DisasContext *s, arg_VSEL *a) -{ - uint32_t rd, rn, rm; - bool dp = a->dp; - - if (!dc_isar_feature(aa32_vsel, s)) { - return false; - } - - /* UNDEF accesses to D16-D31 if they don't exist */ - if (dp && !dc_isar_feature(aa32_fp_d32, s) && - ((a->vm | a->vn | a->vd) & 0x10)) { - return false; - } - rd = a->vd; - rn = a->vn; - rm = a->vm; - - if (!vfp_access_check(s)) { - return true; - } - - if (dp) { - TCGv_i64 frn, frm, dest; - TCGv_i64 tmp, zero, zf, nf, vf; - - zero = tcg_const_i64(0); - - frn = tcg_temp_new_i64(); - frm = tcg_temp_new_i64(); - dest = tcg_temp_new_i64(); - - zf = tcg_temp_new_i64(); - nf = tcg_temp_new_i64(); - vf = tcg_temp_new_i64(); - - tcg_gen_extu_i32_i64(zf, cpu_ZF); - tcg_gen_ext_i32_i64(nf, cpu_NF); - tcg_gen_ext_i32_i64(vf, cpu_VF); - - tcg_gen_ld_f64(frn, cpu_env, vfp_reg_offset(dp, rn)); - tcg_gen_ld_f64(frm, cpu_env, vfp_reg_offset(dp, rm)); - switch (a->cc) { - case 0: /* eq: Z */ - tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero, - frn, frm); - break; - case 1: /* vs: V */ - tcg_gen_movcond_i64(TCG_COND_LT, dest, vf, zero, - frn, frm); - break; - case 2: /* ge: N == V -> N ^ V == 0 */ - tmp = tcg_temp_new_i64(); - tcg_gen_xor_i64(tmp, vf, nf); - tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero, - frn, frm); - tcg_temp_free_i64(tmp); - break; - case 3: /* gt: !Z && N == V */ - tcg_gen_movcond_i64(TCG_COND_NE, dest, zf, zero, - frn, frm); - tmp = tcg_temp_new_i64(); - tcg_gen_xor_i64(tmp, vf, nf); - tcg_gen_movcond_i64(TCG_COND_GE, dest, tmp, zero, - dest, frm); - tcg_temp_free_i64(tmp); - break; - } - tcg_gen_st_f64(dest, cpu_env, vfp_reg_offset(dp, rd)); - tcg_temp_free_i64(frn); - tcg_temp_free_i64(frm); - tcg_temp_free_i64(dest); - - tcg_temp_free_i64(zf); - tcg_temp_free_i64(nf); - tcg_temp_free_i64(vf); - - tcg_temp_free_i64(zero); - } else { - TCGv_i32 frn, frm, dest; - TCGv_i32 tmp, zero; - - zero = tcg_const_i32(0); - - frn = tcg_temp_new_i32(); - frm = tcg_temp_new_i32(); - dest = tcg_temp_new_i32(); - tcg_gen_ld_f32(frn, cpu_env, vfp_reg_offset(dp, rn)); - tcg_gen_ld_f32(frm, cpu_env, vfp_reg_offset(dp, rm)); - switch (a->cc) { - case 0: /* eq: Z */ - tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero, - frn, frm); - break; - case 1: /* vs: V */ - tcg_gen_movcond_i32(TCG_COND_LT, dest, cpu_VF, zero, - frn, frm); - break; - case 2: /* ge: N == V -> N ^ V == 0 */ - tmp = tcg_temp_new_i32(); - tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); - tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero, - frn, frm); - tcg_temp_free_i32(tmp); - break; - case 3: /* gt: !Z && N == V */ - tcg_gen_movcond_i32(TCG_COND_NE, dest, cpu_ZF, zero, - frn, frm); - tmp = tcg_temp_new_i32(); - tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); - tcg_gen_movcond_i32(TCG_COND_GE, dest, tmp, zero, - dest, frm); - tcg_temp_free_i32(tmp); - break; - } - tcg_gen_st_f32(dest, cpu_env, vfp_reg_offset(dp, rd)); - tcg_temp_free_i32(frn); - tcg_temp_free_i32(frm); - tcg_temp_free_i32(dest); - - tcg_temp_free_i32(zero); - } - - return true; -} - -static bool trans_VMINMAXNM(DisasContext *s, arg_VMINMAXNM *a) -{ - uint32_t rd, rn, rm; - bool dp = a->dp; - bool vmin = a->op; - TCGv_ptr fpst; - - if (!dc_isar_feature(aa32_vminmaxnm, s)) { - return false; - } - - /* UNDEF accesses to D16-D31 if they don't exist */ - if (dp && !dc_isar_feature(aa32_fp_d32, s) && - ((a->vm | a->vn | a->vd) & 0x10)) { - return false; - } - rd = a->vd; - rn = a->vn; - rm = a->vm; - - if (!vfp_access_check(s)) { - return true; - } - - fpst = get_fpstatus_ptr(0); - - if (dp) { - TCGv_i64 frn, frm, dest; - - frn = tcg_temp_new_i64(); - frm = tcg_temp_new_i64(); - dest = tcg_temp_new_i64(); - - tcg_gen_ld_f64(frn, cpu_env, vfp_reg_offset(dp, rn)); - tcg_gen_ld_f64(frm, cpu_env, vfp_reg_offset(dp, rm)); - if (vmin) { - gen_helper_vfp_minnumd(dest, frn, frm, fpst); - } else { - gen_helper_vfp_maxnumd(dest, frn, frm, fpst); - } - tcg_gen_st_f64(dest, cpu_env, vfp_reg_offset(dp, rd)); - tcg_temp_free_i64(frn); - tcg_temp_free_i64(frm); - tcg_temp_free_i64(dest); - } else { - TCGv_i32 frn, frm, dest; - - frn = tcg_temp_new_i32(); - frm = tcg_temp_new_i32(); - dest = tcg_temp_new_i32(); - - tcg_gen_ld_f32(frn, cpu_env, vfp_reg_offset(dp, rn)); - tcg_gen_ld_f32(frm, cpu_env, vfp_reg_offset(dp, rm)); - if (vmin) { - gen_helper_vfp_minnums(dest, frn, frm, fpst); - } else { - gen_helper_vfp_maxnums(dest, frn, frm, fpst); - } - tcg_gen_st_f32(dest, cpu_env, vfp_reg_offset(dp, rd)); - tcg_temp_free_i32(frn); - tcg_temp_free_i32(frm); - tcg_temp_free_i32(dest); - } - - tcg_temp_free_ptr(fpst); - return true; -} - -/* - * Table for converting the most common AArch32 encoding of - * rounding mode to arm_fprounding order (which matches the - * common AArch64 order); see ARM ARM pseudocode FPDecodeRM(). - */ -static const uint8_t fp_decode_rm[] = { - FPROUNDING_TIEAWAY, - FPROUNDING_TIEEVEN, - FPROUNDING_POSINF, - FPROUNDING_NEGINF, -}; - -static bool trans_VRINT(DisasContext *s, arg_VRINT *a) -{ - uint32_t rd, rm; - bool dp = a->dp; - TCGv_ptr fpst; - TCGv_i32 tcg_rmode; - int rounding = fp_decode_rm[a->rm]; - - if (!dc_isar_feature(aa32_vrint, s)) { - return false; - } - - /* UNDEF accesses to D16-D31 if they don't exist */ - if (dp && !dc_isar_feature(aa32_fp_d32, s) && - ((a->vm | a->vd) & 0x10)) { - return false; - } - rd = a->vd; - rm = a->vm; - - if (!vfp_access_check(s)) { - return true; - } - - fpst = get_fpstatus_ptr(0); - - tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - - if (dp) { - TCGv_i64 tcg_op; - TCGv_i64 tcg_res; - tcg_op = tcg_temp_new_i64(); - tcg_res = tcg_temp_new_i64(); - tcg_gen_ld_f64(tcg_op, cpu_env, vfp_reg_offset(dp, rm)); - gen_helper_rintd(tcg_res, tcg_op, fpst); - tcg_gen_st_f64(tcg_res, cpu_env, vfp_reg_offset(dp, rd)); - tcg_temp_free_i64(tcg_op); - tcg_temp_free_i64(tcg_res); - } else { - TCGv_i32 tcg_op; - TCGv_i32 tcg_res; - tcg_op = tcg_temp_new_i32(); - tcg_res = tcg_temp_new_i32(); - tcg_gen_ld_f32(tcg_op, cpu_env, vfp_reg_offset(dp, rm)); - gen_helper_rints(tcg_res, tcg_op, fpst); - tcg_gen_st_f32(tcg_res, cpu_env, vfp_reg_offset(dp, rd)); - tcg_temp_free_i32(tcg_op); - tcg_temp_free_i32(tcg_res); - } - - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - tcg_temp_free_i32(tcg_rmode); - - tcg_temp_free_ptr(fpst); - return true; -} - -static bool trans_VCVT(DisasContext *s, arg_VCVT *a) -{ - uint32_t rd, rm; - bool dp = a->dp; - TCGv_ptr fpst; - TCGv_i32 tcg_rmode, tcg_shift; - int rounding = fp_decode_rm[a->rm]; - bool is_signed = a->op; - - if (!dc_isar_feature(aa32_vcvt_dr, s)) { - return false; - } - - /* UNDEF accesses to D16-D31 if they don't exist */ - if (dp && !dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { - return false; - } - rd = a->vd; - rm = a->vm; - - if (!vfp_access_check(s)) { - return true; - } - - fpst = get_fpstatus_ptr(0); - - tcg_shift = tcg_const_i32(0); - - tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - - if (dp) { - TCGv_i64 tcg_double, tcg_res; - TCGv_i32 tcg_tmp; - tcg_double = tcg_temp_new_i64(); - tcg_res = tcg_temp_new_i64(); - tcg_tmp = tcg_temp_new_i32(); - tcg_gen_ld_f64(tcg_double, cpu_env, vfp_reg_offset(1, rm)); - if (is_signed) { - gen_helper_vfp_tosld(tcg_res, tcg_double, tcg_shift, fpst); - } else { - gen_helper_vfp_tould(tcg_res, tcg_double, tcg_shift, fpst); - } - tcg_gen_extrl_i64_i32(tcg_tmp, tcg_res); - tcg_gen_st_f32(tcg_tmp, cpu_env, vfp_reg_offset(0, rd)); - tcg_temp_free_i32(tcg_tmp); - tcg_temp_free_i64(tcg_res); - tcg_temp_free_i64(tcg_double); - } else { - TCGv_i32 tcg_single, tcg_res; - tcg_single = tcg_temp_new_i32(); - tcg_res = tcg_temp_new_i32(); - tcg_gen_ld_f32(tcg_single, cpu_env, vfp_reg_offset(0, rm)); - if (is_signed) { - gen_helper_vfp_tosls(tcg_res, tcg_single, tcg_shift, fpst); - } else { - gen_helper_vfp_touls(tcg_res, tcg_single, tcg_shift, fpst); - } - tcg_gen_st_f32(tcg_res, cpu_env, vfp_reg_offset(0, rd)); - tcg_temp_free_i32(tcg_res); - tcg_temp_free_i32(tcg_single); - } - - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - tcg_temp_free_i32(tcg_rmode); - - tcg_temp_free_i32(tcg_shift); - - tcg_temp_free_ptr(fpst); - - return true; -} - /* * Disassemble a VFP instruction. Returns nonzero if an error occurred * (ie. an undefined instruction). From patchwork Thu Jun 13 12:14:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166625 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp712497ilk; Thu, 13 Jun 2019 05:44:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLFz46UeAIjx4onTIILyy+3HwBI6UJCCasc9JKav31D4THDaBZDAMS2yDoUOBo3wTyCEnt X-Received: by 2002:ac8:34c6:: with SMTP id x6mr10511926qtb.353.1560429860800; Thu, 13 Jun 2019 05:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429860; cv=none; d=google.com; s=arc-20160816; b=l5MqUX4chp8FYdb5msqWKA2VjzO0cGvbb7dGcyE9bfQ27Gg++4CDfWQjB0dHkaNvNp 11NMumwgX0E4y8hVP2UmrXHLoP9zjpZYirrDCCRWcsufxl5zz/c20I1uJfOD7l/2rUC6 /gx2XhDj2IwjIKu4/jcY0lvplKlF910e6+2H0i1Dn9gaUxJGk7JQG83Bh62Ezmd4cHnP pLtL6dvvCIMWeT0lJ2Exhl6dvjm+E1sk3Yoy/uj8kPQwK1aGc4aNSiYHzT4YpqnaVRTW NZSfxBeZBeSw2QkIcFI0MIpUduXt59QwBaK1VUR3SZd0aAjjtptGD6/synI65EsKcr/O jgGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=p3d6LVQh8jIBuSkoLGFeMkgwvGAqT2KuhV1VbxTzLfc=; b=UbQbkfjniZ7NbV7doN2lYxXu/Wjm+1T2d2Z/5kV9AlP8dhrgubQPaollaRelpAxmNU cK4xn3OjxjxUK7Z07BvJ/inF4RwtpS8C+ZEGyN85ZsBuaL1ELih55muZs3pWApuHd6If ujcYV3pG0U/6vYS8psBmBHgznXKIlh06zO5WCn8OyzurGGdwbDR9sW0nhjx2ZV6otkS2 Wq0kN/Cs7Ti7douP0ahhGBCB/+3xgpGSLsaPSsEAhKHRxZ417vjcMP8cFvWBlyd1tTEs +FJNeD+CCrqpgE0g7UA02rgZ7few91IFlAX1cpF8ZU94/jtCV7RospUwGWB471UI/WuO FOgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dF70GZqu; 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=fail (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 h14si1314367qvj.217.2019.06.13.05.44.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:44:20 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=dF70GZqu; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbP5Y-00014i-DY for patch@linaro.org; Thu, 13 Jun 2019 08:44:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59076) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdN-000828-7Y for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdJ-0004Mb-CS for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:11 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:41097) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdF-00046j-Cr for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:07 -0400 Received: by mail-wr1-x441.google.com with SMTP id c2so20520052wrm.8 for ; Thu, 13 Jun 2019 05:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=p3d6LVQh8jIBuSkoLGFeMkgwvGAqT2KuhV1VbxTzLfc=; b=dF70GZquXtytIOxrzkicyKANNZmo78PdUVvZVmlKr6un7lS3LT+nUVbquoS5Rp0ybX Rz4yEPw3ZiCIOWuhjyRwZDH7N0b/hOZg0ECUfTLIHa0oclP4KVJrRf4jAiYR++LnEPix DvXYwSd5LZQXvgKBMwiQ722wH8IOcfIEiB26mKGPEX8adrLZrA6hN18w7sXspzL6oBbI /+CNYWheCPhhm54JsrGkDHl+YI39NZeUiSVbk/7jAQe0TMBo/p6QH/MfeWXp2bAyuQAB N+KmkWmB0zKpFDPAhWQzM0xBrytya8ynRkJ/LhMPiYk4n8j36861O5yP5GujEZShi7RR tSXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p3d6LVQh8jIBuSkoLGFeMkgwvGAqT2KuhV1VbxTzLfc=; b=PjqU0ByBN0mo4cazlumFgoYcvs8O1jRXvulSk6GK5GIWO9zC0YBkXLdtkjPFYS1p16 7A6Fw7XS2hRVFg1296/VngOmUemJRrKO46c9gNp8oPpZ3TDIeo/W7H9fRbfOQWFYkfEr HLxdzuxyz8Lqm6ynqRpMJfW0OA/iHjmCg1YSSwPv5LemZ+CC1+gADCL1QN2OOsKOHkix vvKBefDx3NBJfxgAxHgorp6ZK+6O0NgJQ9bI2LuHxZaaFjKKLGEKIIIoNElK0GrqqGay mfM36ynQhWH7Ob3zov1jECB/8yhrG7RZnJTHl4WgN5cCnw1wxTq+vovzoTcaEFsqKy/T KAuw== X-Gm-Message-State: APjAAAV9xIaVEHEGlnfCsQoiJfeU0nvzeF7DSTFPcubkocYBimBU1hAZ i8AzRvOFz/8VWP197q6QljMwisi6oMcvrg== X-Received: by 2002:a5d:4d84:: with SMTP id b4mr6397452wru.242.1560428094042; Thu, 13 Jun 2019 05:14:54 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:02 +0100 Message-Id: <20190613121433.5246-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 17/48] target/arm: Add helpers for VFP register loads and stores 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The current VFP code has two different idioms for loading and storing from the VFP register file: 1 using the gen_mov_F0_vreg() and similar functions, which load and store to a fixed set of TCG globals cpu_F0s, CPU_F0d, etc 2 by direct calls to tcg_gen_ld_f64() and friends We want to phase out idiom 1 (because the use of the fixed globals is a relic of a much older version of TCG), but idiom 2 is quite longwinded: tcg_gen_ld_f64(tmp, cpu_env, vfp_reg_offset(true, reg)) requires us to specify the 64-bitness twice, once in the function name and once by passing 'true' to vfp_reg_offset(). There's no guard against accidentally passing the wrong flag. Instead, let's move to a convention of accessing 64-bit registers via the existing neon_load_reg64() and neon_store_reg64(), and provide new neon_load_reg32() and neon_store_reg32() for the 32-bit equivalents. Implement the new functions and use them in the code in translate-vfp.inc.c. We will convert the rest of the VFP code as we do the decodetree conversion in subsequent commits. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 40 +++++++++++++++++----------------- target/arm/translate.c | 10 +++++++++ 2 files changed, 30 insertions(+), 20 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 2f070a6e0d9..24358f3d3eb 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -179,8 +179,8 @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) tcg_gen_ext_i32_i64(nf, cpu_NF); tcg_gen_ext_i32_i64(vf, cpu_VF); - tcg_gen_ld_f64(frn, cpu_env, vfp_reg_offset(dp, rn)); - tcg_gen_ld_f64(frm, cpu_env, vfp_reg_offset(dp, rm)); + neon_load_reg64(frn, rn); + neon_load_reg64(frm, rm); switch (a->cc) { case 0: /* eq: Z */ tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero, @@ -207,7 +207,7 @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) tcg_temp_free_i64(tmp); break; } - tcg_gen_st_f64(dest, cpu_env, vfp_reg_offset(dp, rd)); + neon_store_reg64(dest, rd); tcg_temp_free_i64(frn); tcg_temp_free_i64(frm); tcg_temp_free_i64(dest); @@ -226,8 +226,8 @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) frn = tcg_temp_new_i32(); frm = tcg_temp_new_i32(); dest = tcg_temp_new_i32(); - tcg_gen_ld_f32(frn, cpu_env, vfp_reg_offset(dp, rn)); - tcg_gen_ld_f32(frm, cpu_env, vfp_reg_offset(dp, rm)); + neon_load_reg32(frn, rn); + neon_load_reg32(frm, rm); switch (a->cc) { case 0: /* eq: Z */ tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero, @@ -254,7 +254,7 @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) tcg_temp_free_i32(tmp); break; } - tcg_gen_st_f32(dest, cpu_env, vfp_reg_offset(dp, rd)); + neon_store_reg32(dest, rd); tcg_temp_free_i32(frn); tcg_temp_free_i32(frm); tcg_temp_free_i32(dest); @@ -298,14 +298,14 @@ static bool trans_VMINMAXNM(DisasContext *s, arg_VMINMAXNM *a) frm = tcg_temp_new_i64(); dest = tcg_temp_new_i64(); - tcg_gen_ld_f64(frn, cpu_env, vfp_reg_offset(dp, rn)); - tcg_gen_ld_f64(frm, cpu_env, vfp_reg_offset(dp, rm)); + neon_load_reg64(frn, rn); + neon_load_reg64(frm, rm); if (vmin) { gen_helper_vfp_minnumd(dest, frn, frm, fpst); } else { gen_helper_vfp_maxnumd(dest, frn, frm, fpst); } - tcg_gen_st_f64(dest, cpu_env, vfp_reg_offset(dp, rd)); + neon_store_reg64(dest, rd); tcg_temp_free_i64(frn); tcg_temp_free_i64(frm); tcg_temp_free_i64(dest); @@ -316,14 +316,14 @@ static bool trans_VMINMAXNM(DisasContext *s, arg_VMINMAXNM *a) frm = tcg_temp_new_i32(); dest = tcg_temp_new_i32(); - tcg_gen_ld_f32(frn, cpu_env, vfp_reg_offset(dp, rn)); - tcg_gen_ld_f32(frm, cpu_env, vfp_reg_offset(dp, rm)); + neon_load_reg32(frn, rn); + neon_load_reg32(frm, rm); if (vmin) { gen_helper_vfp_minnums(dest, frn, frm, fpst); } else { gen_helper_vfp_maxnums(dest, frn, frm, fpst); } - tcg_gen_st_f32(dest, cpu_env, vfp_reg_offset(dp, rd)); + neon_store_reg32(dest, rd); tcg_temp_free_i32(frn); tcg_temp_free_i32(frm); tcg_temp_free_i32(dest); @@ -379,9 +379,9 @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) TCGv_i64 tcg_res; tcg_op = tcg_temp_new_i64(); tcg_res = tcg_temp_new_i64(); - tcg_gen_ld_f64(tcg_op, cpu_env, vfp_reg_offset(dp, rm)); + neon_load_reg64(tcg_op, rm); gen_helper_rintd(tcg_res, tcg_op, fpst); - tcg_gen_st_f64(tcg_res, cpu_env, vfp_reg_offset(dp, rd)); + neon_store_reg64(tcg_res, rd); tcg_temp_free_i64(tcg_op); tcg_temp_free_i64(tcg_res); } else { @@ -389,9 +389,9 @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) TCGv_i32 tcg_res; tcg_op = tcg_temp_new_i32(); tcg_res = tcg_temp_new_i32(); - tcg_gen_ld_f32(tcg_op, cpu_env, vfp_reg_offset(dp, rm)); + neon_load_reg32(tcg_op, rm); gen_helper_rints(tcg_res, tcg_op, fpst); - tcg_gen_st_f32(tcg_res, cpu_env, vfp_reg_offset(dp, rd)); + neon_store_reg32(tcg_res, rd); tcg_temp_free_i32(tcg_op); tcg_temp_free_i32(tcg_res); } @@ -440,14 +440,14 @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) tcg_double = tcg_temp_new_i64(); tcg_res = tcg_temp_new_i64(); tcg_tmp = tcg_temp_new_i32(); - tcg_gen_ld_f64(tcg_double, cpu_env, vfp_reg_offset(1, rm)); + neon_load_reg64(tcg_double, rm); if (is_signed) { gen_helper_vfp_tosld(tcg_res, tcg_double, tcg_shift, fpst); } else { gen_helper_vfp_tould(tcg_res, tcg_double, tcg_shift, fpst); } tcg_gen_extrl_i64_i32(tcg_tmp, tcg_res); - tcg_gen_st_f32(tcg_tmp, cpu_env, vfp_reg_offset(0, rd)); + neon_store_reg32(tcg_tmp, rd); tcg_temp_free_i32(tcg_tmp); tcg_temp_free_i64(tcg_res); tcg_temp_free_i64(tcg_double); @@ -455,13 +455,13 @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) TCGv_i32 tcg_single, tcg_res; tcg_single = tcg_temp_new_i32(); tcg_res = tcg_temp_new_i32(); - tcg_gen_ld_f32(tcg_single, cpu_env, vfp_reg_offset(0, rm)); + neon_load_reg32(tcg_single, rm); if (is_signed) { gen_helper_vfp_tosls(tcg_res, tcg_single, tcg_shift, fpst); } else { gen_helper_vfp_touls(tcg_res, tcg_single, tcg_shift, fpst); } - tcg_gen_st_f32(tcg_res, cpu_env, vfp_reg_offset(0, rd)); + neon_store_reg32(tcg_res, rd); tcg_temp_free_i32(tcg_res); tcg_temp_free_i32(tcg_single); } diff --git a/target/arm/translate.c b/target/arm/translate.c index 62a6c860d8a..bebd03f9da8 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1689,6 +1689,16 @@ static inline void neon_store_reg64(TCGv_i64 var, int reg) tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg)); } +static inline void neon_load_reg32(TCGv_i32 var, int reg) +{ + tcg_gen_ld_i32(var, cpu_env, vfp_reg_offset(false, reg)); +} + +static inline void neon_store_reg32(TCGv_i32 var, int reg) +{ + tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); +} + static TCGv_ptr vfp_reg_ptr(bool dp, int reg) { TCGv_ptr ret = tcg_temp_new_ptr(); From patchwork Thu Jun 13 12:14:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166624 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp711921ilk; Thu, 13 Jun 2019 05:43:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxhA9B+qxxOC+NNeGxscXIBzjUYx0P1xcBZWjK6TmikAXFhn6+wLum26k6r/dJkHc5E22d X-Received: by 2002:a0c:9302:: with SMTP id d2mr3394577qvd.179.1560429824150; Thu, 13 Jun 2019 05:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429824; cv=none; d=google.com; s=arc-20160816; b=YD8CYYhz6WFYT6PiGa44rcolio9MnXpLsqzjuW/zzIDslVABvY/sNun5ARyuUKLMOX qkEydDdrEgP3oLJgpjT3Qd/b4fc0mYDexAeJKck0IvZ8Q8YWce8FIpiWJW49+IqBXXGX HijhEXjUcyrMoqQsshEWJXeR/uTYiaAd8+fAIGsow7kwCCfGikf0DwmZ8WtPqVhzJjiZ F3cOa62k6TOVT3zwglyhNAaqhuRU0wVi/MKGQ4O5uzfQvv9JoTjsa5l1VXjM80CqUoNC OywGLSR6sNPzCWjRxPpK6nMJ2CNOXMgHUbwNLNXtxgzNnuCe1Y7NjLTdC/HXdUkH+ntO 8DdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Wun7v8ziEJU7Y16HcNfdAppp3ATFiw3GSpGschvFs5g=; b=Uoeu7Hrxgi3WNnpRgI9zZ0GRxiYWOCDvgmrAie2ocjgSbQazS6gauXaNpjKtTNIu/I PQanUR6PF2gHccvJmHC1ddAMR8rM7MiBAobZ0ewBCuVQxdns+E5iy3D/2Xkxc8hTvQHl pcskvuXHQHusk/WrN7E3tLSRm3bfJnO0ls+jMO7vEr5uzV7uIxVQsrJQW995e4hycXK3 A6msMIhWg4OUdjtFlYYWBdqBYvW8Lf3bCq/6iAkloyrYsP6AS+s4ChbTshAvjRNnR4XB yclAnD13UAndMNHTj7HlD9ng72p9v2PARMT5HTcnM/YvJ3RqJNXhQ6trRmK3Nv/TF3pp IN1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=n8DqNydj; 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=fail (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 s45si1752142qtj.304.2019.06.13.05.43.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:43:44 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=n8DqNydj; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbP4x-0000yI-On for patch@linaro.org; Thu, 13 Jun 2019 08:43:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58966) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdH-0007xz-ID for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdE-0004Hh-UH for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:07 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:32988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdA-00049C-41 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:02 -0400 Received: by mail-wr1-x42e.google.com with SMTP id n9so20573060wru.0 for ; Thu, 13 Jun 2019 05:14:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Wun7v8ziEJU7Y16HcNfdAppp3ATFiw3GSpGschvFs5g=; b=n8DqNydjY4dkxEp2lOwg3CURchNCowlqsViLoXYOqYa8yp0nS+CZFNUnw8o4NEAom3 /DYQ6xG3Dlx3SeCp2RBWAhBNr5E7oTvL9eEemm9INH+0KlPqniVD4mTe8G/ZQu4MZ0yD o5llUhkhsUFmd+a6e8+lzyr+8oYc0m7kF107EmtKHyeq/sn+M3eiLdSpWULKLrEkpPa/ AVXWbNs6N8oROtsOecmsOyn74nX7b8iq8OgEpP0FkjGg9YccEuJIy8xizFRbNv32n1zZ oXDtlZQOlPBIYmkNwwR+HN6741eGWxE3FgXC/7YfQIHBsvRttiO2a8pthsc5R3MnfuPm iA3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wun7v8ziEJU7Y16HcNfdAppp3ATFiw3GSpGschvFs5g=; b=P6hS6lDy0sah4sK1SFIhRQRKQMMxqU/5MVJX/D/PSKbE5neo/696x0clXlh0gLym7V NRIEYgfpof9rU8TiAZUr8WzFs0GufY4nvFivd91Tu9PdbxLihERY/hfptqSftw1H//os wLD+rCEIbUqRy3m9O7ROR+0FmcjmHkub8AXpGW2BC+T4IUDTBNMu0IWoxWNhwAWsix7R HxwRRomn9F25AFjkqF9DB3thMpPP8M23BnQHRV3tn3DiKnbAkp+EcetQxGJ6IVGEfXY/ aN4my705RqgO44dxH8iNcmDPrTR9+fxRy0QEvHwJi4Pwmt7WBrlOSy3GT0euORo9b2iv yYZw== X-Gm-Message-State: APjAAAX+1ufexl3KXM4djy1o+7pkyBJ7gig3Vc7bKRYxeaHYvAtM3oAv aBVF5IdAFWSrLkc5quBa56mMq8P15PZERA== X-Received: by 2002:a05:6000:104e:: with SMTP id c14mr8698133wrx.71.1560428095153; Thu, 13 Jun 2019 05:14:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:03 +0100 Message-Id: <20190613121433.5246-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e Subject: [Qemu-devel] [PULL 18/48] target/arm: Convert "double-precision" register moves to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the "double-precision" register moves to decodetree: this covers VMOV scalar-to-gpreg, VMOV gpreg-to-scalar and VDUP. Note that the conversion process has tightened up a few of the UNDEF encoding checks: we now correctly forbid: * VMOV-to-gpr with U:opc1:opc2 == 10x00 or x0x10 * VMOV-from-gpr with opc1:opc2 == 0x10 * VDUP with B:E == 11 * VDUP with Q == 1 and Vn<0> == 1 Signed-off-by: Peter Maydell --- The accesses of elements < 32 bits could be improved by doing direct ld/st of the right size rather than 32-bit read-and-shift or read-modify-write, but we leave this for later cleanup, since this series is generally trying to stick to fixing the decode. Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 147 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 83 +------------------ target/arm/vfp.decode | 36 ++++++++ 3 files changed, 185 insertions(+), 81 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 24358f3d3eb..8b0899fa05c 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -475,3 +475,150 @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) return true; } + +static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) +{ + /* VMOV scalar to general purpose register */ + TCGv_i32 tmp; + int pass; + uint32_t offset; + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vn & 0x10)) { + return false; + } + + offset = a->index << a->size; + pass = extract32(offset, 2, 1); + offset = extract32(offset, 0, 2) * 8; + + if (a->size != 2 && !arm_dc_feature(s, ARM_FEATURE_NEON)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp = neon_load_reg(a->vn, pass); + switch (a->size) { + case 0: + if (offset) { + tcg_gen_shri_i32(tmp, tmp, offset); + } + if (a->u) { + gen_uxtb(tmp); + } else { + gen_sxtb(tmp); + } + break; + case 1: + if (a->u) { + if (offset) { + tcg_gen_shri_i32(tmp, tmp, 16); + } else { + gen_uxth(tmp); + } + } else { + if (offset) { + tcg_gen_sari_i32(tmp, tmp, 16); + } else { + gen_sxth(tmp); + } + } + break; + case 2: + break; + } + store_reg(s, a->rt, tmp); + + return true; +} + +static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) +{ + /* VMOV general purpose register to scalar */ + TCGv_i32 tmp, tmp2; + int pass; + uint32_t offset; + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vn & 0x10)) { + return false; + } + + offset = a->index << a->size; + pass = extract32(offset, 2, 1); + offset = extract32(offset, 0, 2) * 8; + + if (a->size != 2 && !arm_dc_feature(s, ARM_FEATURE_NEON)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp = load_reg(s, a->rt); + switch (a->size) { + case 0: + tmp2 = neon_load_reg(a->vn, pass); + tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8); + tcg_temp_free_i32(tmp2); + break; + case 1: + tmp2 = neon_load_reg(a->vn, pass); + tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16); + tcg_temp_free_i32(tmp2); + break; + case 2: + break; + } + neon_store_reg(a->vn, pass, tmp); + + return true; +} + +static bool trans_VDUP(DisasContext *s, arg_VDUP *a) +{ + /* VDUP (general purpose register) */ + TCGv_i32 tmp; + int size, vec_size; + + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vn & 0x10)) { + return false; + } + + if (a->b && a->e) { + return false; + } + + if (a->q && (a->vn & 1)) { + return false; + } + + vec_size = a->q ? 16 : 8; + if (a->b) { + size = 0; + } else if (a->e) { + size = 1; + } else { + size = 2; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp = load_reg(s, a->rt); + tcg_gen_gvec_dup_i32(size, neon_reg_offset(a->vn, 0), + vec_size, vec_size, tmp); + tcg_temp_free_i32(tmp); + + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index bebd03f9da8..7e0771cd165 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3151,87 +3151,8 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) /* single register transfer */ rd = (insn >> 12) & 0xf; if (dp) { - int size; - int pass; - - VFP_DREG_N(rn, insn); - if (insn & 0xf) - return 1; - if (insn & 0x00c00060 - && !arm_dc_feature(s, ARM_FEATURE_NEON)) { - return 1; - } - - pass = (insn >> 21) & 1; - if (insn & (1 << 22)) { - size = 0; - offset = ((insn >> 5) & 3) * 8; - } else if (insn & (1 << 5)) { - size = 1; - offset = (insn & (1 << 6)) ? 16 : 0; - } else { - size = 2; - offset = 0; - } - if (insn & ARM_CP_RW_BIT) { - /* vfp->arm */ - tmp = neon_load_reg(rn, pass); - switch (size) { - case 0: - if (offset) - tcg_gen_shri_i32(tmp, tmp, offset); - if (insn & (1 << 23)) - gen_uxtb(tmp); - else - gen_sxtb(tmp); - break; - case 1: - if (insn & (1 << 23)) { - if (offset) { - tcg_gen_shri_i32(tmp, tmp, 16); - } else { - gen_uxth(tmp); - } - } else { - if (offset) { - tcg_gen_sari_i32(tmp, tmp, 16); - } else { - gen_sxth(tmp); - } - } - break; - case 2: - break; - } - store_reg(s, rd, tmp); - } else { - /* arm->vfp */ - tmp = load_reg(s, rd); - if (insn & (1 << 23)) { - /* VDUP */ - int vec_size = pass ? 16 : 8; - tcg_gen_gvec_dup_i32(size, neon_reg_offset(rn, 0), - vec_size, vec_size, tmp); - tcg_temp_free_i32(tmp); - } else { - /* VMOV */ - switch (size) { - case 0: - tmp2 = neon_load_reg(rn, pass); - tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8); - tcg_temp_free_i32(tmp2); - break; - case 1: - tmp2 = neon_load_reg(rn, pass); - tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16); - tcg_temp_free_i32(tmp2); - break; - case 2: - break; - } - neon_store_reg(rn, pass, tmp); - } - } + /* already handled by decodetree */ + return 1; } else { /* !dp */ bool is_sysreg; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 28ee664d8c3..8286bdc0729 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -26,3 +26,39 @@ # 1110 1110 .... .... .... 101. .... .... # (but those patterns might also cover some Neon instructions, # which do not live in this file.) + +# VFP registers have an odd encoding with a four-bit field +# and a one-bit field which are assembled in different orders +# depending on whether the register is double or single precision. +# Each individual instruction function must do the checks for +# "double register selected but CPU does not have double support" +# and "double register number has bit 4 set but CPU does not +# support D16-D31" (which should UNDEF). +%vm_dp 5:1 0:4 +%vm_sp 0:4 5:1 +%vn_dp 7:1 16:4 +%vn_sp 16:4 7:1 +%vd_dp 22:1 12:4 +%vd_sp 12:4 22:1 + +%vmov_idx_b 21:1 5:2 +%vmov_idx_h 21:1 6:1 + +# VMOV scalar to general-purpose register; note that this does +# include some Neon cases. +VMOV_to_gp ---- 1110 u:1 1. 1 .... rt:4 1011 ... 1 0000 \ + vn=%vn_dp size=0 index=%vmov_idx_b +VMOV_to_gp ---- 1110 u:1 0. 1 .... rt:4 1011 ..1 1 0000 \ + vn=%vn_dp size=1 index=%vmov_idx_h +VMOV_to_gp ---- 1110 0 0 index:1 1 .... rt:4 1011 .00 1 0000 \ + vn=%vn_dp size=2 u=0 + +VMOV_from_gp ---- 1110 0 1. 0 .... rt:4 1011 ... 1 0000 \ + vn=%vn_dp size=0 index=%vmov_idx_b +VMOV_from_gp ---- 1110 0 0. 0 .... rt:4 1011 ..1 1 0000 \ + vn=%vn_dp size=1 index=%vmov_idx_h +VMOV_from_gp ---- 1110 0 0 index:1 0 .... rt:4 1011 .00 1 0000 \ + vn=%vn_dp size=2 + +VDUP ---- 1110 1 b:1 q:1 0 .... rt:4 1011 . 0 e:1 1 0000 \ + vn=%vn_dp From patchwork Thu Jun 13 12:14:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166622 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp710684ilk; Thu, 13 Jun 2019 05:42:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyYP4stnaIAxSxZEwBok6h26HWRwQSKZlZ63yxaBp9lnXelmrKCdK6eWlA+L2Loewo60gH X-Received: by 2002:a0c:89b2:: with SMTP id 47mr3374799qvr.203.1560429746305; Thu, 13 Jun 2019 05:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429746; cv=none; d=google.com; s=arc-20160816; b=BsiE9ufg7+aVldF1gaYwD4PNBDzG3WsXUFK1WcZJGjVVz+dHZ7rCWh0h/7omHkvYw0 TfT8lwkw+Jy7GMo7TDQSrYv2NwAQdbevUnjKryhqjne57U1Y+uENlF9LuwGlUGoZWiwY 4/8Fp9jj+8NW5qBf5FRkm+NWbgbH2vhiT8c3hVdUVMg9nkbvDD5weG/ZgWtPHAwETdFI MP2f/jIE6d6H1WRagpor+OfdwQkz69FNhd48fKjSXNg/pmK9jOU/hDcZRn/QkICMtkQc r6krBA95DwHtTYFAS7i4zuH+N9SrIASLiE04NNYsJ3PVxCJ6ai++1YU4ghLpvmiWZKdT 3EUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=qxb2cNWVW74TMoQ1jNJbJ2Fkx4aU50yJ9oJqt03juyU=; b=Arm27Ffh6/+eKnlfn4MhMs90/GWPUqgTD7lV9KilP+jifUjCE3YtkMIt3rKSjOUMCd 7r6Pz7WKn+1xrlb2JVMW5xjhaHVrpRP3OujJxrlh7ZaYAgAX/ruIDeaysrB9a8cw+rK6 AHDqsFWKxjtlqyI6diP+IvM5wUI5HRPhlx6i5qzwL1EFFvI37zxZvpXHT1meGopNXzkC ggYWN3RY6aWxzUd82qlSQ8mIPvm+SfO30I6LDN7lZ4HcJpRRGlT/rApWvITbgQQ3kmkg /ff/tac8f2b4Iup1eNgDb0KXkBlET0u3CIC3+fyPcuL6osJ4etriUmv5/9QqV3hgwOpO QetA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DdbsIaWp; 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=fail (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 51si1808781qto.36.2019.06.13.05.42.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:42:26 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=DdbsIaWp; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbP3h-0007WN-TG for patch@linaro.org; Thu, 13 Jun 2019 08:42:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58964) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdH-0007xy-Ie for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdF-0004It-9m for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:07 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:38922) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdC-0004A9-Si for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:04 -0400 Received: by mail-wm1-x344.google.com with SMTP id z23so9872221wma.4 for ; Thu, 13 Jun 2019 05:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qxb2cNWVW74TMoQ1jNJbJ2Fkx4aU50yJ9oJqt03juyU=; b=DdbsIaWpqe4tf6ck5LicxgYnFhCPsBjGl7U/R9IdQUX9WURw9O8gOq6a66t3WaH+Ke F0c7PbL0PTIfr9qGHe+HtYEvzyDsgS0iXxeCYxyhYSDWCPgzWwwn2O1g/MW9dnrIr4mN gjNRJuzfXqqWAo/Ag9lYTwsHah2AUQ90AiWA6ME0hojxLSt71hP8D7nlSD7N6b7kG8hW 9ySI++T/QJm6RZL3st8JS/690ayFLSc/GpC8P8oZ1mRLJYFmO7Vjh4JZ3cTJtRWeRrKA cAa6R3ZVL2mUN3DjY1MlHdwJZkMKJjR2sQbn27sybKIMTU4+eyyxVmiYdIgHN7axmTuG mlBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qxb2cNWVW74TMoQ1jNJbJ2Fkx4aU50yJ9oJqt03juyU=; b=dpbXxVV8REcCLTfJKk5ptPtat72J3MAQGhCwHffoMIvRi1X9+EDHuVY+1K04HCR9Xh nBpwAhyFNmwBqWWNsPHuFqMcwcmIqmeGDLQKmMsOxLVoaFHgwSk/K5rxw0yBBP0gzyRz x/xu++8aJ9D3BPgG05HW6BLFQqPtPS/Jk5CvKkM7CxqX84+t9q9u62fSN0OoUujHA2WG Mxj9OB6gbO9tG6E+vbeS7VPMDPcANghAPWBn5doKrU6VNCSUu9ly8CajFkdL+6aMCjrC w3bQqVI56KVhA8a5acleKFZ0NXXfKzgrdD3kMzQhJb63nZqFBY9SqtS/+ZbDfMr0iIhr NA1Q== X-Gm-Message-State: APjAAAUsfFJotNx8oCpiL4NvgpItkGzcRU2GPsOmmw4J+2pH1+2ExV5u qIPHbCnqMZNk07A+H+K5b5U0BiebZ2yngw== X-Received: by 2002:a1c:2c41:: with SMTP id s62mr3587587wms.8.1560428096451; Thu, 13 Jun 2019 05:14:56 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:55 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:04 +0100 Message-Id: <20190613121433.5246-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PULL 19/48] target/arm: Convert "single-precision" register moves to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the "single-precision" register moves to decodetree: * VMSR * VMRS * VMOV between general purpose register and single precision Note that the VMSR/VMRS conversions make our handling of the "should this UNDEF?" checks consistent between the two instructions: * VMSR to MVFR0, MVFR1, MVFR2 now UNDEF from EL0 (previously was a nop) * VMSR to FPSID now UNDEFs from EL0 or if VFPv3 or better (previously was a nop) * VMSR to FPINST and FPINST2 now UNDEF if VFPv3 or better (previously would write to the register, which had no guest-visible effect because we always UNDEF reads) We also tighten up the decode: we were previously underdecoding some SBZ or SBO bits. The conversion of VMOV_single includes the expansion out of the gen_mov_F0_vreg()/gen_vfp_mrs() and gen_mov_vreg_F0()/gen_vfp_msr() sequences into the simpler direct load/store of the TCG temp via neon_{load,store}_reg32(): we know in the new function that we're always single-precision, we don't need to use the old-and-deprecated cpu_F0* TCG globals, and we don't happen to have the declaration of gen_vfp_msr() and gen_vfp_mrs() at the point in the file where the new function is. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 161 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 148 +----------------------------- target/arm/vfp.decode | 4 + 3 files changed, 168 insertions(+), 145 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 8b0899fa05c..74c10f9024b 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -622,3 +622,164 @@ static bool trans_VDUP(DisasContext *s, arg_VDUP *a) return true; } + +static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) +{ + TCGv_i32 tmp; + bool ignore_vfp_enabled = false; + + if (arm_dc_feature(s, ARM_FEATURE_M)) { + /* + * The only M-profile VFP vmrs/vmsr sysreg is FPSCR. + * Writes to R15 are UNPREDICTABLE; we choose to undef. + */ + if (a->rt == 15 || a->reg != ARM_VFP_FPSCR) { + return false; + } + } + + switch (a->reg) { + case ARM_VFP_FPSID: + /* + * VFPv2 allows access to FPSID from userspace; VFPv3 restricts + * all ID registers to privileged access only. + */ + if (IS_USER(s) && arm_dc_feature(s, ARM_FEATURE_VFP3)) { + return false; + } + ignore_vfp_enabled = true; + break; + case ARM_VFP_MVFR0: + case ARM_VFP_MVFR1: + if (IS_USER(s) || !arm_dc_feature(s, ARM_FEATURE_MVFR)) { + return false; + } + ignore_vfp_enabled = true; + break; + case ARM_VFP_MVFR2: + if (IS_USER(s) || !arm_dc_feature(s, ARM_FEATURE_V8)) { + return false; + } + ignore_vfp_enabled = true; + break; + case ARM_VFP_FPSCR: + break; + case ARM_VFP_FPEXC: + if (IS_USER(s)) { + return false; + } + ignore_vfp_enabled = true; + break; + case ARM_VFP_FPINST: + case ARM_VFP_FPINST2: + /* Not present in VFPv3 */ + if (IS_USER(s) || arm_dc_feature(s, ARM_FEATURE_VFP3)) { + return false; + } + break; + default: + return false; + } + + if (!full_vfp_access_check(s, ignore_vfp_enabled)) { + return true; + } + + if (a->l) { + /* VMRS, move VFP special register to gp register */ + switch (a->reg) { + case ARM_VFP_FPSID: + case ARM_VFP_FPEXC: + case ARM_VFP_FPINST: + case ARM_VFP_FPINST2: + case ARM_VFP_MVFR0: + case ARM_VFP_MVFR1: + case ARM_VFP_MVFR2: + tmp = load_cpu_field(vfp.xregs[a->reg]); + break; + case ARM_VFP_FPSCR: + if (a->rt == 15) { + tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); + tcg_gen_andi_i32(tmp, tmp, 0xf0000000); + } else { + tmp = tcg_temp_new_i32(); + gen_helper_vfp_get_fpscr(tmp, cpu_env); + } + break; + default: + g_assert_not_reached(); + } + + if (a->rt == 15) { + /* Set the 4 flag bits in the CPSR. */ + gen_set_nzcv(tmp); + tcg_temp_free_i32(tmp); + } else { + store_reg(s, a->rt, tmp); + } + } else { + /* VMSR, move gp register to VFP special register */ + switch (a->reg) { + case ARM_VFP_FPSID: + case ARM_VFP_MVFR0: + case ARM_VFP_MVFR1: + case ARM_VFP_MVFR2: + /* Writes are ignored. */ + break; + case ARM_VFP_FPSCR: + tmp = load_reg(s, a->rt); + gen_helper_vfp_set_fpscr(cpu_env, tmp); + tcg_temp_free_i32(tmp); + gen_lookup_tb(s); + break; + case ARM_VFP_FPEXC: + /* + * TODO: VFP subarchitecture support. + * For now, keep the EN bit only + */ + tmp = load_reg(s, a->rt); + tcg_gen_andi_i32(tmp, tmp, 1 << 30); + store_cpu_field(tmp, vfp.xregs[a->reg]); + gen_lookup_tb(s); + break; + case ARM_VFP_FPINST: + case ARM_VFP_FPINST2: + tmp = load_reg(s, a->rt); + store_cpu_field(tmp, vfp.xregs[a->reg]); + break; + default: + g_assert_not_reached(); + } + } + + return true; +} + +static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a) +{ + TCGv_i32 tmp; + + if (!vfp_access_check(s)) { + return true; + } + + if (a->l) { + /* VFP to general purpose register */ + tmp = tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vn); + if (a->rt == 15) { + /* Set the 4 flag bits in the CPSR. */ + gen_set_nzcv(tmp); + tcg_temp_free_i32(tmp); + } else { + store_reg(s, a->rt, tmp); + } + } else { + /* general purpose register to VFP */ + tmp = load_reg(s, a->rt); + neon_store_reg32(tmp, a->vn); + tcg_temp_free_i32(tmp); + } + + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 7e0771cd165..3982c870314 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3097,7 +3097,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) TCGv_i32 addr; TCGv_i32 tmp; TCGv_i32 tmp2; - bool ignore_vfp_enabled = false; if (!arm_dc_feature(s, ARM_FEATURE_VFP)) { return 1; @@ -3133,14 +3132,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) * for invalid encodings; we will generate incorrect syndrome information * for attempts to execute invalid vfp/neon encodings with FP disabled. */ - if ((insn & 0x0fe00fff) == 0x0ee00a10) { - rn = (insn >> 16) & 0xf; - if (rn == ARM_VFP_FPSID || rn == ARM_VFP_FPEXC || rn == ARM_VFP_MVFR2 - || rn == ARM_VFP_MVFR1 || rn == ARM_VFP_MVFR0) { - ignore_vfp_enabled = true; - } - } - if (!full_vfp_access_check(s, ignore_vfp_enabled)) { + if (!vfp_access_check(s)) { return 0; } @@ -3148,142 +3140,8 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch ((insn >> 24) & 0xf) { case 0xe: if (insn & (1 << 4)) { - /* single register transfer */ - rd = (insn >> 12) & 0xf; - if (dp) { - /* already handled by decodetree */ - return 1; - } else { /* !dp */ - bool is_sysreg; - - if ((insn & 0x6f) != 0x00) - return 1; - rn = VFP_SREG_N(insn); - - is_sysreg = extract32(insn, 21, 1); - - if (arm_dc_feature(s, ARM_FEATURE_M)) { - /* - * The only M-profile VFP vmrs/vmsr sysreg is FPSCR. - * Writes to R15 are UNPREDICTABLE; we choose to undef. - */ - if (is_sysreg && (rd == 15 || (rn >> 1) != ARM_VFP_FPSCR)) { - return 1; - } - } - - if (insn & ARM_CP_RW_BIT) { - /* vfp->arm */ - if (is_sysreg) { - /* system register */ - rn >>= 1; - - switch (rn) { - case ARM_VFP_FPSID: - /* VFP2 allows access to FSID from userspace. - VFP3 restricts all id registers to privileged - accesses. */ - if (IS_USER(s) - && arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } - tmp = load_cpu_field(vfp.xregs[rn]); - break; - case ARM_VFP_FPEXC: - if (IS_USER(s)) - return 1; - tmp = load_cpu_field(vfp.xregs[rn]); - break; - case ARM_VFP_FPINST: - case ARM_VFP_FPINST2: - /* Not present in VFP3. */ - if (IS_USER(s) - || arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } - tmp = load_cpu_field(vfp.xregs[rn]); - break; - case ARM_VFP_FPSCR: - if (rd == 15) { - tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); - tcg_gen_andi_i32(tmp, tmp, 0xf0000000); - } else { - tmp = tcg_temp_new_i32(); - gen_helper_vfp_get_fpscr(tmp, cpu_env); - } - break; - case ARM_VFP_MVFR2: - if (!arm_dc_feature(s, ARM_FEATURE_V8)) { - return 1; - } - /* fall through */ - case ARM_VFP_MVFR0: - case ARM_VFP_MVFR1: - if (IS_USER(s) - || !arm_dc_feature(s, ARM_FEATURE_MVFR)) { - return 1; - } - tmp = load_cpu_field(vfp.xregs[rn]); - break; - default: - return 1; - } - } else { - gen_mov_F0_vreg(0, rn); - tmp = gen_vfp_mrs(); - } - if (rd == 15) { - /* Set the 4 flag bits in the CPSR. */ - gen_set_nzcv(tmp); - tcg_temp_free_i32(tmp); - } else { - store_reg(s, rd, tmp); - } - } else { - /* arm->vfp */ - if (is_sysreg) { - rn >>= 1; - /* system register */ - switch (rn) { - case ARM_VFP_FPSID: - case ARM_VFP_MVFR0: - case ARM_VFP_MVFR1: - /* Writes are ignored. */ - break; - case ARM_VFP_FPSCR: - tmp = load_reg(s, rd); - gen_helper_vfp_set_fpscr(cpu_env, tmp); - tcg_temp_free_i32(tmp); - gen_lookup_tb(s); - break; - case ARM_VFP_FPEXC: - if (IS_USER(s)) - return 1; - /* TODO: VFP subarchitecture support. - * For now, keep the EN bit only */ - tmp = load_reg(s, rd); - tcg_gen_andi_i32(tmp, tmp, 1 << 30); - store_cpu_field(tmp, vfp.xregs[rn]); - gen_lookup_tb(s); - break; - case ARM_VFP_FPINST: - case ARM_VFP_FPINST2: - if (IS_USER(s)) { - return 1; - } - tmp = load_reg(s, rd); - store_cpu_field(tmp, vfp.xregs[rn]); - break; - default: - return 1; - } - } else { - tmp = load_reg(s, rd); - gen_vfp_msr(tmp); - gen_mov_vreg_F0(0, rn); - } - } - } + /* already handled by decodetree */ + return 1; } else { /* data processing */ bool rd_is_dp = dp; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 8286bdc0729..bb7de403df3 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -62,3 +62,7 @@ VMOV_from_gp ---- 1110 0 0 index:1 0 .... rt:4 1011 .00 1 0000 \ VDUP ---- 1110 1 b:1 q:1 0 .... rt:4 1011 . 0 e:1 1 0000 \ vn=%vn_dp + +VMSR_VMRS ---- 1110 111 l:1 reg:4 rt:4 1010 0001 0000 +VMOV_single ---- 1110 000 l:1 .... rt:4 1010 . 001 0000 \ + vn=%vn_sp From patchwork Thu Jun 13 12:14:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166627 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp712813ilk; Thu, 13 Jun 2019 05:44:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxafxiWoKDs0M7YA3SlIE0jMs/exFWbFMlXuB1j7T6xrpu3yOaJ/J8xKCD/+O+VLkj0L7p9 X-Received: by 2002:a0c:aecd:: with SMTP id n13mr3459086qvd.182.1560429880218; Thu, 13 Jun 2019 05:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429880; cv=none; d=google.com; s=arc-20160816; b=B3AgCxT8pHJgPkS/KTqXPITOF8JBnDw076K/7NagOsjc8vinU8hAIf7owslO/s59pb Pk0eLhvH6SoMZdtHJ8gW7oOksW/cEGiDxpMJ7z1Fb1CfSQaLhNswb3l7VdKfpMGkEyqP RZGOmaM2casBZdnomVdCkHoTSwpWvUe76BDl6e5qfODaOeeXUHD+H4LMylQTZl4FCCVZ 4KszxMwLPA4rXOqcsGStb3Taw99+AxyZoQUSYhvBMJb5GkUtBydZIZIb6gwC76a8MVkx Xh6FREkSqlsBlo4jVNFx0EzOFZrpILlMXc1B+Z74ifxkG98I8sgkMZlAqQF+rFL0O4s/ TFQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=4+VW3JoxXuJ1NoxNJ7ljWo6K8LodZM2jZoja5e7yMec=; b=ahMN61iRugulmU/hiffwdIkVk1FZafwVfdiC/RtsjUrmT0n6tjha3LmxBvQFi9ib8E mLVkSIeDxbnQ16AvjsOgZkiLlWAQEwNkoM/n4E2aeHa3BHa88tUIDxXnFtX6HBq38N+q 8s1UHExIqMb3E6so7RDSvZn+6gB+dYuGpuxcjKNKQHC9rjGoSxSmRY7zydFxop62/g1H FSIcIsoDCqtozZc/dd1jH9aGfEpCsQ3jvFyS3EZnYdZubNw76ttrpKA/lbqavtujNXLA RQJUBbU+GA58Ep18EUcFYCqv3vomw6zdurh2igJpvml/iSoruWA8mHyzrpr7ffI468fo 7VPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YJkouCQa; 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=fail (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 l9si1446996qvc.198.2019.06.13.05.44.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:44:40 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=YJkouCQa; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbP5r-00024A-Eb for patch@linaro.org; Thu, 13 Jun 2019 08:44:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58961) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdH-0007xu-Gl for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdE-0004HY-T6 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:07 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:34055) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdA-0004Ai-4D for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:02 -0400 Received: by mail-wm1-x32b.google.com with SMTP id w9so6495644wmd.1 for ; Thu, 13 Jun 2019 05:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4+VW3JoxXuJ1NoxNJ7ljWo6K8LodZM2jZoja5e7yMec=; b=YJkouCQaIiZbZia6XQdveXD5o/cvCdlZKocXJQW4D6vfBwYf8rS3hMlgrzKyS9PfPo Ksc5cN1wKGpBpP8bBMnMgagUrdBVUfsANwkNKE1KOH5y2wIUd8+wRiUey/Hl0ku91EDR WhboPCAs9ABWfR7IYr3vx+KrUCYoiUh87Xr8jXhld0BrcbZbenxt+Q3NjGlJ9wrW7RhJ 39TQhS1R9CmNfkZPvqFjGDXDaAbHjyBKuFZ5fZGVHvpQyU0MbNDEiz/FyV8WFzC7A8R3 HYlchRFxe3LJ9l3wHgp4Johcrqv51xs/vi5kifiVdR1AagKF1CeBlA+Wxmu4d/2OrFdf SRIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4+VW3JoxXuJ1NoxNJ7ljWo6K8LodZM2jZoja5e7yMec=; b=m8gSbn682ituhcYCQVzKEOzQSm+5spYeBFxM08ayI+LwtHwrNHUxhJ8H5lSMDply5H pq/N5FBzWXs1ecPa49N3oK71K9c4EjsbYY8lMJ+uazkjhM5TjKzVyQ5gtiIJ2RX0d4on K0Jh+6Pn7/wVf0+pK9h/7gsAXPWj6ORj8DotN7WI0q5yjPLq4R4JgXbSA5pZc27NLy7S Vb/ePh1iOzKGVB/meHgiNCnGhz6ft7gi6c54MFOR/0XC1WFlci0i1RCnpbLNPNWI2x0Z pOu1PwANvH04q8vUYthFAuqInra5EU4FiujHHoyY0G4V/Zp+GWCIV7Z9htlBagfWFvpA mZOQ== X-Gm-Message-State: APjAAAWDDfptyEnaQ9Oy3TyNkdxZI9AwznCg07lkeg8nyuXxhCEDftM5 af/YecrdPS/O8r1/brIZPMJhI8RE+qaR2w== X-Received: by 2002:a1c:4484:: with SMTP id r126mr3672362wma.27.1560428097741; Thu, 13 Jun 2019 05:14:57 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:56 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:05 +0100 Message-Id: <20190613121433.5246-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b Subject: [Qemu-devel] [PULL 20/48] target/arm: Convert VFP two-register transfer insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP two-register transfer instructions to decodetree (in the v8 Arm ARM these are the "Advanced SIMD and floating-point 64-bit move" encoding group). Again, we expand out the sequences involving gen_vfp_msr() and gen_msr_vfp(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 70 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 46 +--------------------- target/arm/vfp.decode | 5 +++ 3 files changed, 77 insertions(+), 44 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 74c10f9024b..5f081221b83 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -783,3 +783,73 @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a) return true; } + +static bool trans_VMOV_64_sp(DisasContext *s, arg_VMOV_64_sp *a) +{ + TCGv_i32 tmp; + + /* + * VMOV between two general-purpose registers and two single precision + * floating point registers + */ + if (!vfp_access_check(s)) { + return true; + } + + if (a->op) { + /* fpreg to gpreg */ + tmp = tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm); + store_reg(s, a->rt, tmp); + tmp = tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm + 1); + store_reg(s, a->rt2, tmp); + } else { + /* gpreg to fpreg */ + tmp = load_reg(s, a->rt); + neon_store_reg32(tmp, a->vm); + tmp = load_reg(s, a->rt2); + neon_store_reg32(tmp, a->vm + 1); + } + + return true; +} + +static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_sp *a) +{ + TCGv_i32 tmp; + + /* + * VMOV between two general-purpose registers and one double precision + * floating point register + */ + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + if (a->op) { + /* fpreg to gpreg */ + tmp = tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm * 2); + store_reg(s, a->rt, tmp); + tmp = tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm * 2 + 1); + store_reg(s, a->rt2, tmp); + } else { + /* gpreg to fpreg */ + tmp = load_reg(s, a->rt); + neon_store_reg32(tmp, a->vm * 2); + tcg_temp_free_i32(tmp); + tmp = load_reg(s, a->rt2); + neon_store_reg32(tmp, a->vm * 2 + 1); + tcg_temp_free_i32(tmp); + } + + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 3982c870314..eb217af579a 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3703,50 +3703,8 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) case 0xc: case 0xd: if ((insn & 0x03e00000) == 0x00400000) { - /* two-register transfer */ - rn = (insn >> 16) & 0xf; - rd = (insn >> 12) & 0xf; - if (dp) { - VFP_DREG_M(rm, insn); - } else { - rm = VFP_SREG_M(insn); - } - - if (insn & ARM_CP_RW_BIT) { - /* vfp->arm */ - if (dp) { - gen_mov_F0_vreg(0, rm * 2); - tmp = gen_vfp_mrs(); - store_reg(s, rd, tmp); - gen_mov_F0_vreg(0, rm * 2 + 1); - tmp = gen_vfp_mrs(); - store_reg(s, rn, tmp); - } else { - gen_mov_F0_vreg(0, rm); - tmp = gen_vfp_mrs(); - store_reg(s, rd, tmp); - gen_mov_F0_vreg(0, rm + 1); - tmp = gen_vfp_mrs(); - store_reg(s, rn, tmp); - } - } else { - /* arm->vfp */ - if (dp) { - tmp = load_reg(s, rd); - gen_vfp_msr(tmp); - gen_mov_vreg_F0(0, rm * 2); - tmp = load_reg(s, rn); - gen_vfp_msr(tmp); - gen_mov_vreg_F0(0, rm * 2 + 1); - } else { - tmp = load_reg(s, rd); - gen_vfp_msr(tmp); - gen_mov_vreg_F0(0, rm); - tmp = load_reg(s, rn); - gen_vfp_msr(tmp); - gen_mov_vreg_F0(0, rm + 1); - } - } + /* Already handled by decodetree */ + return 1; } else { /* Load/store */ rn = (insn >> 16) & 0xf; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index bb7de403df3..134f1c9ef58 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -66,3 +66,8 @@ VDUP ---- 1110 1 b:1 q:1 0 .... rt:4 1011 . 0 e:1 1 0000 \ VMSR_VMRS ---- 1110 111 l:1 reg:4 rt:4 1010 0001 0000 VMOV_single ---- 1110 000 l:1 .... rt:4 1010 . 001 0000 \ vn=%vn_sp + +VMOV_64_sp ---- 1100 010 op:1 rt2:4 rt:4 1010 00.1 .... \ + vm=%vm_sp +VMOV_64_dp ---- 1100 010 op:1 rt2:4 rt:4 1011 00.1 .... \ + vm=%vm_dp From patchwork Thu Jun 13 12:14:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166626 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp712531ilk; Thu, 13 Jun 2019 05:44:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqz49alq3e+ERD+F7/Va/NZDDE7ATz47NmUQn8Y1igmAuSTQ2D15nBHc6JcZpovmCObpbfku X-Received: by 2002:ac8:6984:: with SMTP id o4mr74534172qtq.122.1560429862924; Thu, 13 Jun 2019 05:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429862; cv=none; d=google.com; s=arc-20160816; b=LNxN3cyD0zdzaRzMnSwLH7SkvgGwWNnDJmopbDVU+PIMaILf6wuOhu9kK7V/A8CRxS hjSEvroVBDjkiFp+TrZ9UTp7fuwpdkgoBRUhvJS/htxFn6YIH6gWtG+uWts/r50B9Xw+ ed9SKanK243/9RtfqjlG+EvxLRp5lCRS4woKIzKtCELNVjZlfkV2gZnAMMUMwa6nhR/J f0RJcjOdjGbWJltA7iWXulm7SPLYm4KlOB/gWNrETAPWqSu13RCl5yQNdHl/6WOxqKBw Um2yvTyL7XL3iSMnvDJzId3eCayoNuZ2FcBLc8XXPo4XyLV/Z36ms6FdGh3H2A+XyP1p p6AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=yJiv1hSo+fvJ6FJSmb7ni56s0cGOEaImkCLppkFYZ5s=; b=Ynnz3CfbHeQ6jFq3vyzSkb+MxqTswKZIQiS5WlzCqUEP/0G+ymQrh1bCW84P7Qi4CJ ovfYXJ1YNLZDk5UwyO8c0J2EMpOErvCatft1iAe/ICS1tbIG+1oX20bK1KFxV/zLNoJh uW5eC7nBGwFn5QakErtyH/c/IZzZPO/E7WlPdnY5irKEjmTBA/68EewvlV9v5Zdgj3Uw 2vQd9yfWBFCiL9YaNNlonRMaeDWmwrWkUeIe4wxtgNozfN+khIVMjuWsUiiWbZ+lYkGw xCh7Szzlzu4MXqBW2SkxZA2MHuljpOS4dvn2f7llYSD3VwuDyz9cmzhp4r9mGdXHDN0J 92aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EZUM8ALG; 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=fail (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 w19si1848573qtk.184.2019.06.13.05.44.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:44:22 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=EZUM8ALG; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbP5a-00017B-FT for patch@linaro.org; Thu, 13 Jun 2019 08:44:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59024) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdL-00080W-Bu for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdH-0004Kp-GC for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:10 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:43689) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdF-0004BZ-Cf for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:06 -0400 Received: by mail-wr1-x443.google.com with SMTP id p13so10426556wru.10 for ; Thu, 13 Jun 2019 05:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yJiv1hSo+fvJ6FJSmb7ni56s0cGOEaImkCLppkFYZ5s=; b=EZUM8ALGzK54Lij/0VYowMLWDOZdXqSa67ANbDXhuAqsbOkDXbGLpCoU4LBsgmD5Mo 2iIiK7yLkZV1Ttjy+5Qtf9Sje8JiTxyfzgctb0aPgYZXH4ofucEHddhjlYBceG453YME aDIphsMJZcl3Cbiv/OOAHM0hGRCUBTmt3o1ddH6mTMZlunxnehmW8FqfjbEQFxbveSoh viacgCkRmGaP5rj6Kuxe/dN3jbq/6GXZW03e0do4yftUC7XDD7GeZL0ipydINdXAEXBe UQWnYgTiP7mnZ4/tVQX8qnUWc+X6jKRwthikzTYhUvVo1f1xBAAY2NbO4h9Kf84HJhE6 NlkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yJiv1hSo+fvJ6FJSmb7ni56s0cGOEaImkCLppkFYZ5s=; b=MvHJizA80hgkYmMgx/GsuIupWNXLIFhau0zfnjmeZoJ58mAtZfrdfuDzV22hxLUQjN UmFcR9bHtYVc6WKgYn/AnfqjcXTmzOqgUjtLMpF6trx2clevXLV9+aVYMrCRnVfpWF4I 0C46r9MeuSsOInW1bLP3Lj1kYka2qZg5rPOo2b1ivZZJyiDQboAQr6fyGtztAywEgB+v OxMsXsnzGjJFrrAi6eqiFr6LB9vYbNOMB5zGT/U9xc2lK4/cCtgeymQTghaye+4OcKG0 D+QKLYQC24J7r9V0c2jDqImGX6yiy8Ao4pVpCIx34R410eo9B5yi1/7vxAEPtwuy7Ojd Ax4g== X-Gm-Message-State: APjAAAW5e5i+tcjdVfeebIZPVus+ROi69+KhsHaCDCQDWc5MIXje/E4S vvRHElRK4O6fY5IsO/H2f1Z2QxMKzc87vw== X-Received: by 2002:a5d:4949:: with SMTP id r9mr751651wrs.289.1560428098932; Thu, 13 Jun 2019 05:14:58 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:06 +0100 Message-Id: <20190613121433.5246-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 21/48] target/arm: Convert VFP VLDR and VSTR to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP single load/store insns VLDR and VSTR to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 73 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 22 +--------- target/arm/vfp.decode | 7 ++++ 3 files changed, 82 insertions(+), 20 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 5f081221b83..40f2cac3e2e 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -853,3 +853,76 @@ static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_sp *a) return true; } + +static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) +{ + uint32_t offset; + TCGv_i32 addr; + + if (!vfp_access_check(s)) { + return true; + } + + offset = a->imm << 2; + if (!a->u) { + offset = -offset; + } + + if (s->thumb && a->rn == 15) { + /* This is actually UNPREDICTABLE */ + addr = tcg_temp_new_i32(); + tcg_gen_movi_i32(addr, s->pc & ~2); + } else { + addr = load_reg(s, a->rn); + } + tcg_gen_addi_i32(addr, addr, offset); + if (a->l) { + gen_vfp_ld(s, false, addr); + gen_mov_vreg_F0(false, a->vd); + } else { + gen_mov_F0_vreg(false, a->vd); + gen_vfp_st(s, false, addr); + } + tcg_temp_free_i32(addr); + + return true; +} + +static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_sp *a) +{ + uint32_t offset; + TCGv_i32 addr; + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + offset = a->imm << 2; + if (!a->u) { + offset = -offset; + } + + if (s->thumb && a->rn == 15) { + /* This is actually UNPREDICTABLE */ + addr = tcg_temp_new_i32(); + tcg_gen_movi_i32(addr, s->pc & ~2); + } else { + addr = load_reg(s, a->rn); + } + tcg_gen_addi_i32(addr, addr, offset); + if (a->l) { + gen_vfp_ld(s, true, addr); + gen_mov_vreg_F0(true, a->vd); + } else { + gen_mov_F0_vreg(true, a->vd); + gen_vfp_st(s, true, addr); + } + tcg_temp_free_i32(addr); + + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index eb217af579a..0c92f3ed4ec 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3713,26 +3713,8 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) else rd = VFP_SREG_D(insn); if ((insn & 0x01200000) == 0x01000000) { - /* Single load/store */ - offset = (insn & 0xff) << 2; - if ((insn & (1 << 23)) == 0) - offset = -offset; - if (s->thumb && rn == 15) { - /* This is actually UNPREDICTABLE */ - addr = tcg_temp_new_i32(); - tcg_gen_movi_i32(addr, s->pc & ~2); - } else { - addr = load_reg(s, rn); - } - tcg_gen_addi_i32(addr, addr, offset); - if (insn & (1 << 20)) { - gen_vfp_ld(s, dp, addr); - gen_mov_vreg_F0(dp, rd); - } else { - gen_mov_F0_vreg(dp, rd); - gen_vfp_st(s, dp, addr); - } - tcg_temp_free_i32(addr); + /* Already handled by decodetree */ + return 1; } else { /* load/store multiple */ int w = insn & (1 << 21); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 134f1c9ef58..8fa7fa0bead 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -71,3 +71,10 @@ VMOV_64_sp ---- 1100 010 op:1 rt2:4 rt:4 1010 00.1 .... \ vm=%vm_sp VMOV_64_dp ---- 1100 010 op:1 rt2:4 rt:4 1011 00.1 .... \ vm=%vm_dp + +# Note that the half-precision variants of VLDR and VSTR are +# not part of this decodetree at all because they have bits [9:8] == 0b01 +VLDR_VSTR_sp ---- 1101 u:1 .0 l:1 rn:4 .... 1010 imm:8 \ + vd=%vd_sp +VLDR_VSTR_dp ---- 1101 u:1 .0 l:1 rn:4 .... 1011 imm:8 \ + vd=%vd_dp From patchwork Thu Jun 13 12:14:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166651 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp759304ilk; Thu, 13 Jun 2019 06:23:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGJFpJ4/X4lsz3AzNJTbim997yT/lnzBP/QH69o5eh85N1vtnx2KN+dZ7Xl8/eIbK7SFap X-Received: by 2002:a0c:96e7:: with SMTP id b36mr3583187qvd.155.1560432224520; Thu, 13 Jun 2019 06:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560432224; cv=none; d=google.com; s=arc-20160816; b=ZlY0mgkCpZRMmO3Zc0J48DhLJpwzMvQrObg/NvT9OvcRIE1mgb2VLJoD5Hrz/Fa4oE 1RCOnZ/96xwIxi6caGdy4d1bcaIk58dkP7LwyoSqYFrceZoLP47AOJHPmlf2wKrqaTF8 xkoWqVfppRU85O6bQW5j2QZCY3yREkewTqBGoraWcB1r4ozJqAq97VsjTx91dMHS2NFP 5Fki2urM2QbbMJh79Cz86QWo1aybTgnVCiqepnqvnEXLvhZVC0/gcJuRhUJJy23OoIna Gic0dL/dn0Z9X+aLcvfyKSBOxJxfcruZakDL19ne1SsyVNm7FFvO/JSD+0ku2TXKK1/J exJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=9pWSJmsiYxVaBT4ZhuUEOssPCHT4ENw/4ruzvNmgVzc=; b=nrYiBc7WlCq0Vce9uhj0iJGkZdSWRnKRi9me86LnxIq8zQt2QClV/MBDoti/uUDkqR tyXOFkRVkid1VzgzvvwKlSrE+NJ+ABjLnbJ6TCp/JO41vJBhTdzxzrT+oO8JJu6+wr/p Simtw5s7IsHp2xTmfMeTRN7kDHbJ71adQr1HkAE4a1MVrXi9cuOUTe/uPycD9Ye/w5oB b365aAKzP9m1dTL0+FtIpK3YDzx/1Eqzi2U2RAnlOVbkHfvBSzjDtzEjEIu+wpfPVzIa OJG9cVOGNWr/qoor9BcCZ3w/wE1/c/4kzA+Gq1VJAXODglKhmxiZ073yPZB8DPOUE1aE utyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ALMXSS7s; 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=fail (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 a184si1789065qke.181.2019.06.13.06.23.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:23:44 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=ALMXSS7s; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPhg-0006fh-1w for patch@linaro.org; Thu, 13 Jun 2019 09:23:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59692) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdr-0008R0-SO for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdW-0004fO-8Y for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:36 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:37510) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdV-0004DD-I8 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:21 -0400 Received: by mail-wm1-x343.google.com with SMTP id 22so9882387wmg.2 for ; Thu, 13 Jun 2019 05:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9pWSJmsiYxVaBT4ZhuUEOssPCHT4ENw/4ruzvNmgVzc=; b=ALMXSS7siIl0gHl2/VshaCisXwC0DAT0vjZEashtRRo/A9ZYVIRabYZ2NYyW+VQkzm dyGthGcY0kR/lh/tFCY0MkxczlYMpu5amH562hAG9f765o6JvC34qdYZBBnBReF5sY/5 zYawAN4PPjLZF4FDO7CveXaJfS7pQGdDr+Qk9kXZCSz+Ot7AU3bvoy+kR7rp7GCUqpVC W3kxV2+PgDYAQz51Ks2vFqUf9ydrWrq9cQKwRV7x19EXCEvgba9dgTG/aX/zCREpkIAr MIj5RhEJqV903mBuz9P6uobkhQlx0WY0cc6hfVQLF4zkK7LqNV33HscY6SwZyyO0zd0R nx7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9pWSJmsiYxVaBT4ZhuUEOssPCHT4ENw/4ruzvNmgVzc=; b=GUg3+bdWXIh1KCI8fsab+XkMacSD2teUwiYYMByUzILqwdLxMyM7ugwC5Raf1VO6Yl Rqh3/7k7SjfqF2UY99dN/1nhIDlQOx2442t4w8N6uMQe29PJTFwUDx7yo2Fw59vA+eSt fB3Oe0k7Eb3nS3S33qUBjbGex90qhOB/inkLB9RSosc6Bk26RU/+bYI5Ri/J3C9yD693 kyN4a7wkiictaZ+MVnu6kct8svdDDHgueyUDVqqVEUcnJ0dBKLsuaEbgitpe4Fm4CLGv YtyofIObPXyCIZzXEr7KpU3Ht7z0MCQCVadm2Ewx8UATTgDf3ixswYChWTfSxpAJqOpa J/8A== X-Gm-Message-State: APjAAAX3u4gEOPArdRkJ0AssB/FL7OC8Su6BZBx7hlyQJBJnD+NwkdnY sGcvjuzq1j6ztoUxQo7DKhCMjbQ+dIezPw== X-Received: by 2002:a05:600c:20ca:: with SMTP id y10mr3445878wmm.72.1560428100032; Thu, 13 Jun 2019 05:15:00 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:07 +0100 Message-Id: <20190613121433.5246-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 22/48] target/arm: Convert the VFP load/store multiple insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP load/store multiple insns to decodetree. This includes tightening up the UNDEF checking for pre-VFPv3 CPUs which only have D0-D15 : they now UNDEF for any access to D16-D31, not merely when the smallest register in the transfer list is in D16-D31. This conversion does not try to share code between the single precision and the double precision versions; this looks a bit duplicative of code, but it leaves the door open for a future refactoring which gets rid of the use of the "F0" registers by inlining the various functions like gen_vfp_ld() and gen_mov_F0_reg() which are hiding "if (dp) { ... } else { ... }" conditionalisation. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 162 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 97 +------------------- target/arm/vfp.decode | 18 ++++ 3 files changed, 183 insertions(+), 94 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 40f2cac3e2e..32a1805e582 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -926,3 +926,165 @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_sp *a) return true; } + +static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) +{ + uint32_t offset; + TCGv_i32 addr; + int i, n; + + n = a->imm; + + if (n == 0 || (a->vd + n) > 32) { + /* + * UNPREDICTABLE cases for bad immediates: we choose to + * UNDEF to avoid generating huge numbers of TCG ops + */ + return false; + } + if (a->rn == 15 && a->w) { + /* writeback to PC is UNPREDICTABLE, we choose to UNDEF */ + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + if (s->thumb && a->rn == 15) { + /* This is actually UNPREDICTABLE */ + addr = tcg_temp_new_i32(); + tcg_gen_movi_i32(addr, s->pc & ~2); + } else { + addr = load_reg(s, a->rn); + } + if (a->p) { + /* pre-decrement */ + tcg_gen_addi_i32(addr, addr, -(a->imm << 2)); + } + + if (s->v8m_stackcheck && a->rn == 13 && a->w) { + /* + * Here 'addr' is the lowest address we will store to, + * and is either the old SP (if post-increment) or + * the new SP (if pre-decrement). For post-increment + * where the old value is below the limit and the new + * value is above, it is UNKNOWN whether the limit check + * triggers; we choose to trigger. + */ + gen_helper_v8m_stackcheck(cpu_env, addr); + } + + offset = 4; + for (i = 0; i < n; i++) { + if (a->l) { + /* load */ + gen_vfp_ld(s, false, addr); + gen_mov_vreg_F0(false, a->vd + i); + } else { + /* store */ + gen_mov_F0_vreg(false, a->vd + i); + gen_vfp_st(s, false, addr); + } + tcg_gen_addi_i32(addr, addr, offset); + } + if (a->w) { + /* writeback */ + if (a->p) { + offset = -offset * n; + tcg_gen_addi_i32(addr, addr, offset); + } + store_reg(s, a->rn, addr); + } else { + tcg_temp_free_i32(addr); + } + + return true; +} + +static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) +{ + uint32_t offset; + TCGv_i32 addr; + int i, n; + + n = a->imm >> 1; + + if (n == 0 || (a->vd + n) > 32 || n > 16) { + /* + * UNPREDICTABLE cases for bad immediates: we choose to + * UNDEF to avoid generating huge numbers of TCG ops + */ + return false; + } + if (a->rn == 15 && a->w) { + /* writeback to PC is UNPREDICTABLE, we choose to UNDEF */ + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd + n) > 16) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + if (s->thumb && a->rn == 15) { + /* This is actually UNPREDICTABLE */ + addr = tcg_temp_new_i32(); + tcg_gen_movi_i32(addr, s->pc & ~2); + } else { + addr = load_reg(s, a->rn); + } + if (a->p) { + /* pre-decrement */ + tcg_gen_addi_i32(addr, addr, -(a->imm << 2)); + } + + if (s->v8m_stackcheck && a->rn == 13 && a->w) { + /* + * Here 'addr' is the lowest address we will store to, + * and is either the old SP (if post-increment) or + * the new SP (if pre-decrement). For post-increment + * where the old value is below the limit and the new + * value is above, it is UNKNOWN whether the limit check + * triggers; we choose to trigger. + */ + gen_helper_v8m_stackcheck(cpu_env, addr); + } + + offset = 8; + for (i = 0; i < n; i++) { + if (a->l) { + /* load */ + gen_vfp_ld(s, true, addr); + gen_mov_vreg_F0(true, a->vd + i); + } else { + /* store */ + gen_mov_F0_vreg(true, a->vd + i); + gen_vfp_st(s, true, addr); + } + tcg_gen_addi_i32(addr, addr, offset); + } + if (a->w) { + /* writeback */ + if (a->p) { + offset = -offset * n; + } else if (a->imm & 1) { + offset = 4; + } else { + offset = 0; + } + + if (offset != 0) { + tcg_gen_addi_i32(addr, addr, offset); + } + store_reg(s, a->rn, addr); + } else { + tcg_temp_free_i32(addr); + } + + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 0c92f3ed4ec..f9b07247b4c 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3092,9 +3092,8 @@ static void gen_neon_dup_high16(TCGv_i32 var) */ static int disas_vfp_insn(DisasContext *s, uint32_t insn) { - uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask; + uint32_t rd, rn, rm, op, i, n, delta_d, delta_m, bank_mask; int dp, veclen; - TCGv_i32 addr; TCGv_i32 tmp; TCGv_i32 tmp2; @@ -3702,98 +3701,8 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) break; case 0xc: case 0xd: - if ((insn & 0x03e00000) == 0x00400000) { - /* Already handled by decodetree */ - return 1; - } else { - /* Load/store */ - rn = (insn >> 16) & 0xf; - if (dp) - VFP_DREG_D(rd, insn); - else - rd = VFP_SREG_D(insn); - if ((insn & 0x01200000) == 0x01000000) { - /* Already handled by decodetree */ - return 1; - } else { - /* load/store multiple */ - int w = insn & (1 << 21); - if (dp) - n = (insn >> 1) & 0x7f; - else - n = insn & 0xff; - - if (w && !(((insn >> 23) ^ (insn >> 24)) & 1)) { - /* P == U , W == 1 => UNDEF */ - return 1; - } - if (n == 0 || (rd + n) > 32 || (dp && n > 16)) { - /* UNPREDICTABLE cases for bad immediates: we choose to - * UNDEF to avoid generating huge numbers of TCG ops - */ - return 1; - } - if (rn == 15 && w) { - /* writeback to PC is UNPREDICTABLE, we choose to UNDEF */ - return 1; - } - - if (s->thumb && rn == 15) { - /* This is actually UNPREDICTABLE */ - addr = tcg_temp_new_i32(); - tcg_gen_movi_i32(addr, s->pc & ~2); - } else { - addr = load_reg(s, rn); - } - if (insn & (1 << 24)) /* pre-decrement */ - tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2)); - - if (s->v8m_stackcheck && rn == 13 && w) { - /* - * Here 'addr' is the lowest address we will store to, - * and is either the old SP (if post-increment) or - * the new SP (if pre-decrement). For post-increment - * where the old value is below the limit and the new - * value is above, it is UNKNOWN whether the limit check - * triggers; we choose to trigger. - */ - gen_helper_v8m_stackcheck(cpu_env, addr); - } - - if (dp) - offset = 8; - else - offset = 4; - for (i = 0; i < n; i++) { - if (insn & ARM_CP_RW_BIT) { - /* load */ - gen_vfp_ld(s, dp, addr); - gen_mov_vreg_F0(dp, rd + i); - } else { - /* store */ - gen_mov_F0_vreg(dp, rd + i); - gen_vfp_st(s, dp, addr); - } - tcg_gen_addi_i32(addr, addr, offset); - } - if (w) { - /* writeback */ - if (insn & (1 << 24)) - offset = -offset * n; - else if (dp && (insn & 1)) - offset = 4; - else - offset = 0; - - if (offset != 0) - tcg_gen_addi_i32(addr, addr, offset); - store_reg(s, rn, addr); - } else { - tcg_temp_free_i32(addr); - } - } - } - break; + /* Already handled by decodetree */ + return 1; default: /* Should never happen. */ return 1; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 8fa7fa0bead..68c9ffcfd3c 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -78,3 +78,21 @@ VLDR_VSTR_sp ---- 1101 u:1 .0 l:1 rn:4 .... 1010 imm:8 \ vd=%vd_sp VLDR_VSTR_dp ---- 1101 u:1 .0 l:1 rn:4 .... 1011 imm:8 \ vd=%vd_dp + +# We split the load/store multiple up into two patterns to avoid +# overlap with other insns in the "Advanced SIMD load/store and 64-bit move" +# grouping: +# P=0 U=0 W=0 is 64-bit VMOV +# P=1 W=0 is VLDR/VSTR +# P=U W=1 is UNDEF +# leaving P=0 U=1 W=x and P=1 U=0 W=1 for load/store multiple. +# These include FSTM/FLDM. +VLDM_VSTM_sp ---- 1100 1 . w:1 l:1 rn:4 .... 1010 imm:8 \ + vd=%vd_sp p=0 u=1 +VLDM_VSTM_dp ---- 1100 1 . w:1 l:1 rn:4 .... 1011 imm:8 \ + vd=%vd_dp p=0 u=1 + +VLDM_VSTM_sp ---- 1101 0.1 l:1 rn:4 .... 1010 imm:8 \ + vd=%vd_sp p=1 u=0 w=1 +VLDM_VSTM_dp ---- 1101 0.1 l:1 rn:4 .... 1011 imm:8 \ + vd=%vd_dp p=1 u=0 w=1 From patchwork Thu Jun 13 12:14:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166634 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp722744ilk; Thu, 13 Jun 2019 05:55:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAPLW3f3uWes+XIIT/n8I8MAEw9Zpaddxok774bOHmNIPdP/4f8eUAkViof4sxL+EE3DzF X-Received: by 2002:ac8:2a69:: with SMTP id l38mr9939001qtl.212.1560430500773; Thu, 13 Jun 2019 05:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430500; cv=none; d=google.com; s=arc-20160816; b=NprcaBXFh/d52/7u9Tm1GcKGAka1urBGVR6IOPZA/f4uaU7pIK/EJ5qRIAWWb/7/W5 TaMvd4v8mzeG94lLRlKqpr0j9D8nwidvVBBeHoreMJtA3Z1uisgr1LEzKNnm003UHrCJ hr8+BPDg/N1oV6CVnpcJlFU9qYlzzT2bHpRlmGmQTvnkrTVRFEqzFEih5J9NbAbbgR5f oSp8FQvJ4M/w6cF9cwaEo6taXABcdKpgMfRiUfVAbGwvU7cLLYIoOgdm5QNcOoyiee9r oBtFUOHkLTuJunX5K8WfnKaDh5IMcCyrZWWCUrPfdLi+6435X/skyMsf0mXfEFss0SDT /3ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZrHyvKvOWaE4Pp/kVtSvphKsec2oq7Qnq1JNeO01iSY=; b=XgxOBfNhLIxbRI7xBAgfLFu44RKvFAkCdIQa4HoNR2n7gvhe9dhNXlTYqYwT4wKV0n ZZ+Ay1zZIQXg7JDKnjvfgbCajCOyDuQkzBi2qrIuKOIu7gqeCuqOouqzju1yr4xds83F PcFD6ZOVMxSv84XV8a/J0+2N71l2ede/mEue7gVaZ4nYf8Eim/XsdqtogS9fpHf0PCnj 9nF5VHR19EUVPEQ+KjRmRTUMksTxt569/dIVYl3uPA08rQg1hIXrnHoIDR+LwEav55kQ PWvKfPbk+RPnMQ1H2vruxAaXPwWSD0LgliXbl+J0tqQ/g27gFElgP5WWeqolxhu5JZIB QdrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DBOFN0Yq; 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=fail (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 m20si1826420qtg.330.2019.06.13.05.55.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:55:00 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=DBOFN0Yq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPFq-00022e-T6 for patch@linaro.org; Thu, 13 Jun 2019 08:54:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59016) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdL-00080T-AB for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdI-0004Li-63 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:11 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:38648) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdF-0004DU-FS for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:07 -0400 Received: by mail-wr1-x441.google.com with SMTP id d18so20521857wrs.5 for ; Thu, 13 Jun 2019 05:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZrHyvKvOWaE4Pp/kVtSvphKsec2oq7Qnq1JNeO01iSY=; b=DBOFN0Yq9c90uggDHRoPGNbmriMw0X6gV3Q3BI++NUUsLF0weDM3cUa/Cf2DzWxpOV jY7Gvga9BsdG78sQMOB72Tclccn/du57tS868vqm+yewl5hO7X0+nYtEgM0da4ceArMP RXVbPmH1w276FlJKXZof1CBBUC70V2ePTv5DwXX7Q+yRo/4P0skZYr+VgYGuHcfVMS2n AcRFwGog5Wvo9Bx9XLYojRTxIw2q589SCZdXCYYE0f3/IqJViBc0qMAYZukaC1LvuNay z5h6hYLBu/73PAV15AlV3X4EfsU5txGk/kE0qt2ejVYOXDrM5PB0feJRG2nXmLmERSC7 o9zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZrHyvKvOWaE4Pp/kVtSvphKsec2oq7Qnq1JNeO01iSY=; b=W+9OrOhI/JfRmRDJ+6KxQU74/XHhx4qvqGJeseXWKWZDnaEtz4VLKXRTMM4JpS3Q7g mE1aaFIa1MYjl6gylcdayFECC8kgsNLAvAo60/uQ2TX6MUFLzwItEg94/DQlax8wo0pt SU98STpkWU/xEywuTUIAefVsBcN1o33zwom/RqhmWwrNZ2x21GP9nGy4mEVa92b68VzP DRloGEO18gO5hkqBtMfZM3bKSf/2WsVNF7Igrq8++CcwesnPZb2bChAocwoSKyzNE+AO tmac0EM+/tTpfwbKLE65lXk1XwvloV49BLBIlHeSgNnsO1ccJ4jYMsXrd7EekMmRdnb4 zTIA== X-Gm-Message-State: APjAAAVn/hEbuBEd/2QFECIGanWuGu+Bz/QBK8v6a4BYkdBqlc/y2adZ AdGlwy5o6eumpUe1EvkpkwdtxqHwKaB8gA== X-Received: by 2002:adf:f181:: with SMTP id h1mr1582290wro.86.1560428100925; Thu, 13 Jun 2019 05:15:00 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:08 +0100 Message-Id: <20190613121433.5246-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 23/48] target/arm: Remove VLDR/VSTR/VLDM/VSTM use of cpu_F0s and cpu_F0d 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Expand out the sequences in the new decoder VLDR/VSTR/VLDM/VSTM trans functions which perform the memory accesses by going via the TCG globals cpu_F0s and cpu_F0d, to use local TCG temps instead. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 46 +++++++++++++++++++++------------- target/arm/translate.c | 18 ------------- 2 files changed, 28 insertions(+), 36 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 32a1805e582..9729946d734 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -857,7 +857,7 @@ static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_sp *a) static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) { uint32_t offset; - TCGv_i32 addr; + TCGv_i32 addr, tmp; if (!vfp_access_check(s)) { return true; @@ -876,13 +876,15 @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) addr = load_reg(s, a->rn); } tcg_gen_addi_i32(addr, addr, offset); + tmp = tcg_temp_new_i32(); if (a->l) { - gen_vfp_ld(s, false, addr); - gen_mov_vreg_F0(false, a->vd); + gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); + neon_store_reg32(tmp, a->vd); } else { - gen_mov_F0_vreg(false, a->vd); - gen_vfp_st(s, false, addr); + neon_load_reg32(tmp, a->vd); + gen_aa32_st32(s, tmp, addr, get_mem_index(s)); } + tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); return true; @@ -892,6 +894,7 @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_sp *a) { uint32_t offset; TCGv_i32 addr; + TCGv_i64 tmp; /* UNDEF accesses to D16-D31 if they don't exist */ if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { @@ -915,13 +918,15 @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_sp *a) addr = load_reg(s, a->rn); } tcg_gen_addi_i32(addr, addr, offset); + tmp = tcg_temp_new_i64(); if (a->l) { - gen_vfp_ld(s, true, addr); - gen_mov_vreg_F0(true, a->vd); + gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); + neon_store_reg64(tmp, a->vd); } else { - gen_mov_F0_vreg(true, a->vd); - gen_vfp_st(s, true, addr); + neon_load_reg64(tmp, a->vd); + gen_aa32_st64(s, tmp, addr, get_mem_index(s)); } + tcg_temp_free_i64(tmp); tcg_temp_free_i32(addr); return true; @@ -930,7 +935,7 @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_sp *a) static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) { uint32_t offset; - TCGv_i32 addr; + TCGv_i32 addr, tmp; int i, n; n = a->imm; @@ -976,18 +981,20 @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) } offset = 4; + tmp = tcg_temp_new_i32(); for (i = 0; i < n; i++) { if (a->l) { /* load */ - gen_vfp_ld(s, false, addr); - gen_mov_vreg_F0(false, a->vd + i); + gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); + neon_store_reg32(tmp, a->vd + i); } else { /* store */ - gen_mov_F0_vreg(false, a->vd + i); - gen_vfp_st(s, false, addr); + neon_load_reg32(tmp, a->vd + i); + gen_aa32_st32(s, tmp, addr, get_mem_index(s)); } tcg_gen_addi_i32(addr, addr, offset); } + tcg_temp_free_i32(tmp); if (a->w) { /* writeback */ if (a->p) { @@ -1006,6 +1013,7 @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) { uint32_t offset; TCGv_i32 addr; + TCGv_i64 tmp; int i, n; n = a->imm >> 1; @@ -1056,18 +1064,20 @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) } offset = 8; + tmp = tcg_temp_new_i64(); for (i = 0; i < n; i++) { if (a->l) { /* load */ - gen_vfp_ld(s, true, addr); - gen_mov_vreg_F0(true, a->vd + i); + gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); + neon_store_reg64(tmp, a->vd + i); } else { /* store */ - gen_mov_F0_vreg(true, a->vd + i); - gen_vfp_st(s, true, addr); + neon_load_reg64(tmp, a->vd + i); + gen_aa32_st64(s, tmp, addr, get_mem_index(s)); } tcg_gen_addi_i32(addr, addr, offset); } + tcg_temp_free_i64(tmp); if (a->w) { /* writeback */ if (a->p) { diff --git a/target/arm/translate.c b/target/arm/translate.c index f9b07247b4c..1c5c87d7d01 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1522,24 +1522,6 @@ VFP_GEN_FIX(uhto, ) VFP_GEN_FIX(ulto, ) #undef VFP_GEN_FIX -static inline void gen_vfp_ld(DisasContext *s, int dp, TCGv_i32 addr) -{ - if (dp) { - gen_aa32_ld64(s, cpu_F0d, addr, get_mem_index(s)); - } else { - gen_aa32_ld32u(s, cpu_F0s, addr, get_mem_index(s)); - } -} - -static inline void gen_vfp_st(DisasContext *s, int dp, TCGv_i32 addr) -{ - if (dp) { - gen_aa32_st64(s, cpu_F0d, addr, get_mem_index(s)); - } else { - gen_aa32_st32(s, cpu_F0s, addr, get_mem_index(s)); - } -} - static inline long vfp_reg_offset(bool dp, unsigned reg) { if (dp) { From patchwork Thu Jun 13 12:14:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166644 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp740975ilk; Thu, 13 Jun 2019 06:09:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLEw5AUTdt6Mrpp6XVb1NHMaGXpf0SdN11pSsQY1F8hVfA3jOJ2qELNHcwuOL63VzsLe+A X-Received: by 2002:a0c:bf47:: with SMTP id b7mr3511818qvj.4.1560431374701; Thu, 13 Jun 2019 06:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560431374; cv=none; d=google.com; s=arc-20160816; b=QB436PLUH7PGVKF7khOXzfW3X9qUJZy7s9LlL6/zpgIqmH0h0us3hhAvEyoDVvlQBC 3sNun7vuRLWYqtm9OYoJR9pPSyz1sy3/2SctgmACaHGMhq9oiUCnudoICcAZbZmB19HB ep1g58+oLwgtj01O+MAGBwCFrWrh2VxIbxcCRifkQw6eTuYcMBj+pZgtbUf0XVQELqjU efwb4iGkmQPrJHjiOQyw+6MQksPUxRlDzfZdXjGR3mfbbxMuAaPW8l2TNFrt7/5LsoS4 mVCPBQYRUIzYPGMPMz4i0+/GNUhmDDNKCpEtzPMopi+Yq/AWevleYNjKX7iGzarKrtBA Tuhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=wrdA+aPHtyjFkj1EffpVWM0FArUe1r3bFIrTxDQB6FE=; b=hRpfhtt9Ej8h2D5x49yjCjYfETOSp4Vy0cVy89Jl4zZ57JWpmSoUyefv0Rntx1C5v1 c1TLZ9B7qePEs8e4Mji1MXwTp5uBj0fwr7d3OXQtcuyW0AA0exbrnCgF0bzUg/dZ/86S CNkfGrxOmM/EHKRpLsPSIq2vQlNSo8GCMlz5Ux2fXKa1ZABv2LmzFV4jcco6V5qpDw/B VX/BiJU/4MijVQrcORnP0VgFbf6fcvtninEQSOcBVFuMCE2QBW91hH/vaoeNC9VWK+mL h4zkQHa9N1Xmt/iwcICeJrZSMCqF0Z3XIPpuT9NCIBJM8FjbJq6qe/7pW2s8FJ9lL2nv jR5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="fB7msO/b"; 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=fail (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 d5si1768400qtr.124.2019.06.13.06.09.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:09:34 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b="fB7msO/b"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPTy-0005Ki-AP for patch@linaro.org; Thu, 13 Jun 2019 09:09:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59663) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdo-0008Qw-5R for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdV-0004dB-DG for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:30 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:42885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdU-0004FN-S1 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:21 -0400 Received: by mail-wr1-x429.google.com with SMTP id x17so5234477wrl.9 for ; Thu, 13 Jun 2019 05:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wrdA+aPHtyjFkj1EffpVWM0FArUe1r3bFIrTxDQB6FE=; b=fB7msO/bs0N0WSGsDk8+Vkr7RwY1VsrarW/IewXuwjbMFktNpJOQacP1mObZQ5RkzF hEih+0VSTby3+8znO532GZMgZidODZphX8QVIXT0bGxZPweZLhj0YWtvIV2qZiWciZcM AAUQy5odljSCWKwD5zEsehAw+Ewhu+y1wYtk/mveGZUWDDU4uT01dnFLVahtD1q2+3Rr 1YbVdmBxEkiKU+yXPFo1swwEZA5WqT03UkJeJqHE/BByijwwXhAyojZPkIvtUBskfw9j mmD847obvWzj0fpKMERVcrw5plchR6qTCyoDyFiOIQdnpTAEvKhAhyBD4T6cxb5aYuDs NRPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wrdA+aPHtyjFkj1EffpVWM0FArUe1r3bFIrTxDQB6FE=; b=Njqi7HN6ewMdxz4Ed1cpZeLVvSVKy68l1xUocaKWk7M/EM3Z+7RkSPMhWDuPXuUUz4 Iu88lQKS5vDbpVwQlDFUzmpb3tqBPxEx4SROW6/x0YjXnJMJjpGPedXzdVae8JfxDXtI UuqtpG2t9NO4lSAIVQiMv58aW3mhOJeXrZdd70EbY6Gr+dPG0VKrPufd6h+comiNEZyu rUuvO+h69BDp57wR185WxUk/NgEINbVkdlPk2AbNjqpJE/8vreiN2dLenkMFoa7DDDqh vFyzXsRO2nsUwJ0IBpJTO+RUnEZ4V95qyIGYT9wAAyTBmGvU+u7jY4qQ7GvGqZQ3McJj p+fA== X-Gm-Message-State: APjAAAW6+GRs+CD3SWbpQyPoVOzrYT9bg9vELb8RiP9KCVOFCHZSK9Sa bT3GN954mdLd5pnDTBr4KM8pUljIUvZs+A== X-Received: by 2002:adf:e8cb:: with SMTP id k11mr58140472wrn.244.1560428102044; Thu, 13 Jun 2019 05:15:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:01 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:09 +0100 Message-Id: <20190613121433.5246-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 24/48] target/arm: Convert VFP VMLA to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP VMLA instruction to decodetree. This is the first of the VFP 3-operand data processing instructions, so we include in this patch the code which loops over the elements for an old-style VFP vector operation. The existing code to do this looping uses the deprecated cpu_F0s/F0d/F1s/F1d TCG globals; since we are going to be converting instructions one at a time anyway we can take the opportunity to make the new loop use TCG temporaries, which means we can do that conversion one operation at a time rather than needing to do it all in one go. We include an UNDEF check which was missing in the old code: short-vector operations (with stride or length non-zero) were deprecated in v7A and must UNDEF in v8A, so if the MVFR0 FPShVec field does not indicate that support for short vectors is present we UNDEF the operations that would use them. (This is a change of behaviour for Cortex-A7, Cortex-A15 and the v8 CPUs, which previously were all incorrectly allowing short-vector operations.) Note that the conversion fixes a bug in the old code for the case of VFP short-vector "mixed scalar/vector operations". These happen where the destination register is in a vector bank but but the second operand is in a scalar bank. For example vmla.f64 d10, d1, d16 with length 2 stride 2 is equivalent to the pair of scalar operations vmla.f64 d10, d1, d16 vmla.f64 d8, d3, d16 where the destination and first input register cycle through their vector but the second input is scalar (d16). In the old decoder the gen_vfp_F1_mul() operation uses cpu_F1{s,d} as a temporary output for the multiply, which trashes the second input operand. For the fully-scalar case (where we never do a second iteration) and the fully-vector case (where the loop loads the new second input operand) this doesn't matter, but for the mixed scalar/vector case we will end up using the wrong value for later loop iterations. In the new code we use TCG temporaries and so avoid the bug. This bug is present for all the multiply-accumulate insns that operate on short vectors: VMLA, VMLS, VNMLA, VNMLS. Note 2: the expression used to calculate the next register number in the vector bank is not in fact correct; we leave this behaviour unchanged from the old decoder and will fix this bug later in the series. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/cpu.h | 5 + target/arm/translate-vfp.inc.c | 205 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 14 ++- target/arm/vfp.decode | 6 + 4 files changed, 224 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index dc50c86e318..92298624215 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3377,6 +3377,11 @@ static inline bool isar_feature_aa32_fp_d32(const ARMISARegisters *id) return FIELD_EX64(id->mvfr0, MVFR0, SIMDREG) >= 2; } +static inline bool isar_feature_aa32_fpshvec(const ARMISARegisters *id) +{ + return FIELD_EX64(id->mvfr0, MVFR0, FPSHVEC) > 0; +} + /* * We always set the FP and SIMD FP16 fields to indicate identical * levels of support (assuming SIMD is implemented at all), so diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 9729946d734..4f922dc8405 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1098,3 +1098,208 @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) return true; } + +/* + * Types for callbacks for do_vfp_3op_sp() and do_vfp_3op_dp(). + * The callback should emit code to write a value to vd. If + * do_vfp_3op_{sp,dp}() was passed reads_vd then the TCGv vd + * will contain the old value of the relevant VFP register; + * otherwise it must be written to only. + */ +typedef void VFPGen3OpSPFn(TCGv_i32 vd, + TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst); +typedef void VFPGen3OpDPFn(TCGv_i64 vd, + TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst); + +/* + * Perform a 3-operand VFP data processing instruction. fn is the + * callback to do the actual operation; this function deals with the + * code to handle looping around for VFP vector processing. + */ +static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, + int vd, int vn, int vm, bool reads_vd) +{ + uint32_t delta_m = 0; + uint32_t delta_d = 0; + uint32_t bank_mask = 0; + int veclen = s->vec_len; + TCGv_i32 f0, f1, fd; + TCGv_ptr fpst; + + if (!dc_isar_feature(aa32_fpshvec, s) && + (veclen != 0 || s->vec_stride != 0)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + if (veclen > 0) { + bank_mask = 0x18; + + /* Figure out what type of vector operation this is. */ + if ((vd & bank_mask) == 0) { + /* scalar */ + veclen = 0; + } else { + delta_d = s->vec_stride + 1; + + if ((vm & bank_mask) == 0) { + /* mixed scalar/vector */ + delta_m = 0; + } else { + /* vector */ + delta_m = delta_d; + } + } + } + + f0 = tcg_temp_new_i32(); + f1 = tcg_temp_new_i32(); + fd = tcg_temp_new_i32(); + fpst = get_fpstatus_ptr(0); + + neon_load_reg32(f0, vn); + neon_load_reg32(f1, vm); + + for (;;) { + if (reads_vd) { + neon_load_reg32(fd, vd); + } + fn(fd, f0, f1, fpst); + neon_store_reg32(fd, vd); + + if (veclen == 0) { + break; + } + + /* Set up the operands for the next iteration */ + veclen--; + vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + vn = ((vn + delta_d) & (bank_mask - 1)) | (vn & bank_mask); + neon_load_reg32(f0, vn); + if (delta_m) { + vm = ((vm + delta_m) & (bank_mask - 1)) | (vm & bank_mask); + neon_load_reg32(f1, vm); + } + } + + tcg_temp_free_i32(f0); + tcg_temp_free_i32(f1); + tcg_temp_free_i32(fd); + tcg_temp_free_ptr(fpst); + + return true; +} + +static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, + int vd, int vn, int vm, bool reads_vd) +{ + uint32_t delta_m = 0; + uint32_t delta_d = 0; + uint32_t bank_mask = 0; + int veclen = s->vec_len; + TCGv_i64 f0, f1, fd; + TCGv_ptr fpst; + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (!dc_isar_feature(aa32_fp_d32, s) && ((vd | vn | vm) & 0x10)) { + return false; + } + + if (!dc_isar_feature(aa32_fpshvec, s) && + (veclen != 0 || s->vec_stride != 0)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + if (veclen > 0) { + bank_mask = 0xc; + + /* Figure out what type of vector operation this is. */ + if ((vd & bank_mask) == 0) { + /* scalar */ + veclen = 0; + } else { + delta_d = (s->vec_stride >> 1) + 1; + + if ((vm & bank_mask) == 0) { + /* mixed scalar/vector */ + delta_m = 0; + } else { + /* vector */ + delta_m = delta_d; + } + } + } + + f0 = tcg_temp_new_i64(); + f1 = tcg_temp_new_i64(); + fd = tcg_temp_new_i64(); + fpst = get_fpstatus_ptr(0); + + neon_load_reg64(f0, vn); + neon_load_reg64(f1, vm); + + for (;;) { + if (reads_vd) { + neon_load_reg64(fd, vd); + } + fn(fd, f0, f1, fpst); + neon_store_reg64(fd, vd); + + if (veclen == 0) { + break; + } + /* Set up the operands for the next iteration */ + veclen--; + vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + vn = ((vn + delta_d) & (bank_mask - 1)) | (vn & bank_mask); + neon_load_reg64(f0, vn); + if (delta_m) { + vm = ((vm + delta_m) & (bank_mask - 1)) | (vm & bank_mask); + neon_load_reg64(f1, vm); + } + } + + tcg_temp_free_i64(f0); + tcg_temp_free_i64(f1); + tcg_temp_free_i64(fd); + tcg_temp_free_ptr(fpst); + + return true; +} + +static void gen_VMLA_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst) +{ + /* Note that order of inputs to the add matters for NaNs */ + TCGv_i32 tmp = tcg_temp_new_i32(); + + gen_helper_vfp_muls(tmp, vn, vm, fpst); + gen_helper_vfp_adds(vd, vd, tmp, fpst); + tcg_temp_free_i32(tmp); +} + +static bool trans_VMLA_sp(DisasContext *s, arg_VMLA_sp *a) +{ + return do_vfp_3op_sp(s, gen_VMLA_sp, a->vd, a->vn, a->vm, true); +} + +static void gen_VMLA_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst) +{ + /* Note that order of inputs to the add matters for NaNs */ + TCGv_i64 tmp = tcg_temp_new_i64(); + + gen_helper_vfp_muld(tmp, vn, vm, fpst); + gen_helper_vfp_addd(vd, vd, tmp, fpst); + tcg_temp_free_i64(tmp); +} + +static bool trans_VMLA_dp(DisasContext *s, arg_VMLA_sp *a) +{ + return do_vfp_3op_dp(s, gen_VMLA_dp, a->vd, a->vn, a->vm, true); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 1c5c87d7d01..ad8f947a13b 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3133,6 +3133,14 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1); rn = VFP_SREG_N(insn); + switch (op) { + case 0: + /* Already handled by decodetree */ + return 1; + default: + break; + } + if (op == 15) { /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { @@ -3312,12 +3320,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 0: /* VMLA: fd + (fn * fm) */ - /* Note that order of inputs to the add matters for NaNs */ - gen_vfp_F1_mul(dp); - gen_mov_F0_vreg(dp, rd); - gen_vfp_add(dp); - break; case 1: /* VMLS: fd + -(fn * fm) */ gen_vfp_mul(dp); gen_vfp_F1_neg(dp); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 68c9ffcfd3c..9530e17ae02 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -96,3 +96,9 @@ VLDM_VSTM_sp ---- 1101 0.1 l:1 rn:4 .... 1010 imm:8 \ vd=%vd_sp p=1 u=0 w=1 VLDM_VSTM_dp ---- 1101 0.1 l:1 rn:4 .... 1011 imm:8 \ vd=%vd_dp p=1 u=0 w=1 + +# 3-register VFP data-processing; bits [23,21:20,6] identify the operation. +VMLA_sp ---- 1110 0.00 .... .... 1010 .0.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp +VMLA_dp ---- 1110 0.00 .... .... 1011 .0.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp From patchwork Thu Jun 13 12:14:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166629 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp719576ilk; Thu, 13 Jun 2019 05:51:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlc+vh+mke49riIsOpB5Oz12QceObDDV8k+bPhEJIaf6ymKTxVN7wfi2okqRXpNXf7lUrf X-Received: by 2002:ac8:156:: with SMTP id f22mr56900800qtg.58.1560430292777; Thu, 13 Jun 2019 05:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430292; cv=none; d=google.com; s=arc-20160816; b=jP3MsvLF3LI6FL2687o8otNos9uTecXm2rb0ercLeNjF7qvJUnNBymituyfKOBKh0T S6nrmrHGAk8xC25tsD7B0SA+nYGEVVSAv2q6neAJgEnYP/yc6H5P8blyDvjBocLSKQVf d+PNOgFTt2w4sXLMxSXrGYr1MfaxneQd12giUIEibEFo9sOF8LYhiEuh+HCE+I8M+a9Z HG7jntSu6EqBijANwRBYeH4k3Jv8UstDrr2QD8n2s5k57p/9BUm3PeZEdLVzb+ZnFc7N zgH94BEegZgIMAbBde+JZCQx/aeuVMWBFc/rSQBIvRXNDUFpY2vgGKlO5Xt7OrZuycE+ uEHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=IRZuW3taWPCfJ37rwCt/vodP6fN4Yy7faj6/F0vMpBk=; b=XXyB5SPD//I+Ix1OTO1IA/AVDPPbHFt+vpvS0sR4CQYJvmrUhaC/pXTBTsbKUfkrzU dSqzBYqd8TnCYxmko7wHg31NDlahZx+N4vVQ6djwO7X7UtIuCuwJeG1e+xMKV3o4dGLx MnXunU7mrTYfwIpkYxgH+2wz1/Q+nyZeagDPTlLxTRoDyR1K3UgrudqYTGjxZfdGOqYw y0eTqiScdxOKQjMTq4aQCgRXm6TqDdnL7XkBXB94HUH95UZol4QD5JvTvuQe/TiPlyNF obQ46sGvUR9/ozyAGEUqd5vwsASAVmJWveCdXCw13bPjp2NS4aDN5788lR/5yFMd40dB nxiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oLQA8r7U; 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=fail (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 c30si1808161qtk.109.2019.06.13.05.51.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:51:32 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=oLQA8r7U; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPCW-0006Z5-Bp for patch@linaro.org; Thu, 13 Jun 2019 08:51:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59025) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdL-00080Z-Ce for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdH-0004Kj-FG for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:10 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:34022) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdF-0004GR-Bq for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:05 -0400 Received: by mail-wr1-x436.google.com with SMTP id k11so2349590wrl.1 for ; Thu, 13 Jun 2019 05:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IRZuW3taWPCfJ37rwCt/vodP6fN4Yy7faj6/F0vMpBk=; b=oLQA8r7UuXmNoTYEPEC6QiGnVdR3Zc2aIIXxn27myZqylPWNSxqWsCg4nvMWQ+n4xl XjMGrKl84vH/c6iRM7YL99EuU67nCat1bZbnDz367Dhh7kqbKm0F1wJCdbvl6svdjn5L gNen86jGdt2uUTUFfu9sS/tn5QZd2UwrJNrg0m0yhty1y0oYj47nlV2/kuM44JsjiRTD pERp1BAIgZsFy5u4/Wkcp34pr/SRbb7RUOZblMR3SJsspuoF/4LeEOI5dSB2whFq79T8 1H/Df1y+nPPcutC3FNNN0Utc0mwvGX9GuICypDfJ1eTFvNnMCaGHGPalLqpAc9k6Jsss 4XNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IRZuW3taWPCfJ37rwCt/vodP6fN4Yy7faj6/F0vMpBk=; b=kUhqxBpH+jCSaoY2Yh0PsaXQ51URrUqEVKe6XIWPrzPF9fCntPSVlNpOqOIW47r6o4 UQHU+Ff8TouiBipOP2GUcionNVDx/l46/0JilTwCyCc4DRi1wkmlQJh38xJ7a7BhybGs nmPjcrqRM6Ufi/e5l+ob0YgIYNzo4G8wab5MlmU6B9qW77dPMLgi2FLhtmSPWQ+jpCVi 3/D5gn5kN22O7iQGoSgcxMDfeS4+UuIYWsAdnWF5rTao+0IK7bnM01XPpcPTB2kXlrhN IjbMyai5ZNst3Gyxvmds17ka6rOalNjJo3Nkm0pPdh7BnX4GU+cVQCNKQe3anWH9F8h7 PknA== X-Gm-Message-State: APjAAAXrTor5Q9jBWNoUJ3N7ySVALk+20fV0ehMNrq6awnOOJ2mmrvDy PrOSwKvDzJ32uClf1lYp+642kHoAk024Nw== X-Received: by 2002:adf:a18a:: with SMTP id u10mr37082207wru.351.1560428103352; Thu, 13 Jun 2019 05:15:03 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:02 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:10 +0100 Message-Id: <20190613121433.5246-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 Subject: [Qemu-devel] [PULL 25/48] target/arm: Convert VFP VMLS to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP VMLS instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 38 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 8 +------ target/arm/vfp.decode | 5 +++++ 3 files changed, 44 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 4f922dc8405..00f64401dda 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1303,3 +1303,41 @@ static bool trans_VMLA_dp(DisasContext *s, arg_VMLA_sp *a) { return do_vfp_3op_dp(s, gen_VMLA_dp, a->vd, a->vn, a->vm, true); } + +static void gen_VMLS_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst) +{ + /* + * VMLS: vd = vd + -(vn * vm) + * Note that order of inputs to the add matters for NaNs. + */ + TCGv_i32 tmp = tcg_temp_new_i32(); + + gen_helper_vfp_muls(tmp, vn, vm, fpst); + gen_helper_vfp_negs(tmp, tmp); + gen_helper_vfp_adds(vd, vd, tmp, fpst); + tcg_temp_free_i32(tmp); +} + +static bool trans_VMLS_sp(DisasContext *s, arg_VMLS_sp *a) +{ + return do_vfp_3op_sp(s, gen_VMLS_sp, a->vd, a->vn, a->vm, true); +} + +static void gen_VMLS_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst) +{ + /* + * VMLS: vd = vd + -(vn * vm) + * Note that order of inputs to the add matters for NaNs. + */ + TCGv_i64 tmp = tcg_temp_new_i64(); + + gen_helper_vfp_muld(tmp, vn, vm, fpst); + gen_helper_vfp_negd(tmp, tmp); + gen_helper_vfp_addd(vd, vd, tmp, fpst); + tcg_temp_free_i64(tmp); +} + +static bool trans_VMLS_dp(DisasContext *s, arg_VMLS_sp *a) +{ + return do_vfp_3op_dp(s, gen_VMLS_dp, a->vd, a->vn, a->vm, true); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index ad8f947a13b..2afab7fbc20 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3134,7 +3134,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0: + case 0 ... 1: /* Already handled by decodetree */ return 1; default: @@ -3320,12 +3320,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 1: /* VMLS: fd + -(fn * fm) */ - gen_vfp_mul(dp); - gen_vfp_F1_neg(dp); - gen_mov_F0_vreg(dp, rd); - gen_vfp_add(dp); - break; case 2: /* VNMLS: -fd + (fn * fm) */ /* Note that it isn't valid to replace (-A + B) with (B - A) * or similar plausible looking simplifications diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 9530e17ae02..7bcf2260eec 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -102,3 +102,8 @@ VMLA_sp ---- 1110 0.00 .... .... 1010 .0.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp VMLA_dp ---- 1110 0.00 .... .... 1011 .0.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp + +VMLS_sp ---- 1110 0.00 .... .... 1010 .1.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp +VMLS_dp ---- 1110 0.00 .... .... 1011 .1.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp From patchwork Thu Jun 13 12:14:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166628 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp719510ilk; Thu, 13 Jun 2019 05:51:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwphnFJlUBm4HegRkGezdZG+5jdVRuk83T5bbalHbkSw52zY5EZVhV26yY9VyDao14m+Rz8 X-Received: by 2002:a0c:baa7:: with SMTP id x39mr3462279qvf.100.1560430289014; Thu, 13 Jun 2019 05:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430289; cv=none; d=google.com; s=arc-20160816; b=WSmUtuCqI9E2Vw7Rol46zbM/MH5BNyWuhYHZL+m4GbiRGkCnG+HuNui8fOa49IT7jC 4bkNHCd5iIIFlK9+247+az+0JUS6H1rjHHKVoXUXtWm2TzcyHeO2ItK5ix0vrhHs0xAL P39HvV1nl8CSxdmbFXnKdZ6x4tc3C1OjFnDmL/mDF9EXlj3ntxdrb+oZEkeowmO7KgSw Y5eLIUxiUdwD7Br4xrSn2OLn8Jrsp85hXsjNAwXuie0xXHCDQF0uN5maCsZM0aeJve14 4OXe+j6JNdl5qTmtVUuNbnllCMOiaVvsoMzQ8K6Tvoo2JQTT6hPMZ/mZmqtxqjt/pOA0 k1tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ePUtfqYkh2qkpSIViahtoMcVRf0/pRm/M8l5xG6Fj2o=; b=aFzePfxzChjCBeQ2X3tBoYZB+v1TnLVQ26owbvI7h4QQ5+UgrD92FYyQeQNHEWg8Ps o7zPnhIqL61+kUrX7Wy6fzmRpkNwbCIbyrXQB4ZExCyZZCvjoF2H+D0AtEFNdLo3dZuP xrQVYWw4boULKuXMdz7gMktcX9AYIydKWb+1L9xvqhqwGlSCBSsSMDDlzx/u3qJuJHkK ruAGyFpZmaz0h5hvOw7C6bzVyzWU028SJBCyVExpMtDyph/M/BNvkUmNax6xhqE2eJZF YlRXlMMkYs6JxUhgTl0ETwDD6lYathV432U7kMqrg7w4pUJBnOqYTxFLrTLuXxc1U/6Z HUCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zDqslaU8; 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=fail (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 u51si1858262qte.390.2019.06.13.05.51.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:51:29 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=zDqslaU8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPCS-0005uu-Hr for patch@linaro.org; Thu, 13 Jun 2019 08:51:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59461) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOde-0008PQ-FP for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdW-0004en-0M for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:29 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdV-0004Ii-H3 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:21 -0400 Received: by mail-wm1-x343.google.com with SMTP id c6so9907878wml.0 for ; Thu, 13 Jun 2019 05:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ePUtfqYkh2qkpSIViahtoMcVRf0/pRm/M8l5xG6Fj2o=; b=zDqslaU80NGzl9NmPRtgN5gtHzKKuPy5WQaPqHRfjhW0DdA3ldAluWokG8rLLdyobu Qlv2/LpDb7ND0a/h9yScLU3RYuvJM5/IMwlzwJ+FR0yHriDJDfbXnCgZGgjZRO4Y/h5G NiBSNNIJlZZ5oY7lK3B0SrvkbWIJFo6bczRzvfSrGudohjRNHPKu23ttnCyvi9+QgQpZ FLuQEWonS+TLNSS1GH76pbYPSG68WhIBQAX0r1csUmq0WOIwg4fuJoN5Xnv8s9eLEWLu wUdZ4sJZScWY1bKM91qhpg1rXt4Rz03k6zFb96bkrd7YQVwvvCoO0W7V3yABrKppCflg +eKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ePUtfqYkh2qkpSIViahtoMcVRf0/pRm/M8l5xG6Fj2o=; b=n38RBd8YtAE2Nx2N7VBfQn4Ld2IIDPn4gs3D2XbdFT8mo8POpGj2TlwL52E50PsZOA J/SZbhOmz7G+QCXjDN998hnZptw+MxBd69PTyAUioXTMY8FK3tungNu8bAXgPSG3aOZG jk+hWiKLuYe25ZXZLNc679LgLorxKaUwljbhRSVsAA3Y5+lk95t8n2cqKSi2nXydSouQ G5YGJA00ebo/UCxjpadmybKPNXN1pe9oplwpZ/wGMQnZm40eOwvYb9yOAqi3U22eesVL y5MqlLeWWeVYZ5CDVuujSeaz1bmAD7Eb3dHxbibZY7dvm3VFd7sLgHAA9ng6fEjuiJ2n 7fXQ== X-Gm-Message-State: APjAAAWWcb9mC81CzAWNC0SOd1lagqdp7g+xcukenjbspLM0A8R24HlR XEaEvTxlBS06kDEF375Y60n8kFfA1Fv4oA== X-Received: by 2002:a1c:b68a:: with SMTP id g132mr3720442wmf.66.1560428104383; Thu, 13 Jun 2019 05:15:04 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:03 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:11 +0100 Message-Id: <20190613121433.5246-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 26/48] target/arm: Convert VFP VNMLS to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP VNMLS instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 42 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 24 +------------------ target/arm/vfp.decode | 5 ++++ 3 files changed, 48 insertions(+), 23 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 00f64401dda..1d7100debe4 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1341,3 +1341,45 @@ static bool trans_VMLS_dp(DisasContext *s, arg_VMLS_sp *a) { return do_vfp_3op_dp(s, gen_VMLS_dp, a->vd, a->vn, a->vm, true); } + +static void gen_VNMLS_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst) +{ + /* + * VNMLS: -fd + (fn * fm) + * Note that it isn't valid to replace (-A + B) with (B - A) or similar + * plausible looking simplifications because this will give wrong results + * for NaNs. + */ + TCGv_i32 tmp = tcg_temp_new_i32(); + + gen_helper_vfp_muls(tmp, vn, vm, fpst); + gen_helper_vfp_negs(vd, vd); + gen_helper_vfp_adds(vd, vd, tmp, fpst); + tcg_temp_free_i32(tmp); +} + +static bool trans_VNMLS_sp(DisasContext *s, arg_VNMLS_sp *a) +{ + return do_vfp_3op_sp(s, gen_VNMLS_sp, a->vd, a->vn, a->vm, true); +} + +static void gen_VNMLS_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst) +{ + /* + * VNMLS: -fd + (fn * fm) + * Note that it isn't valid to replace (-A + B) with (B - A) or similar + * plausible looking simplifications because this will give wrong results + * for NaNs. + */ + TCGv_i64 tmp = tcg_temp_new_i64(); + + gen_helper_vfp_muld(tmp, vn, vm, fpst); + gen_helper_vfp_negd(vd, vd); + gen_helper_vfp_addd(vd, vd, tmp, fpst); + tcg_temp_free_i64(tmp); +} + +static bool trans_VNMLS_dp(DisasContext *s, arg_VNMLS_sp *a) +{ + return do_vfp_3op_dp(s, gen_VNMLS_dp, a->vd, a->vn, a->vm, true); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 2afab7fbc20..42701884101 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1393,18 +1393,6 @@ VFP_OP2(div) #undef VFP_OP2 -static inline void gen_vfp_F1_mul(int dp) -{ - /* Like gen_vfp_mul() but put result in F1 */ - TCGv_ptr fpst = get_fpstatus_ptr(0); - if (dp) { - gen_helper_vfp_muld(cpu_F1d, cpu_F0d, cpu_F1d, fpst); - } else { - gen_helper_vfp_muls(cpu_F1s, cpu_F0s, cpu_F1s, fpst); - } - tcg_temp_free_ptr(fpst); -} - static inline void gen_vfp_F1_neg(int dp) { /* Like gen_vfp_neg() but put result in F1 */ @@ -3134,7 +3122,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0 ... 1: + case 0 ... 2: /* Already handled by decodetree */ return 1; default: @@ -3320,16 +3308,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 2: /* VNMLS: -fd + (fn * fm) */ - /* Note that it isn't valid to replace (-A + B) with (B - A) - * or similar plausible looking simplifications - * because this will give wrong results for NaNs. - */ - gen_vfp_F1_mul(dp); - gen_mov_F0_vreg(dp, rd); - gen_vfp_neg(dp); - gen_vfp_add(dp); - break; case 3: /* VNMLA: -fd + -(fn * fm) */ gen_vfp_mul(dp); gen_vfp_F1_neg(dp); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 7bcf2260eec..08e4f427408 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -107,3 +107,8 @@ VMLS_sp ---- 1110 0.00 .... .... 1010 .1.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp VMLS_dp ---- 1110 0.00 .... .... 1011 .1.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp + +VNMLS_sp ---- 1110 0.01 .... .... 1010 .0.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp +VNMLS_dp ---- 1110 0.01 .... .... 1011 .0.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp From patchwork Thu Jun 13 12:14:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166642 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp740630ilk; Thu, 13 Jun 2019 06:09:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEoOpMFgahwQ+nI0Rnb3WKvGdX6p9LDE52n1nS51C8m28Mx9DqBU2yddA7iIrXC5UhLxCX X-Received: by 2002:a05:620a:16cc:: with SMTP id a12mr12907092qkn.256.1560431359027; Thu, 13 Jun 2019 06:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560431359; cv=none; d=google.com; s=arc-20160816; b=dDFCTQSUq069VyWMNvLIcUqAZ6pPsNTqNb/h3BZ9f1vHFbik7ADLCeeltOWHXiw2Nb 90BKorceZtFtj36d3yT2+jqObcEP2SdSe5GEAvtvmLXwJkZfpJUvhP9L2aQ21dqvzaYn S0s4P+frOfojNyjT/CTLp++YkFCo8jDQ3Ofmwab2lrB7DUN/K5iV2QPaC0++OdIiDP2Z zL3+9OdDJCQDO/zL8AMtYNFLg6I8RDTErXgWb5S8QIHrJ0fIGop9mcZl0E5A6Hiag8t4 TYf+A1rWKm118zchfhFxHG8QzVfDBBceXHip3oSjan3preU7bPiarJFryB+6Z6dJp9Oo Ebdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=u8F8E/4POHXbij/G30GWx/MM7QuKTGRas6m/d3Ld7BI=; b=iHnTCqyd9eqEN3XiSr7ufKOaVqjeorKa03rrDv9utd8DE2tWHmzEYJDZI2sT4BU+vO r3g0U3n+SQiadDThWAxmcXzX4weXHY6Ex+Hj3d/auWhXIjOo1x0Kc4a+HqtWj+M2digQ 8bvPazXNMTFvkbxt70zCGKFBgkd/ZoFBpC7aznDhpZMlmOk4XiblB/fJdHy12t+WJpIc Ub8P2fybvPol1s3RsgNi25LJSsalODl9l4y3zj6uIctSnbnqwaNRar/heGm94cBqg/L4 e8fEerU6j/q3mI0LddXYUlo342Y3NQ4QUFjhTQLm+Bvp7G6/9Z8Jf6T6B5xjcWFqHrwY BW9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hv8q4ECJ; 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=fail (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 a74si1602483qkb.123.2019.06.13.06.09.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:09:19 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=hv8q4ECJ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPTi-0005CH-JQ for patch@linaro.org; Thu, 13 Jun 2019 09:09:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59378) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOda-0008HH-1S for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdU-0004aT-LF for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:25 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:54531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdU-0004JZ-5r for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:20 -0400 Received: by mail-wm1-x333.google.com with SMTP id g135so9952515wme.4 for ; Thu, 13 Jun 2019 05:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=u8F8E/4POHXbij/G30GWx/MM7QuKTGRas6m/d3Ld7BI=; b=hv8q4ECJI0kn/dKaUJ/V2EDBMd9xap7BMtRUlXo7sd/6YHRIY18qVgulRE/iQ18+4R aLpYboJJO3+CuXoifsNuTwapX+SB5Fw3tCjAEAu7GqqWizCvWoEFLqJgrFIyxYWQdO7f 2Y6IPUlJitrVO23V93i7An1sinUeFhwMfYqPkNZzacLGoGCe0l6MDqE1LKwKH5LUbjsu 6MI3KkYqfBR17no6Fx7Azs5J1TLZzqt/sz/iYHNzbJJ52mtPLyFpvcogCHoBd1PhCvbF Kz7ZUZ8Nxp2O1Qewm1cKH90+DBO5tdmlASCyQf9JKx4ybC4Xiud3OqwBLTZUEDeweRhY Cftg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u8F8E/4POHXbij/G30GWx/MM7QuKTGRas6m/d3Ld7BI=; b=Zw/57moVCEhuownYwLfZoP4/bDKN/YpKI8Z9ZWA1cCV5HSmfwIDVge27mloBHBZ+Yl LwKnV2sBV1pSjBYEGCpB2b1/cuH+0EHFilmgZ9tsTsHh9zLBPq3LFNr2eTN5OEpES+Bl Ohq5vl6DBsKV9M04lDvtvpLyK8oG9blPT5c1ISGe4opTrQzYN/9GFpWvfJbxDuh5mmfP 4D112hoaqxlMjbFLsQQ+WBY1qR0Ofn6Fvh2uoRm1nUxhlwRI7OWr09N/A6/sya7785n2 uiaOLKmd73k+F/UGfQGWat0vGd9GBZXsHlDG/2Bj9tKE9qeKv2tHkOgwV4/WxC1R4LkN LNHg== X-Gm-Message-State: APjAAAU5H/It2aMvDM5LSPUGfV6votFPL1c/K1TlKn2H1kBePKxg3NHs 15/j05CT+XRNiDvnY3TlhX/ogk3KBP6CQA== X-Received: by 2002:a1c:80c1:: with SMTP id b184mr3267469wmd.24.1560428105331; Thu, 13 Jun 2019 05:15:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:12 +0100 Message-Id: <20190613121433.5246-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [PULL 27/48] target/arm: Convert VFP VNMLA to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP VNMLA instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 34 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 19 +------------------ target/arm/vfp.decode | 5 +++++ 3 files changed, 40 insertions(+), 18 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 1d7100debe4..8532bf4abcd 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1383,3 +1383,37 @@ static bool trans_VNMLS_dp(DisasContext *s, arg_VNMLS_sp *a) { return do_vfp_3op_dp(s, gen_VNMLS_dp, a->vd, a->vn, a->vm, true); } + +static void gen_VNMLA_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst) +{ + /* VNMLA: -fd + -(fn * fm) */ + TCGv_i32 tmp = tcg_temp_new_i32(); + + gen_helper_vfp_muls(tmp, vn, vm, fpst); + gen_helper_vfp_negs(tmp, tmp); + gen_helper_vfp_negs(vd, vd); + gen_helper_vfp_adds(vd, vd, tmp, fpst); + tcg_temp_free_i32(tmp); +} + +static bool trans_VNMLA_sp(DisasContext *s, arg_VNMLA_sp *a) +{ + return do_vfp_3op_sp(s, gen_VNMLA_sp, a->vd, a->vn, a->vm, true); +} + +static void gen_VNMLA_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst) +{ + /* VNMLA: -fd + (fn * fm) */ + TCGv_i64 tmp = tcg_temp_new_i64(); + + gen_helper_vfp_muld(tmp, vn, vm, fpst); + gen_helper_vfp_negd(tmp, tmp); + gen_helper_vfp_negd(vd, vd); + gen_helper_vfp_addd(vd, vd, tmp, fpst); + tcg_temp_free_i64(tmp); +} + +static bool trans_VNMLA_dp(DisasContext *s, arg_VNMLA_sp *a) +{ + return do_vfp_3op_dp(s, gen_VNMLA_dp, a->vd, a->vn, a->vm, true); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 42701884101..0b998552df2 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1393,16 +1393,6 @@ VFP_OP2(div) #undef VFP_OP2 -static inline void gen_vfp_F1_neg(int dp) -{ - /* Like gen_vfp_neg() but put result in F1 */ - if (dp) { - gen_helper_vfp_negd(cpu_F1d, cpu_F0d); - } else { - gen_helper_vfp_negs(cpu_F1s, cpu_F0s); - } -} - static inline void gen_vfp_abs(int dp) { if (dp) @@ -3122,7 +3112,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0 ... 2: + case 0 ... 3: /* Already handled by decodetree */ return 1; default: @@ -3308,13 +3298,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 3: /* VNMLA: -fd + -(fn * fm) */ - gen_vfp_mul(dp); - gen_vfp_F1_neg(dp); - gen_mov_F0_vreg(dp, rd); - gen_vfp_neg(dp); - gen_vfp_add(dp); - break; case 4: /* mul: fn * fm */ gen_vfp_mul(dp); break; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 08e4f427408..c50d2c3ebf3 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -112,3 +112,8 @@ VNMLS_sp ---- 1110 0.01 .... .... 1010 .0.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp VNMLS_dp ---- 1110 0.01 .... .... 1011 .0.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp + +VNMLA_sp ---- 1110 0.01 .... .... 1010 .1.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp +VNMLA_dp ---- 1110 0.01 .... .... 1011 .1.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp From patchwork Thu Jun 13 12:14:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166635 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp723424ilk; Thu, 13 Jun 2019 05:55:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhKhWx5DP8ojnRVeRWA2MwBTyDgno1ELFFqaOJc1biNYQKWEtAC5KwzdgSlW0IyBiSul7X X-Received: by 2002:ac8:2763:: with SMTP id h32mr77061406qth.350.1560430540510; Thu, 13 Jun 2019 05:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430540; cv=none; d=google.com; s=arc-20160816; b=xm5gjAfVXUrkDqrN/iO4Btc6H1ldkgyqJ+T2UV9MAWITRSnPUcnQnvC522mxGbfr81 jb18tFOXU47JPNteU+/zHBRHZSAbrshL+uKlo5kbiAYGSSAK4pNN9w9DbOqOq9XdjHKG hEQgxy+rl5NnHUn1mhg9fxBxRcX0drCtDeWYrCahgTjOCQRpLaFqv2Ij/V05QIek//kq noNmdSUETCQxNJinXSU2kCpX3I5tEDzRZxRJoQ0fky+Xqvo7c5uFQVzPz9zEPYPr/qHf EGHFn5PF8hfVtO0XcFTrr7WQAOsF+9mnXDkuRi+kIt8DyZBaJqySY8y0jBqWqGduBPI2 sm6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=4keYJTShaE3kyMWHr8Guw8e7EydlG5N8a+TAXs29Ato=; b=aLpT8SxXO0m1nZM2k7uoax4/I2yYdg/wFNycljuTBVnIDlLBuNxNeR0NyF1sTfMfh3 XyBjnS+LKWOBwP0I35YriB6bbPMm7ua08ahUBk6NRrZkllmZDZsXwNURri/QOE4+Ip86 9vf1yctihXm0fApxbftRP5L4mkOPKbmWVxBuL4sqztlzVKRSNs00eRkTs8uo8Weoy2Tm j/b+wgD85dajd0AazyXjC9g+fFsROJ5MKu5belorL7NIzKsyA+eB5w1rOpuPnPV9zlxj Mt5aVdAvgVnMP7UlYq8L16oXrOgaO7KakgtxeEbUZIBVsNBHi/c7EtBfvzIvWHs0zIr3 ZkZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KaiXqWA1; 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=fail (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 t12si1799913qte.169.2019.06.13.05.55.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:55:40 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=KaiXqWA1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPGW-0002R5-01 for patch@linaro.org; Thu, 13 Jun 2019 08:55:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59259) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdW-0008BC-21 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdT-0004XM-SC for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:21 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:45624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdR-0004KJ-Li for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:19 -0400 Received: by mail-wr1-x444.google.com with SMTP id f9so20488068wre.12 for ; Thu, 13 Jun 2019 05:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4keYJTShaE3kyMWHr8Guw8e7EydlG5N8a+TAXs29Ato=; b=KaiXqWA1SqB2S3kxrhKzGXmCGCCuv8j078OreQRhYMQM2exCWTCM/iPdJNPZuQZp1/ vDRB+0zuPHp8upJUY5VbqPXrOadmfD0p9eXIHB9fJahHL5HtfItjv3svdVkY5cxn1cRu F0LGTCh3cLB70a2kNpY2wnSLBv/ZedrvAOXxNa1FDfZr1yPedsZgY2vWid6DAuK9yQIB ePzGXSlEbTrD92T5/78iCkYEbkQD+5lJAfnwRMemIDbh1d4oaMrrbwfcFklxaZSj1ZCv qwJwZK8IhuBVpF/Ww6/j5j0IUsWO2003WMtr4sRxjkDApPZKCVonnFzlEYXF3mwj7/ic uGPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4keYJTShaE3kyMWHr8Guw8e7EydlG5N8a+TAXs29Ato=; b=lIhBxcOEcGkoHHUX45v7bbzYSkmPr2D6Zrj4LCX74mZlr3VKWJCNNG5Z0xPYIpD6C+ k6ntnsn4PfOapjCaOkjbEosQoygJag2uO6LvYybY5ljdZA2YOCQNtVX1GQM5MGMQH3m1 r0IpggZUJIXmr2AobPW/aB9puFPx89JjF/jnXzXi139jDGI+vmdwWbnb6leisBHcKkmK nrSrbbnfkyOGcQcg5BgDmRCwsiU+H/ZCicgQR4WzOAzyzsvcYSBz5DcLLWt5VVlAaB9u lmQsJLt/y8/GVbJWqQTj0oHyZCKnonkHNWVQi/e4dxFrIRmfKpD5UVn+xpd1MjTJI78d vOsA== X-Gm-Message-State: APjAAAWhkxhokvOz+T56HCl55r+PzsBGXm5lNUcghnev2TkwNNDVl0yO 7n8rFwpYC9gjZGzLQGlrglduilW1HAx82Q== X-Received: by 2002:adf:e8c8:: with SMTP id k8mr31277546wrn.285.1560428106361; Thu, 13 Jun 2019 05:15:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:13 +0100 Message-Id: <20190613121433.5246-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 28/48] target/arm: Convert VMUL to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VMUL instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 10 ++++++++++ target/arm/translate.c | 5 +---- target/arm/vfp.decode | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 8532bf4abcd..a2afe82b349 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1417,3 +1417,13 @@ static bool trans_VNMLA_dp(DisasContext *s, arg_VNMLA_sp *a) { return do_vfp_3op_dp(s, gen_VNMLA_dp, a->vd, a->vn, a->vm, true); } + +static bool trans_VMUL_sp(DisasContext *s, arg_VMUL_sp *a) +{ + return do_vfp_3op_sp(s, gen_helper_vfp_muls, a->vd, a->vn, a->vm, false); +} + +static bool trans_VMUL_dp(DisasContext *s, arg_VMUL_sp *a) +{ + return do_vfp_3op_dp(s, gen_helper_vfp_muld, a->vd, a->vn, a->vm, false); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 0b998552df2..34be68fb8cb 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3112,7 +3112,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0 ... 3: + case 0 ... 4: /* Already handled by decodetree */ return 1; default: @@ -3298,9 +3298,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 4: /* mul: fn * fm */ - gen_vfp_mul(dp); - break; case 5: /* nmul: -(fn * fm) */ gen_vfp_mul(dp); gen_vfp_neg(dp); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index c50d2c3ebf3..d7fcb9709a9 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -117,3 +117,8 @@ VNMLA_sp ---- 1110 0.01 .... .... 1010 .1.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp VNMLA_dp ---- 1110 0.01 .... .... 1011 .1.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp + +VMUL_sp ---- 1110 0.10 .... .... 1010 .0.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp +VMUL_dp ---- 1110 0.10 .... .... 1011 .0.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp From patchwork Thu Jun 13 12:14:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166643 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp740676ilk; Thu, 13 Jun 2019 06:09:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOlFg/1re8wKk8sy09+KRL7pBBWEhHcnOKQTvz89vZdUCqxWzoWCo79pcV89w4A6KFZklO X-Received: by 2002:aed:38c2:: with SMTP id k60mr3234781qte.83.1560431360798; Thu, 13 Jun 2019 06:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560431360; cv=none; d=google.com; s=arc-20160816; b=LPYEZVra+VyvFJEWl7cuxeZhvFXFmp0drtdCsgcSCX5z/e7+TdpUa1DBpEHnVcwH3Y wUQPW0Gh6k8cX33f5ulOH3lLcxm5r0UHBLt8IXQy0h3TFMXR2AlykQDvQLpHNylK7O8D DaxmWgDBe+f8Ey2ENnYTKyLfzPC7itj7NmZ5Zbar6xzynMReCiwq04kLSF/X0Ee0e7gR lV6DMf6+JvDRWvwaefBsFND6n+kOE2BsW7lxz53xsRhDW0U5LlDAOGE3O+FrBfZ9EcuS VlJOb1zGBizZxZMYHMnvkV7zEvA8BfgvT8PIsyhbEbiRzayhvjONm+vLK5ZbaoNPYDH9 Rr8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=pAYGcuXLW+jNCf7bXM4RKr51ic5n9fmJq+PJHu/PS/w=; b=MHbKyzXMIGrK8mPa1u05+Q3LIkgCHpLRtou43e1deQfBo+Rj9UbsWPplc4r1Y+nTss QHrmtVjECvNKwWDeMXmdJoUpUi2uSmH9fhEh/qWFi2hOPphg3icnKluPO6l+5u82i+mf CJaGdLIf3TH1LdwIe+P3FH3ZcafB03ETvVl9ZVwSJ8Xd/g1hp2F87AsEh8qscWC6JKM8 P9NGRFrby2Q/28HI6PF4ffo0cbEe/BFwIy98g2B0FbPO9+nOPHGpKL0SOPwzA7prC2Mj yykPSv8l2d61A8I+nL4ydE/VSIqADFEMxONLvnHPZTXAo+wJFiRGSxOYCmsggvhuU2Xs ZPZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=B4ZehyvK; 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=fail (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 m6si1824259qtb.11.2019.06.13.06.09.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:09:20 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=B4ZehyvK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPTk-0005GA-Cf for patch@linaro.org; Thu, 13 Jun 2019 09:09:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59364) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdZ-0008Gm-Sm for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdU-0004ac-M8 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:25 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:45254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdU-0004LS-4d for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:20 -0400 Received: by mail-wr1-x42b.google.com with SMTP id f9so20488128wre.12 for ; Thu, 13 Jun 2019 05:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=pAYGcuXLW+jNCf7bXM4RKr51ic5n9fmJq+PJHu/PS/w=; b=B4ZehyvKgPIt39ZnVifSsXVpQvA2aqEJVKpgnIh4H8ocTWZf8H/Uk9U7fav70veePn cN5uf/1t6dyO6Zoe0cMGxk1qeD5EH3+O3Kko1hRIs9prqwZSOZmsNUfs8hIv7xMwUdcn ldpL72XMguYKWaE4UTZaanBOnmnLHqyM4JmsDAMWZTmhPo3jWL6gQxbzKviteagqxd/v K7o60idFipD+ELWdxp6HDuMw5zjypdJyP0lxC7VP66iNIwIGkajCsyOIl14Qy6lYOPT6 SAFfxVQPCTSgnZmF6NQ8Fb0EyUfbsuw3CZStKF/qnHArrSfQDvWNviIphhcPAVOYezw6 QQUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pAYGcuXLW+jNCf7bXM4RKr51ic5n9fmJq+PJHu/PS/w=; b=NuZRNGuVV29UoeMDoMxnNI7vi/D4umTc1hvfbUexQwgOkO3Kr8T87TzOqGNQHspWsb S8MyRf6C3Vpel38ZWPMY7+sxDZKUqTZax8BG/TbHaTNFDhL2H8Hju0KIK81QmdC0uT3D o0WY8QNKyNimpWe1APKhbhYVQuli/jq3YwojQydROMM7CnEdo7+sisIRZ1rSmq2YfW3t r/FCBvTJ6vhk9i4rYvlEzYDeFD1enOUfscYlF7cTc4IkHDNKuiYgHvhHMg3dF+f470bA ncxVgiTn7LnplT+7bFvq3YUTQQ1Nu08T0psBbZPIRQQWkt/LLwYR/kPtyTI0UBj09ESV km1g== X-Gm-Message-State: APjAAAWtWmHC1+w7eKxuVLhrjRGhNoMBUvPj1sWknqim+ZyeqqaeTeXZ JXuRtUoNRYztEFEdOYhj77wi8AA6Ed/zjw== X-Received: by 2002:a5d:5089:: with SMTP id a9mr2461264wrt.290.1560428107222; Thu, 13 Jun 2019 05:15:07 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:06 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:14 +0100 Message-Id: <20190613121433.5246-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [PULL 29/48] target/arm: Convert VNMUL to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VNMUL instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 24 ++++++++++++++++++++++++ target/arm/translate.c | 7 +------ target/arm/vfp.decode | 5 +++++ 3 files changed, 30 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index a2afe82b349..4c684f033b6 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1427,3 +1427,27 @@ static bool trans_VMUL_dp(DisasContext *s, arg_VMUL_sp *a) { return do_vfp_3op_dp(s, gen_helper_vfp_muld, a->vd, a->vn, a->vm, false); } + +static void gen_VNMUL_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst) +{ + /* VNMUL: -(fn * fm) */ + gen_helper_vfp_muls(vd, vn, vm, fpst); + gen_helper_vfp_negs(vd, vd); +} + +static bool trans_VNMUL_sp(DisasContext *s, arg_VNMUL_sp *a) +{ + return do_vfp_3op_sp(s, gen_VNMUL_sp, a->vd, a->vn, a->vm, false); +} + +static void gen_VNMUL_dp(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst) +{ + /* VNMUL: -(fn * fm) */ + gen_helper_vfp_muld(vd, vn, vm, fpst); + gen_helper_vfp_negd(vd, vd); +} + +static bool trans_VNMUL_dp(DisasContext *s, arg_VNMUL_sp *a) +{ + return do_vfp_3op_dp(s, gen_VNMUL_dp, a->vd, a->vn, a->vm, false); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 34be68fb8cb..cf03672db8c 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1388,7 +1388,6 @@ static inline void gen_vfp_##name(int dp) \ VFP_OP2(add) VFP_OP2(sub) -VFP_OP2(mul) VFP_OP2(div) #undef VFP_OP2 @@ -3112,7 +3111,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0 ... 4: + case 0 ... 5: /* Already handled by decodetree */ return 1; default: @@ -3298,10 +3297,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 5: /* nmul: -(fn * fm) */ - gen_vfp_mul(dp); - gen_vfp_neg(dp); - break; case 6: /* add: fn + fm */ gen_vfp_add(dp); break; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index d7fcb9709a9..3063fcac23f 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -122,3 +122,8 @@ VMUL_sp ---- 1110 0.10 .... .... 1010 .0.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp VMUL_dp ---- 1110 0.10 .... .... 1011 .0.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp + +VNMUL_sp ---- 1110 0.10 .... .... 1010 .1.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp +VNMUL_dp ---- 1110 0.10 .... .... 1011 .1.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp From patchwork Thu Jun 13 12:14:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166637 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp725571ilk; Thu, 13 Jun 2019 05:57:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGv8XEARFP6vWqp6NUl7b2hVXhhaZGEWRO08RyFxivfdLrZ83vAAFKdXBIpKDqPzcIVZ3M X-Received: by 2002:ae9:c10c:: with SMTP id z12mr17661321qki.110.1560430679806; Thu, 13 Jun 2019 05:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430679; cv=none; d=google.com; s=arc-20160816; b=dww6ayi1MmC3pPXa0FqYMnx5ngyHWWMJzp8PMBVlP8rFwG5M4RAHskxf/aissiqlri c7Qt1N28EPgnz3l6HWO+W8Oj3W4oYaDiX23amrY0M4CRH7EZuaZvIEybm9AzgzNud06U ycmYrDWddXzkxlc6x7mkiAl0SKq96UQ7mLaA5Vx1H/DY0OgjpXbjkv4ghPytqkDbKJle 4olZb9oGf3URENG4LBseD1Wbq4nXSB2yFcywgR1qEQwHpcO8mXQrPR0XTDzFhAzpJp4Y IWoToPXA3o8OcNcbDgge7KTpU2nfpmpyvKhCx+jpEaj5cFKGsqdA7BJ1X+e5/xtN4Emb uxyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=eYuZ4JfNpv8LMEYu119hBSFj+2/7pHYpoxLLGG2Y2VU=; b=ohYsdQWog0NbS/2MVpLlSLuY0zGXT4qfFTy5V4XQebyj9Ucww5Hx9hu51KYOcRHr2y YqwEL73jgqnKwK+DT5jA9L9X86sPW/YeJRfwij4m389d5I22AqP+MjxpiO4sx0NUf8KY 7qEGV6z1a9E1bxO2LdRYsDb19zCCZAv6oQcJ/rs1bZ+fBNIPOCa24QtGQRWzqHnxrg0+ vE/i2FHl6fVT0LTyWPcOJy3mb0YQWNWSCsFWaAWoqbvfc7KegN+ZV46l+/39Zr2hOU6L P3e7EdEZPXkhowM9kT2GP4UHs/1LdGFoEqre0lfYumW8cz8942yEdST1IH6A8xN8YK7n zRfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SZodAsV8; 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=fail (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 g13si1527197qke.211.2019.06.13.05.57.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:57:59 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=SZodAsV8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPIl-0005PC-8j for patch@linaro.org; Thu, 13 Jun 2019 08:57:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59396) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOda-0008Hl-BS for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdV-0004d4-Bi for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:26 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:52170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdU-0004M0-Rz for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:21 -0400 Received: by mail-wm1-x331.google.com with SMTP id 207so2082006wma.1 for ; Thu, 13 Jun 2019 05:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=eYuZ4JfNpv8LMEYu119hBSFj+2/7pHYpoxLLGG2Y2VU=; b=SZodAsV8Mr+FemOgPqb1thHU4CE03OhOyF8GRtm8hvpuNipUfkkkScpoip3ZrWiWpF A3y7fUnTKppe7Dka6MiDphUxq86znav0/VPJXpS0YRMxItRUCPLWQgI+IZH/WNe2f8uR GyFyTN/l+P0jUDLtMEzDYMTkZBIspoH7UXv83u6l2Cn/zTnDI2GCL9pyz7sskoMCb5Wl 1p/nl+6deTSNzrePLhYS5tJF534S7w2ByyBIYEL/PmshFLX6j0mRXvFuxdGc0PdYH+aF LfIRYfCQPGSF8oR2BcWOnOIAD9qD0FyfCKMRmJ6V5UBWG27hOTZCLWS6bgJVVVh/A30O KgnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eYuZ4JfNpv8LMEYu119hBSFj+2/7pHYpoxLLGG2Y2VU=; b=c5j5f9p4abbpNeMAaoyq/t00l70bEP9AfyVwMcC6kIlKDeiNFMpSPr40c+J8xkeAv5 83IPGP/CQhTlStOpl2HqjrJ6Mnn8F+xzMP0aelj5shEITS+WLqLRxcEPur5i6BbRChEp BBmAzHhPjz/89nq+Lh36L0aYwO7Ok8CoXRtjrPFTf8cV7XBfmh0FNKLtkEGLP3EV+pQr zj/UjOoIHnNCeDME8V3uCXn+HEKNxjHo3UrcV68Q1OXeqnSUgPMGiiXxZTodY27nIh90 OGKm53cnze0DNURHx/PFWK8ugcFQ9oLqm6+F4gJtYrfqTClJuyslwwZ9dfbCbLRpX1NU ATZw== X-Gm-Message-State: APjAAAUoYx9PWZxTeVNa3R4NIW7BZiPhs8E2GwmXRa+c/YrwI8ODXr/A PSdTOd2m7Hs/JSV25zUEB54YiI8RuEqq4w== X-Received: by 2002:a1c:f205:: with SMTP id s5mr3777869wmc.14.1560428108144; Thu, 13 Jun 2019 05:15:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:07 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:15 +0100 Message-Id: <20190613121433.5246-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [PULL 30/48] target/arm: Convert VADD to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VADD instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 10 ++++++++++ target/arm/translate.c | 6 +----- target/arm/vfp.decode | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 4c684f033b6..14aeb25f597 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1451,3 +1451,13 @@ static bool trans_VNMUL_dp(DisasContext *s, arg_VNMUL_sp *a) { return do_vfp_3op_dp(s, gen_VNMUL_dp, a->vd, a->vn, a->vm, false); } + +static bool trans_VADD_sp(DisasContext *s, arg_VADD_sp *a) +{ + return do_vfp_3op_sp(s, gen_helper_vfp_adds, a->vd, a->vn, a->vm, false); +} + +static bool trans_VADD_dp(DisasContext *s, arg_VADD_sp *a) +{ + return do_vfp_3op_dp(s, gen_helper_vfp_addd, a->vd, a->vn, a->vm, false); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index cf03672db8c..2341479a7c2 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1386,7 +1386,6 @@ static inline void gen_vfp_##name(int dp) \ tcg_temp_free_ptr(fpst); \ } -VFP_OP2(add) VFP_OP2(sub) VFP_OP2(div) @@ -3111,7 +3110,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0 ... 5: + case 0 ... 6: /* Already handled by decodetree */ return 1; default: @@ -3297,9 +3296,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 6: /* add: fn + fm */ - gen_vfp_add(dp); - break; case 7: /* sub: fn - fm */ gen_vfp_sub(dp); break; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 3063fcac23f..d911f12dfd0 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -127,3 +127,8 @@ VNMUL_sp ---- 1110 0.10 .... .... 1010 .1.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp VNMUL_dp ---- 1110 0.10 .... .... 1011 .1.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp + +VADD_sp ---- 1110 0.11 .... .... 1010 .0.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp +VADD_dp ---- 1110 0.11 .... .... 1011 .0.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp From patchwork Thu Jun 13 12:14:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166633 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp722511ilk; Thu, 13 Jun 2019 05:54:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNytltuBgbLmjyzfiAmK+AagDXIyB5/wKJPwtwhsdwu4HFbkuPKHtaA+ogbtRG0dNLDokG X-Received: by 2002:a37:a1d6:: with SMTP id k205mr52192883qke.171.1560430486837; Thu, 13 Jun 2019 05:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430486; cv=none; d=google.com; s=arc-20160816; b=GWt/RIo4I/2jnl5P0cakqZfja53E0q10dcQlygQY+PActkfwYs8Q51zk11scfIPDef AzHTJx1+uCbWs/gMIX+ane8LcaDCUJO0/QcuUoXlUF9r4MyyYWjXMHpRq3IWbFZvx4u+ Y9t3z4MEdX2sZ8xZeDBFDruBgxyJzT27Yuqcs7GVXnyg6CsI+Hx8rNBMmo0AK4es9/Ad UzgYiDKD558s4lzjpe93rOkjfQkiIoRUv+g8JW9lMpvqgbefLW6iIJPuVshN2Kuj7BlG l4n+vyYvFkfD7OpSpjSNT8B4CSLsp0R2EdYvlSPZrHeEkct27ssHTQn004rrYduuuDV4 A5KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=n6lixbnjvJpGmbP+wJzw0YyYNuM8C0qvQLRRdQPH6UY=; b=CvNmcokdU52Yjl/DubfWL1QvhUiyezGNbH6GsIqUg7eFoH8pS3M/sW+AXeTGLdfpfi Z/sjEBjSMJyEB8tgpG9isNXPB4m2iOkcTeIPm2LwjXyJjpMhEwzCD6XYBmj2sbiaT1XC Pcpr9sZRTPMWKRLnU//4ZVwBJe5ZmzRDmAQ7rb0YAEfr/CulbQkm68fejbNfqlj84IsQ hPXyqJsnQUMVd4/gK5Fgy5ojgujexWsa10uRgA25vqVimaM4/P+X1fjANUeRLUI9K2dm YOhrWi/EEXv+wSyVdZbrtmthRg2yjmzinwnFunKO3FFtFPaZFgGPLWSSIVC10gl9D4fo b2tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lnyco95W; 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=fail (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 k4si1692807qte.360.2019.06.13.05.54.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:54:46 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=Lnyco95W; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPFe-0001Mj-DB for patch@linaro.org; Thu, 13 Jun 2019 08:54:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59131) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdR-00085b-JK for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdN-0004QP-A0 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:15 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:34062) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdL-0004Mq-By for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:13 -0400 Received: by mail-wm1-x331.google.com with SMTP id w9so6496220wmd.1 for ; Thu, 13 Jun 2019 05:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=n6lixbnjvJpGmbP+wJzw0YyYNuM8C0qvQLRRdQPH6UY=; b=Lnyco95WaHnU9n7B1RJc4kb4AqyZbhXBY9WPW+5ETnNyL4c2QJm7lnqJhKOZVAt0vx C9oUDSvQCm7LB7P2TksNuv6h0M2c9dQ4KcglPuZqIJX+bkcJ/27W91Pd/T8qkraWHEXg keKVbLsj5IA2J+CigRXqUQnm/tvSv+hO3FnjrYLApePECTr4Yt4N5OjvKboUrw0Iu/Q5 g+WxLhv8zvff5Z0Ck2yXl87wReEZxbCxYU47MUp51v7939m+sYURC87BhHa81e3lLBZl +QZC6aHbpvJ6qXc3XY/51DKjz7F0XfwRUo9GfNvcctMBDnB0lsu1ybE1stqlhw/ndz0m KcAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n6lixbnjvJpGmbP+wJzw0YyYNuM8C0qvQLRRdQPH6UY=; b=gD51Mc6DWK39VJMt8/+oJ+zmdjgoJ4RwMrB/oiMHeY7CAnefVHexd/6WvoHP7UADUv 3heD3T15TWw4hxS4XMUDGkCLSFg9m8/wD5HYMgfySCPdVmMSoL81hArvil3PGQdCmBlL GyK9O51+yp1Pq7NcO7amroIqgf2RdW5vIirN0OL1yGZUq5vIVshWyMgzXsehmm+JiJFg CH6xgIAMNePUPWcVP06Hc19rdhniqlaxiUuROjM9xtMVWP2Xo9Qg37xeYZF9HOSTBTtu M40xceZ8xJVi49wmyEySyOaFJAawcwxRl8bMkmSHLSfgO3bsy1ovbj7cFiRJf9NJrbCf mBwg== X-Gm-Message-State: APjAAAUktFXkb/Ujp56AxlBPbU2i4d4WjBheHoEBzQw7VzShMsvaCgtv G/MrxFKLWvjd6ZQQsDbH9zCeq1VCM058GQ== X-Received: by 2002:a1c:3942:: with SMTP id g63mr3191936wma.61.1560428108976; Thu, 13 Jun 2019 05:15:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:08 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:16 +0100 Message-Id: <20190613121433.5246-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [PULL 31/48] target/arm: Convert VSUB to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VSUB instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 10 ++++++++++ target/arm/translate.c | 6 +----- target/arm/vfp.decode | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 14aeb25f597..12da3b8acb8 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1461,3 +1461,13 @@ static bool trans_VADD_dp(DisasContext *s, arg_VADD_sp *a) { return do_vfp_3op_dp(s, gen_helper_vfp_addd, a->vd, a->vn, a->vm, false); } + +static bool trans_VSUB_sp(DisasContext *s, arg_VSUB_sp *a) +{ + return do_vfp_3op_sp(s, gen_helper_vfp_subs, a->vd, a->vn, a->vm, false); +} + +static bool trans_VSUB_dp(DisasContext *s, arg_VSUB_sp *a) +{ + return do_vfp_3op_dp(s, gen_helper_vfp_subd, a->vd, a->vn, a->vm, false); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 2341479a7c2..a7f79395e31 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1386,7 +1386,6 @@ static inline void gen_vfp_##name(int dp) \ tcg_temp_free_ptr(fpst); \ } -VFP_OP2(sub) VFP_OP2(div) #undef VFP_OP2 @@ -3110,7 +3109,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0 ... 6: + case 0 ... 7: /* Already handled by decodetree */ return 1; default: @@ -3296,9 +3295,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 7: /* sub: fn - fm */ - gen_vfp_sub(dp); - break; case 8: /* div: fn / fm */ gen_vfp_div(dp); break; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index d911f12dfd0..de56f44efc9 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -132,3 +132,8 @@ VADD_sp ---- 1110 0.11 .... .... 1010 .0.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp VADD_dp ---- 1110 0.11 .... .... 1011 .0.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp + +VSUB_sp ---- 1110 0.11 .... .... 1010 .1.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp +VSUB_dp ---- 1110 0.11 .... .... 1011 .1.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp From patchwork Thu Jun 13 12:14:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166648 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp752433ilk; Thu, 13 Jun 2019 06:17:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzE1m1aaM2NWy/B8PAX1oTilaPmcTuWMcQJVhtJ9DkcIalOCXF7Vwzsk4NrOhi2SLHVYhaX X-Received: by 2002:a37:640f:: with SMTP id y15mr2758124qkb.79.1560431879443; Thu, 13 Jun 2019 06:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560431879; cv=none; d=google.com; s=arc-20160816; b=SgxyTegmr81KEtRzWJ2jIpbHw5f1N47zjut+cxj263s3YbuI5J3B03JKtjoRx9m9BE TVs/XJWkNtQWtMt0TwFz9Qm4TrqJ91dvi6lVXypH7bw/Kf5eelE70A/TJttoEo6g44KZ kwYVako0MvoTd5Qk8/6+f4ngE3r3Yw3XOW4wvn3cPyCTe2gRC/iUGM5tGoFet6idzVZJ t26GoVysfR2U2PLO8MbO0sFJGtA5e6YnyHkzzP6ev3uTOd4gZDevTdmpvTP6EjtZ9POJ nV25bgHqQ036UvhT5gcD5PuyBaElNOLGSHpdak6fSwOggNBXEaoZGEf03XkBDhkFi5ZI WKkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Xek76Z21N6AcxCeV/KMXFd6TB5Qk1G4QFM9zTsJV+oA=; b=fbVOiU7cQAiCXlm8U40+Szl7OXHSAb1OqI6zv0vfo0yGHoDW9ThNoNSkxnS7NVdr/7 FhKEMMN111ot64Z1ZiCZKp98NzjMzU5t2YdmFfAwVgWZJfvOaDOE8+u7vXvSI5GrYIeB tmxwChhispPkeEhzNuXi4yDhwG6/iPW3YH2Fn4+IZhhTkrrqJRZ5hJphwgU2Ma9f39Va AUVCicbCtcDPHI+R5cux8O68eieX1PKO1kLbxrW5t66Q6vgU3gNzvAyS4sA3vC+sDlUS dTOewQh8aTHSSoozTvAkQkHfl6b2pxtZkfrjxTHnYW3Jv9JzmDuXOPYIoeCRmZj6LSIX BA/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NbE333tJ; 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=fail (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 l57si1913350qtl.94.2019.06.13.06.17.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:17:59 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=NbE333tJ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPc7-0002PW-0X for patch@linaro.org; Thu, 13 Jun 2019 09:17:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59370) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdZ-0008HA-Ub for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdU-0004aP-Kf for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:25 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:47025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdU-0004ND-5v for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:20 -0400 Received: by mail-wr1-x442.google.com with SMTP id n4so20484152wrw.13 for ; Thu, 13 Jun 2019 05:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Xek76Z21N6AcxCeV/KMXFd6TB5Qk1G4QFM9zTsJV+oA=; b=NbE333tJ3eT3wD79M9E226KMwElA1OMqzy4AoZWfEjyu93jMjmVtx0h20r+fRISPe/ 7a97oZIwh4FlwqUUUXMCwT33H13i4eM8/noegKXTH851JIP/VKpHNfntfLIkQpezlUhC jWp+SOy3LBSIL/SB9b0/mnrJ8U1mj2qbUnq6uLaCEHpEzuBlDx6EB+/LTg7Bdyz9qqEZ 491nxlT/Gi5vvoyn4M8xFau2P+wrWQl7wE6P1itRbCU3UWHNxtOaQscPkND5RSYf0mlq haHch9/NWVwuE5Moxp9aWt/IyiEdSwVoCQlo4kSZwbxoamvfY/MHJk/p7csDTmq4/LjW 2amg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xek76Z21N6AcxCeV/KMXFd6TB5Qk1G4QFM9zTsJV+oA=; b=UwrA/8oZevii0WUGacWfskalhNYHGRFySGvfXlGqR9569chfpmrR428fTrQ4py4lfZ Hlbe/WSC7OiPKoNRakt2xaATwqEbW3sQdRTAqQt238v7zdrkAhMbzh7y3HYrE1dVqX2l i1/oyzcQAaxUcWBN56acxonUDILLW5RsTdsyBWODOvTSoRWCYTT4vnV2fZ4K7MbCtfgt QcsWVz4NX9IoAOxtnqXv6g5UHBp7XPGxp+oG1wGAfmPSIfVy5uBBvlGz/sakCFpPXper qVc/5m8NdTkArB4Ici5/1v8jzsXwEc3jy76AAQMKdoypMVNJ5nZMYf5L5jWZu2QC6cH1 HvZg== X-Gm-Message-State: APjAAAU83aX7nTVklFXDVcZrwpytovH3vnzeZT2jLvoDeYMokHObTPmi RkJ0ovw1S/hhMf4/PtBMxkURJlypJGEpPw== X-Received: by 2002:adf:9cd0:: with SMTP id h16mr42665889wre.211.1560428109883; Thu, 13 Jun 2019 05:15:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:17 +0100 Message-Id: <20190613121433.5246-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL 32/48] target/arm: Convert VDIV to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VDIV instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 10 ++++++++++ target/arm/translate.c | 21 +-------------------- target/arm/vfp.decode | 5 +++++ 3 files changed, 16 insertions(+), 20 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 12da3b8acb8..6af99605d5c 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1471,3 +1471,13 @@ static bool trans_VSUB_dp(DisasContext *s, arg_VSUB_sp *a) { return do_vfp_3op_dp(s, gen_helper_vfp_subd, a->vd, a->vn, a->vm, false); } + +static bool trans_VDIV_sp(DisasContext *s, arg_VDIV_sp *a) +{ + return do_vfp_3op_sp(s, gen_helper_vfp_divs, a->vd, a->vn, a->vm, false); +} + +static bool trans_VDIV_dp(DisasContext *s, arg_VDIV_sp *a) +{ + return do_vfp_3op_dp(s, gen_helper_vfp_divd, a->vd, a->vn, a->vm, false); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index a7f79395e31..d802f046769 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1374,22 +1374,6 @@ static TCGv_ptr get_fpstatus_ptr(int neon) return statusptr; } -#define VFP_OP2(name) \ -static inline void gen_vfp_##name(int dp) \ -{ \ - TCGv_ptr fpst = get_fpstatus_ptr(0); \ - if (dp) { \ - gen_helper_vfp_##name##d(cpu_F0d, cpu_F0d, cpu_F1d, fpst); \ - } else { \ - gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, cpu_F1s, fpst); \ - } \ - tcg_temp_free_ptr(fpst); \ -} - -VFP_OP2(div) - -#undef VFP_OP2 - static inline void gen_vfp_abs(int dp) { if (dp) @@ -3109,7 +3093,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0 ... 7: + case 0 ... 8: /* Already handled by decodetree */ return 1; default: @@ -3295,9 +3279,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 8: /* div: fn / fm */ - gen_vfp_div(dp); - break; case 10: /* VFNMA : fd = muladd(-fd, fn, fm) */ case 11: /* VFNMS : fd = muladd(-fd, -fn, fm) */ case 12: /* VFMA : fd = muladd( fd, fn, fm) */ diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index de56f44efc9..de305f60e18 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -137,3 +137,8 @@ VSUB_sp ---- 1110 0.11 .... .... 1010 .1.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp VSUB_dp ---- 1110 0.11 .... .... 1011 .1.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp + +VDIV_sp ---- 1110 1.00 .... .... 1010 .0.0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp +VDIV_dp ---- 1110 1.00 .... .... 1011 .0.0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp From patchwork Thu Jun 13 12:14:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166636 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp725192ilk; Thu, 13 Jun 2019 05:57:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYeRbcBxYurPi3kyAUUGUedWrTNpI56XSuT1N6yhPSPswvznce5+PAyBHfn4dMRqbLlmQY X-Received: by 2002:a05:620a:232:: with SMTP id u18mr52515478qkm.131.1560430656594; Thu, 13 Jun 2019 05:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430656; cv=none; d=google.com; s=arc-20160816; b=seURmFPoJGB932LchIyR8UJFPT/HV8c5jBJgYjEbbI/TV9zjDfPcFbhvY6njiE4rXs nD+y0rEdcG0MaukgwxO/KgJCZ8s0OnaQoAQWibtHcKBG8kgDNRUrjrc7q2ebyVORYjyR Qe5HvZr1Rcz7BYphPTEo1zLU+9GKQ+Ba2KT2mY8nnWEas3ifBmD+pnrX7P7XIh9GktrG pkB/bXRd0xgy0Xr4Z55nJnXOafpkYgOWA8axwVhXZ0wzlPscUKgshyFAP4B8zp8sRtrZ C1vbJfvn4fhga2fVXfIj3+EG2waiubPRpDLrz+z5TAfv4poRu5OoJyu27W9wGgR1URQZ fB0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=jTppJkM3EO9LMSyvXV94q5a6w/CwGAvYzQRIh3u70xk=; b=QUE0QqkMEO4JYVl6Az7oxa3TAzg7+CPgR7GAttLoWM2vjOGTgxsLWuP6KalbBXDRMj DSC8kgpJwK5cxmJgNpTqly5rfvlYfWBICyYanpIB6sRhppuUtISOJdpqFAaa8xl3GOeh H1tjaJc6BgYzzJuzyTpj/aAzamSG945tjxyGnNoKzUYRVEO/4noPH7wnv5g0867IB097 4V8wpfa3culgBN5vfzno1JD9MQZvqn3+SFmJgaD93fwT7x8qkQjZ16UGwNN0qVkvD/dr 6dn1sQgyqQsil/E0zNChk80dWHgcGc6/9FniHPlIUuY3nWEIKZvBjJOmq/HRhb2H3722 JXhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EXZpBIPP; 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=fail (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 t4si1809108qtq.2.2019.06.13.05.57.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:57:36 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=EXZpBIPP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPIO-0005L7-6C for patch@linaro.org; Thu, 13 Jun 2019 08:57:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59366) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdZ-0008Gu-Uc for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdT-0004X4-Qc for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:25 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:32995) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdR-0004P4-LG for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:19 -0400 Received: by mail-wr1-x432.google.com with SMTP id n9so20574248wru.0 for ; Thu, 13 Jun 2019 05:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=jTppJkM3EO9LMSyvXV94q5a6w/CwGAvYzQRIh3u70xk=; b=EXZpBIPPGaZa/qXM4JMh5R4v/2nL+F2ZeaM507y1PBiWkzJoeNWJK/xir/VfZibRU7 zN/cZaiwBUBHNsio3lf1llzuLTyaECWbt51XnZ2Tv1BK5beQ7IcthsYNC5rPB3FLpj5L /xqhfDsHcTpWgn1t+/BKPHmTBrl/8IOv5tR7EtxksTrQ7Whu+Vrj0tkQnqlkfWVlsv36 IduZBa/ztKS5DaIdpjxU/Cg3mEyDGQHXlqH/MaomINPmvmVhsBtNz49DPPFbREkUMeEW IyCTGWvEvIMSFdJi2u+S1+wejZji/7tOXO3bs/DRNxdaJn6lXune7pfdMSS30q/Y1mtl dzkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jTppJkM3EO9LMSyvXV94q5a6w/CwGAvYzQRIh3u70xk=; b=WJ/MFH26zurdH7JfrcEuTlTAUA8bF/bLIRJt1zGgkjRftCXeV0ndDpFcRwteBBIlrN zbl/i/lDsY2MoVqgnUBOTeqmXcnEr4lDGkBFj0ZYFw2TuY3kYT8Qa4O5A9RdMj39tR+O Bcaypsr3S0O1T7pavkU/ekYiKdLrlKHGpuT8ld02UrdJUg+JA1I9Mv7F9HCiJqHjx+QD GsPcSGsBzusR6XKnwKEPi8Ce/ZkscG6/lJ4yhBHJYtJkBudWfksz1U5vUx19vTe43Y+f DCyNcFdia24MJEgWgd+TSurDy6ImyKxVCH+vy5Mudi48AL12XVyHNCaV1RbSKnSQPdzr lRsA== X-Gm-Message-State: APjAAAUQz9A+4QpiLj96wbzM/HaxN4a6ylvjJAwIIXnKTOk4YqkrfqaT 5GxMPq3QTwke6jrD2tBQgo3g8V0XTJp6og== X-Received: by 2002:adf:f683:: with SMTP id v3mr2045559wrp.258.1560428110985; Thu, 13 Jun 2019 05:15:10 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:18 +0100 Message-Id: <20190613121433.5246-34-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 Subject: [Qemu-devel] [PULL 33/48] target/arm: Convert VFP fused multiply-add insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP fused multiply-add instructions (VFNMA, VFNMS, VFMA, VFMS) to decodetree. Note that in the old decode structure we were implementing these to honour the VFP vector stride/length. These instructions were introduced in VFPv4, and in the v7A architecture they are UNPREDICTABLE if the vector stride or length are non-zero. In v8A they must UNDEF if stride or length are non-zero, like all VFP instructions; we choose to UNDEF always. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 121 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 53 +-------------- target/arm/vfp.decode | 9 +++ 3 files changed, 131 insertions(+), 52 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 6af99605d5c..ba6506a378c 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1481,3 +1481,124 @@ static bool trans_VDIV_dp(DisasContext *s, arg_VDIV_sp *a) { return do_vfp_3op_dp(s, gen_helper_vfp_divd, a->vd, a->vn, a->vm, false); } + +static bool trans_VFM_sp(DisasContext *s, arg_VFM_sp *a) +{ + /* + * VFNMA : fd = muladd(-fd, fn, fm) + * VFNMS : fd = muladd(-fd, -fn, fm) + * VFMA : fd = muladd( fd, fn, fm) + * VFMS : fd = muladd( fd, -fn, fm) + * + * These are fused multiply-add, and must be done as one floating + * point operation with no rounding between the multiplication and + * addition steps. NB that doing the negations here as separate + * steps is correct : an input NaN should come out with its sign + * bit flipped if it is a negated-input. + */ + TCGv_ptr fpst; + TCGv_i32 vn, vm, vd; + + /* + * Present in VFPv4 only. + * In v7A, UNPREDICTABLE with non-zero vector length/stride; from + * v8A, must UNDEF. We choose to UNDEF for both v7A and v8A. + */ + if (!arm_dc_feature(s, ARM_FEATURE_VFP4) || + (s->vec_len != 0 || s->vec_stride != 0)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vn = tcg_temp_new_i32(); + vm = tcg_temp_new_i32(); + vd = tcg_temp_new_i32(); + + neon_load_reg32(vn, a->vn); + neon_load_reg32(vm, a->vm); + if (a->o2) { + /* VFNMS, VFMS */ + gen_helper_vfp_negs(vn, vn); + } + neon_load_reg32(vd, a->vd); + if (a->o1 & 1) { + /* VFNMA, VFNMS */ + gen_helper_vfp_negs(vd, vd); + } + fpst = get_fpstatus_ptr(0); + gen_helper_vfp_muladds(vd, vn, vm, vd, fpst); + neon_store_reg32(vd, a->vd); + + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(vn); + tcg_temp_free_i32(vm); + tcg_temp_free_i32(vd); + + return true; +} + +static bool trans_VFM_dp(DisasContext *s, arg_VFM_sp *a) +{ + /* + * VFNMA : fd = muladd(-fd, fn, fm) + * VFNMS : fd = muladd(-fd, -fn, fm) + * VFMA : fd = muladd( fd, fn, fm) + * VFMS : fd = muladd( fd, -fn, fm) + * + * These are fused multiply-add, and must be done as one floating + * point operation with no rounding between the multiplication and + * addition steps. NB that doing the negations here as separate + * steps is correct : an input NaN should come out with its sign + * bit flipped if it is a negated-input. + */ + TCGv_ptr fpst; + TCGv_i64 vn, vm, vd; + + /* + * Present in VFPv4 only. + * In v7A, UNPREDICTABLE with non-zero vector length/stride; from + * v8A, must UNDEF. We choose to UNDEF for both v7A and v8A. + */ + if (!arm_dc_feature(s, ARM_FEATURE_VFP4) || + (s->vec_len != 0 || s->vec_stride != 0)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vn | a->vm) & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vn = tcg_temp_new_i64(); + vm = tcg_temp_new_i64(); + vd = tcg_temp_new_i64(); + + neon_load_reg64(vn, a->vn); + neon_load_reg64(vm, a->vm); + if (a->o2) { + /* VFNMS, VFMS */ + gen_helper_vfp_negd(vn, vn); + } + neon_load_reg64(vd, a->vd); + if (a->o1 & 1) { + /* VFNMA, VFNMS */ + gen_helper_vfp_negd(vd, vd); + } + fpst = get_fpstatus_ptr(0); + gen_helper_vfp_muladdd(vd, vn, vm, vd, fpst); + neon_store_reg64(vd, a->vd); + + tcg_temp_free_ptr(fpst); + tcg_temp_free_i64(vn); + tcg_temp_free_i64(vm); + tcg_temp_free_i64(vd); + + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index d802f046769..75280e0e524 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3093,7 +3093,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0 ... 8: + case 0 ... 13: /* Already handled by decodetree */ return 1; default: @@ -3279,57 +3279,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 10: /* VFNMA : fd = muladd(-fd, fn, fm) */ - case 11: /* VFNMS : fd = muladd(-fd, -fn, fm) */ - case 12: /* VFMA : fd = muladd( fd, fn, fm) */ - case 13: /* VFMS : fd = muladd( fd, -fn, fm) */ - /* These are fused multiply-add, and must be done as one - * floating point operation with no rounding between the - * multiplication and addition steps. - * NB that doing the negations here as separate steps is - * correct : an input NaN should come out with its sign bit - * flipped if it is a negated-input. - */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP4)) { - return 1; - } - if (dp) { - TCGv_ptr fpst; - TCGv_i64 frd; - if (op & 1) { - /* VFNMS, VFMS */ - gen_helper_vfp_negd(cpu_F0d, cpu_F0d); - } - frd = tcg_temp_new_i64(); - tcg_gen_ld_f64(frd, cpu_env, vfp_reg_offset(dp, rd)); - if (op & 2) { - /* VFNMA, VFNMS */ - gen_helper_vfp_negd(frd, frd); - } - fpst = get_fpstatus_ptr(0); - gen_helper_vfp_muladdd(cpu_F0d, cpu_F0d, - cpu_F1d, frd, fpst); - tcg_temp_free_ptr(fpst); - tcg_temp_free_i64(frd); - } else { - TCGv_ptr fpst; - TCGv_i32 frd; - if (op & 1) { - /* VFNMS, VFMS */ - gen_helper_vfp_negs(cpu_F0s, cpu_F0s); - } - frd = tcg_temp_new_i32(); - tcg_gen_ld_f32(frd, cpu_env, vfp_reg_offset(dp, rd)); - if (op & 2) { - gen_helper_vfp_negs(frd, frd); - } - fpst = get_fpstatus_ptr(0); - gen_helper_vfp_muladds(cpu_F0s, cpu_F0s, - cpu_F1s, frd, fpst); - tcg_temp_free_ptr(fpst); - tcg_temp_free_i32(frd); - } - break; case 14: /* fconst */ if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { return 1; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index de305f60e18..37eec0e1310 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -142,3 +142,12 @@ VDIV_sp ---- 1110 1.00 .... .... 1010 .0.0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp VDIV_dp ---- 1110 1.00 .... .... 1011 .0.0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp + +VFM_sp ---- 1110 1.01 .... .... 1010 . o2:1 . 0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp o1=1 +VFM_dp ---- 1110 1.01 .... .... 1011 . o2:1 . 0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp o1=1 +VFM_sp ---- 1110 1.10 .... .... 1010 . o2:1 . 0 .... \ + vm=%vm_sp vn=%vn_sp vd=%vd_sp o1=2 +VFM_dp ---- 1110 1.10 .... .... 1011 . o2:1 . 0 .... \ + vm=%vm_dp vn=%vn_dp vd=%vd_dp o1=2 From patchwork Thu Jun 13 12:14:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166639 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp726515ilk; Thu, 13 Jun 2019 05:59:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzokeby2G2WXob/QdnzUv29NTug730oXRo0QwmUomhaA+O7zE6PBri99LzfODzpm1BJ/GJl X-Received: by 2002:ac8:224d:: with SMTP id p13mr54833733qtp.154.1560430744936; Thu, 13 Jun 2019 05:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430744; cv=none; d=google.com; s=arc-20160816; b=lhYgxSJ4d0NDmJMPwW97ToXBPvFT35oLDqAx08fMf1hqrXyT3Sd2EWVGNdEjTefrfJ Zi8gasnUpUM6eyGLFBlwVTpLrWUp36hJ4FfU8wf4NqYbDp0EF58PJ/Lc1sGHmwEe9onS e1pSXd4se3YxEF4Yt7je/QSBaqiyLSll5IpRoa862apEurCmsOtikWz6s12fdWQ9PJzg o3WggGyA+GO+tQiH9Z5EMoG/eVXexNIlqPtupgBeGEUJeTjMdSQf1yYPYaHtHng1lXQP Wq5iW3GZQN0mYFvCBMAItqNbN4YCowowrOlzzcHP7Z4dhUBTXRVL+aZuWsCB42Ppd8zi ayfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZxLqU47/zu103NNnSAFyZsvu3wGIQylPHAykvX/ZYgU=; b=VMgJEVAvdE4QRY7aBk8xfAteUnp76M/EaxgmVFiBjrAylolqA6aVGRWuIePFULwAgj U/F64wdqngqsCpUkvWWZPdrBx5Z964h7P/3EPMPjiTkT+hDYTCuLvh2+3c17kxmNuIkJ +LU4E365HZpygKjHdj81i+7dflcKH61+8MNvKif55RCK1GaXCzlxPT+mLcZd6IppFcPg GXG2YOp9x9FL0b//4trpg6SeMC0jACjPy9T0rhKCCMjhL7mBpGU4igMj9zaoztqOtf/k Ak9wVbsW6YoL99CrLHk6Gl1W+0pof1kY/wNbt/1gn5Ptkmq2GFojVNba/ViGSup0ML/3 nVvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mUTagof+; 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=fail (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 t188si1636607qkh.84.2019.06.13.05.59.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:59:04 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=mUTagof+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPJo-0006F5-Bd for patch@linaro.org; Thu, 13 Jun 2019 08:59:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59426) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdc-0008Lm-4h for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdV-0004bu-4w for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:27 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdU-0004Pg-EP for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:20 -0400 Received: by mail-wm1-x343.google.com with SMTP id c6so9908394wml.0 for ; Thu, 13 Jun 2019 05:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZxLqU47/zu103NNnSAFyZsvu3wGIQylPHAykvX/ZYgU=; b=mUTagof+QENGT9hFlrkDNZbdx72vXBsVhweZeN7NGbRMX2iIBtDuGmqBYYc2w88hBB w6I+mZ0U3h9mlwa8QqA52LsQIz9ALO1XD5k12zGKmypx2V/T9JZufHHQKeX4ToDngmRZ T4BmhSbHvmH6W+EPWxOkCLekedY5a1lyv9thwntsywv26bhCQ3rTm6+0QY+W7H1NyD/4 mb9PNLG5hMEPJFOUEzleNtevyhV5/dBSnPpc+bjBS1exA++yZHokKQR9W1Y5Q0D+cElH 5A2szSzecizLh9FNTOH0yOlGExmrBQjIwIxDNN5EMPOWewp4gCJFgsH5SaKhXWGLrSkT rPXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZxLqU47/zu103NNnSAFyZsvu3wGIQylPHAykvX/ZYgU=; b=Aqj5eubLDIxSiMkWMMeUlKJkI9csvFD4h+74F4qUCqBdftE5AwjbeAa5ewHGgLqlD6 BAdyRdObmbDfssZM5uZx09yZVLoupZ09zxIM/3HEnXVMUi+eYssBHGDf8x42BW8edrN/ RHQFvCaUHlFBOm+0UzTv0Fdu0I519zQn4afgpOGwxlbSalN2WojBCZ6NoKNY6XCuozKs 5mGtpR+DC8GjAegs1hW/9CXLj+QHpeAMIqadLEJe/ZQx7XT/ACTp9GokLC9rGWmbq9qx RCBR9X+gA3kdauT2JcWGL1KRXyIRZo1fc7PMxbQkQAT5OqDVEVS7OMimba/RsWpkY5G2 hLWw== X-Gm-Message-State: APjAAAVGh0c6FgmmAT7m7gXJJll2YpnzWOSKDRubkgy0V2POE+pjePrb fz84kuWFm1YDEOqma/9dec2vvvHiw2kJ9w== X-Received: by 2002:a7b:cbc6:: with SMTP id n6mr3753140wmi.14.1560428112112; Thu, 13 Jun 2019 05:15:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:11 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:19 +0100 Message-Id: <20190613121433.5246-35-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 34/48] target/arm: Convert VMOV (imm) to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP VMOV (immediate) instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 129 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 27 +------ target/arm/vfp.decode | 5 ++ 3 files changed, 136 insertions(+), 25 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index ba6506a378c..a2eeb6cb511 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1602,3 +1602,132 @@ static bool trans_VFM_dp(DisasContext *s, arg_VFM_sp *a) return true; } + +static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) +{ + uint32_t delta_d = 0; + uint32_t bank_mask = 0; + int veclen = s->vec_len; + TCGv_i32 fd; + uint32_t n, i, vd; + + vd = a->vd; + + if (!dc_isar_feature(aa32_fpshvec, s) && + (veclen != 0 || s->vec_stride != 0)) { + return false; + } + + if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + if (veclen > 0) { + bank_mask = 0x18; + /* Figure out what type of vector operation this is. */ + if ((vd & bank_mask) == 0) { + /* scalar */ + veclen = 0; + } else { + delta_d = s->vec_stride + 1; + } + } + + n = (a->imm4h << 28) & 0x80000000; + i = ((a->imm4h << 4) & 0x70) | a->imm4l; + if (i & 0x40) { + i |= 0x780; + } else { + i |= 0x800; + } + n |= i << 19; + + fd = tcg_temp_new_i32(); + tcg_gen_movi_i32(fd, n); + + for (;;) { + neon_store_reg32(fd, vd); + + if (veclen == 0) { + break; + } + + /* Set up the operands for the next iteration */ + veclen--; + vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + } + + tcg_temp_free_i32(fd); + return true; +} + +static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) +{ + uint32_t delta_d = 0; + uint32_t bank_mask = 0; + int veclen = s->vec_len; + TCGv_i64 fd; + uint32_t n, i, vd; + + vd = a->vd; + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (vd & 0x10)) { + return false; + } + + if (!dc_isar_feature(aa32_fpshvec, s) && + (veclen != 0 || s->vec_stride != 0)) { + return false; + } + + if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + if (veclen > 0) { + bank_mask = 0xc; + /* Figure out what type of vector operation this is. */ + if ((vd & bank_mask) == 0) { + /* scalar */ + veclen = 0; + } else { + delta_d = (s->vec_stride >> 1) + 1; + } + } + + n = (a->imm4h << 28) & 0x80000000; + i = ((a->imm4h << 4) & 0x70) | a->imm4l; + if (i & 0x40) { + i |= 0x3f80; + } else { + i |= 0x4000; + } + n |= i << 16; + + fd = tcg_temp_new_i64(); + tcg_gen_movi_i64(fd, ((uint64_t)n) << 32); + + for (;;) { + neon_store_reg64(fd, vd); + + if (veclen == 0) { + break; + } + + /* Set up the operands for the next iteration */ + veclen--; + vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + } + + tcg_temp_free_i64(fd); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 75280e0e524..30d96fbf5a6 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3033,7 +3033,7 @@ static void gen_neon_dup_high16(TCGv_i32 var) */ static int disas_vfp_insn(DisasContext *s, uint32_t insn) { - uint32_t rd, rn, rm, op, i, n, delta_d, delta_m, bank_mask; + uint32_t rd, rn, rm, op, delta_d, delta_m, bank_mask; int dp, veclen; TCGv_i32 tmp; TCGv_i32 tmp2; @@ -3093,7 +3093,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rn = VFP_SREG_N(insn); switch (op) { - case 0 ... 13: + case 0 ... 14: /* Already handled by decodetree */ return 1; default: @@ -3279,29 +3279,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) for (;;) { /* Perform the calculation. */ switch (op) { - case 14: /* fconst */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } - - n = (insn << 12) & 0x80000000; - i = ((insn >> 12) & 0x70) | (insn & 0xf); - if (dp) { - if (i & 0x40) - i |= 0x3f80; - else - i |= 0x4000; - n |= i << 16; - tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32); - } else { - if (i & 0x40) - i |= 0x780; - else - i |= 0x800; - n |= i << 19; - tcg_gen_movi_i32(cpu_F0s, n); - } - break; case 15: /* extension space */ switch (rn) { case 0: /* cpy */ diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 37eec0e1310..1818d4f71e1 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -151,3 +151,8 @@ VFM_sp ---- 1110 1.10 .... .... 1010 . o2:1 . 0 .... \ vm=%vm_sp vn=%vn_sp vd=%vd_sp o1=2 VFM_dp ---- 1110 1.10 .... .... 1011 . o2:1 . 0 .... \ vm=%vm_dp vn=%vn_dp vd=%vd_dp o1=2 + +VMOV_imm_sp ---- 1110 1.11 imm4h:4 .... 1010 0000 imm4l:4 \ + vd=%vd_sp +VMOV_imm_dp ---- 1110 1.11 imm4h:4 .... 1011 0000 imm4l:4 \ + vd=%vd_dp From patchwork Thu Jun 13 12:14:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166654 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp767985ilk; Thu, 13 Jun 2019 06:31:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzES9SjFBNylQtDYgaqqUwX+1gnKkNBjaqhBSriMGakNQiCg9adrO36pq/4PDVsS1RP6Mx X-Received: by 2002:a0c:99e2:: with SMTP id y34mr3600317qve.8.1560432665966; Thu, 13 Jun 2019 06:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560432665; cv=none; d=google.com; s=arc-20160816; b=tNO9CUf3nh5mF5nswcZ+CxbcbVmwEFptker79Q7bKgWzEw6QLmG0npS/SLfENTGvJp YQ8K9QqmAyGd1ZbUY9RuEGm1wfUwBI7MGAWYW27sgvwhfs5kvV6Fw/pZs2ZQPupHbpF/ xAaJVLzf5e6hLjulU9/anLRY184vwKBD5MqgPYxgZU99MyHpefB8Ia5TXXm+DDbCbLz9 DxqYrpEQ9c7WwfDBjTzZtvCwatl1EA2MuSLmiXXSEm6F4ucovbKLoUl2+QyXX++HJL+h SUcf7Q5nI6jmooEnC97pCpoFwkiC1uqupPtq0aK44u0xI9KwV+b/M5nnP4wgXFk966zI B8eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=B3aO9h78VYlbl+c2Ti7U2GX0dd1QukUCluotJULAcHg=; b=aaQeeGng8UG1r7gH5T64u6+RF+CyK5KguQBBkhyrU4C0S9rgShBpzyE30QAsMrwZHM UseeOadCR+xeZfUIgJVq2nRv+hWV3PT3NmTidDlNCsH7QTu4J/FHOK94ZXdWaeLQdsJf PAUTk+93U9qPbDo7ZuBvAso4HOjb/3GHw1FWGDfU29/Fx4241Bvq0qnHlSdsWaNmZZ5G opb6INaEjC8gGD1EO1iYWO2lYT9cuTjHGFBp9S+dsvwN0PFnXZ5TqOECN/xGbtMIe5WJ AkA9N9q7yyKcsoMtCVkbIjXnrT5C0L8r5nrZKy2boN1j5L5NBokLQ/SfWSz/Piul7C4c 6hFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QhKDpHui; 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=fail (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 v29si1890341qtj.132.2019.06.13.06.31.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:31:05 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=QhKDpHui; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPon-00068C-Fw for patch@linaro.org; Thu, 13 Jun 2019 09:31:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59700) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdr-0008R3-US for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdX-0004h1-0K for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:36 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:43694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdW-0004RF-C5 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:22 -0400 Received: by mail-wr1-x444.google.com with SMTP id p13so10427515wru.10 for ; Thu, 13 Jun 2019 05:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=B3aO9h78VYlbl+c2Ti7U2GX0dd1QukUCluotJULAcHg=; b=QhKDpHuiuCQxLaU11rlIhA70R5hqLzqbrMYxH3Q07T5OYvHoEXIiJLj2eFx5iHfKSY HpmCkQcOYx/oWCvAxk4jsWO547YFcGA4AxUgPSp8L4/ks1yJwIeKOkdcOKOtszlb8Are CxpQ+GCe54D6vpHkzrXK4NXkFUZrzDTHoUMG946nnpja6vA6gq8GuowF57Fer4EPTOVJ +Ty7LK1Gd5rGMShQ0zzy4r+JR0fWDgbwEoiZoJDRO9jTrw+4gfU1jJdCvHCworWzyjP4 +OhhQLgymZK1aNmpVZoceYUM3W9wIXfn5zxJPpOuaiEMiFNPJpU4O8e5jOpluxEZdIpt BdrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B3aO9h78VYlbl+c2Ti7U2GX0dd1QukUCluotJULAcHg=; b=Q/5pl1k27j6xHZP8/HxXd8JnTZNoiQKLzGC6gvhbjJVOVLmoCtfAJPn94CAOPRwMnE voqDIF3XTLyzytIU3GEZnRc6sIlf7rsuDxquWp6+NdCc2dSHo9OcrX7WzLHiae+yjzwS Pp32E0t4UQB+IOqZUrw7gW7NSyja2IPEwEIlzJry0nHEe+oV7xWqu3fmEXsluo5k+E0F dvvrwpoC86M7x1Re8o50r4Jrncw4GkN8yUbFx0gGd7lK4SOGpuRkyoGHUGnKaRNuWxQd Rc3QzWU8R5TC/qMu/ywsTiQ9FMXqefVo0mg9vMdLTLWcPTJ4sKDddwkb1u1PH0hrwgdr nIcA== X-Gm-Message-State: APjAAAWYC80qbfjW5yLbzo4D8+SRFYvSazuE01vV0/3zMhg6eHKeEvRZ KW09n1VY5Jn7zF3cbzGuYnfmI4zX0p8ctQ== X-Received: by 2002:a5d:4bc5:: with SMTP id l5mr1730421wrt.214.1560428113123; Thu, 13 Jun 2019 05:15:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:20 +0100 Message-Id: <20190613121433.5246-36-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 35/48] target/arm: Convert VABS to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP VABS instruction to decodetree. Unlike the 3-op versions, we don't pass fpst to the VFPGen2OpSPFn or VFPGen2OpDPFn because none of the operations which use this format and support short vectors will need it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 167 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 12 ++- target/arm/vfp.decode | 5 + 3 files changed, 180 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index a2eeb6cb511..d0282f1f921 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1111,6 +1111,14 @@ typedef void VFPGen3OpSPFn(TCGv_i32 vd, typedef void VFPGen3OpDPFn(TCGv_i64 vd, TCGv_i64 vn, TCGv_i64 vm, TCGv_ptr fpst); +/* + * Types for callbacks for do_vfp_2op_sp() and do_vfp_2op_dp(). + * The callback should emit code to write a value to vd (which + * should be written to only). + */ +typedef void VFPGen2OpSPFn(TCGv_i32 vd, TCGv_i32 vm); +typedef void VFPGen2OpDPFn(TCGv_i64 vd, TCGv_i64 vm); + /* * Perform a 3-operand VFP data processing instruction. fn is the * callback to do the actual operation; this function deals with the @@ -1274,6 +1282,155 @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, return true; } +static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) +{ + uint32_t delta_m = 0; + uint32_t delta_d = 0; + uint32_t bank_mask = 0; + int veclen = s->vec_len; + TCGv_i32 f0, fd; + + if (!dc_isar_feature(aa32_fpshvec, s) && + (veclen != 0 || s->vec_stride != 0)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + if (veclen > 0) { + bank_mask = 0x18; + + /* Figure out what type of vector operation this is. */ + if ((vd & bank_mask) == 0) { + /* scalar */ + veclen = 0; + } else { + delta_d = s->vec_stride + 1; + + if ((vm & bank_mask) == 0) { + /* mixed scalar/vector */ + delta_m = 0; + } else { + /* vector */ + delta_m = delta_d; + } + } + } + + f0 = tcg_temp_new_i32(); + fd = tcg_temp_new_i32(); + + neon_load_reg32(f0, vm); + + for (;;) { + fn(fd, f0); + neon_store_reg32(fd, vd); + + if (veclen == 0) { + break; + } + + if (delta_m == 0) { + /* single source one-many */ + while (veclen--) { + vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + neon_store_reg32(fd, vd); + } + break; + } + + /* Set up the operands for the next iteration */ + veclen--; + vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + vm = ((vm + delta_m) & (bank_mask - 1)) | (vm & bank_mask); + neon_load_reg32(f0, vm); + } + + tcg_temp_free_i32(f0); + tcg_temp_free_i32(fd); + + return true; +} + +static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) +{ + uint32_t delta_m = 0; + uint32_t delta_d = 0; + uint32_t bank_mask = 0; + int veclen = s->vec_len; + TCGv_i64 f0, fd; + + /* UNDEF accesses to D16-D31 if they don't exist */ + if (!dc_isar_feature(aa32_fp_d32, s) && ((vd | vm) & 0x10)) { + return false; + } + + if (!dc_isar_feature(aa32_fpshvec, s) && + (veclen != 0 || s->vec_stride != 0)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + if (veclen > 0) { + bank_mask = 0xc; + + /* Figure out what type of vector operation this is. */ + if ((vd & bank_mask) == 0) { + /* scalar */ + veclen = 0; + } else { + delta_d = (s->vec_stride >> 1) + 1; + + if ((vm & bank_mask) == 0) { + /* mixed scalar/vector */ + delta_m = 0; + } else { + /* vector */ + delta_m = delta_d; + } + } + } + + f0 = tcg_temp_new_i64(); + fd = tcg_temp_new_i64(); + + neon_load_reg64(f0, vm); + + for (;;) { + fn(fd, f0); + neon_store_reg64(fd, vd); + + if (veclen == 0) { + break; + } + + if (delta_m == 0) { + /* single source one-many */ + while (veclen--) { + vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + neon_store_reg64(fd, vd); + } + break; + } + + /* Set up the operands for the next iteration */ + veclen--; + vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + vm = ((vm + delta_m) & (bank_mask - 1)) | (vm & bank_mask); + neon_load_reg64(f0, vm); + } + + tcg_temp_free_i64(f0); + tcg_temp_free_i64(fd); + + return true; +} + static void gen_VMLA_sp(TCGv_i32 vd, TCGv_i32 vn, TCGv_i32 vm, TCGv_ptr fpst) { /* Note that order of inputs to the add matters for NaNs */ @@ -1731,3 +1888,13 @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) tcg_temp_free_i64(fd); return true; } + +static bool trans_VABS_sp(DisasContext *s, arg_VABS_sp *a) +{ + return do_vfp_2op_sp(s, gen_helper_vfp_abss, a->vd, a->vm); +} + +static bool trans_VABS_dp(DisasContext *s, arg_VABS_dp *a) +{ + return do_vfp_2op_dp(s, gen_helper_vfp_absd, a->vd, a->vm); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 30d96fbf5a6..010dc32c5f7 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3096,6 +3096,14 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) case 0 ... 14: /* Already handled by decodetree */ return 1; + case 15: + switch (rn) { + case 1: + /* Already handled by decodetree */ + return 1; + default: + break; + } default: break; } @@ -3104,7 +3112,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { case 0x00: /* vmov */ - case 0x01: /* vabs */ case 0x02: /* vneg */ case 0x03: /* vsqrt */ break; @@ -3284,9 +3291,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) case 0: /* cpy */ /* no-op */ break; - case 1: /* abs */ - gen_vfp_abs(dp); - break; case 2: /* neg */ gen_vfp_neg(dp); break; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 1818d4f71e1..7035861c270 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -156,3 +156,8 @@ VMOV_imm_sp ---- 1110 1.11 imm4h:4 .... 1010 0000 imm4l:4 \ vd=%vd_sp VMOV_imm_dp ---- 1110 1.11 imm4h:4 .... 1011 0000 imm4l:4 \ vd=%vd_dp + +VABS_sp ---- 1110 1.11 0000 .... 1010 11.0 .... \ + vd=%vd_sp vm=%vm_sp +VABS_dp ---- 1110 1.11 0000 .... 1011 11.0 .... \ + vd=%vd_dp vm=%vm_dp From patchwork Thu Jun 13 12:14:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166638 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp725642ilk; Thu, 13 Jun 2019 05:58:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+GDJ8cDEvs8c5pcO+30koVDEctx2qkzWDVOxKttD5GLN5Hph3nNvRvqVUF81gbWhaKvkZ X-Received: by 2002:a37:a7d2:: with SMTP id q201mr68873599qke.150.1560430684698; Thu, 13 Jun 2019 05:58:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430684; cv=none; d=google.com; s=arc-20160816; b=QvPHzXHardrYHBMKoqIFaTn+dtzRip8RPKIu7dYZmPjep53P1U6X5+M/0UIYqGhezJ vWln5OcETkpaYlgPXWpxWJgyNPtSz23MchUffrvwXrcbb1PmdumsyO/SgZ242/RqdNuB N8/wsOem8bs24lp6R55sJXgu3EtFnrtcRyWKn95rJvRXUOz3iP8N/GhWt1Fih6LFvghR i9lTuxw5664sPs8Zw3XGTpUaleEOww7t3uAa1d0zDAWQkxppw+i/Xv5OZREIRcKZYgLF mNjIMGFiUXa7J4suGm27khbmNOezIJtWNeYZYc5MMR0+A1rXYtIBLSYl36g3luY9fZb9 T+vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=AWW9PYoqGFrrUdmPkFR1zqFQl9klTG/mXKnSCy19Aj8=; b=ozEpF1A6vP3N8t0tzQnK6oI4OPA8T/VcWNe5mihTjxRhSZ3hZ8IhbBE9HGV4lKB3wv t3Pek2ASVtIE6ikcv7O73xnBt3707GpmImUdqa41pRVJBLj9vOcU8GoN5jXJH6AmI8Gx P5UO5MMNq1ll9/v/eGmsv7PdH8p7sTPaWr0n4yzE6+FXXSdCs5e7A88XB/c4Cjsu7OI9 1HpXWXy8Pn6lLf6OTIxeqIoEr4mgxAHxr2XNEJpOqV7xbNpLTygJxI6JWECv0vMEkfkb PF4xXfs6p9ME5GvUfmkHszSO8fDLcqG291EifRH6jKGwaMvMcAJEniY3qi6y423e6Ppn p/Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UK8vLKLs; 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=fail (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 d20si1523253qkj.100.2019.06.13.05.58.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:58:04 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=UK8vLKLs; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPIq-0005U3-A7 for patch@linaro.org; Thu, 13 Jun 2019 08:58:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59359) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdZ-0008GV-QG for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdU-0004aA-LM for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:25 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:34218) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdU-0004Ro-36 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:20 -0400 Received: by mail-wm1-x342.google.com with SMTP id w9so6496388wmd.1 for ; Thu, 13 Jun 2019 05:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AWW9PYoqGFrrUdmPkFR1zqFQl9klTG/mXKnSCy19Aj8=; b=UK8vLKLsSwwci+QKStlpX9wExGCcwQIOoeokNN/QRdTJps0GL31OzlP/7oQuIm7Kd8 Vg+oArs6FH2M2T8cYvo97IB49tvUSU2Gfgz/pQ5AEPQI3fW8nTYIJ6MmueZ1kMxEif8d Jnac6IhI+Lmt1Q2M8YQoblgliBYbOLobqX5oC+P1wTK8mNrdZcmO1b4PTQjzjceRrxP4 /1YFeyxYefUZwkkMZqVsLZAdcGzjIRktzytfB//vpsqUcZkvfa8hH2iLtQ3LJ8Wv7j+M w6QUkRJ35FHQqazS7IQywaO5ttZ75S8yvYO7YX7YvVoa70tLqAh0gmGp+CofNgQIxp/x RbSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AWW9PYoqGFrrUdmPkFR1zqFQl9klTG/mXKnSCy19Aj8=; b=p+dw4So71VS1b4iQRzGskFcCvV6Aa1is3/oCEsNRqT+W2bN2yobolbTWi8fkqqoDEw 1meWZzEWH9nrIYXc2WVIswvd5YzSZ9nzep9CuT4i/IwO03Uz9qAshIZWkNbVY63FKVU/ /e3gj+oJBoqSUtgs2JeyGu4ZXHRR2nVoY/flOUDRutMvokunsqmG2kZhtNxtZnB49E7z st+0jJW1JIGD+K/bkgl8ZDCz/xgEHIJenPUjuIQrpRMYWQBOR46cyP1SwUPdPMOJR0Ub j7y4dU9j5lrQlFYP/vhzUGEIdCpAtQO0LA6+37oaKHX1qB8LmcHNt6U06dA8Z0Fuu3/A yx/Q== X-Gm-Message-State: APjAAAXccVnK7eXmlCCCVV9r513DVf6ybeq2wxD3QfFf//Z6Zq/rGL+h sYjPNvPSUD0HrC2MJXDEZIGtfJy63FaDYw== X-Received: by 2002:a1c:cc19:: with SMTP id h25mr3438305wmb.167.1560428114057; Thu, 13 Jun 2019 05:15:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:21 +0100 Message-Id: <20190613121433.5246-37-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PULL 36/48] target/arm: Convert VNEG to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VNEG instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 10 ++++++++++ target/arm/translate.c | 6 +----- target/arm/vfp.decode | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index d0282f1f921..6e06b2a130a 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1898,3 +1898,13 @@ static bool trans_VABS_dp(DisasContext *s, arg_VABS_dp *a) { return do_vfp_2op_dp(s, gen_helper_vfp_absd, a->vd, a->vm); } + +static bool trans_VNEG_sp(DisasContext *s, arg_VNEG_sp *a) +{ + return do_vfp_2op_sp(s, gen_helper_vfp_negs, a->vd, a->vm); +} + +static bool trans_VNEG_dp(DisasContext *s, arg_VNEG_dp *a) +{ + return do_vfp_2op_dp(s, gen_helper_vfp_negd, a->vd, a->vm); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 010dc32c5f7..3baf2baec3f 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3098,7 +3098,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 1: + case 1 ... 2: /* Already handled by decodetree */ return 1; default: @@ -3112,7 +3112,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { case 0x00: /* vmov */ - case 0x02: /* vneg */ case 0x03: /* vsqrt */ break; @@ -3291,9 +3290,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) case 0: /* cpy */ /* no-op */ break; - case 2: /* neg */ - gen_vfp_neg(dp); - break; case 3: /* sqrt */ gen_vfp_sqrt(dp); break; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 7035861c270..79e41963be4 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -161,3 +161,8 @@ VABS_sp ---- 1110 1.11 0000 .... 1010 11.0 .... \ vd=%vd_sp vm=%vm_sp VABS_dp ---- 1110 1.11 0000 .... 1011 11.0 .... \ vd=%vd_dp vm=%vm_dp + +VNEG_sp ---- 1110 1.11 0001 .... 1010 01.0 .... \ + vd=%vd_sp vm=%vm_sp +VNEG_dp ---- 1110 1.11 0001 .... 1011 01.0 .... \ + vd=%vd_dp vm=%vm_dp From patchwork Thu Jun 13 12:14:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166645 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp741655ilk; Thu, 13 Jun 2019 06:10:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUrCMSjuxe+jpW6EL0eR3PiTWz1i0oQvs2KH/Q5St8jrfXk+Y/Q93+vZCGta+7cA2p8mWW X-Received: by 2002:a0c:879d:: with SMTP id 29mr3447722qvj.91.1560431403945; Thu, 13 Jun 2019 06:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560431403; cv=none; d=google.com; s=arc-20160816; b=sMIv8rxQxrSJaX0+bVBZm2i4PZ5yOefQrUmucpsEH08Lap2XB/uy8qWCU7ne+2Jaah oQRD6tG/nmAI5lr/phKhCpNPOsJTqJ6gENNu2HTU/EIs5FSuCKx9XZSSez3NnU3Sb+6s Gw5nf4mnpq8IHC0nISZ4Je+qCuVaTJ7ZPWQ/r3nfX0IEL26t4fHWEBgq9fMhBbrA9DMO 2EHDKfvhq5t0FVYMJ7k7MXPNlxmFSkYL/XIPt75KqTEbdBDm5RjGn+TtqZB3nzv/K6KB msrqUaVUEQakLDHxXX1nJ64y+ikToEUJhVvTdx6qPmed5Bjl0ZusR22iEKVFrSzLZGMJ 5u7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=sy3O4KyBuYWQ/J2PNF/xf+lfkK6caYhPQsGZjkxlcxg=; b=OwupArEitpHoCciMIf48vtd5EPtKFSrfYZgGAxqe2sc4ZGNWgaSVi+FK6yt4ztZ0E0 jpflBoMrGtjlPq8LzuaRTJJyRhkDM0tkIAh00ImsYKl5Gtr5jd8p9VEKzVawRa1YzhM+ PIOJITDIfYOTcUqxNrjVVKtSBn0W0uxQh+OInttEv7oG3cOk/QZd5jiVtKXRWTI4y/FE uYSaNUR4GX6vOqak5kqxOquJ99qjgNka3wxGdBGq1Bm/40qxzypIKwSQA+vtRutcWZW0 A5ZEHnt+Tc+HMz741t/tzLS4oEk0gloPFou137vkwip2Y2zC62/LmdVc/7men7SORF8H WimA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Sn/Etjvw"; 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=fail (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 x129si1610393qka.133.2019.06.13.06.10.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:10:03 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b="Sn/Etjvw"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPUR-00061e-HP for patch@linaro.org; Thu, 13 Jun 2019 09:10:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59304) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdX-0008CM-6x for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdU-0004Y7-49 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:22 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:45625) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdT-0004Sg-Nv for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:19 -0400 Received: by mail-wr1-x441.google.com with SMTP id f9so20488615wre.12 for ; Thu, 13 Jun 2019 05:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sy3O4KyBuYWQ/J2PNF/xf+lfkK6caYhPQsGZjkxlcxg=; b=Sn/EtjvwLVlC3e35jkEjy1lqBiAN5BfKGFVUztQUeOtug2IUJQOtWqhcXGpg8MXZI9 LF0KcxeBexe0uO02uvEW9t5nfvIVDxyJ+LI9qVjwFESjyeOSoM51nbH5yMd0ldTCI+UV FFu8ddm1awzPlxpWYFttA5cEHydkiwkxa8JCWbRaWqMIR75wuCjslk5Me4Q3u9yCVk2f 8CxpnpMLjQvYdRSuUCf4alcfqlB+hfpBZsWpexIilt3SSmcHXqk65w6jvCS4DOSji5jS b4OkcqXks2bMwpN4zYPKfXXT0pp4UQ/x6lzEA+opSkpRe584KIi4dk1XUPtXZMezyJTb GMZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sy3O4KyBuYWQ/J2PNF/xf+lfkK6caYhPQsGZjkxlcxg=; b=VwuWqf4UJDRSuaUkdaMfr7svz6F4KX4sjOjCBcWSnvGXan4BJXsZtaUlXss88tV/VX scvA3V5chv06J39Yao8kztkc/9oR4f1jxBazuFF+XFULkAN8cSQsv8EGHwDoRxFly/B0 NzN6gyjc/rlW1sd5eb66fGue9UxN1C7zkVFE6rc2XfHHpd0oAjE01sNkI14+kRqO8V/l c+aXrOR2uSPmIdvdwuFrIjXlzYcfaVoDKCBqiPyF2qYcSjWniC6XmWsmcI3w7HU6nGuG 5JqiGsvy1D3lUKxbNbhJ/NYBKVZDFtVE0Npyl2+uj73p3A+mLXeadbjhEjkYJT1yhgkO R16Q== X-Gm-Message-State: APjAAAVWGU2ZsLgZwCfqnSK8lAwyw6+C4ya2eVSDKkTupUf6u76zAPDr DaIImyxKsjqt8w0Aq/bNUgKREJIuy/xDKw== X-Received: by 2002:adf:b64e:: with SMTP id i14mr6406348wre.248.1560428115061; Thu, 13 Jun 2019 05:15:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:22 +0100 Message-Id: <20190613121433.5246-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 37/48] target/arm: Convert VSQRT to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VSQRT instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 20 ++++++++++++++++++++ target/arm/translate.c | 14 +------------- target/arm/vfp.decode | 5 +++++ 3 files changed, 26 insertions(+), 13 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 6e06b2a130a..ae2f77a873b 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1908,3 +1908,23 @@ static bool trans_VNEG_dp(DisasContext *s, arg_VNEG_dp *a) { return do_vfp_2op_dp(s, gen_helper_vfp_negd, a->vd, a->vm); } + +static void gen_VSQRT_sp(TCGv_i32 vd, TCGv_i32 vm) +{ + gen_helper_vfp_sqrts(vd, vm, cpu_env); +} + +static bool trans_VSQRT_sp(DisasContext *s, arg_VSQRT_sp *a) +{ + return do_vfp_2op_sp(s, gen_VSQRT_sp, a->vd, a->vm); +} + +static void gen_VSQRT_dp(TCGv_i64 vd, TCGv_i64 vm) +{ + gen_helper_vfp_sqrtd(vd, vm, cpu_env); +} + +static bool trans_VSQRT_dp(DisasContext *s, arg_VSQRT_dp *a) +{ + return do_vfp_2op_dp(s, gen_VSQRT_dp, a->vd, a->vm); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 3baf2baec3f..b0fd4051f1f 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1390,14 +1390,6 @@ static inline void gen_vfp_neg(int dp) gen_helper_vfp_negs(cpu_F0s, cpu_F0s); } -static inline void gen_vfp_sqrt(int dp) -{ - if (dp) - gen_helper_vfp_sqrtd(cpu_F0d, cpu_F0d, cpu_env); - else - gen_helper_vfp_sqrts(cpu_F0s, cpu_F0s, cpu_env); -} - static inline void gen_vfp_cmp(int dp) { if (dp) @@ -3098,7 +3090,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 1 ... 2: + case 1 ... 3: /* Already handled by decodetree */ return 1; default: @@ -3112,7 +3104,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { case 0x00: /* vmov */ - case 0x03: /* vsqrt */ break; case 0x04: /* vcvtb.f64.f16, vcvtb.f32.f16 */ @@ -3290,9 +3281,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) case 0: /* cpy */ /* no-op */ break; - case 3: /* sqrt */ - gen_vfp_sqrt(dp); - break; case 4: /* vcvtb.f32.f16, vcvtb.f64.f16 */ { TCGv_ptr fpst = get_fpstatus_ptr(false); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 79e41963be4..2780e1ed9ea 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -166,3 +166,8 @@ VNEG_sp ---- 1110 1.11 0001 .... 1010 01.0 .... \ vd=%vd_sp vm=%vm_sp VNEG_dp ---- 1110 1.11 0001 .... 1011 01.0 .... \ vd=%vd_dp vm=%vm_dp + +VSQRT_sp ---- 1110 1.11 0001 .... 1010 11.0 .... \ + vd=%vd_sp vm=%vm_sp +VSQRT_dp ---- 1110 1.11 0001 .... 1011 11.0 .... \ + vd=%vd_dp vm=%vm_dp From patchwork Thu Jun 13 12:14:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166649 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp753215ilk; Thu, 13 Jun 2019 06:18:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7bzATiaog+babAVqbcNFevuC3adkMM1XgedaTwzVopeyc2MtO4yJvSmhf30X3IaR2x1cM X-Received: by 2002:ac8:4a10:: with SMTP id x16mr1772865qtq.282.1560431914923; Thu, 13 Jun 2019 06:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560431914; cv=none; d=google.com; s=arc-20160816; b=Gv1azFD+QngrTCXbW10alsaBMQW+95WRyC7SEnwXGsGm6EJsYNDObGiqFl9Gd1MC3m hHuOAvF5FMyyEy2IYns0qKYB1jhLM3XXVX61SjHI2GOr/u9PBWv32yw2JsEYzlQUKmNA 1ma4cqKAQiIllbO98e5KZGikLVM4QDtHTCQQ/+f+oMW2R2HkM4KBxAaiQ1KiuK1cLQQF oNLePaZ/e0fJGogb9QkRGW4lex2SLOsdUCI7k2ntAyYpaFSkMOTDsJ+3BA1wOdFogoK6 V1Sb64NEN+a/Tn5p0O63vuqxx2KX/u6tcZnvNbrHCjHIghrXAJi8Y/Peh5MlNtqwG7Ld NN7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=RdrTqHHHmaF6iJZ3JzcpCUEEhs68e3HO51ReGF+FJxk=; b=ZIAGa+Spgf1IYll9ZhQW+NSqD+7dGbdLXMYchQAwJ1/W0nDH+otfsD0kkzXO+hJjBW X/LBr3XYmNxymuRHvcNlrhBV8SS0nzUPvtvmsnPtD9K+RRQyD6RXu2K8q843/0R72rBk b+KpQMDLfiZw9bHoWUNhXFBRm6ZmrYLl0goEPN517xbiaoYiRjBzIN4RvMbVNO0g/WZX qb5ErnM5V1+YX/eZCiu+t5sJ5SYjXV+9OA2w932q689PJTv2NMIiXiL7uWqDm0vFGYUt b9UsWvlA0ZknXOplmSE061Rc1oz8/MYKn1KyjbJmZ7MjxDWbXJ0qh7v0xVnmZmGMRV7W aa5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FrF6EXLB; 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=fail (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 q19si1883235qtj.324.2019.06.13.06.18.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:18:34 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=FrF6EXLB; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPcg-0002YA-Ep for patch@linaro.org; Thu, 13 Jun 2019 09:18:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59371) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOda-0008HD-0f for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdU-0004aI-Kc for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:25 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:35887) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdU-0004Ta-5q for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:20 -0400 Received: by mail-wm1-x32c.google.com with SMTP id u8so9889522wmm.1 for ; Thu, 13 Jun 2019 05:15:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RdrTqHHHmaF6iJZ3JzcpCUEEhs68e3HO51ReGF+FJxk=; b=FrF6EXLBlhmi/P/C603R3jpIcAxrN0lBj9lMba00Au+xRY8Ju/9A9PV2aamyblfIMK 8AG4Z34icAHqpHFeh+AvtmMWoTb8N4P14bbmfemeaTP2PXRgtI1ACWVQaZFyMA8TATCP GaQO2ZUG79U4gEhwjJHDWBtVmt0HIS3FQnIHvPwHlb9/KT6ahQG7VKQH8bO4QFRBJHDF ZrkDkuR7GdDeFGvmUIpAIYdXWM0qU7eTxvA2pMGJ6Ql8JlbCC8jTWb7Ke3gAVcyQ+AKt MELQ5uecAZ1LWWpOYJb2Ix0FRuFxS0kZAgs+fZSgkSiJnHH+CplIK9Ofq4aT9UGVAKJT ZP/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RdrTqHHHmaF6iJZ3JzcpCUEEhs68e3HO51ReGF+FJxk=; b=fNvxnB8CtGcdA9Xj9OI1bYhWLrGEUqRPpnFthxsDG34C6kUrmylb019c6hIROQWWfe 1JscZtKsIktTXAD1T4fzidAbXcE7cKXhFUlMi8mnmV1lAahHOqht53Iv87+ZXwcH7Plq DsBZP77tOOvILbEGmkJoGKkJLsdTvYZj/KxuBAUypXMIL7RBC4GFqnZt2lmpRuJmt2zW K4nx/57PZr930Wa9fkAnVKgmCFL5LVkFQlF2m13EgWY1t16OdnO+rOy5rB259uRbjJGh 4Sy7nG5U+pT16uVbjj7eAH/LcKAt2TK9ZC3qAMPuchz6AKG7e/lZLiXSRIDfthRy22Mp 5tww== X-Gm-Message-State: APjAAAXKCkdJ7AR9/rNiF02iE7Gu8a6ym4yGvgXeH/Tm+YgH+aa3hTtp 8r/Rzxrb6cEvsbbc+I66zSpSEeD1sI3dbA== X-Received: by 2002:a1c:452:: with SMTP id 79mr3640062wme.149.1560428116130; Thu, 13 Jun 2019 05:15:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:23 +0100 Message-Id: <20190613121433.5246-39-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32c Subject: [Qemu-devel] [PULL 38/48] target/arm: Convert VMOV (register) to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 10 ++++++++++ target/arm/translate.c | 8 +------- target/arm/vfp.decode | 5 +++++ 3 files changed, 16 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index ae2f77a873b..a7e4ae31985 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1889,6 +1889,16 @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) return true; } +static bool trans_VMOV_reg_sp(DisasContext *s, arg_VMOV_reg_sp *a) +{ + return do_vfp_2op_sp(s, tcg_gen_mov_i32, a->vd, a->vm); +} + +static bool trans_VMOV_reg_dp(DisasContext *s, arg_VMOV_reg_dp *a) +{ + return do_vfp_2op_dp(s, tcg_gen_mov_i64, a->vd, a->vm); +} + static bool trans_VABS_sp(DisasContext *s, arg_VABS_sp *a) { return do_vfp_2op_sp(s, gen_helper_vfp_abss, a->vd, a->vm); diff --git a/target/arm/translate.c b/target/arm/translate.c index b0fd4051f1f..b26242d3498 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3090,7 +3090,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 1 ... 3: + case 0 ... 3: /* Already handled by decodetree */ return 1; default: @@ -3103,9 +3103,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) if (op == 15) { /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { - case 0x00: /* vmov */ - break; - case 0x04: /* vcvtb.f64.f16, vcvtb.f32.f16 */ case 0x05: /* vcvtt.f64.f16, vcvtt.f32.f16 */ /* @@ -3278,9 +3275,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 0: /* cpy */ - /* no-op */ - break; case 4: /* vcvtb.f32.f16, vcvtb.f64.f16 */ { TCGv_ptr fpst = get_fpstatus_ptr(false); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 2780e1ed9ea..b72ab8b8067 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -157,6 +157,11 @@ VMOV_imm_sp ---- 1110 1.11 imm4h:4 .... 1010 0000 imm4l:4 \ VMOV_imm_dp ---- 1110 1.11 imm4h:4 .... 1011 0000 imm4l:4 \ vd=%vd_dp +VMOV_reg_sp ---- 1110 1.11 0000 .... 1010 01.0 .... \ + vd=%vd_sp vm=%vm_sp +VMOV_reg_dp ---- 1110 1.11 0000 .... 1011 01.0 .... \ + vd=%vd_dp vm=%vm_dp + VABS_sp ---- 1110 1.11 0000 .... 1010 11.0 .... \ vd=%vd_sp vm=%vm_sp VABS_dp ---- 1110 1.11 0000 .... 1011 11.0 .... \ From patchwork Thu Jun 13 12:14:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166646 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp746086ilk; Thu, 13 Jun 2019 06:13:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcWK/5HL9GORC3t+hlMINKbvQA0AZto4yJEK9cgR+pt38OPEmrGRwjpEzjd36uRLLxYAOs X-Received: by 2002:a05:620a:141a:: with SMTP id d26mr70428254qkj.32.1560431600765; Thu, 13 Jun 2019 06:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560431600; cv=none; d=google.com; s=arc-20160816; b=SYTbJVKFX1Wzw1jO01Kmihx01p4oDaU6SZgrX0vaR9Dk/BthtUpChBT4I8ymdT6RuE eyZQPxC/c9XbVDEKJdWO5RXQ+odXSXqIBsrfsOVLe47uEoUi5XXlXFWLC4czbX0tnOLn /gFCqLQLFcZorEr7KP23O7F2W/iMMR6ZM57B3tYnre2imNgXJsn70G0MdESwCBm1Q9Vx 7tEW4HqrER9YIZrFM9yUaBc0Zqm8N8xez+3UYn3QlJ65piWthJFLFnY6NL0GUgllUFDx +XD2jhwN65IGdZXsU4DSWCfMQ7SNKmUeI633YDrWU/wN7IogwO04xaOfU4vGd5GzrRev qDFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=fpGsIWOoUsjHLITABC3kThd/MgC+CdV/FGLa2lIHkA8=; b=FgOiUadAGpF/+O7ylfLxuCS1R7+Lal/UjIBPmaCUCZo8yYSuawW3Kuiy8an1OX5qS4 XoDA5ryFYbz2Oy2Y8Qv8Y97GzJs0jaZWpedhYCufKrZlGy9ucLMhFo03rCfB1WuLhksp XWZKr/V/JVTDnRo5GfIgrfPV/Aoouw9H0uk45yljsomXji2aA04oRbDdYGy4JFsaZOH8 TjQTz8UXuhSk767EO+EqaIq5SDFYkbY6RfcrIX+Y4FinIfGfDCEuuykfuDM6QM6VmZuu K0yWKs32Ad7FOHytUQYj1XVF4aCjA446McTfs5vYN9trAIpF78DRlbKRUfp4bXBewWKY kAnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qsdLSz0u; 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=fail (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 k127si1765761qkf.93.2019.06.13.06.13.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:13:20 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=qsdLSz0u; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPXc-0007eF-CV for patch@linaro.org; Thu, 13 Jun 2019 09:13:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59691) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdr-0008Qz-Rt for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdW-0004gn-UE for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:36 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:52242) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdW-0004VA-9M for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:22 -0400 Received: by mail-wm1-x342.google.com with SMTP id s3so9967539wms.2 for ; Thu, 13 Jun 2019 05:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fpGsIWOoUsjHLITABC3kThd/MgC+CdV/FGLa2lIHkA8=; b=qsdLSz0u4mT+V1h1NAwSNTlKVSsQF1OGTRacJpxq8jLD9NECCB/FeBziIRMcxVCNqD 5eniX2Ga0NkIbH8uCJGVq7fXK5iiEvD6bq5f32hQ8WimiIayDBfuYeGGP6PKzUIqKaw2 iQsAkv6nCl0Bxmkoe8CrlGRuQVZgRza5O5baKDhE7HEQt0O0cYbkopXEzZUIRDBPJtEz LnXma1BNu/WcziIHv2AYCWFk9BGOURVfj29EbHLiN2WpeO0wjKwAMok4hbgAw7gukTBB vkyPZ+cJzUqmCZP8YwL4VAOFZOTz38Daamavd96xDBdVQgq2Ff/TqDxl6D4DLKXG+fGH qFbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fpGsIWOoUsjHLITABC3kThd/MgC+CdV/FGLa2lIHkA8=; b=WaM7Hwqqw05znW3MsGRbMJPQvNncFZveLTYBsZgeFth2Iob4z1Z7z7IeY9mjYonbqc /NtrYsrlNDryQtjWUtSOkc9eILeNXVhqpWv+Ru1yBBEE91TQ9sqA5PkJ8t8sfv4Tvmwx oianitBsOytPB1MVpPQkd7DCcRkOnpgAK0TksQbpKkPCI5AQZFjjFmxX1AfSP3YUyEnF jLieIveC3nE9fBUg5rehWDPiSzrUnDO78MOBlwsugVPYpEKC1wR34VC+/36P8i5mb17e Wh1vY579UtoNbs3K6vQAOYw+vAHpACOEqfISS1Za2FhUwTe9onMcpuu8AzcYD1GcttgW hOVw== X-Gm-Message-State: APjAAAUJkjWoiedUlbtVH83VBEcTNEDZ07yIxN27imwfNwGhemj7TQhJ Qz5OpuOEObV3wWLoBmTDVkdW745sTT/lhw== X-Received: by 2002:a1c:3:: with SMTP id 3mr3729120wma.44.1560428117341; Thu, 13 Jun 2019 05:15:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:16 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:24 +0100 Message-Id: <20190613121433.5246-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PULL 39/48] target/arm: Convert VFP comparison insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP comparison instructions to decodetree. Note that comparison instructions should not honour the VFP short-vector length and stride information: they are scalar-only operations. This applies to all the 2-operand instructions except for VMOV, VABS, VNEG and VSQRT. (In the old decoder this is implemented via the "if (op == 15 && rn > 3) { veclen = 0; }" check.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 75 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 51 +---------------------- target/arm/vfp.decode | 5 +++ 3 files changed, 81 insertions(+), 50 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index a7e4ae31985..ebde86210a6 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1938,3 +1938,78 @@ static bool trans_VSQRT_dp(DisasContext *s, arg_VSQRT_dp *a) { return do_vfp_2op_dp(s, gen_VSQRT_dp, a->vd, a->vm); } + +static bool trans_VCMP_sp(DisasContext *s, arg_VCMP_sp *a) +{ + TCGv_i32 vd, vm; + + /* Vm/M bits must be zero for the Z variant */ + if (a->z && a->vm != 0) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vd = tcg_temp_new_i32(); + vm = tcg_temp_new_i32(); + + neon_load_reg32(vd, a->vd); + if (a->z) { + tcg_gen_movi_i32(vm, 0); + } else { + neon_load_reg32(vm, a->vm); + } + + if (a->e) { + gen_helper_vfp_cmpes(vd, vm, cpu_env); + } else { + gen_helper_vfp_cmps(vd, vm, cpu_env); + } + + tcg_temp_free_i32(vd); + tcg_temp_free_i32(vm); + + return true; +} + +static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a) +{ + TCGv_i64 vd, vm; + + /* Vm/M bits must be zero for the Z variant */ + if (a->z && a->vm != 0) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vm) & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vd = tcg_temp_new_i64(); + vm = tcg_temp_new_i64(); + + neon_load_reg64(vd, a->vd); + if (a->z) { + tcg_gen_movi_i64(vm, 0); + } else { + neon_load_reg64(vm, a->vm); + } + + if (a->e) { + gen_helper_vfp_cmped(vd, vm, cpu_env); + } else { + gen_helper_vfp_cmpd(vd, vm, cpu_env); + } + + tcg_temp_free_i64(vd); + tcg_temp_free_i64(vm); + + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index b26242d3498..af1d01c49b7 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1390,30 +1390,6 @@ static inline void gen_vfp_neg(int dp) gen_helper_vfp_negs(cpu_F0s, cpu_F0s); } -static inline void gen_vfp_cmp(int dp) -{ - if (dp) - gen_helper_vfp_cmpd(cpu_F0d, cpu_F1d, cpu_env); - else - gen_helper_vfp_cmps(cpu_F0s, cpu_F1s, cpu_env); -} - -static inline void gen_vfp_cmpe(int dp) -{ - if (dp) - gen_helper_vfp_cmped(cpu_F0d, cpu_F1d, cpu_env); - else - gen_helper_vfp_cmpes(cpu_F0s, cpu_F1s, cpu_env); -} - -static inline void gen_vfp_F1_ld0(int dp) -{ - if (dp) - tcg_gen_movi_i64(cpu_F1d, 0); - else - tcg_gen_movi_i32(cpu_F1s, 0); -} - #define VFP_GEN_ITOF(name) \ static inline void gen_vfp_##name(int dp, int neon) \ { \ @@ -3091,6 +3067,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) case 15: switch (rn) { case 0 ... 3: + case 8 ... 11: /* Already handled by decodetree */ return 1; default: @@ -3135,11 +3112,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rd_is_dp = false; break; - case 0x08: case 0x0a: /* vcmp, vcmpz */ - case 0x09: case 0x0b: /* vcmpe, vcmpez */ - no_output = true; - break; - case 0x0c: /* vrintr */ case 0x0d: /* vrintz */ case 0x0e: /* vrintx */ @@ -3240,14 +3212,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) /* Load the initial operands. */ if (op == 15) { switch (rn) { - case 0x08: case 0x09: /* Compare */ - gen_mov_F0_vreg(dp, rd); - gen_mov_F1_vreg(dp, rm); - break; - case 0x0a: case 0x0b: /* Compare with zero */ - gen_mov_F0_vreg(dp, rd); - gen_vfp_F1_ld0(dp); - break; case 0x14: /* vcvt fp <-> fixed */ case 0x15: case 0x16: @@ -3357,19 +3321,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) gen_vfp_msr(tmp); break; } - case 8: /* cmp */ - gen_vfp_cmp(dp); - break; - case 9: /* cmpe */ - gen_vfp_cmpe(dp); - break; - case 10: /* cmpz */ - gen_vfp_cmp(dp); - break; - case 11: /* cmpez */ - gen_vfp_F1_ld0(dp); - gen_vfp_cmpe(dp); - break; case 12: /* vrintr */ { TCGv_ptr fpst = get_fpstatus_ptr(0); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index b72ab8b8067..9db7aa7021a 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -176,3 +176,8 @@ VSQRT_sp ---- 1110 1.11 0001 .... 1010 11.0 .... \ vd=%vd_sp vm=%vm_sp VSQRT_dp ---- 1110 1.11 0001 .... 1011 11.0 .... \ vd=%vd_dp vm=%vm_dp + +VCMP_sp ---- 1110 1.11 010 z:1 .... 1010 e:1 1.0 .... \ + vd=%vd_sp vm=%vm_sp +VCMP_dp ---- 1110 1.11 010 z:1 .... 1011 e:1 1.0 .... \ + vd=%vd_dp vm=%vm_dp From patchwork Thu Jun 13 12:14:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166650 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp758815ilk; Thu, 13 Jun 2019 06:23:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwC9/V4/TA2JOhehZvhSyMMZ6NVFkYkfSiCWSgzjViMjZPIe4msdC++5SHJ7OxVpkV5jo91 X-Received: by 2002:a37:e506:: with SMTP id e6mr3251062qkg.229.1560432197624; Thu, 13 Jun 2019 06:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560432197; cv=none; d=google.com; s=arc-20160816; b=u6zEf+YKuirbYCx7eRWOXiksBb4EYjfDyNgYQa1nC/gPt2fpkUwcnbHHzqlHNxFuff qyy79jsSfvx0n65q79gfDW4ykKFZV1i3SK3VUO+h46y/Ns1GDziOzXjYo7Ve+Ccr7OoU n+kXnJIcn5s99rjI0VvZO1GioMXgOv+91ZRybfRNWr79DfkTtAP9TbpmA3fM+DxPh1mv M51Mgk3WuuqwsbnKZB9KH20c7c+8DO6BnRYQx30oANIpLe3U/3HiM75BMmRE+qv0Gojn VJChT9t/3k1zLICB7HLQtTqwAh4HYr4BnOR0q4FuoQhEMWaDf1baf5YN+eaZWX1k4Usj gVfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ntm/Cb4AncOPeCVYJ1Vrv7fiT2IGGzLZpdC//b8Kuds=; b=SjnLLqjnNKW2Q8hjnzWYQLKxBzy1sdImeE9LfcrWRfgZgk3t4JHFjBdj7Dl4xMAO5a VWS70GGoaPUJsU90bbwHfgyDOXJyMSDfIAbI4dYtw+sD1d+/evnFieKkXL7qdyaVimDp h3dF2/n0widephEUMMPnsO57docUmqc+hJNWXZxdYq2u8g8ScNMwlNtpGsxlc/E9+hty GAqOsQkj7XGQ/Kuiv8t4pXc8Gop8p+6yYEU54iv2pahFG0Irmb5chpqUwDm5xnWUrLvs 4B14b1tn72O3AmM2aXCcwQGlkNObNvtqjO/pl3LNODXItXIlL+libiMte3baBOhiX4Aa gmZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ks1KLPCX; 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=fail (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 u45si1463761qvc.170.2019.06.13.06.23.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:23:17 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=Ks1KLPCX; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPhF-0005pP-0S for patch@linaro.org; Thu, 13 Jun 2019 09:23:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59439) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdd-0008PO-7U for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdV-0004do-MI for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:29 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:52171) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdV-0004Vg-5W for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:21 -0400 Received: by mail-wm1-x330.google.com with SMTP id 207so2082552wma.1 for ; Thu, 13 Jun 2019 05:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ntm/Cb4AncOPeCVYJ1Vrv7fiT2IGGzLZpdC//b8Kuds=; b=Ks1KLPCXk7vsjkTIQMuWoqHydm9jSDKxd1t3W3GQi1D2sHuGpgNnbjYv1dbJPMn0kc TanY1+2sDQVNOpE340765asdmZ4wi7d1PkqsYumShgbHAJOaWBzbiKFBtmnjAzobjN0c VyXPSo8dsFr8W6pL7qrsRD0SqZII5/EyGyzVA8XjCI1/nU8se1nG167eFDEemJvMR/ES BezGL+gj0jhOmMCIn8Lx6GUWyCJW6XuqT/Kc6nB+PGEPzEOrfD9m8K7SI4SUceRtDqo8 9Il1Ui0YNcpZoV+nvpl0QwzirOxz/SumKNeR0h0gNK8y/e4PfdETQIywWKqsv96A7W+4 Dl8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ntm/Cb4AncOPeCVYJ1Vrv7fiT2IGGzLZpdC//b8Kuds=; b=bKzpQQCcYZOyNukkWlnBV1QPTUDEuAYGgq5rLOoO8Eogx87bM1byFZ6RhCs3pi895n yMp9l31vKUk9sNOAou5weEFMT0iWBPzLvv6etJzZmO2LhLfXaqKwtkuXnWXHtt1Kkutl YEiNhZnO5Mi2S/7lSb/ENzbl5Vv4UYwy9afBppl69oa41ef5J3ZvyeAPQ9zvc/F7xffl cD58K5+PLaSOjFFIXVTGTtNBoGo7WsCi3rExZoLwi68WcXsfIsa3ks7YRAnJGFosML0B SI0rzg0z8MglYyaBif7OPmOP0gMOYkR9W8V57IeyAyJCUniMo/Pr4z8lhc4yxI4dkfQu T/Yg== X-Gm-Message-State: APjAAAWn27fWeWpFLmpgcuD/wUaD6DuX4hS4VAEybVuhOUveEm7zQVs8 fopW7RTyrsqNHtnN2ZO0shyYKGVCTyuOqg== X-Received: by 2002:a1c:b707:: with SMTP id h7mr3520312wmf.45.1560428118311; Thu, 13 Jun 2019 05:15:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:25 +0100 Message-Id: <20190613121433.5246-41-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 Subject: [Qemu-devel] [PULL 40/48] target/arm: Convert the VCVT-from-f16 insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VCVTT, VCVTB instructions that deal with conversion from half-precision floats to f32 or 64 to decodetree. Since we're no longer constrained to the old decoder's style using cpu_F0s and cpu_F0d we can perform a direct 16 bit load of the right half of the input single-precision register rather than loading the full 32 bits and then doing a separate shift or sign-extension. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 82 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 56 +---------------------- target/arm/vfp.decode | 6 +++ 3 files changed, 89 insertions(+), 55 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index ebde86210a6..732bf6020a9 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -30,6 +30,26 @@ #include "decode-vfp.inc.c" #include "decode-vfp-uncond.inc.c" +/* + * Return the offset of a 16-bit half of the specified VFP single-precision + * register. If top is true, returns the top 16 bits; otherwise the bottom + * 16 bits. + */ +static inline long vfp_f16_offset(unsigned reg, bool top) +{ + long offs = vfp_reg_offset(false, reg); +#ifdef HOST_WORDS_BIGENDIAN + if (!top) { + offs += 2; + } +#else + if (top) { + offs += 2; + } +#endif + return offs; +} + /* * Check that VFP access is enabled. If it is, do the necessary * M-profile lazy-FP handling and then return true. @@ -2013,3 +2033,65 @@ static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a) return true; } + +static bool trans_VCVT_f32_f16(DisasContext *s, arg_VCVT_f32_f16 *a) +{ + TCGv_ptr fpst; + TCGv_i32 ahp_mode; + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_fp16_spconv, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(false); + ahp_mode = get_ahp_flag(); + tmp = tcg_temp_new_i32(); + /* The T bit tells us if we want the low or high 16 bits of Vm */ + tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t)); + gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp_mode); + neon_store_reg32(tmp, a->vd); + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} + +static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) +{ + TCGv_ptr fpst; + TCGv_i32 ahp_mode; + TCGv_i32 tmp; + TCGv_i64 vd; + + if (!dc_isar_feature(aa32_fp16_dpconv, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(false); + ahp_mode = get_ahp_flag(); + tmp = tcg_temp_new_i32(); + /* The T bit tells us if we want the low or high 16 bits of Vm */ + tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t)); + vd = tcg_temp_new_i64(); + gen_helper_vfp_fcvt_f16_to_f64(vd, tmp, fpst, ahp_mode); + neon_store_reg64(vd, a->vd); + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + tcg_temp_free_i64(vd); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index af1d01c49b7..a2cb2cdba58 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3066,7 +3066,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 0 ... 3: + case 0 ... 5: case 8 ... 11: /* Already handled by decodetree */ return 1; @@ -3080,24 +3080,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) if (op == 15) { /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { - case 0x04: /* vcvtb.f64.f16, vcvtb.f32.f16 */ - case 0x05: /* vcvtt.f64.f16, vcvtt.f32.f16 */ - /* - * VCVTB, VCVTT: only present with the halfprec extension - * UNPREDICTABLE if bit 8 is set prior to ARMv8 - * (we choose to UNDEF) - */ - if (dp) { - if (!dc_isar_feature(aa32_fp16_dpconv, s)) { - return 1; - } - } else { - if (!dc_isar_feature(aa32_fp16_spconv, s)) { - return 1; - } - } - rm_is_dp = false; - break; case 0x06: /* vcvtb.f16.f32, vcvtb.f16.f64 */ case 0x07: /* vcvtt.f16.f32, vcvtt.f16.f64 */ if (dp) { @@ -3239,42 +3221,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 4: /* vcvtb.f32.f16, vcvtb.f64.f16 */ - { - TCGv_ptr fpst = get_fpstatus_ptr(false); - TCGv_i32 ahp_mode = get_ahp_flag(); - tmp = gen_vfp_mrs(); - tcg_gen_ext16u_i32(tmp, tmp); - if (dp) { - gen_helper_vfp_fcvt_f16_to_f64(cpu_F0d, tmp, - fpst, ahp_mode); - } else { - gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, - fpst, ahp_mode); - } - tcg_temp_free_i32(ahp_mode); - tcg_temp_free_ptr(fpst); - tcg_temp_free_i32(tmp); - break; - } - case 5: /* vcvtt.f32.f16, vcvtt.f64.f16 */ - { - TCGv_ptr fpst = get_fpstatus_ptr(false); - TCGv_i32 ahp = get_ahp_flag(); - tmp = gen_vfp_mrs(); - tcg_gen_shri_i32(tmp, tmp, 16); - if (dp) { - gen_helper_vfp_fcvt_f16_to_f64(cpu_F0d, tmp, - fpst, ahp); - } else { - gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, - fpst, ahp); - } - tcg_temp_free_i32(tmp); - tcg_temp_free_i32(ahp); - tcg_temp_free_ptr(fpst); - break; - } case 6: /* vcvtb.f16.f32, vcvtb.f16.f64 */ { TCGv_ptr fpst = get_fpstatus_ptr(false); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 9db7aa7021a..53d9544f7cd 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -181,3 +181,9 @@ VCMP_sp ---- 1110 1.11 010 z:1 .... 1010 e:1 1.0 .... \ vd=%vd_sp vm=%vm_sp VCMP_dp ---- 1110 1.11 010 z:1 .... 1011 e:1 1.0 .... \ vd=%vd_dp vm=%vm_dp + +# VCVTT and VCVTB from f16: Vd format depends on size bit; Vm is always vm_sp +VCVT_f32_f16 ---- 1110 1.11 0010 .... 1010 t:1 1.0 .... \ + vd=%vd_sp vm=%vm_sp +VCVT_f64_f16 ---- 1110 1.11 0010 .... 1011 t:1 1.0 .... \ + vd=%vd_dp vm=%vm_sp From patchwork Thu Jun 13 12:14:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166640 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp726906ilk; Thu, 13 Jun 2019 05:59:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdUQKiYtNX7oNE55Cz8SnC7ntneiPS61CMgffaBoJ1JxYUIAaWXvpJlZ2MriW6H40GbnYQ X-Received: by 2002:a37:4793:: with SMTP id u141mr45486328qka.355.1560430770809; Thu, 13 Jun 2019 05:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430770; cv=none; d=google.com; s=arc-20160816; b=pPMfqnDBeKrIfS6MJnF/ZLpKoDgXqfj/VpIcLwni/M7X2eoaNRcM3uky23TYpmisWQ FUKn3pJAE9ofNhAN4h3SxsEoKJr5MLpo3k1WTHDCKV6kUixl544NK8wGJCI08F52x0YH RYC4nwWLzXmgAMxlenfOugS+Yro7Dw47dpD4Dr0NbJbQ3lZqhzsCx7tX0ZNTV7dDCDju q6FkFRPlLm/tBYnIV+j7kum2Djd9TVDmd31Bnqq8TzdLVad7CjehzBto/N0Iph393KBf Bgbc651KewbbvNisw0RWC4FMqIlKSxL9PKin4JNCinZaXB1JsKrmDHam+dpaa9Q2wdS5 Z4Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=cxBzWnFf3vKNg5qQ3a9HApwDlxGPwcmAzzGsAXBP4UY=; b=kjVbZp6tnrIRjz+LOY/AS4tDxETuGknJjrNwCKWElvRb7WdKlp6X+9S/0DAsMo8Be6 KZk122q+3P/EJtKfijy6I89/M5XRfoGnoclEULvf8gLt69+ld8ZOF1m8DGdW9kqkoxCt 7q+KMIqedyDowTwSgOV3M4s11v3AK7xpT2SM0a3tEaJ0Q4tDR0iWPMWhq6Ut8fVyhrG5 gxIPK5pM6hGDn4F1lU7C/LBg4HEOTd92I+FqjPaKnwxt1RDi0q2FNZoSD/E0u5qIkG5x 9IC+bTAiN5FIgMQLeRRBBCVmfonz7brOU1VQUcVudTl2i4Ogt/ssV7yXBkmgjywl82eO 5Eeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PbuUBUqe; 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=fail (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 x22si1436759qvd.87.2019.06.13.05.59.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:59:30 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=PbuUBUqe; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPKE-00078R-9q for patch@linaro.org; Thu, 13 Jun 2019 08:59:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59699) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdr-0008R2-UP for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdX-0004hZ-4s for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:36 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44204) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdW-0004Xp-FM for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:22 -0400 Received: by mail-wr1-x444.google.com with SMTP id r16so1385014wrl.11 for ; Thu, 13 Jun 2019 05:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cxBzWnFf3vKNg5qQ3a9HApwDlxGPwcmAzzGsAXBP4UY=; b=PbuUBUqezc+T6vHOIbxVAmL81mRLU0B9mLsCPjWH0zT6jYs5eSg2xNRSUTlsSgXXnU 2TAwVGpOH3aNeF4hYe61Hp818v25cr2huC+WhEKWgc7SVheAXCoHypCpo9sV1qDt8mEd Fpxz5mVe6hEgM7NM5CiRpDCDPiCKdS/0PWhbZjhYzq+WtEPGxP0a/KIilyGLo9goKdjv 0cXM+rCtKKbMS54s8FFw/c9AmGUAcIp5ED37w447dXW/cEzOudZpMVgGFJloG/vQdTJq KIRetGFuzVydXGz63NXxJTErrfSr9iIOsB7jxwqpOeS+kO2kfCBR6n/uEDiXSbBV7rZq 7eYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cxBzWnFf3vKNg5qQ3a9HApwDlxGPwcmAzzGsAXBP4UY=; b=U+Tj3n/XeLNwP77KBx/28NgJTLx3J16S4JRAacxkJhX6bNreYA6ydl9iTY/MPBjpb4 f9lGOL28OsD0wTlIDm6lWZLeEnAlQMK9Gzv0F+xd+sKiozh0tGZRtxdasLAr6r9XzPSV H5q1pCSV02iKJPa+QLNwDxH1onGMTfmywNRmulNQkOWvWyHz9/XZLI4yBk0zWkfiPOUd lHB4Er6vLDJJ5GAPqYNRyMGUihYZvYJzX+lLDmhZLKsc//h9i6AinpcqrKvSdTLPqPtH 2ZqJu1OGpOnmXR/Ua7PglV+iAZR07LagI42iNDqNchojPrONPsoJnK9sJGMjXZMyZ+5E voeA== X-Gm-Message-State: APjAAAUu0sKM1yd/B332tUTORsVgFWcVdrtOBG59KIyOamsS/A4ZqIEZ aOe2eMkL69L+7P9wMEbZw7f6tIlP9SRLnQ== X-Received: by 2002:adf:f5c5:: with SMTP id k5mr8612735wrp.280.1560428119249; Thu, 13 Jun 2019 05:15:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:26 +0100 Message-Id: <20190613121433.5246-42-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 41/48] target/arm: Convert the VCVT-to-f16 insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VCVTT and VCVTB instructions which convert from f32 and f64 to f16 to decodetree. Since we're no longer constrained to the old decoder's style using cpu_F0s and cpu_F0d we can perform a direct 16 bit store of the right half of the input single-precision register rather than doing a load/modify/store sequence on the full 32 bits. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 62 ++++++++++++++++++++++++++ target/arm/translate.c | 79 +--------------------------------- target/arm/vfp.decode | 6 +++ 3 files changed, 69 insertions(+), 78 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 732bf6020a9..a19ede86719 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -2095,3 +2095,65 @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) tcg_temp_free_i64(vd); return true; } + +static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a) +{ + TCGv_ptr fpst; + TCGv_i32 ahp_mode; + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_fp16_spconv, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(false); + ahp_mode = get_ahp_flag(); + tmp = tcg_temp_new_i32(); + + neon_load_reg32(tmp, a->vm); + gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp_mode); + tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} + +static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) +{ + TCGv_ptr fpst; + TCGv_i32 ahp_mode; + TCGv_i32 tmp; + TCGv_i64 vm; + + if (!dc_isar_feature(aa32_fp16_dpconv, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(false); + ahp_mode = get_ahp_flag(); + tmp = tcg_temp_new_i32(); + vm = tcg_temp_new_i64(); + + neon_load_reg64(vm, a->vm); + gen_helper_vfp_fcvt_f64_to_f16(tmp, vm, fpst, ahp_mode); + tcg_temp_free_i64(vm); + tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index a2cb2cdba58..21423b264fa 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -2963,20 +2963,6 @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn) #define VFP_SREG_M(insn) VFP_SREG(insn, 0, 5) #define VFP_DREG_M(reg, insn) VFP_DREG(reg, insn, 0, 5) -/* Move between integer and VFP cores. */ -static TCGv_i32 gen_vfp_mrs(void) -{ - TCGv_i32 tmp = tcg_temp_new_i32(); - tcg_gen_mov_i32(tmp, cpu_F0s); - return tmp; -} - -static void gen_vfp_msr(TCGv_i32 tmp) -{ - tcg_gen_mov_i32(cpu_F0s, tmp); - tcg_temp_free_i32(tmp); -} - static void gen_neon_dup_low16(TCGv_i32 var) { TCGv_i32 tmp = tcg_temp_new_i32(); @@ -3003,8 +2989,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) { uint32_t rd, rn, rm, op, delta_d, delta_m, bank_mask; int dp, veclen; - TCGv_i32 tmp; - TCGv_i32 tmp2; if (!arm_dc_feature(s, ARM_FEATURE_VFP)) { return 1; @@ -3066,8 +3050,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 0 ... 5: - case 8 ... 11: + case 0 ... 11: /* Already handled by decodetree */ return 1; default: @@ -3080,20 +3063,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) if (op == 15) { /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { - case 0x06: /* vcvtb.f16.f32, vcvtb.f16.f64 */ - case 0x07: /* vcvtt.f16.f32, vcvtt.f16.f64 */ - if (dp) { - if (!dc_isar_feature(aa32_fp16_dpconv, s)) { - return 1; - } - } else { - if (!dc_isar_feature(aa32_fp16_spconv, s)) { - return 1; - } - } - rd_is_dp = false; - break; - case 0x0c: /* vrintr */ case 0x0d: /* vrintz */ case 0x0e: /* vrintx */ @@ -3221,52 +3190,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 6: /* vcvtb.f16.f32, vcvtb.f16.f64 */ - { - TCGv_ptr fpst = get_fpstatus_ptr(false); - TCGv_i32 ahp = get_ahp_flag(); - tmp = tcg_temp_new_i32(); - - if (dp) { - gen_helper_vfp_fcvt_f64_to_f16(tmp, cpu_F0d, - fpst, ahp); - } else { - gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, - fpst, ahp); - } - tcg_temp_free_i32(ahp); - tcg_temp_free_ptr(fpst); - gen_mov_F0_vreg(0, rd); - tmp2 = gen_vfp_mrs(); - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); - tcg_gen_or_i32(tmp, tmp, tmp2); - tcg_temp_free_i32(tmp2); - gen_vfp_msr(tmp); - break; - } - case 7: /* vcvtt.f16.f32, vcvtt.f16.f64 */ - { - TCGv_ptr fpst = get_fpstatus_ptr(false); - TCGv_i32 ahp = get_ahp_flag(); - tmp = tcg_temp_new_i32(); - if (dp) { - gen_helper_vfp_fcvt_f64_to_f16(tmp, cpu_F0d, - fpst, ahp); - } else { - gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, - fpst, ahp); - } - tcg_temp_free_i32(ahp); - tcg_temp_free_ptr(fpst); - tcg_gen_shli_i32(tmp, tmp, 16); - gen_mov_F0_vreg(0, rd); - tmp2 = gen_vfp_mrs(); - tcg_gen_ext16u_i32(tmp2, tmp2); - tcg_gen_or_i32(tmp, tmp, tmp2); - tcg_temp_free_i32(tmp2); - gen_vfp_msr(tmp); - break; - } case 12: /* vrintr */ { TCGv_ptr fpst = get_fpstatus_ptr(0); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 53d9544f7cd..b88d1d06f02 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -187,3 +187,9 @@ VCVT_f32_f16 ---- 1110 1.11 0010 .... 1010 t:1 1.0 .... \ vd=%vd_sp vm=%vm_sp VCVT_f64_f16 ---- 1110 1.11 0010 .... 1011 t:1 1.0 .... \ vd=%vd_dp vm=%vm_sp + +# VCVTB and VCVTT to f16: Vd format is always vd_sp; Vm format depends on size bit +VCVT_f16_f32 ---- 1110 1.11 0011 .... 1010 t:1 1.0 .... \ + vd=%vd_sp vm=%vm_sp +VCVT_f16_f64 ---- 1110 1.11 0011 .... 1011 t:1 1.0 .... \ + vd=%vd_sp vm=%vm_dp From patchwork Thu Jun 13 12:14:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166653 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp760353ilk; Thu, 13 Jun 2019 06:24:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH4HemP0ZaxmUvmtBSwHZUSBQV70njwkAoKmyG81V2PixS6EinkBV5M1E114d78r9/++fX X-Received: by 2002:aed:2667:: with SMTP id z94mr77568486qtc.2.1560432281857; Thu, 13 Jun 2019 06:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560432281; cv=none; d=google.com; s=arc-20160816; b=Nhj84pacJ1Gj+FOy934nybFIhFnK1hvL2+qXhdNrjzuV1AC93ljb7V2CSeF+2jB6DC g9Cfb+jMXSYpOzc1QDeBUgUbZKJ94x6E8zCN9f07Ri6DmMcJlEVPD+gCGTx8FwhvefA1 Mfdh+Y9XhEOMX+0PS3feerRsuQRhbwNjw3R6WDInnUhkA+QGpXfGruEe0mRK+t3114oE SYHMA1FA2DrC1ghPOhiI2+eQ2/+OvNDSFvy6bmKdDiaU1NRuOrxJzAKGEIymJjPVy9BJ OTnwPm6bHJ8Ri49rYkhO4pYf2S039JhbWCcSbKKH7GWNxHoAtO9P8Eu8W/3qC0bNJt4s KWcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=UWZ8POqtCLLS+7rTG+ATFraE2eoKU38JQdvr+gOnm4E=; b=cbszXwyCsXFQhygZ81SRlKPy3VUK1f6JfVb7lnwNoRf3Xa31x0d0dbhhgQcrvirQ/A b85mot9XDBXKMHy78Rdu311cQ9RiPuHohiJm05E7GgaXs9eklJQFfg98Yw47FjQsfJZz MHbHJN+DkdptKNsE+ayxjwLbBpN1hn7FtNsmsYblDfvnMkazBdXAaiSC1xpj8tor7c3o DTSEEbttNIaOD4E4B78YJDREA3ohnEvRk634eNjrMjHI5H+pClIQMqywAJtVjv/Lf8LR lryfEGqNxhaf4zvC+9rB+KmeW+6k+faPiJwVQnc1qZY6qAI6zayKAm5wDrvB8KF4Ktlq kolg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rwoSxga9; 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=fail (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 n32si1452435qvd.214.2019.06.13.06.24.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:24:41 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=rwoSxga9; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPib-0007Tz-Du for patch@linaro.org; Thu, 13 Jun 2019 09:24:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59724) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdt-0008TP-Qp for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdX-0004is-N2 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:40 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:50723) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdX-0004dN-1S for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:23 -0400 Received: by mail-wm1-x333.google.com with SMTP id c66so9956600wmf.0 for ; Thu, 13 Jun 2019 05:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UWZ8POqtCLLS+7rTG+ATFraE2eoKU38JQdvr+gOnm4E=; b=rwoSxga9YcTH0TJ/d3JVVO2z1lFR+N14ciXmtQyMKgwMulsEfeHn+xpXs0JruILQAs MkwWWxx5vdKbC+hJbZHrHcIYAFdxcWwbSGXeOP5dacv2nfZzr0AIZsQ0zCno5olxfXAJ 0ysTKT/+da/gZFCrlsHs033IFkzn//1AnWmVg5oP4hsi+i8OPwG/L7u91kHQHNPmBUpL h1CNmPp1rbtL38OEkG6dzrORk2SDeumhiVPAkNeHdrgix3fhRQshINuTblWTERwkazAT 0hAk7l6+UC9xrIGj/7pF1RMXe3aXFZS5lEjkjywZ6wNB555tXXnkkKboIpFz1QEJ1EOI rJJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UWZ8POqtCLLS+7rTG+ATFraE2eoKU38JQdvr+gOnm4E=; b=JhpmNsKIUqRRnxLvV7++LZV8h+AkagBcIWCJqYOIaKd/GL4U1POqM2AABbSQM+Y9KC Iv7mikGaoswLsmlQPMTBVNc77omsbIYPkLqBfFwz51msnbSq+wekvjvSVU84mS0dUfiP 9f2lOOsRK3nKc2Nx+bYV4HyZLxopCr8S1knDHN2rqwXrYo14S+A9ZRgYykvgYji6/YG8 LA34yokk/4mSAldXQaOIyfMZT6gcHSLeNOsFxxlh0y6aEhjcC/KtB71mgOheL4/HSXAP BvYJ3dacmAapwNPAQszV2Bela+ig6VMLfUsbrqbXFhHy7SmizRjmZOUi49zw2YgRyhN3 dUSQ== X-Gm-Message-State: APjAAAXQbNEGktzsrZk9wJhEgs2y5UTYlzuwKjQu0YvuMY3lG3FlJBhD NKU1NbZMam6gx3RpUI+WJw6UP/yqz8oFdA== X-Received: by 2002:a1c:2c41:: with SMTP id s62mr3589122wms.8.1560428120342; Thu, 13 Jun 2019 05:15:20 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:27 +0100 Message-Id: <20190613121433.5246-43-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [PULL 42/48] target/arm: Convert VFP round insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VFP round-to-integer instructions VRINTR, VRINTZ and VRINTX to decodetree. These instructions were only introduced as part of the "VFP misc" additions in v8A, so we check this. The old decoder's implementation was incorrectly providing them even for v7A CPUs. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 163 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 45 +-------- target/arm/vfp.decode | 15 +++ 3 files changed, 179 insertions(+), 44 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index a19ede86719..e94a8f2f0c5 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -2157,3 +2157,166 @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) tcg_temp_free_i32(tmp); return true; } + +static bool trans_VRINTR_sp(DisasContext *s, arg_VRINTR_sp *a) +{ + TCGv_ptr fpst; + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_vrint, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp = tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm); + fpst = get_fpstatus_ptr(false); + gen_helper_rints(tmp, tmp, fpst); + neon_store_reg32(tmp, a->vd); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} + +static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_sp *a) +{ + TCGv_ptr fpst; + TCGv_i64 tmp; + + if (!dc_isar_feature(aa32_vrint, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vm) & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp = tcg_temp_new_i64(); + neon_load_reg64(tmp, a->vm); + fpst = get_fpstatus_ptr(false); + gen_helper_rintd(tmp, tmp, fpst); + neon_store_reg64(tmp, a->vd); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i64(tmp); + return true; +} + +static bool trans_VRINTZ_sp(DisasContext *s, arg_VRINTZ_sp *a) +{ + TCGv_ptr fpst; + TCGv_i32 tmp; + TCGv_i32 tcg_rmode; + + if (!dc_isar_feature(aa32_vrint, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp = tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm); + fpst = get_fpstatus_ptr(false); + tcg_rmode = tcg_const_i32(float_round_to_zero); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_helper_rints(tmp, tmp, fpst); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + neon_store_reg32(tmp, a->vd); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tcg_rmode); + tcg_temp_free_i32(tmp); + return true; +} + +static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_sp *a) +{ + TCGv_ptr fpst; + TCGv_i64 tmp; + TCGv_i32 tcg_rmode; + + if (!dc_isar_feature(aa32_vrint, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vm) & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp = tcg_temp_new_i64(); + neon_load_reg64(tmp, a->vm); + fpst = get_fpstatus_ptr(false); + tcg_rmode = tcg_const_i32(float_round_to_zero); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_helper_rintd(tmp, tmp, fpst); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + neon_store_reg64(tmp, a->vd); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i64(tmp); + tcg_temp_free_i32(tcg_rmode); + return true; +} + +static bool trans_VRINTX_sp(DisasContext *s, arg_VRINTX_sp *a) +{ + TCGv_ptr fpst; + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_vrint, s)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp = tcg_temp_new_i32(); + neon_load_reg32(tmp, a->vm); + fpst = get_fpstatus_ptr(false); + gen_helper_rints_exact(tmp, tmp, fpst); + neon_store_reg32(tmp, a->vd); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tmp); + return true; +} + +static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) +{ + TCGv_ptr fpst; + TCGv_i64 tmp; + + if (!dc_isar_feature(aa32_vrint, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && ((a->vd | a->vm) & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + tmp = tcg_temp_new_i64(); + neon_load_reg64(tmp, a->vm); + fpst = get_fpstatus_ptr(false); + gen_helper_rintd_exact(tmp, tmp, fpst); + neon_store_reg64(tmp, a->vd); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i64(tmp); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 21423b264fa..0c855069d85 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3050,7 +3050,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 0 ... 11: + case 0 ... 14: /* Already handled by decodetree */ return 1; default: @@ -3063,11 +3063,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) if (op == 15) { /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { - case 0x0c: /* vrintr */ - case 0x0d: /* vrintz */ - case 0x0e: /* vrintx */ - break; - case 0x0f: /* vcvt double<->single */ rd_is_dp = !dp; break; @@ -3190,44 +3185,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 12: /* vrintr */ - { - TCGv_ptr fpst = get_fpstatus_ptr(0); - if (dp) { - gen_helper_rintd(cpu_F0d, cpu_F0d, fpst); - } else { - gen_helper_rints(cpu_F0s, cpu_F0s, fpst); - } - tcg_temp_free_ptr(fpst); - break; - } - case 13: /* vrintz */ - { - TCGv_ptr fpst = get_fpstatus_ptr(0); - TCGv_i32 tcg_rmode; - tcg_rmode = tcg_const_i32(float_round_to_zero); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - if (dp) { - gen_helper_rintd(cpu_F0d, cpu_F0d, fpst); - } else { - gen_helper_rints(cpu_F0s, cpu_F0s, fpst); - } - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); - tcg_temp_free_i32(tcg_rmode); - tcg_temp_free_ptr(fpst); - break; - } - case 14: /* vrintx */ - { - TCGv_ptr fpst = get_fpstatus_ptr(0); - if (dp) { - gen_helper_rintd_exact(cpu_F0d, cpu_F0d, fpst); - } else { - gen_helper_rints_exact(cpu_F0s, cpu_F0s, fpst); - } - tcg_temp_free_ptr(fpst); - break; - } case 15: /* single<->double conversion */ if (dp) { gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env); diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index b88d1d06f02..9942d2ae7ad 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -193,3 +193,18 @@ VCVT_f16_f32 ---- 1110 1.11 0011 .... 1010 t:1 1.0 .... \ vd=%vd_sp vm=%vm_sp VCVT_f16_f64 ---- 1110 1.11 0011 .... 1011 t:1 1.0 .... \ vd=%vd_sp vm=%vm_dp + +VRINTR_sp ---- 1110 1.11 0110 .... 1010 01.0 .... \ + vd=%vd_sp vm=%vm_sp +VRINTR_dp ---- 1110 1.11 0110 .... 1011 01.0 .... \ + vd=%vd_dp vm=%vm_dp + +VRINTZ_sp ---- 1110 1.11 0110 .... 1010 11.0 .... \ + vd=%vd_sp vm=%vm_sp +VRINTZ_dp ---- 1110 1.11 0110 .... 1011 11.0 .... \ + vd=%vd_dp vm=%vm_dp + +VRINTX_sp ---- 1110 1.11 0111 .... 1010 01.0 .... \ + vd=%vd_sp vm=%vm_sp +VRINTX_dp ---- 1110 1.11 0111 .... 1011 01.0 .... \ + vd=%vd_dp vm=%vm_dp From patchwork Thu Jun 13 12:14:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166652 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp759336ilk; Thu, 13 Jun 2019 06:23:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhCW+7RW3zw2Yk3zWJWOoqFzS7s+B+TlMOaOdZW+qrJebI2ec9tfJSr5NDL4nwTpxcAmvH X-Received: by 2002:a05:620a:1335:: with SMTP id p21mr49518443qkj.280.1560432226781; Thu, 13 Jun 2019 06:23:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560432226; cv=none; d=google.com; s=arc-20160816; b=gm0hNJelooSuH/0Nicq3WWQ946FJ835V4vm9ZyGvwS2/kF/xEWosbkuKwCkO9QgIBA GJAc+VzoPlR80wQgvsAWxYbjZe9TRpDeeSSayhcB3woiCu54rn42Mwc6FJ3jFBBhSFEd A+YBTvHkNZdVc6H/23DAPQZE+lxuHVbCLyixxB317QEgTUEzBHpwz8po8RyqmesC1KCm rOFDDQC+TmqI84p+NVNnPPt4lCWkcvuQoOfgVSV1bj0o2LOK3hcVqTF7s1SjgW8+bDPt A5VdqG0eTjP+Jg/hkV7DKfea8pRFkPh/GTxTbP+oynL3WqgBLx1dKVM+M349n0bN3ayD Qjrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=LtAQM8pEHu6SHKexNJlmMSxzxlY/d7BbtS01EMAQYdU=; b=ygt6o2piTAH9rXto7r877pjAP5bXOk0z2g4NSXAayGrCBjxWy+z3Bgl8FiV4nbBpbw b0f4Yg0PyQhqMh3fJC3UH7EecDKoBvlR2N6wMWX+VxQf4+xzwLap1DLJqmzGtIQY74eO Y+Bu4mvR3SoCLPavbigK+WqK+2BuuntPuPS30NKuVS1DKKN0tXkbNxR+XXQPTe1DfSFn pKWKbl1qTCmUjeZFtf6UMKq/dnOQDff0nYzfq9cDgJ1Az4X4HGGnQoUnW1Qr7+e28V4k 7CR5BcyQWY0HgiIqdMwVhdrwi8pRWcLBkjk9bRdXgDsLe3zGqe9ufRcuMgzCKGdUcCRs QIhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="eC/hc0Am"; 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=fail (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 d24si1480045qvh.140.2019.06.13.06.23.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:23:46 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b="eC/hc0Am"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPhi-0007L0-5l for patch@linaro.org; Thu, 13 Jun 2019 09:23:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59732) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdu-0008TY-1Y for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOda-0004nk-Eh for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:42 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:33254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdZ-0004eI-UX for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:26 -0400 Received: by mail-wr1-x443.google.com with SMTP id n9so20574875wru.0 for ; Thu, 13 Jun 2019 05:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LtAQM8pEHu6SHKexNJlmMSxzxlY/d7BbtS01EMAQYdU=; b=eC/hc0Am/kkKjLoBtRlqMaknAf66Pa5B2OYxzFyU+XT8TYz5C/JqFF8a5RdXvKFCKw gQQe01IbIVyr4arQLz9c0vyapW6t343g4vc8xEB1j2fT8ixLUeWzbTEbm1v0l808dW/O g+bc8ekztzKoFMRem8Xi7Wd1eRynLxfrS0I71UzbzAmLKXw/z1MrMdEfCI4w8M0XTNW/ 8rI8Tt6SK+p3AIK2w6Uw+hHjTcwfY1tukLJsRimbkRhxKaBXlc6U4djby1PF8NqyD4vS DZWCoPfUrHeS6+KXtlQqz/J+ayuuhtlxrBCSlgv7Rbs/1KgZAkY8+iJtFJoXypvxcMDt OGIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LtAQM8pEHu6SHKexNJlmMSxzxlY/d7BbtS01EMAQYdU=; b=gVQBI2Vl4KU6zLng8YhtV/lvlXL017uQ3V+6aJvZWZc5Wb3P34ldCNhaH5VtXlvFO/ fH81mFsxGDWIwUxeSQT44gSy/DnB66lzTQzWWNTo4iA8jEez+f/7yMGZpJWIY50Yjgju kPyKCGS92fQ2TdYUsHqiwQohgvMXKpRT70Ro2sfJ36LiNCVXqHqSyZrJDQ2g4tX4coDC 7yoHeozEjeO/gO2dX/J5IP1D+HYbg4J5qVyZNWc0qlLpcpHuywxVN39U5uBrO16/hP29 WFFx5cjwBCBwDhlk0mA/7zfwDYAFX+oe7yr82bg902929VDK0QYBukQFlbwvS0DkLn4g b6WQ== X-Gm-Message-State: APjAAAXvUN6VaDYHDwcXJWkJcWqdGb6EqtZ82x/cWkfIzsc8E4kuFnjA CU1WMk2bSjgk9O5Ob0dnQZ3gspFgKsxaWA== X-Received: by 2002:a5d:6b90:: with SMTP id n16mr14806003wrx.206.1560428121180; Thu, 13 Jun 2019 05:15:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:28 +0100 Message-Id: <20190613121433.5246-44-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 43/48] target/arm: Convert double-single precision conversion insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VCVT double/single precision conversion insns to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 48 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 13 +-------- target/arm/vfp.decode | 6 +++++ 3 files changed, 55 insertions(+), 12 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index e94a8f2f0c5..c50093776b6 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -2320,3 +2320,51 @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) tcg_temp_free_i64(tmp); return true; } + +static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) +{ + TCGv_i64 vd; + TCGv_i32 vm; + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vm = tcg_temp_new_i32(); + vd = tcg_temp_new_i64(); + neon_load_reg32(vm, a->vm); + gen_helper_vfp_fcvtds(vd, vm, cpu_env); + neon_store_reg64(vd, a->vd); + tcg_temp_free_i32(vm); + tcg_temp_free_i64(vd); + return true; +} + +static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) +{ + TCGv_i64 vm; + TCGv_i32 vd; + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vd = tcg_temp_new_i32(); + vm = tcg_temp_new_i64(); + neon_load_reg64(vm, a->vm); + gen_helper_vfp_fcvtsd(vd, vm, cpu_env); + neon_store_reg32(vd, a->vd); + tcg_temp_free_i32(vd); + tcg_temp_free_i64(vm); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 0c855069d85..40e52c3b700 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3050,7 +3050,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 0 ... 14: + case 0 ... 15: /* Already handled by decodetree */ return 1; default: @@ -3063,10 +3063,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) if (op == 15) { /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { - case 0x0f: /* vcvt double<->single */ - rd_is_dp = !dp; - break; - case 0x10: /* vcvt.fxx.u32 */ case 0x11: /* vcvt.fxx.s32 */ rm_is_dp = false; @@ -3185,13 +3181,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 15: /* single<->double conversion */ - if (dp) { - gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env); - } else { - gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env); - } - break; case 16: /* fuito */ gen_vfp_uito(dp, 0); break; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 9942d2ae7ad..56b8b4e6046 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -208,3 +208,9 @@ VRINTX_sp ---- 1110 1.11 0111 .... 1010 01.0 .... \ vd=%vd_sp vm=%vm_sp VRINTX_dp ---- 1110 1.11 0111 .... 1011 01.0 .... \ vd=%vd_dp vm=%vm_dp + +# VCVT between single and double: Vm precision depends on size; Vd is its reverse +VCVT_sp ---- 1110 1.11 0111 .... 1010 11.0 .... \ + vd=%vd_dp vm=%vm_sp +VCVT_dp ---- 1110 1.11 0111 .... 1011 11.0 .... \ + vd=%vd_sp vm=%vm_dp From patchwork Thu Jun 13 12:14:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166657 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp775765ilk; Thu, 13 Jun 2019 06:37:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzV9ACajyevQ5EIfuOfZHCCyPAl9WMjEQ4IgbReR/udENpVOltuuurAT5773MEaSXgDTUSV X-Received: by 2002:a0c:b0e4:: with SMTP id p33mr3699361qvc.208.1560433049195; Thu, 13 Jun 2019 06:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560433049; cv=none; d=google.com; s=arc-20160816; b=kTtPmxN3g3jHDL/Cv6a05dmjgNWEOByGPFXtuQQkmi9snWRlnhMxRdjNp15ax22F4e dLI3DCI2aeIftWiMV04jAXZd4PYfSfdOU4bMTXrOY2btjntgsqPZ3Oq8AyNtPiQxpFgC /KJN3vIQllEp95jxcktXK9AXVSZQnRz3tzB7Pk/+tY2cTBvQfrItQXiHEyiHaV+J3sbG U5k3UeKDXJEmb7fr/m2WOx3U3cigA+wJE9VlxZYVAfKvNh/wkIb67NkeOg8bOAeJR+TP x+2JMgF0nbxbEa+y5amvbuQ4vwPyhxUHieLjf6cxS/Kf03tSGIs5pwh61q3GPlTvAoiC 8zLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=cM/krYcMONIsOnkfHxTnbrqFSYhnAz5GTPgsBXD7Q3Y=; b=kzV66+PcwyIZ3d+qCMXPfqwtOktYpXN/bX5FDrKMSFIOykbgrVzIhi3BE2A+kUQwrm xmiSbRpRR+gAWyGku/0bCoSPCXNXjIvsaGNiBwwXw/C4jlm7ImDNpaX+ueOhHcpCPTeC oDzVIA29imuR6qyD5Zv6Nbk6CsB7qmXqqS8NBVZ+wShm+aZHNQyU59rDM6vD1cB26rSo 0TNojFJDlBiAOSuy1ycQRkFGH1FBn0k05IDfBIZYEtTOMPurAgHBFqiC4Dh9bFTpmzsR m9AbcUdTe3kHI7d8hd4yn8Zv0g/DrByYb7cK887OChL6I7OEOCaEDrk0FAIaGqS7QGIn BCRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="gmd/724/"; 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=fail (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 e22si2022190qte.250.2019.06.13.06.37.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:37:29 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b="gmd/724/"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPuy-0002DB-MO for patch@linaro.org; Thu, 13 Jun 2019 09:37:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60079) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOeR-0000E4-L1 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:16:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOeI-0005SW-1J for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:16:15 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:42618) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOeG-0004j5-1R for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:16:08 -0400 Received: by mail-wr1-x443.google.com with SMTP id x17so5235774wrl.9 for ; Thu, 13 Jun 2019 05:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cM/krYcMONIsOnkfHxTnbrqFSYhnAz5GTPgsBXD7Q3Y=; b=gmd/724/HKFju8tHx+3ur+SFcX7iq5hEkYFuFLo7YxhY8PNqWm4QUTn5j4GrHerpyb 47Qds0+iD7RA7L6WDxSmK0ddAfVNj+fUFO7bu+di9FjpL8C0KY11XTIcmHky4nEJAy3U iV94550mYqeU+/uy3VyS0osdnDqKV6IS9qi+78ydn6OeOrYcrArgPBv3c7WtYDx5X5D8 alSUvoNEARlMW4cDD7P49pF3uc+/4WjcKRgHcAkbEnI2FH5UALmoL7XbuL83J30ZhatF fA96MCD/BvIMo6jqzRF7B1odM75bPLw2tWWCkkvpj1gCgj5RDM3PSTKUFQ9kaFv9yDYF oYYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cM/krYcMONIsOnkfHxTnbrqFSYhnAz5GTPgsBXD7Q3Y=; b=XYqPz8sx9hfzzIuZ4Fo9o8C45xFznZLeN/9p5gRKSmtdxK5eF77AZQ2lMZNplUA16x +sziCP+6abOp6SKs8LkGrYFBBsqIXcL9VuwULajRg4EHJBKvCJlJ8tGb0wFrUiWK1m2+ yX3Udfc8tgHnHTrN7GumNAdUBOvQCtl60SjcEeit24aAc+ReaUfPJI2bvVmsayvNGUxP eFqVHh+1fQ4XGdw+LhMWMUFC+FJdxQyC4SxIJ6MFLizstFD07tGWqPjspTwe8EG2bsk6 sLwQPTVdF4ahBMNsel668CSyFwt3V97KhEXyqDx1aXhvR1NrSYjBE5tvPHJT0Hy1fB96 LwTw== X-Gm-Message-State: APjAAAUll2U8TekbDri2PWiXheMY7TyFisW07V16jf3m7Z/mYw3w4oWz 30fd0lq2QkZ887h5r0BC/ohcUBlYnUC8nQ== X-Received: by 2002:adf:f181:: with SMTP id h1mr1583765wro.86.1560428122050; Thu, 13 Jun 2019 05:15:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:29 +0100 Message-Id: <20190613121433.5246-45-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 44/48] target/arm: Convert integer-to-float insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VCVT integer-to-float instructions to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 58 ++++++++++++++++++++++++++++++++++ target/arm/translate.c | 12 +------ target/arm/vfp.decode | 6 ++++ 3 files changed, 65 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index c50093776b6..cc3f61d9c41 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -2368,3 +2368,61 @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) tcg_temp_free_i64(vm); return true; } + +static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a) +{ + TCGv_i32 vm; + TCGv_ptr fpst; + + if (!vfp_access_check(s)) { + return true; + } + + vm = tcg_temp_new_i32(); + neon_load_reg32(vm, a->vm); + fpst = get_fpstatus_ptr(false); + if (a->s) { + /* i32 -> f32 */ + gen_helper_vfp_sitos(vm, vm, fpst); + } else { + /* u32 -> f32 */ + gen_helper_vfp_uitos(vm, vm, fpst); + } + neon_store_reg32(vm, a->vd); + tcg_temp_free_i32(vm); + tcg_temp_free_ptr(fpst); + return true; +} + +static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) +{ + TCGv_i32 vm; + TCGv_i64 vd; + TCGv_ptr fpst; + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vm = tcg_temp_new_i32(); + vd = tcg_temp_new_i64(); + neon_load_reg32(vm, a->vm); + fpst = get_fpstatus_ptr(false); + if (a->s) { + /* i32 -> f64 */ + gen_helper_vfp_sitod(vd, vm, fpst); + } else { + /* u32 -> f64 */ + gen_helper_vfp_uitod(vd, vm, fpst); + } + neon_store_reg64(vd, a->vd); + tcg_temp_free_i32(vm); + tcg_temp_free_i64(vd); + tcg_temp_free_ptr(fpst); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index 40e52c3b700..da4d4e9d012 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3050,7 +3050,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 0 ... 15: + case 0 ... 17: /* Already handled by decodetree */ return 1; default: @@ -3063,10 +3063,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) if (op == 15) { /* rn is opcode, encoded as per VFP_SREG_N. */ switch (rn) { - case 0x10: /* vcvt.fxx.u32 */ - case 0x11: /* vcvt.fxx.s32 */ - rm_is_dp = false; - break; case 0x18: /* vcvtr.u32.fxx */ case 0x19: /* vcvtz.u32.fxx */ case 0x1a: /* vcvtr.s32.fxx */ @@ -3181,12 +3177,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 16: /* fuito */ - gen_vfp_uito(dp, 0); - break; - case 17: /* fsito */ - gen_vfp_sito(dp, 0); - break; case 19: /* vjcvt */ gen_helper_vjcvt(cpu_F0s, cpu_F0d, cpu_env); break; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 56b8b4e6046..6da9a7913da 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -214,3 +214,9 @@ VCVT_sp ---- 1110 1.11 0111 .... 1010 11.0 .... \ vd=%vd_dp vm=%vm_sp VCVT_dp ---- 1110 1.11 0111 .... 1011 11.0 .... \ vd=%vd_sp vm=%vm_dp + +# VCVT from integer to floating point: Vm always single; Vd depends on size +VCVT_int_sp ---- 1110 1.11 1000 .... 1010 s:1 1.0 .... \ + vd=%vd_sp vm=%vm_sp +VCVT_int_dp ---- 1110 1.11 1000 .... 1011 s:1 1.0 .... \ + vd=%vd_dp vm=%vm_sp From patchwork Thu Jun 13 12:14:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166656 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp774894ilk; Thu, 13 Jun 2019 06:36:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0iHwl28muWsAIRqy3YVOGSZIS3lyJ4+T5xGPLrwDQlIjWXCSAKxZcBmiTCrIanOMrdFJ8 X-Received: by 2002:a37:5d41:: with SMTP id r62mr52528369qkb.315.1560433004141; Thu, 13 Jun 2019 06:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560433004; cv=none; d=google.com; s=arc-20160816; b=GwM+iIEDDOk8QJCtAucw8JqIIs3z7/X/aVgxsykuqBI1aH5kDxMZIxJy4/UrAkhzTb rwbIg8pov91wZn/1upLC7wlGRaxh0cjG4B4qI+QWb/YqPUXFAxOzfgDT3I30QiYw78wY hPN1I2ae2l7tjPNZ0tD/kfk0EKp0er6pavN+2AAZTQWUnKjjNYbhEUvlq6dOuHBOtB/H UtFcTU1hjexh8FSUktuf/Dnyb43ZJ6qZoBsO8a73KLrawhBGiDYUSMYnhoXbMMmVYV+H a97V9AwkImRCUQbYRHb38kVWtDbZ4F8j6eLYQ5yXssmYe9wq1XrERg/aUTVSMWIxIDGo AzTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=dlG/h4e/09Nwqt8ZUUNPJpFZPx9E3DXWrZDW3I5mo2w=; b=y51WLau2yBcO5PT8QaoGnt10CSqpU+Wfk2HMO+LukLHeZemBV9BO3GFUls/G5O1De6 mV91xT9DO9pwNkGUBNycU3xV1ZnN8BdrEcKh7W9XdSHlG7rob2eR7xgZuyxP5xUQPeQ9 U9zeXoQNt+/06wUSbkCcMbwCfrCmi+fb8/bY7tNBwFCfgQ8vQpxmsocvF6ipMjOxmvIe lDSLwmh8iUlc2vMmd3AJxTMGqovztF1CIbQihjuDUZTjd2te1svuWfeyPsPZfulXwwdG mGd09ZOdzKCgJoxE77vr2PiPMwWbBPjiTPnUaSEAnS2vP5lUmCGur6QEbocJ6jyMyIj/ YBEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=csH9Zwa5; 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=fail (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 o10si1765592qko.75.2019.06.13.06.36.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:36:44 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=csH9Zwa5; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPuF-00023j-N8 for patch@linaro.org; Thu, 13 Jun 2019 09:36:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59736) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdu-0008Tf-22 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdh-0004ur-S8 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:43 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:44903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdc-0004iv-Dp for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:29 -0400 Received: by mail-wr1-x42f.google.com with SMTP id r16so1385216wrl.11 for ; Thu, 13 Jun 2019 05:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dlG/h4e/09Nwqt8ZUUNPJpFZPx9E3DXWrZDW3I5mo2w=; b=csH9Zwa5FP+jekeVGIuXk6esmvwkb7NPhHCyy6TpP5TcfS5mIFRnAHLZGqOO5YPoGr CyPO/Rtd3RGwN/a9QbxgX8w+EHReSxLaZ6J7wcWhJKk3ueuRJC2KSuaB99qnHjNXHXGv 9rWHlohSW12bt0Y6QoGir2HCHP9Dk1ZgrPo5gQ1yvFjV1uFSEhFeY3bVDynq6Ch4K2tJ XvRqsW1ZJR6wePcYhZeihTxID4JCCYY9mimCU7uXW9DxsIAaaXe6KjPMLr5XGjS9sq3A tue4ESCnF3yoftZGBC/Q4EJKwu/3GRyfc7r2Qcz2hSKs5xxpwT1wOBdYiR7iJlLDo1ya Okqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dlG/h4e/09Nwqt8ZUUNPJpFZPx9E3DXWrZDW3I5mo2w=; b=c+DZznvtUkSk/EqNeQod8dL/ylOtvfb56v5B28uDarFVG+rrW2s5ofRD6ZZJ3bjss+ N+pvMkXjChSvlnp/w8ADDiReo/3Bg2fWwa6puUOhcXhvLL3MRt031RlS4tGWpYUnHBVF fPgOWxLM78Q4YdLC8dH5HVkvLQdF9h/IzjF7KNRKok0FCJ5lMifQsndGgfPfrl/nXAcP dOYGRw5hK7tNtH+f9LWWwBTQ2Q6tQ6UJOPht0xCLx3Nk3WL9y1qj5NTmzoCKycotWqvw pk4vvZIMNTtGrMUY5braebgkMGbDT7qPy08igWPA8k2GO8mQDS+EF2NWHfjey/lJhu8c 3N9w== X-Gm-Message-State: APjAAAWdpIvwZCxTakdpF/n+gWFRBr9cCaR9vGxE5Oy/Ah9tAzHzUhU6 CiYfp2hcCPtQ3DxOI1bPPgS8lmxnQ53FrQ== X-Received: by 2002:adf:e8cb:: with SMTP id k11mr58142015wrn.244.1560428122859; Thu, 13 Jun 2019 05:15:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:30 +0100 Message-Id: <20190613121433.5246-46-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f Subject: [Qemu-devel] [PULL 45/48] target/arm: Convert VJCVT to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VJCVT instruction to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 28 ++++++++++++++++++++++++++++ target/arm/translate.c | 12 +----------- target/arm/vfp.decode | 4 ++++ 3 files changed, 33 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index cc3f61d9c41..161f0fdd888 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -2426,3 +2426,31 @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) tcg_temp_free_ptr(fpst); return true; } + +static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) +{ + TCGv_i32 vd; + TCGv_i64 vm; + + if (!dc_isar_feature(aa32_jscvt, s)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + vm = tcg_temp_new_i64(); + vd = tcg_temp_new_i32(); + neon_load_reg64(vm, a->vm); + gen_helper_vjcvt(vd, vm, cpu_env); + neon_store_reg32(vd, a->vd); + tcg_temp_free_i64(vm); + tcg_temp_free_i32(vd); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index da4d4e9d012..d5347c55ad4 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3050,7 +3050,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 0 ... 17: + case 0 ... 19: /* Already handled by decodetree */ return 1; default: @@ -3085,13 +3085,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rm_is_dp = false; break; - case 0x13: /* vjcvt */ - if (!dp || !dc_isar_feature(aa32_jscvt, s)) { - return 1; - } - rd_is_dp = false; - break; - default: return 1; } @@ -3177,9 +3170,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 19: /* vjcvt */ - gen_helper_vjcvt(cpu_F0s, cpu_F0d, cpu_env); - break; case 20: /* fshto */ gen_vfp_shto(dp, 16 - rm, 0); break; diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 6da9a7913da..1a7c9b533de 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -220,3 +220,7 @@ VCVT_int_sp ---- 1110 1.11 1000 .... 1010 s:1 1.0 .... \ vd=%vd_sp vm=%vm_sp VCVT_int_dp ---- 1110 1.11 1000 .... 1011 s:1 1.0 .... \ vd=%vd_dp vm=%vm_sp + +# VJCVT is always dp to sp +VJCVT ---- 1110 1.11 1001 .... 1011 11.0 .... \ + vd=%vd_sp vm=%vm_dp From patchwork Thu Jun 13 12:14:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166641 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp727153ilk; Thu, 13 Jun 2019 05:59:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5330YFR72Y2MFPCd2+tnRhJt6CMsQNExfUffzNLrVgq6wUSrzue0iaJavfn/S/hVbklRZ X-Received: by 2002:a05:620a:51:: with SMTP id t17mr71756423qkt.149.1560430784831; Thu, 13 Jun 2019 05:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560430784; cv=none; d=google.com; s=arc-20160816; b=mvMJpx9N8BRIEmhcaFKJSkEKSUelW9zfeYhGhDWRRFXzoTlQOTbCv9a6s8uEOgk0l+ iD/4pZ4kcqRtYLO/jfmZPHOddOkOZ31RyHyPb9QmsndSPJZho+ngCLmHVE08sEpISeBR oDO3vnzIJHq2Z5hBf6KeZLOJ9nPxy60Q+rs1L/eclqxiTvJLXCmjTdSOsuT67UKbqgOi V2pAhU5EIX7IgQMTRwCwKGhOSNdrFYMq5qt8TiY9Ubao79Y4tYIIaV4gQgqiR2ARIeWE U5EdHU0btycGzcakswLq63tNG9xNzNJDK/G01N2+rGX6RcFMwnK2hClb2PJbBCGRViYe 8LkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=k5KHJjeORXTvuSg87MPqOF7vkfCS42YLavByWjR0+X0=; b=1LxIdbNEOWyab/n6JTyMXjT2QWLEqNEIxXS4obmJ74jSiJS9En7lStUwF1yv7bh8WZ 9UYTnBNZyTdj6XgXfyp4puCRf6OD8WQ7LZwUwJV730e2GLKcblOE/wVYzV6wli6vNZAv WT4DHGGDMiQVD/p/jeoISrQQ2eYIQZf4JR0VrqqDyG6ExNRh/tTXCcHCd7jHcm6UXafC ofh4OkkO+pHOvF0DmJT/5IAeK2aGbOZzVFLyFNFMS0E79e372RfCS8BK15sN1orckPnk 9RFxqfkTkHwBWeLnVjCX9x7HftHtctohE4z7uzy8tn8O2fkW3qq4+zuNIGWII4+5wibN bb1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pGPy8QlX; 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=fail (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 u56si1760360qtb.382.2019.06.13.05.59.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:59:44 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=pGPy8QlX; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPKS-0007HC-Bb for patch@linaro.org; Thu, 13 Jun 2019 08:59:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59734) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOdu-0008Te-2x for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOdh-0004um-SB for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:43 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:42896) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOdc-0004kq-CT for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:15:29 -0400 Received: by mail-wr1-x431.google.com with SMTP id x17so5235862wrl.9 for ; Thu, 13 Jun 2019 05:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=k5KHJjeORXTvuSg87MPqOF7vkfCS42YLavByWjR0+X0=; b=pGPy8QlXvlNRmv3Viy/OMe7NY1322AvTyB/8xB6Ht6D4inemf1qS0ridrFQbDnvJpi I3ZUNZHLfOP8KTDAuNR6OxciaFdUWiq8ioPkVxqdErl7jvZXaTJxV5OjPwPXooJnp1Ns JBuMieBVxaJt+qjFrybWBoDjokZr49oL9rz32jvwrqamKTdqW7+IDJPm1Pm+5ihZR1Bd jXpXx2vvNifvvwSAdIfCbwXXalgglM8KX5UUjxwHUvY/FyN1hbuhFesbTE1cqxR7i954 Mr3e3mQwisb/3HdX1OHE6T87kR+fgyrcOzeHTuz9iH5EYzQv4vwqX8iQcURAXUI7vyw8 NhqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k5KHJjeORXTvuSg87MPqOF7vkfCS42YLavByWjR0+X0=; b=nRwBEUX54zR61WUcRpb30bdID677Y91dLqstZDgxXAwIvfFpCkowvo3Yn7HKDRm51p HM3N0bGGU9o9Aqt8U3BQ2uq/R2vH1I3/7ewCeQ/7BM3VhPR2itPQAKYi4etMXiM0djxJ ETGqR/qrFJInqDf8Svv2nXHz1GOnRt5KiXeQfASOJuJaRpxh0qZufdruRvV7k205gtvT qSjuB+WY8baTceXeRaFOdwk4BFRSv/WEZwL8c7P9/tu/ESPnscMZycvy/Xn/ryF8IduS 06QFFGrWSBBrsLNZKMsuPB13HVurHd9FnL762OcxzbUHLy09JeyIy7mpzekmuRjoRAcv icBw== X-Gm-Message-State: APjAAAV6AjBEKCsAmbYztsMo1ZAyyzyv9L4vSJkLp50h7TNEhyDhr/6j 2TcRGkJeYcVM7qUGwYxpx05P+TRQ4FQf4A== X-Received: by 2002:adf:a18a:: with SMTP id u10mr37083745wru.351.1560428124256; Thu, 13 Jun 2019 05:15:24 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:23 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:31 +0100 Message-Id: <20190613121433.5246-47-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 Subject: [Qemu-devel] [PULL 46/48] target/arm: Convert VCVT fp/fixed-point conversion insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VCVT (between floating-point and fixed-point) instructions to decodetree. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 124 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 57 +-------------- target/arm/vfp.decode | 10 +++ 3 files changed, 136 insertions(+), 55 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 161f0fdd888..db07fdd8736 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -2454,3 +2454,127 @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) tcg_temp_free_i32(vd); return true; } + +static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a) +{ + TCGv_i32 vd, shift; + TCGv_ptr fpst; + int frac_bits; + + if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm); + + vd = tcg_temp_new_i32(); + neon_load_reg32(vd, a->vd); + + fpst = get_fpstatus_ptr(false); + shift = tcg_const_i32(frac_bits); + + /* Switch on op:U:sx bits */ + switch (a->opc) { + case 0: + gen_helper_vfp_shtos(vd, vd, shift, fpst); + break; + case 1: + gen_helper_vfp_sltos(vd, vd, shift, fpst); + break; + case 2: + gen_helper_vfp_uhtos(vd, vd, shift, fpst); + break; + case 3: + gen_helper_vfp_ultos(vd, vd, shift, fpst); + break; + case 4: + gen_helper_vfp_toshs_round_to_zero(vd, vd, shift, fpst); + break; + case 5: + gen_helper_vfp_tosls_round_to_zero(vd, vd, shift, fpst); + break; + case 6: + gen_helper_vfp_touhs_round_to_zero(vd, vd, shift, fpst); + break; + case 7: + gen_helper_vfp_touls_round_to_zero(vd, vd, shift, fpst); + break; + default: + g_assert_not_reached(); + } + + neon_store_reg32(vd, a->vd); + tcg_temp_free_i32(vd); + tcg_temp_free_i32(shift); + tcg_temp_free_ptr(fpst); + return true; +} + +static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) +{ + TCGv_i64 vd; + TCGv_i32 shift; + TCGv_ptr fpst; + int frac_bits; + + if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vd & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm); + + vd = tcg_temp_new_i64(); + neon_load_reg64(vd, a->vd); + + fpst = get_fpstatus_ptr(false); + shift = tcg_const_i32(frac_bits); + + /* Switch on op:U:sx bits */ + switch (a->opc) { + case 0: + gen_helper_vfp_shtod(vd, vd, shift, fpst); + break; + case 1: + gen_helper_vfp_sltod(vd, vd, shift, fpst); + break; + case 2: + gen_helper_vfp_uhtod(vd, vd, shift, fpst); + break; + case 3: + gen_helper_vfp_ultod(vd, vd, shift, fpst); + break; + case 4: + gen_helper_vfp_toshd_round_to_zero(vd, vd, shift, fpst); + break; + case 5: + gen_helper_vfp_tosld_round_to_zero(vd, vd, shift, fpst); + break; + case 6: + gen_helper_vfp_touhd_round_to_zero(vd, vd, shift, fpst); + break; + case 7: + gen_helper_vfp_tould_round_to_zero(vd, vd, shift, fpst); + break; + default: + g_assert_not_reached(); + } + + neon_store_reg64(vd, a->vd); + tcg_temp_free_i64(vd); + tcg_temp_free_i32(shift); + tcg_temp_free_ptr(fpst); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index d5347c55ad4..d7a77fca9ac 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1439,13 +1439,9 @@ static inline void gen_vfp_##name(int dp, int shift, int neon) \ tcg_temp_free_i32(tmp_shift); \ tcg_temp_free_ptr(statusptr); \ } -VFP_GEN_FIX(tosh, _round_to_zero) VFP_GEN_FIX(tosl, _round_to_zero) -VFP_GEN_FIX(touh, _round_to_zero) VFP_GEN_FIX(toul, _round_to_zero) -VFP_GEN_FIX(shto, ) VFP_GEN_FIX(slto, ) -VFP_GEN_FIX(uhto, ) VFP_GEN_FIX(ulto, ) #undef VFP_GEN_FIX @@ -3050,7 +3046,8 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 1; case 15: switch (rn) { - case 0 ... 19: + case 0 ... 23: + case 28 ... 31: /* Already handled by decodetree */ return 1; default: @@ -3070,21 +3067,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rd_is_dp = false; break; - case 0x14: /* vcvt fp <-> fixed */ - case 0x15: - case 0x16: - case 0x17: - case 0x1c: - case 0x1d: - case 0x1e: - case 0x1f: - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } - /* Immediate frac_bits has same format as SREG_M. */ - rm_is_dp = false; - break; - default: return 1; } @@ -3143,17 +3125,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) /* Load the initial operands. */ if (op == 15) { switch (rn) { - case 0x14: /* vcvt fp <-> fixed */ - case 0x15: - case 0x16: - case 0x17: - case 0x1c: - case 0x1d: - case 0x1e: - case 0x1f: - /* Source and destination the same. */ - gen_mov_F0_vreg(dp, rd); - break; default: /* One source operand. */ gen_mov_F0_vreg(rm_is_dp, rm); @@ -3170,18 +3141,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) switch (op) { case 15: /* extension space */ switch (rn) { - case 20: /* fshto */ - gen_vfp_shto(dp, 16 - rm, 0); - break; - case 21: /* fslto */ - gen_vfp_slto(dp, 32 - rm, 0); - break; - case 22: /* fuhto */ - gen_vfp_uhto(dp, 16 - rm, 0); - break; - case 23: /* fulto */ - gen_vfp_ulto(dp, 32 - rm, 0); - break; case 24: /* ftoui */ gen_vfp_toui(dp, 0); break; @@ -3194,18 +3153,6 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) case 27: /* ftosiz */ gen_vfp_tosiz(dp, 0); break; - case 28: /* ftosh */ - gen_vfp_tosh(dp, 16 - rm, 0); - break; - case 29: /* ftosl */ - gen_vfp_tosl(dp, 32 - rm, 0); - break; - case 30: /* ftouh */ - gen_vfp_touh(dp, 16 - rm, 0); - break; - case 31: /* ftoul */ - gen_vfp_toul(dp, 32 - rm, 0); - break; default: /* undefined */ g_assert_not_reached(); } diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index 1a7c9b533de..c3223a124ac 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -224,3 +224,13 @@ VCVT_int_dp ---- 1110 1.11 1000 .... 1011 s:1 1.0 .... \ # VJCVT is always dp to sp VJCVT ---- 1110 1.11 1001 .... 1011 11.0 .... \ vd=%vd_sp vm=%vm_dp + +# VCVT between floating-point and fixed-point. The immediate value +# is in the same format as a Vm single-precision register number. +# We assemble bits 18 (op), 16 (u) and 7 (sx) into a single opc field +# for the convenience of the trans_VCVT_fix functions. +%vcvt_fix_op 18:1 16:1 7:1 +VCVT_fix_sp ---- 1110 1.11 1.1. .... 1010 .1.0 .... \ + vd=%vd_sp imm=%vm_sp opc=%vcvt_fix_op +VCVT_fix_dp ---- 1110 1.11 1.1. .... 1011 .1.0 .... \ + vd=%vd_dp imm=%vm_sp opc=%vcvt_fix_op From patchwork Thu Jun 13 12:14:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166655 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp770402ilk; Thu, 13 Jun 2019 06:32:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzktet7MCLINo8z00VexTq2kfiCsKI5VrB89P4x3n8ZVV+QfTipD4dukiJIzsZxkXFMVbi1 X-Received: by 2002:ac8:828:: with SMTP id u37mr18797261qth.96.1560432777541; Thu, 13 Jun 2019 06:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560432777; cv=none; d=google.com; s=arc-20160816; b=XlRPmH4ZQvcjGXd/3U8TTjVb482hCRJAqo2x773f57sUgNrrgrU3EhA8Jt9JMlWdFY XCPTbTmSJMQPLRZYecpXsn2aCbJtifQpsPI4hEctQ7uGZIcotDH38rsL8PPF6f0JTVru IfX53F3QKBLBXW34Gz7vziKY1hIzhS//QxmHuEaEDBo1Bo5FIeEu2z3cDRhJwurO1zy9 AzdPd8hY45+AzbvrRcNIGZwePK1MuVnwj53msX1k1/CHMz5HnFZcp/I4zi7XvJGjywg6 dpgBPeBaCKjvj/61l1oGuz5umylTkoAozddeYfsKOPKpHyhINt51RAIk4Ypft8TS3jtS eaxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=5gtpw2YUK/SlJN0xIUzASKxApJAmaIC/1IkdztKlHx0=; b=Cd4Qo/so4rLV+4Yo8GnYlTFif9LPY9TzelsUhVyAMBzH3BuA1H1X+8rUGcmlO60UyS 1NaWFKr61B87ARGatnNjSn9aOqew8SY2Mt4idfsn78m0fB+XlzhX+inH5ucRE+o+6odz /D7K9uwaYCXqKd2PnlvuwwhjLm1KTjWiEwGZBhZrixBQW6QGVTWcDZPGbZtAneccgFYo UDKC7GyRBOc2wWr5cE+SuoRpslZBIYQsRBNDJls5IuOxH61lE0vTAAITZVl7VRZ8AbmG IFndRgnZ/6ELQlNCAXwrBJZ4/BW3rDDunYLFk4WC0n9vEBXdFG1wt71q9Dm+2kXG79vE UYQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UNa8JizK; 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=fail (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 f7si1444103qvj.150.2019.06.13.06.32.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:32:57 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=UNa8JizK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbPqa-00083z-Mz for patch@linaro.org; Thu, 13 Jun 2019 09:32:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60056) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOeN-0000DY-7l for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:16:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOeF-0005OB-QL for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:16:13 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:54474) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOe6-0004nO-SI for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:16:03 -0400 Received: by mail-wm1-x344.google.com with SMTP id g135so9953733wme.4 for ; Thu, 13 Jun 2019 05:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5gtpw2YUK/SlJN0xIUzASKxApJAmaIC/1IkdztKlHx0=; b=UNa8JizKuD3noTjRRWXOi0qVIDZpZkTbDbpGSR+M99Rw9+nfjjk5UcNsXGAjb75E/d 4P9aqhhPimpcu2HNpgluey1XDs2LNE8P+JAGtxz9UIDtlE0suJtfMRpD0/nsC4IOb+wL VoUJd6RBubV35YK2sHnjXjTlQKvbgAt66Nzgl158aulsq3bhZo+IxgvXwMxtPJGvHoyv OkBp6R3ntNcPr9SpVLZ2EBp/aHGflEkCkXPRQoy7EmA+XsPlFiM8gXGohoQhr23Qaz9N FoKSTEZQN0OnCUl3mIwFqV3C0DTkexSoKy9Iyv8tcQ9iVQ1AToe6JXZskqalXPT4eiUj k/Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5gtpw2YUK/SlJN0xIUzASKxApJAmaIC/1IkdztKlHx0=; b=HtHdwLatQxsazZXLSu+kr0tgE1wMv4JCEKUdFHBMmtaJT0Q5aTX5qH3nlYLELZPC1w h0SjwtKO3HThrHSulClzoXCDFI6lGx48QY9ZdTtoR7GD4Ik7HxIhWAWxCGvVZvIbYQob ZNXEvx2+PCWDRr5pGnOCmNrxXRvnqydqUXJ2AESt5/yWsViZ5KHStv7ZPruBHc5V8SNY PBVf3YatWSoXZiJK6TblheyVfWaHQEr/q/bylw/0mBhluox3zMfyBBYfckSLY6EEnHsN RIVs/6ZNu6czndJc2u/uZaZqtY+1OzMf0T+b3Fg2+GbHwBwrv6tM2vAAARxT/VQjK6nj yUxQ== X-Gm-Message-State: APjAAAW+eatYEdhDdm1HcCaAeMxRHD9fmy2hp7R8AF5Xx53r/cMsVab+ 0UAT5d63lp3yBgl1U1lz4eYv0CSsR4x1tw== X-Received: by 2002:a05:600c:2149:: with SMTP id v9mr3470964wml.141.1560428125378; Thu, 13 Jun 2019 05:15:25 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:24 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:32 +0100 Message-Id: <20190613121433.5246-48-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PULL 47/48] target/arm: Convert float-to-integer VCVT insns to decodetree 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the float-to-integer VCVT instructions to decodetree. Since these are the last unconverted instructions, we can delete the old decoder structure entirely now. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 72 ++++++++++ target/arm/translate.c | 241 +-------------------------------- target/arm/vfp.decode | 6 + 3 files changed, 80 insertions(+), 239 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index db07fdd8736..8216dba796e 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -2578,3 +2578,75 @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) tcg_temp_free_ptr(fpst); return true; } + +static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a) +{ + TCGv_i32 vm; + TCGv_ptr fpst; + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(false); + vm = tcg_temp_new_i32(); + neon_load_reg32(vm, a->vm); + + if (a->s) { + if (a->rz) { + gen_helper_vfp_tosizs(vm, vm, fpst); + } else { + gen_helper_vfp_tosis(vm, vm, fpst); + } + } else { + if (a->rz) { + gen_helper_vfp_touizs(vm, vm, fpst); + } else { + gen_helper_vfp_touis(vm, vm, fpst); + } + } + neon_store_reg32(vm, a->vd); + tcg_temp_free_i32(vm); + tcg_temp_free_ptr(fpst); + return true; +} + +static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) +{ + TCGv_i32 vd; + TCGv_i64 vm; + TCGv_ptr fpst; + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_fp_d32, s) && (a->vm & 0x10)) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + fpst = get_fpstatus_ptr(false); + vm = tcg_temp_new_i64(); + vd = tcg_temp_new_i32(); + neon_load_reg64(vm, a->vm); + + if (a->s) { + if (a->rz) { + gen_helper_vfp_tosizd(vd, vm, fpst); + } else { + gen_helper_vfp_tosid(vd, vm, fpst); + } + } else { + if (a->rz) { + gen_helper_vfp_touizd(vd, vm, fpst); + } else { + gen_helper_vfp_touid(vd, vm, fpst); + } + } + neon_store_reg32(vd, a->vd); + tcg_temp_free_i32(vd); + tcg_temp_free_i64(vm); + tcg_temp_free_ptr(fpst); + return true; +} diff --git a/target/arm/translate.c b/target/arm/translate.c index d7a77fca9ac..4a66a35a7f6 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1418,9 +1418,7 @@ static inline void gen_vfp_##name(int dp, int neon) \ tcg_temp_free_ptr(statusptr); \ } -VFP_GEN_FTOI(toui) VFP_GEN_FTOI(touiz) -VFP_GEN_FTOI(tosi) VFP_GEN_FTOI(tosiz) #undef VFP_GEN_FTOI @@ -1612,33 +1610,7 @@ static TCGv_ptr vfp_reg_ptr(bool dp, int reg) } #define tcg_gen_ld_f32 tcg_gen_ld_i32 -#define tcg_gen_ld_f64 tcg_gen_ld_i64 #define tcg_gen_st_f32 tcg_gen_st_i32 -#define tcg_gen_st_f64 tcg_gen_st_i64 - -static inline void gen_mov_F0_vreg(int dp, int reg) -{ - if (dp) - tcg_gen_ld_f64(cpu_F0d, cpu_env, vfp_reg_offset(dp, reg)); - else - tcg_gen_ld_f32(cpu_F0s, cpu_env, vfp_reg_offset(dp, reg)); -} - -static inline void gen_mov_F1_vreg(int dp, int reg) -{ - if (dp) - tcg_gen_ld_f64(cpu_F1d, cpu_env, vfp_reg_offset(dp, reg)); - else - tcg_gen_ld_f32(cpu_F1s, cpu_env, vfp_reg_offset(dp, reg)); -} - -static inline void gen_mov_vreg_F0(int dp, int reg) -{ - if (dp) - tcg_gen_st_f64(cpu_F0d, cpu_env, vfp_reg_offset(dp, reg)); - else - tcg_gen_st_f32(cpu_F0s, cpu_env, vfp_reg_offset(dp, reg)); -} #define ARM_CP_RW_BIT (1 << 20) @@ -2983,9 +2955,6 @@ static void gen_neon_dup_high16(TCGv_i32 var) */ static int disas_vfp_insn(DisasContext *s, uint32_t insn) { - uint32_t rd, rn, rm, op, delta_d, delta_m, bank_mask; - int dp, veclen; - if (!arm_dc_feature(s, ARM_FEATURE_VFP)) { return 1; } @@ -3005,214 +2974,8 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) return 0; } } - - if (extract32(insn, 28, 4) == 0xf) { - /* - * Encodings with T=1 (Thumb) or unconditional (ARM): these - * were all handled by the decodetree decoder, so any insn - * patterns which get here must be UNDEF. - */ - return 1; - } - - /* - * FIXME: this access check should not take precedence over UNDEF - * for invalid encodings; we will generate incorrect syndrome information - * for attempts to execute invalid vfp/neon encodings with FP disabled. - */ - if (!vfp_access_check(s)) { - return 0; - } - - dp = ((insn & 0xf00) == 0xb00); - switch ((insn >> 24) & 0xf) { - case 0xe: - if (insn & (1 << 4)) { - /* already handled by decodetree */ - return 1; - } else { - /* data processing */ - bool rd_is_dp = dp; - bool rm_is_dp = dp; - bool no_output = false; - - /* The opcode is in bits 23, 21, 20 and 6. */ - op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1); - rn = VFP_SREG_N(insn); - - switch (op) { - case 0 ... 14: - /* Already handled by decodetree */ - return 1; - case 15: - switch (rn) { - case 0 ... 23: - case 28 ... 31: - /* Already handled by decodetree */ - return 1; - default: - break; - } - default: - break; - } - - if (op == 15) { - /* rn is opcode, encoded as per VFP_SREG_N. */ - switch (rn) { - case 0x18: /* vcvtr.u32.fxx */ - case 0x19: /* vcvtz.u32.fxx */ - case 0x1a: /* vcvtr.s32.fxx */ - case 0x1b: /* vcvtz.s32.fxx */ - rd_is_dp = false; - break; - - default: - return 1; - } - } else if (dp) { - /* rn is register number */ - VFP_DREG_N(rn, insn); - } - - if (rd_is_dp) { - VFP_DREG_D(rd, insn); - } else { - rd = VFP_SREG_D(insn); - } - if (rm_is_dp) { - VFP_DREG_M(rm, insn); - } else { - rm = VFP_SREG_M(insn); - } - - veclen = s->vec_len; - if (op == 15 && rn > 3) { - veclen = 0; - } - - /* Shut up compiler warnings. */ - delta_m = 0; - delta_d = 0; - bank_mask = 0; - - if (veclen > 0) { - if (dp) - bank_mask = 0xc; - else - bank_mask = 0x18; - - /* Figure out what type of vector operation this is. */ - if ((rd & bank_mask) == 0) { - /* scalar */ - veclen = 0; - } else { - if (dp) - delta_d = (s->vec_stride >> 1) + 1; - else - delta_d = s->vec_stride + 1; - - if ((rm & bank_mask) == 0) { - /* mixed scalar/vector */ - delta_m = 0; - } else { - /* vector */ - delta_m = delta_d; - } - } - } - - /* Load the initial operands. */ - if (op == 15) { - switch (rn) { - default: - /* One source operand. */ - gen_mov_F0_vreg(rm_is_dp, rm); - break; - } - } else { - /* Two source operands. */ - gen_mov_F0_vreg(dp, rn); - gen_mov_F1_vreg(dp, rm); - } - - for (;;) { - /* Perform the calculation. */ - switch (op) { - case 15: /* extension space */ - switch (rn) { - case 24: /* ftoui */ - gen_vfp_toui(dp, 0); - break; - case 25: /* ftouiz */ - gen_vfp_touiz(dp, 0); - break; - case 26: /* ftosi */ - gen_vfp_tosi(dp, 0); - break; - case 27: /* ftosiz */ - gen_vfp_tosiz(dp, 0); - break; - default: /* undefined */ - g_assert_not_reached(); - } - break; - default: /* undefined */ - return 1; - } - - /* Write back the result, if any. */ - if (!no_output) { - gen_mov_vreg_F0(rd_is_dp, rd); - } - - /* break out of the loop if we have finished */ - if (veclen == 0) { - break; - } - - if (op == 15 && delta_m == 0) { - /* single source one-many */ - while (veclen--) { - rd = ((rd + delta_d) & (bank_mask - 1)) - | (rd & bank_mask); - gen_mov_vreg_F0(dp, rd); - } - break; - } - /* Setup the next operands. */ - veclen--; - rd = ((rd + delta_d) & (bank_mask - 1)) - | (rd & bank_mask); - - if (op == 15) { - /* One source operand. */ - rm = ((rm + delta_m) & (bank_mask - 1)) - | (rm & bank_mask); - gen_mov_F0_vreg(dp, rm); - } else { - /* Two source operands. */ - rn = ((rn + delta_d) & (bank_mask - 1)) - | (rn & bank_mask); - gen_mov_F0_vreg(dp, rn); - if (delta_m) { - rm = ((rm + delta_m) & (bank_mask - 1)) - | (rm & bank_mask); - gen_mov_F1_vreg(dp, rm); - } - } - } - } - break; - case 0xc: - case 0xd: - /* Already handled by decodetree */ - return 1; - default: - /* Should never happen. */ - return 1; - } - return 0; + /* If the decodetree decoder didn't handle this insn, it must be UNDEF */ + return 1; } static inline bool use_goto_tb(DisasContext *s, target_ulong dest) diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode index c3223a124ac..ea24365bb4c 100644 --- a/target/arm/vfp.decode +++ b/target/arm/vfp.decode @@ -234,3 +234,9 @@ VCVT_fix_sp ---- 1110 1.11 1.1. .... 1010 .1.0 .... \ vd=%vd_sp imm=%vm_sp opc=%vcvt_fix_op VCVT_fix_dp ---- 1110 1.11 1.1. .... 1011 .1.0 .... \ vd=%vd_dp imm=%vm_sp opc=%vcvt_fix_op + +# VCVT float to integer (VCVT and VCVTR): Vd always single; Vd depends on size +VCVT_sp_int ---- 1110 1.11 110 s:1 .... 1010 rz:1 1.0 .... \ + vd=%vd_sp vm=%vm_sp +VCVT_dp_int ---- 1110 1.11 110 s:1 .... 1011 rz:1 1.0 .... \ + vd=%vd_sp vm=%vm_dp From patchwork Thu Jun 13 12:14:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166658 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp794053ilk; Thu, 13 Jun 2019 06:55:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKFQSldTWxvWX/jtnSA+nBXDbZawHANRJ/pN19HY/5cqc3E7SCTU+gy1Mi6FXCrhqnL3tU X-Received: by 2002:ac8:2b51:: with SMTP id 17mr20087783qtv.206.1560434107982; Thu, 13 Jun 2019 06:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560434107; cv=none; d=google.com; s=arc-20160816; b=gtwPDOzNip3NjXhs0kxOE24SWhQyhFVb5FwH3BlIpEvnpsXrle2Jvuq2EodOcHTk0W x+UXWdqOnNisauXgMmtSl8oaX4blGMp6/Oz8RmIBsnMjvSGkfowA1p7/p3HimxLwFF22 8LIrHHQZ3ixbk8Ees75u6J65UvjUHtSCTHxNUrKNUp0YhnPNMqFJnlEh7n8GM5+55nC3 jsquYRfcK3WvJrzCkFMPgHjIquY1X8ptQXhsrMa7dUN6ZmAupva0Ze4z3+k7tAPE3gj7 xMxmVL/TAth7qweIWunsLcPz0Gk3JVCg4jmos7KnYXaHLtZXLChGZBE9RKhb5W2P8fIp S43A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=gPYLikUR5ZuBlGRaNvlfd3hHYV0xbs6/Y2luBsY5Vwk=; b=sDP3jDNWvQhqbx82Mz+J88wYRTIVUV5a9uZGRQ+ATqORlXjGgns5Xa4RMSGuEoMOXh 6fGc5kGnEUX525kUxGE3GkuBkTPCE2zUF2DNcBwSf46ZrKoIWTyTaOvFkVf8eZ5xT+gU YwQ4B4xpHMyfhjCn2p+MM/SjI5x983p9mG9ySFUTuMakEpiBJcQ8DzuUYLZX/mrd4SeW AxH7wa7/U2bquuR3X0lwLHtY1Oh59FfoH0YXgk7MWHLnqIxifQ0qSxjR3DdrogeqBL11 eK6tMdf6b2IoTQxtgow2Pt8IN2qTkJcSFxVYO/02RItd801BHo6GkV/P7iTSdZW22lxe Gqeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eE4zt0pj; 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=fail (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 w43si1903615qta.166.2019.06.13.06.55.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 06:55:07 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=eE4zt0pj; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbQC3-0004Qf-HW for patch@linaro.org; Thu, 13 Jun 2019 09:55:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60652) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOfB-0000d9-8V for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:17:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOeq-0005xC-2c for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:16:57 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:53262) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOep-0004ok-JI for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:16:43 -0400 Received: by mail-wm1-x342.google.com with SMTP id x15so9958768wmj.3 for ; Thu, 13 Jun 2019 05:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gPYLikUR5ZuBlGRaNvlfd3hHYV0xbs6/Y2luBsY5Vwk=; b=eE4zt0pjr4qx+BpFhkcAeCPI92isygBNkRHQOVy999Vh5uXYpNFftLMZoQmQ5gpdWQ ruSIFkMcyogHbozDht+ZcMyzhZCiDNnhmP51dPEV47m7WfgXtWWJP8UB1/dk3c0JPEhg grRM/dGpilLzXbS9x7zv2GvF3MNwHjeO3b39tCxDPCTLRNizFVemAzB3+XPGOvJBcbfB nHZcSCQq/noQdayFX5fei3IPJiOkIcmd3XZ84y1fp2Ctoe+69IRs76k72L7hFe01DS/K /rw9pg0FbyWHB+ZsXerAkg+0gSE6VJWw+MDwZMPN+b4f+devMO+gJt6BUMHIKoAeL+lo uPrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gPYLikUR5ZuBlGRaNvlfd3hHYV0xbs6/Y2luBsY5Vwk=; b=q6OUFB555oz6k3axINtOfwnwqYE4MOSizlUxBtH83CyxUqZcRZ+aavC/UC5ckehbDQ LDNnWe2T0fSR2qtvAd+V4VFBrjGU1ppX99vd2O8hqn0qRyxr8pqMc62KOF6Njp0Bf8I9 Gb10KwC5zYsJoMNURZCYV41Wwai1wfykYz9P7rFvI0Xj5wEN9kcV0oqnqtiBEcx/4soh c5lafhMvlS6m5klbNW+kk6TwHE+D9gL8v49dFYL4+CVBDGJW1RDQN4Rwpcglju0kChAA bSuMUfTA01WJdsUwloImv/IaNQV+bXgxD82s1q2aDNxJGAXpRWPwsTeLuSVfh+tBRzxS 7Pcg== X-Gm-Message-State: APjAAAWDJj23LGAmoh8r6OJPeZyatM8Lj+0ueelEI9aVIH3G9cg2OITy j8aHwjdqBQ/pcFZyt5Jxas04O5USLsA7uA== X-Received: by 2002:a05:600c:c6:: with SMTP id u6mr3589411wmm.153.1560428126721; Thu, 13 Jun 2019 05:15:26 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.15.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:15:25 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:14:33 +0100 Message-Id: <20190613121433.5246-49-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PULL 48/48] target/arm: Fix short-vector increment behaviour 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For VFP short vectors, the VFP registers are divided into a series of banks: for single-precision these are s0-s7, s8-s15, s16-s23 and s24-s31; for double-precision they are d0-d3, d4-d7, ... d28-d31. Some banks are "scalar" meaning that use of a register within them triggers a pure-scalar or mixed vector-scalar operation rather than a full vector operation. The scalar banks are s0-s7, d0-d3 and d16-d19. When using a bank as part of a vector operation, we iterate through it, increasing the register number by the specified stride each time, and wrapping around to the beginning of the bank. Unfortunately our calculation of the "increment" part of this was incorrect: vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask) will only do the intended thing if bank_mask has exactly one set high bit. For instance for doubles (bank_mask = 0xc), if we start with vd = 6 and delta_d = 2 then vd is updated to 12 rather than the intended 4. This only causes problems in the unlikely case that the starting register is not the first in its bank: if the register number doesn't have to wrap around then the expression happens to give the right answer. Fix this bug by abstracting out the "check whether register is in a scalar bank" and "advance register within bank" operations to utility functions which use the right bit masking operations. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/translate-vfp.inc.c | 100 ++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 40 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 8216dba796e..709fc65374d 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -1139,6 +1139,42 @@ typedef void VFPGen3OpDPFn(TCGv_i64 vd, typedef void VFPGen2OpSPFn(TCGv_i32 vd, TCGv_i32 vm); typedef void VFPGen2OpDPFn(TCGv_i64 vd, TCGv_i64 vm); +/* + * Return true if the specified S reg is in a scalar bank + * (ie if it is s0..s7) + */ +static inline bool vfp_sreg_is_scalar(int reg) +{ + return (reg & 0x18) == 0; +} + +/* + * Return true if the specified D reg is in a scalar bank + * (ie if it is d0..d3 or d16..d19) + */ +static inline bool vfp_dreg_is_scalar(int reg) +{ + return (reg & 0xc) == 0; +} + +/* + * Advance the S reg number forwards by delta within its bank + * (ie increment the low 3 bits but leave the rest the same) + */ +static inline int vfp_advance_sreg(int reg, int delta) +{ + return ((reg + delta) & 0x7) | (reg & ~0x7); +} + +/* + * Advance the D reg number forwards by delta within its bank + * (ie increment the low 2 bits but leave the rest the same) + */ +static inline int vfp_advance_dreg(int reg, int delta) +{ + return ((reg + delta) & 0x3) | (reg & ~0x3); +} + /* * Perform a 3-operand VFP data processing instruction. fn is the * callback to do the actual operation; this function deals with the @@ -1149,7 +1185,6 @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, { uint32_t delta_m = 0; uint32_t delta_d = 0; - uint32_t bank_mask = 0; int veclen = s->vec_len; TCGv_i32 f0, f1, fd; TCGv_ptr fpst; @@ -1164,16 +1199,14 @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, } if (veclen > 0) { - bank_mask = 0x18; - /* Figure out what type of vector operation this is. */ - if ((vd & bank_mask) == 0) { + if (vfp_sreg_is_scalar(vd)) { /* scalar */ veclen = 0; } else { delta_d = s->vec_stride + 1; - if ((vm & bank_mask) == 0) { + if (vfp_sreg_is_scalar(vm)) { /* mixed scalar/vector */ delta_m = 0; } else { @@ -1204,11 +1237,11 @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, /* Set up the operands for the next iteration */ veclen--; - vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); - vn = ((vn + delta_d) & (bank_mask - 1)) | (vn & bank_mask); + vd = vfp_advance_sreg(vd, delta_d); + vn = vfp_advance_sreg(vn, delta_d); neon_load_reg32(f0, vn); if (delta_m) { - vm = ((vm + delta_m) & (bank_mask - 1)) | (vm & bank_mask); + vm = vfp_advance_sreg(vm, delta_m); neon_load_reg32(f1, vm); } } @@ -1226,7 +1259,6 @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, { uint32_t delta_m = 0; uint32_t delta_d = 0; - uint32_t bank_mask = 0; int veclen = s->vec_len; TCGv_i64 f0, f1, fd; TCGv_ptr fpst; @@ -1246,16 +1278,14 @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, } if (veclen > 0) { - bank_mask = 0xc; - /* Figure out what type of vector operation this is. */ - if ((vd & bank_mask) == 0) { + if (vfp_dreg_is_scalar(vd)) { /* scalar */ veclen = 0; } else { delta_d = (s->vec_stride >> 1) + 1; - if ((vm & bank_mask) == 0) { + if (vfp_dreg_is_scalar(vm)) { /* mixed scalar/vector */ delta_m = 0; } else { @@ -1285,11 +1315,11 @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, } /* Set up the operands for the next iteration */ veclen--; - vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); - vn = ((vn + delta_d) & (bank_mask - 1)) | (vn & bank_mask); + vd = vfp_advance_dreg(vd, delta_d); + vn = vfp_advance_dreg(vn, delta_d); neon_load_reg64(f0, vn); if (delta_m) { - vm = ((vm + delta_m) & (bank_mask - 1)) | (vm & bank_mask); + vm = vfp_advance_dreg(vm, delta_m); neon_load_reg64(f1, vm); } } @@ -1306,7 +1336,6 @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) { uint32_t delta_m = 0; uint32_t delta_d = 0; - uint32_t bank_mask = 0; int veclen = s->vec_len; TCGv_i32 f0, fd; @@ -1320,16 +1349,14 @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) } if (veclen > 0) { - bank_mask = 0x18; - /* Figure out what type of vector operation this is. */ - if ((vd & bank_mask) == 0) { + if (vfp_sreg_is_scalar(vd)) { /* scalar */ veclen = 0; } else { delta_d = s->vec_stride + 1; - if ((vm & bank_mask) == 0) { + if (vfp_sreg_is_scalar(vm)) { /* mixed scalar/vector */ delta_m = 0; } else { @@ -1355,7 +1382,7 @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) if (delta_m == 0) { /* single source one-many */ while (veclen--) { - vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + vd = vfp_advance_sreg(vd, delta_d); neon_store_reg32(fd, vd); } break; @@ -1363,8 +1390,8 @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) /* Set up the operands for the next iteration */ veclen--; - vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); - vm = ((vm + delta_m) & (bank_mask - 1)) | (vm & bank_mask); + vd = vfp_advance_sreg(vd, delta_d); + vm = vfp_advance_sreg(vm, delta_m); neon_load_reg32(f0, vm); } @@ -1378,7 +1405,6 @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) { uint32_t delta_m = 0; uint32_t delta_d = 0; - uint32_t bank_mask = 0; int veclen = s->vec_len; TCGv_i64 f0, fd; @@ -1397,16 +1423,14 @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) } if (veclen > 0) { - bank_mask = 0xc; - /* Figure out what type of vector operation this is. */ - if ((vd & bank_mask) == 0) { + if (vfp_dreg_is_scalar(vd)) { /* scalar */ veclen = 0; } else { delta_d = (s->vec_stride >> 1) + 1; - if ((vm & bank_mask) == 0) { + if (vfp_dreg_is_scalar(vm)) { /* mixed scalar/vector */ delta_m = 0; } else { @@ -1432,7 +1456,7 @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) if (delta_m == 0) { /* single source one-many */ while (veclen--) { - vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + vd = vfp_advance_dreg(vd, delta_d); neon_store_reg64(fd, vd); } break; @@ -1440,8 +1464,8 @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) /* Set up the operands for the next iteration */ veclen--; - vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); - vm = ((vm + delta_m) & (bank_mask - 1)) | (vm & bank_mask); + vd = vfp_advance_dreg(vd, delta_d); + vd = vfp_advance_dreg(vm, delta_m); neon_load_reg64(f0, vm); } @@ -1783,7 +1807,6 @@ static bool trans_VFM_dp(DisasContext *s, arg_VFM_sp *a) static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) { uint32_t delta_d = 0; - uint32_t bank_mask = 0; int veclen = s->vec_len; TCGv_i32 fd; uint32_t n, i, vd; @@ -1804,9 +1827,8 @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) } if (veclen > 0) { - bank_mask = 0x18; /* Figure out what type of vector operation this is. */ - if ((vd & bank_mask) == 0) { + if (vfp_sreg_is_scalar(vd)) { /* scalar */ veclen = 0; } else { @@ -1835,7 +1857,7 @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) /* Set up the operands for the next iteration */ veclen--; - vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + vd = vfp_advance_sreg(vd, delta_d); } tcg_temp_free_i32(fd); @@ -1845,7 +1867,6 @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) { uint32_t delta_d = 0; - uint32_t bank_mask = 0; int veclen = s->vec_len; TCGv_i64 fd; uint32_t n, i, vd; @@ -1871,9 +1892,8 @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) } if (veclen > 0) { - bank_mask = 0xc; /* Figure out what type of vector operation this is. */ - if ((vd & bank_mask) == 0) { + if (vfp_dreg_is_scalar(vd)) { /* scalar */ veclen = 0; } else { @@ -1902,7 +1922,7 @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) /* Set up the operands for the next iteration */ veclen--; - vd = ((vd + delta_d) & (bank_mask - 1)) | (vd & bank_mask); + vfp_advance_dreg(vd, delta_d); } tcg_temp_free_i64(fd);