From patchwork Thu Nov 2 01:29:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 740422 Delivered-To: patch@linaro.org Received: by 2002:a5d:538f:0:b0:32d:baff:b0ca with SMTP id d15csp598423wrv; Wed, 1 Nov 2023 18:50:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGf5FPHHJ4NM1zu8kyj2X86DjosSJx6tyg0XMLAcqJoyDbRFMTHNJQ8cnNRbmdVQViYd6Z5 X-Received: by 2002:a5b:88b:0:b0:da0:3c5a:e1bd with SMTP id e11-20020a5b088b000000b00da03c5ae1bdmr17475954ybq.5.1698889836807; Wed, 01 Nov 2023 18:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698889836; cv=none; d=google.com; s=arc-20160816; b=Exku/a5YXybLW8NT7wcnDah5vgkvNd/Xwnt89lFMzfoyFoxwoUY2o+8yJU72IPo691 dwuunMtQxpW4hm2rFNq7FwAp81HE6HchQfr+bVgSNG3Rrj+hjpJknklOIb07TAgBvuUG YdbXxh8lh/upf8XJIHsONbSwJebFrE2yiIoW90+FKXYN+7ealVYD6Gb/TEY8mcfjADVU +vTBv/+6oFqIxYG5qvyI3hdh3rpsl24PNUpjVVn7qHJd+L+NfK4jeJk1B4WB985XOGJL Hm9G4n5iQoN9Ngyj3kO52g70AuMzvidlAngGwm4TG86HPObm6dd9So+6gDbMdZ6/QAi5 cVIg== 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=Z97fFY7Wn9zj1ZAonEuX35kI8FxyV8+JUDBvaH54V24=; fh=f2WZoDMBYjCKWIIOoPI+rQtxlv4fmOm4u+dLdQLqpOk=; b=ioiKErqRnS6XL5NmN4J2/glnG8Us/NISY175FFuo0CAN6OwxbjnuRsPjOKKfWfkFhd lTkqAYL33H3ynvO9fT/Q9T4gQSm/7Zd8a6zr9xpQFFMKNDf+UIM/ZrvvSnsb1ik3/TxS msIqy2rK7m0n5IPeK8372TDb/SRUZka2xsipDtW9Z8AXpJEnja+MyavKOC2YQ4gOG6zO 30A8C/UzTtaeKa24r3KtZLtTMEzKIcXp92WL673Dwg0WtiaJc3CA+sN82I5feW3+m84E pTxAsGacUa9rfTuswDpIunZ3cdkHdajuehZz6pBq03ualgHSuKY9J4tsVDDvm97q25kM G6mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g2wQE7J4; 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 e18-20020a0cf752000000b00670bcfd310bsi3687253qvo.602.2023.11.01.18.50.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Nov 2023 18:50: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=pass header.i=@linaro.org header.s=google header.b=g2wQE7J4; 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 1qyMbl-000749-Ge; Wed, 01 Nov 2023 21:34:53 -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 1qyMbA-0006YT-3B for qemu-devel@nongnu.org; Wed, 01 Nov 2023 21:34:17 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyMb8-00022C-4d for qemu-devel@nongnu.org; Wed, 01 Nov 2023 21:34:15 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1cacde97002so3130785ad.2 for ; Wed, 01 Nov 2023 18:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698888852; x=1699493652; 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=Z97fFY7Wn9zj1ZAonEuX35kI8FxyV8+JUDBvaH54V24=; b=g2wQE7J4/4/rUswXZYAM8IzBJaHolz8LrpA/6Id0hKZ6lzFIPD14SAbbo7sBULTlpe 3yVQJbgu1owcUyZ8Ix8cKbaqSBcq7sCcIjvKErdMC3W0CR3U+9q6V4s+90zbgCRbMP0H tU3qroAGR/el3Zax2d3wBhMv9mrOYJe1B8OyJiMy1DjhTPr5jsukbYo66MEaVhPh81Lj S2VvkKm9aeKxQr/8pRr/8mnPbVqTfjnQy1uvSMso1IKQafq1qkGFfHWVPwkbTHzjuC9u S2xKNMl7pKFu4ds9Yl29RvBATqru3TDGxBYl+d7iFhUm1GEbBGha+ol98oEzq9/Mf9Ic VLpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698888852; x=1699493652; 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=Z97fFY7Wn9zj1ZAonEuX35kI8FxyV8+JUDBvaH54V24=; b=HiscghbQF+04/p+T0IUk19ZpcUmMEvtVN0l81BniDpsNJjIcAf5sba1f/u1WshuYu5 4/TGwZgNp6ClQCOpAnF6A1q/3T4f68pCLaqQ511xbiAc17nXGOBG0+9N4XUypgnotWog MTcBG5BMxJ57SnLQybUxmiC4gaDsfDCoU2aJin9Se4cnh2Kw3K8OJI36ZcEIKbUWFiz4 m27YE0bF7ZJfYsGWdGDslVubdbbFSP2Gvbo2tZGmizwzP8a7a7tOvu+4x7P1pavv5Y0Y yLiSMB5gGggyQkGyHO3VyGh93DbGTgfj53LMaIhf8nJ9hjDPdsGRQFKA2FHjciBHnLEy cnSw== X-Gm-Message-State: AOJu0YwRXHbo5wQLZg/zACtGzOfpopSCWdc9lFTSjcifVh8U4sTMr1eM aqAzkX3Tip4XXlJmS6/SkB7NZiMbvD7vyTX0KGs= X-Received: by 2002:a17:902:f550:b0:1cc:62d0:6008 with SMTP id h16-20020a170902f55000b001cc62d06008mr8882741plf.55.1698888852662; Wed, 01 Nov 2023 18:34:12 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id t2-20020a1709027fc200b001a98f844e60sm1918125plb.263.2023.11.01.18.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 18:34:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH v3 64/88] target/hppa: Implement HSUB Date: Wed, 1 Nov 2023 18:29:52 -0700 Message-Id: <20231102013016.369010-65-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231102013016.369010-1-richard.henderson@linaro.org> References: <20231102013016.369010-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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-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 b3c961b50d..02798aa105 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 4bcfc94b1c..29b49c6cf4 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 f564aea8fb..2f1333b91c 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2804,6 +2804,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) {