From patchwork Mon May 30 16:05:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 577233 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:330b:0:0:0:0 with SMTP id f11csp409202mag; Mon, 30 May 2022 09:54:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbqGA0nt1LMDoQvOI18W4OK/NypXK3QdyuG8/LXr8NpVdY7GkKoWY0e+c8+cHmRkG7TP0w X-Received: by 2002:a37:655:0:b0:6a5:e7f7:271c with SMTP id 82-20020a370655000000b006a5e7f7271cmr11015667qkg.473.1653929678563; Mon, 30 May 2022 09:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653929678; cv=none; d=google.com; s=arc-20160816; b=TuxKR3eWL2nCuenHbrZHr21TZLSI68s/Qj8Z3whj06gbSzRPUneApZ0ZY8fvbumdLO 0x/6c85WgGY5/Ho2Lh23XXb2VzjO7UYpgWHMpdfQcbjABSlAxly8gxXht3BsgC/oesAO 5rW41f/A1o/kehsUUECFeK+zDxyT/YTBhWjCJaSVKKAy+i4gS4zsSmxcwzbc/D9f8Ywl tGnarrdUWGSusa/rj23RHPatXBWV7gBqkp5GuCe+jxvSG1Dqi6/TIH0PHMUXJZKBkDNx /8fgkkruvLZNYnllcuCIggAU6PXCKBbMTPy6eywteJCU9ww5uCHf5jMMFlGfYLr/AZE0 35wA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UKXoP1U+BIwA0P27wZhDfy2XM5fzL0S3w/Fk9L/JDNI=; b=wIpcTQ9ZaNEDbnFE/2AAI66NbtyNUXJw4RynATa3IccyucTqJDZPX6CEn7joQJxsTS rEJGGqltwnodJdyXObwn8ouzfnZ5K0aNnBkxziAvmzdhwwXsYsCwaEktioZHWGqruvdL TRfM0gvyCrHC+08+N4JlmNFVWBwk3kTnd+Tx7P9sz9+IWHwLFOkS7EHUHrFeCCWw7Jc7 aOfXEgbvF/RJjT7rheY1o5AJD16f/yD6t8w/K73v4mSMbaRut90qvG1kX3camhcDdxdO qTpAzRa7rkwgubspDmqlYEz+TYjPV6EFXG1Tiu5QE/7BY9v5PUxu6qydhyv97QM/zh0t MzkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x4U1LnAQ; 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=pass (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 a16-20020a05622a02d000b002f935e78950si7509812qtx.100.2022.05.30.09.54.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 May 2022 09:54:38 -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=pass header.i=@linaro.org header.s=google header.b=x4U1LnAQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvif8-0002Sa-4g for patch@linaro.org; Mon, 30 May 2022 12:54:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvhvr-0003dz-DJ for qemu-devel@nongnu.org; Mon, 30 May 2022 12:07:56 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:42544) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nvhvp-0007Ju-Ov for qemu-devel@nongnu.org; Mon, 30 May 2022 12:07:51 -0400 Received: by mail-wm1-x32e.google.com with SMTP id l188-20020a1c25c5000000b003978df8a1e2so4642191wml.1 for ; Mon, 30 May 2022 09:07: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=UKXoP1U+BIwA0P27wZhDfy2XM5fzL0S3w/Fk9L/JDNI=; b=x4U1LnAQTAxc6uGISlvYQlio4GpSi1klsoAKd068EP9AOFtYtgFRjGjf2UEzKHg8Ed 2eKU8xIq2YhNAsHoW8wWG4Dt38xIwmCtAIIynPE2+7mQiUHP0CKT/paCxpk0tyFc6C/G +e9VxjM7cr+iY/c4oNflDSyKGh88keLV1LTG9LZyi7XjHr35DEg7XgsuKIVo87NSSSjx lcUdasG1QCtDpXT0f3dqb3KhJt9/wkW9vhFA4zPPC6T7x5sIyc+TUOGFk8Opj10fDnR7 LWvYez9JZGGT1Gymf69K4IFgtahH6sjampbdWIjFBT/Xl8Iv0lhUfzsnbaSUlKGwfsDu 6XpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UKXoP1U+BIwA0P27wZhDfy2XM5fzL0S3w/Fk9L/JDNI=; b=pINWBHw9My3d/YVbLMuPUfxTxjOMx00HMVwPdOVMc5odrmseDYkqA6WiqSFZ5CCXLA 94VfNzR7bnBOkSXP2jAcRWJ9E1HDthW3rCUtrQipMZRN1rccEZ5o0oEk5m5ebF7ocMAW UmQJJxaOKzJSy2zmF8VhcgebfT1hspJW6xI/pfdoYLS+HXGQG+XQNjmW4YJT4ZvjfEbV Rb3NUBDQm1d5QiSVwTeEOu1sH2jfkY8qEY8n5rg0f4rRygEV12+yalXUk9bg4yEbUjLc CT9AcPI6cCKQ0Sq9ISo2cuBkxu1eiWkvGpT+0/6edkdOVb8+kDvKik3EiSgKJ+HXMOlT 5qPg== X-Gm-Message-State: AOAM5332mZ1wsNgCb6gx5Uu1um740f6TiZd9wS/ihL5zKxcplbTjlRqy re5S1WzH7O/H3Su96n+A+kb6Vxmf6yYbQA== X-Received: by 2002:a7b:c2e8:0:b0:397:4a00:6955 with SMTP id e8-20020a7bc2e8000000b003974a006955mr19770618wmk.74.1653926868222; Mon, 30 May 2022 09:07:48 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi12-20020a05600c3d8c00b003974b95d897sm10232152wmb.37.2022.05.30.09.07.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 09:07:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 048/117] target/arm: Introduce do_shift_zpzi Date: Mon, 30 May 2022 17:05:59 +0100 Message-Id: <20220530160708.726466-49-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220530160708.726466-1-peter.maydell@linaro.org> References: <20220530160708.726466-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Share code between the various shifts using arg_rpri_esz. Signed-off-by: Richard Henderson Message-id: 20220527181907.189259-46-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/translate-sve.c | 68 +++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index f15e9a30b39..c7c16863c0b 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -900,20 +900,39 @@ static bool do_movz_zpz(DisasContext *s, int rd, int rn, int pg, return gen_gvec_ool_zzp(s, fns[esz], rd, rn, pg, invert); } +static bool do_shift_zpzi(DisasContext *s, arg_rpri_esz *a, bool asr, + gen_helper_gvec_3 * const fns[4]) +{ + int max; + + if (a->esz < 0) { + /* Invalid tsz encoding -- see tszimm_esz. */ + return false; + } + + /* + * Shift by element size is architecturally valid. + * For arithmetic right-shift, it's the same as by one less. + * For logical shifts and ASRD, it is a zeroing operation. + */ + max = 8 << a->esz; + if (a->imm >= max) { + if (asr) { + a->imm = max - 1; + } else { + return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); + } + } + return gen_gvec_ool_arg_zpzi(s, fns[a->esz], a); +} + static bool trans_ASR_zpzi(DisasContext *s, arg_rpri_esz *a) { static gen_helper_gvec_3 * const fns[4] = { gen_helper_sve_asr_zpzi_b, gen_helper_sve_asr_zpzi_h, gen_helper_sve_asr_zpzi_s, gen_helper_sve_asr_zpzi_d, }; - if (a->esz < 0) { - /* Invalid tsz encoding -- see tszimm_esz. */ - return false; - } - /* Shift by element size is architecturally valid. For - arithmetic right-shift, it's the same as by one less. */ - a->imm = MIN(a->imm, (8 << a->esz) - 1); - return gen_gvec_ool_arg_zpzi(s, fns[a->esz], a); + return do_shift_zpzi(s, a, true, fns); } static bool trans_LSR_zpzi(DisasContext *s, arg_rpri_esz *a) @@ -922,16 +941,7 @@ static bool trans_LSR_zpzi(DisasContext *s, arg_rpri_esz *a) gen_helper_sve_lsr_zpzi_b, gen_helper_sve_lsr_zpzi_h, gen_helper_sve_lsr_zpzi_s, gen_helper_sve_lsr_zpzi_d, }; - if (a->esz < 0) { - return false; - } - /* Shift by element size is architecturally valid. - For logical shifts, it is a zeroing operation. */ - if (a->imm >= (8 << a->esz)) { - return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); - } else { - return gen_gvec_ool_arg_zpzi(s, fns[a->esz], a); - } + return do_shift_zpzi(s, a, false, fns); } static bool trans_LSL_zpzi(DisasContext *s, arg_rpri_esz *a) @@ -940,16 +950,7 @@ static bool trans_LSL_zpzi(DisasContext *s, arg_rpri_esz *a) gen_helper_sve_lsl_zpzi_b, gen_helper_sve_lsl_zpzi_h, gen_helper_sve_lsl_zpzi_s, gen_helper_sve_lsl_zpzi_d, }; - if (a->esz < 0) { - return false; - } - /* Shift by element size is architecturally valid. - For logical shifts, it is a zeroing operation. */ - if (a->imm >= (8 << a->esz)) { - return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); - } else { - return gen_gvec_ool_arg_zpzi(s, fns[a->esz], a); - } + return do_shift_zpzi(s, a, false, fns); } static bool trans_ASRD(DisasContext *s, arg_rpri_esz *a) @@ -958,16 +959,7 @@ static bool trans_ASRD(DisasContext *s, arg_rpri_esz *a) gen_helper_sve_asrd_b, gen_helper_sve_asrd_h, gen_helper_sve_asrd_s, gen_helper_sve_asrd_d, }; - if (a->esz < 0) { - return false; - } - /* Shift by element size is architecturally valid. For arithmetic - right shift for division, it is a zeroing operation. */ - if (a->imm >= (8 << a->esz)) { - return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true); - } else { - return gen_gvec_ool_arg_zpzi(s, fns[a->esz], a); - } + return do_shift_zpzi(s, a, false, fns); } static gen_helper_gvec_3 * const sqshl_zpzi_fns[4] = {