From patchwork Fri Oct 20 20:43:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 736315 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp502414wrl; Fri, 20 Oct 2023 13:49:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfBVA3EKJxsHt+R13Gw4FoxBjfz85R6pvrbZnLdHgYRC16OBoL3odRBbCqHcmD0DhT+bVQ X-Received: by 2002:a05:6214:1c43:b0:66d:182a:c083 with SMTP id if3-20020a0562141c4300b0066d182ac083mr3455946qvb.9.1697834981627; Fri, 20 Oct 2023 13:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697834981; cv=none; d=google.com; s=arc-20160816; b=h2/HPulf1GLBCTUfYNaMtaqeUCSWjIQT229JXsRAIKlXNv8eFrczMKT5E1hQehfMaj 30z+GjiQ1y2tMo3VfRHv8VTBk54h917bbP+8mpL3CPnkLuPykXwJ4uKcZ1wrE2Jpf/Yi JO+yh2mPjiSUHRptwYBanrzRuVapG2c0F3/aWY2VadjJlOhSQb4dMtSF2JXpvm2uz+p7 JQ/8TzVMe6lZmAsmqpqkUVPwB9gCJmtsOvNTc/HlHaJuEp3d+1XA7jCoJf9EpxOseI3u lxITiv2JM+bLsKFho2fJkKY420LTntVA/epwxz8DKd3SJs3Q0rwWXNbOQnrxZF97fX/u wKNw== 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:cc:to :from:dkim-signature; bh=m2B6dMamMnRVER/FMmJuOoUUmNaPsvlpsYZS/xeL1qA=; fh=f2WZoDMBYjCKWIIOoPI+rQtxlv4fmOm4u+dLdQLqpOk=; b=mLl+9aC21dHSZ5ZSn13+ppF8QNz/IHMNPu9oFXK92v/G/AE4OvouKJEkUy/KavG500 vmeFSbPoAOpIpRHtnGtUd60aMWWPDg5kRUStXMnkhJJuH1JG3MvHD1TQQZkSrCtrWyQR 2hoL38wOTMh7ppEsfS9vglLXjTZxrhTpyQJDFsMT2GZ8/P5qwtBAiIL3Sb4ksMliahhS d50odRHA1IMp2oHDiQr9DSNwDC5UkNHPiOo6PQK6YwHCl2BPerokqNZxfxLHSatLDw2I vr52uObE4FElQabURxzTZWXTAfEmJtMWgljABRhXXO/4xTYKLD38BkaBbYE51hVAA/+M cTgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ieUUD//7"; 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 w21-20020a05622a135500b0041cb481b92esi1855134qtk.388.2023.10.20.13.49.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2023 13:49: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=pass header.i=@linaro.org header.s=google header.b="ieUUD//7"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtwOz-0001yX-Kr; Fri, 20 Oct 2023 16:47:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtwOx-0001tm-O5 for qemu-devel@nongnu.org; Fri, 20 Oct 2023 16:47:23 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtwOv-0001C7-TU for qemu-devel@nongnu.org; Fri, 20 Oct 2023 16:47:23 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6b87c1edfd5so1109407b3a.1 for ; Fri, 20 Oct 2023 13:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697834840; x=1698439640; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m2B6dMamMnRVER/FMmJuOoUUmNaPsvlpsYZS/xeL1qA=; b=ieUUD//7IfQJ2odz+gSHb2wXU3BH1Q0JrOl9J7HWl6BkHbQ1NLrX+/y0+8YcycUaV7 /5cuXvutvTZ8gkTU4icXbjAqs2HS1TIZuxoPPVvc63gDKagnsGXNAdBLzObWWtcvdMWd 3oX3yq7c5P15WLiVL4Kl/lj/hg3+MserEAoAzIdb8aDLEomJ9Sx3jKkza++2/7K2UNwe 0jKveXWOe6nAdYPH472yNlIWBXFluwQQRN97kNXqzSK0Em9Sm1a0CLqU4jZ5AivFcrr9 Wy9hrrYUIzOTK+CvSP5H5lMNoqk+A3AAJjQD+qlaV3c9Cm3F+T2/4ktj731Y9qEFnA6+ PrOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697834840; x=1698439640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m2B6dMamMnRVER/FMmJuOoUUmNaPsvlpsYZS/xeL1qA=; b=QmgJ4118kkHldChEpGYzHzz6w+UXI7j9TqGjZzVVFmbdxiURsI0ZDMXVFxeONdknEY BriLMHEIFQ4REW0BNt2tQsZEz/uEWHzMfXhQjn5LZKYdKVAVI56IPa30nm2SEDCQ0ziO 4eA0/NegkPD0JQNTPweul4fIugxXCrRpKqtcWq5SGFT9aQ5SUzNU+KuXYh+lJCPPYQwy OoLlyTt4vh5tk8F3lVMDRPEImtKYVAvgsK8qsKmoYbGmjxoB6OgMO/qwE43GHDXgKDLQ xyg2JB6A/vP4S85OzUbMIGxFaVI5fhR4TwIAT055/xdMzgP2jBckclEvrz5ntOl7loLB UrpQ== X-Gm-Message-State: AOJu0Yz2GRDiseQtiFWbVJoB3sk6lF4dPdqhGSYoJtDvXelTYjL4hmAq 5WEGG5IW6i5PeS91eFNdUcJGjL/92mFntWQRcro= X-Received: by 2002:a05:6a21:66c7:b0:163:2dc7:d077 with SMTP id ze7-20020a056a2166c700b001632dc7d077mr1415795pzb.55.1697834840189; Fri, 20 Oct 2023 13:47:20 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id u7-20020aa78487000000b00694fee1011asm1946775pfn.208.2023.10.20.13.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 13:47:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH v2 53/65] target/hppa: Implement HSUB Date: Fri, 20 Oct 2023 13:43:19 -0700 Message-Id: <20231020204331.139847-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020204331.139847-1-richard.henderson@linaro.org> References: <20231020204331.139847-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- target/hppa/helper.h | 2 ++ target/hppa/insns.decode | 4 ++++ target/hppa/op_helper.c | 32 ++++++++++++++++++++++++++++++++ target/hppa/translate.c | 15 +++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/target/hppa/helper.h b/target/hppa/helper.h index ff2695797e..99486f4cf8 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -16,6 +16,8 @@ DEF_HELPER_FLAGS_1(ldc_check, TCG_CALL_NO_RWG, void, tl) DEF_HELPER_FLAGS_2(hadd_ss, TCG_CALL_NO_RWG, i64, i64, i64) DEF_HELPER_FLAGS_2(hadd_us, TCG_CALL_NO_RWG, i64, i64, i64) +DEF_HELPER_FLAGS_2(hsub_ss, TCG_CALL_NO_RWG, i64, i64, i64) +DEF_HELPER_FLAGS_2(hsub_us, TCG_CALL_NO_RWG, i64, i64, i64) DEF_HELPER_FLAGS_4(probe, TCG_CALL_NO_WG, tl, env, tl, i32, i32) diff --git a/target/hppa/insns.decode b/target/hppa/insns.decode index 88248ed3e2..1830b06c76 100644 --- a/target/hppa/insns.decode +++ b/target/hppa/insns.decode @@ -214,6 +214,10 @@ hadd 000010 ..... ..... 00000011 11 0 ..... @rrr hadd_ss 000010 ..... ..... 00000011 01 0 ..... @rrr hadd_us 000010 ..... ..... 00000011 00 0 ..... @rrr +hsub 000010 ..... ..... 00000001 11 0 ..... @rrr +hsub_ss 000010 ..... ..... 00000001 01 0 ..... @rrr +hsub_us 000010 ..... ..... 00000001 00 0 ..... @rrr + #### # Index Mem #### diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index a230a3a0c3..ece523bea0 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -409,3 +409,35 @@ uint64_t HELPER(hadd_us)(uint64_t r1, uint64_t r2) } return ret; } + +uint64_t HELPER(hsub_ss)(uint64_t r1, uint64_t r2) +{ + uint64_t ret = 0; + + for (int i = 0; i < 64; i += 16) { + int f1 = sextract64(r1, i, 16); + int f2 = sextract64(r2, i, 16); + int fr = f1 - f2; + + fr = MIN(fr, INT16_MAX); + fr = MAX(fr, INT16_MIN); + ret = deposit64(ret, i, 16, fr); + } + return ret; +} + +uint64_t HELPER(hsub_us)(uint64_t r1, uint64_t r2) +{ + uint64_t ret = 0; + + for (int i = 0; i < 64; i += 16) { + int f1 = extract64(r1, i, 16); + int f2 = sextract64(r2, i, 16); + int fr = f1 - f2; + + fr = MIN(fr, UINT16_MAX); + fr = MAX(fr, 0); + ret = deposit64(ret, i, 16, fr); + } + return ret; +} diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 0d72c96fd5..63c6a28cef 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2776,6 +2776,21 @@ static bool trans_hadd_us(DisasContext *ctx, arg_rrr *a) return do_multimedia(ctx, a, gen_helper_hadd_us); } +static bool trans_hsub(DisasContext *ctx, arg_rrr *a) +{ + return do_multimedia(ctx, a, tcg_gen_vec_sub16_i64); +} + +static bool trans_hsub_ss(DisasContext *ctx, arg_rrr *a) +{ + return do_multimedia(ctx, a, gen_helper_hsub_ss); +} + +static bool trans_hsub_us(DisasContext *ctx, arg_rrr *a) +{ + return do_multimedia(ctx, a, gen_helper_hsub_us); +} + static bool trans_ld(DisasContext *ctx, arg_ldst *a) { if (!ctx->is_pa20 && a->size > MO_32) {