From patchwork Wed Oct 18 21:51:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 735100 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1226073wro; Wed, 18 Oct 2023 14:58:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGk6f5MBreSJ2jMhTb8DooqTqd2u7XPryKtTCpyBAmOH3MXIM7mF828QIVPy5dGyD/sp6BP X-Received: by 2002:a05:620a:469e:b0:775:937b:c594 with SMTP id bq30-20020a05620a469e00b00775937bc594mr455996qkb.58.1697666334455; Wed, 18 Oct 2023 14:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697666334; cv=none; d=google.com; s=arc-20160816; b=fJNS8+xRShJjAtunoCbve3cw/hevLAB4hlA5zwRGSXaI2ijaNHUY/9NUyNdW8iKdZ5 leBzLaCz9eylsOAqtoB3e//Txb8yDxr5qpr8ess0OfnzCaeaRev/iSdFQFtUGTQIB7Tz cGwZLyGUX2dSUY6x7X1zIAfZe6+96PdfZ+GrCoThioRXgnIOKsXOcMauVNzvNTr2EaGE mz40HOre1c0bRclnOw8p4G+lPtxSdHEvFzdmybm2E7YdKuB721ZpuSw6HSOvJdGlctuD dt2pkO169LLO+H3qoX9LkrFYkgv2H3ux0j5woOCfV6LqY6bkf2yxenzpjvpG9UPOYVo3 0NhQ== 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=CAcoAZN0zZMn9SMNjn5rzCUBcFL8BPxCVl2F5+s0D30=; fh=f2WZoDMBYjCKWIIOoPI+rQtxlv4fmOm4u+dLdQLqpOk=; b=vPPoT3W7Ft5Vw+18F65Wx8xaD6b4pWadc0qSTbvYixYgDiQKeCOmI2/PqT+g9tikxF ePAoWKZKuJJ7IYJSvp/oCXdmwZ/gmMZSukmfiKfg8YBefAhtWN+eWIwyEnU1AXcsbiDM ktv5bT1pt4OToI1R2wVAPCKsIjIYg7ms2SaXPctyUrscKBwkjUjVbpNppLjHTg6/uOja su7IxIy9kutOC3zv7E6AinWWaucKuS3EaPCnv51EEZurwbCfXnJJZ/OCvSpTYtovVdXy 1aSLKjtgj47gRQVyMhcEPJh7eLSXeR+GnsD6PNXLd0qxpmCnidH+cUrMuImoctkxoNyi CPIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iYL1p3Kv; 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 b17-20020a05620a089100b0076cb7c7d9d1si583630qka.637.2023.10.18.14.58.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Oct 2023 14:58:54 -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=iYL1p3Kv; 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 1qtEVi-0002EN-Pn; Wed, 18 Oct 2023 17:55:26 -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 1qtEVg-0002Da-Q3 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:55:24 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtEVf-00054H-5t for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:55:24 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6c4d625da40so5051105a34.1 for ; Wed, 18 Oct 2023 14:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697666122; x=1698270922; 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=CAcoAZN0zZMn9SMNjn5rzCUBcFL8BPxCVl2F5+s0D30=; b=iYL1p3KvUuZ5gg45XF3bNb8T81y14Yse/85G3cvAg2q8l9IE37E3X5SfqK0tHeBQ1+ Z80BGaeNAJWmPHoRAdVsA1lEF4HrtGWXFXES3/NEazISocKtix16YtOZM7JQsxIRSmBl 58wUk3Uid21p2xxH53fdZMxNqR6q/fIRPZ50Bzcqv/PHOI3B4xO/1nkim3gZwnKFFPIW TjLFDfVubdyC7KINR+Jzh7VTanrtA7bROYSQdOGwZ+/NWE5bqMo1wnAKqLg2jX0t8LJS mfbCI+P+0eHAtEeCvwZfBEB8zJDGRkNSsCXWs+fg24AIPzI4xy4m2JPr7TK47m6/D01y wJSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697666122; x=1698270922; 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=CAcoAZN0zZMn9SMNjn5rzCUBcFL8BPxCVl2F5+s0D30=; b=h92G1EBNsQoDvL48kVSZF/2AG8KFolpEA+Hfu+9VkFifBU6HojfTj0C1Rm7oOBNZ+/ 83pVjEeP1UfK5+S1f5+30Atyf1Rmi28n2h2NF6mjOWLwEJDrciQd47H3/h0fe4TZUAC6 8puRcIO65JWwFFQoBdYTE9ouplC12UMlKS/L+RzHYR/rhlu7vidQcvNrybB8QCOoL2rs nStaORjjj5GFIJ+iUqP4EYCyRcnOARmT3MNm96XQ5eUOxmQcOnNiCQq/HWlgyZnWKADk gHNGfL9f0HtP7sdqoICcmKINFST6HmgXHyNMyATf1+pVnE2Ng0/Bie/NIWFGic/anEKq YuFg== X-Gm-Message-State: AOJu0YwtGzmvoMYIk1ycyy0zKZiAxM8vhhLWoptY7AJ78qn0UO+PBs5M 9vcpMem83SkTMJesinX5aqI+oGKwvN1n5sgm8IE= X-Received: by 2002:a05:6830:13d0:b0:6c6:4843:2abc with SMTP id e16-20020a05683013d000b006c648432abcmr566384otq.18.1697666122038; Wed, 18 Oct 2023 14:55:22 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id r15-20020aa7962f000000b006889348ba6esm3796263pfg.127.2023.10.18.14.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:55:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH 52/61] target/hppa: Implement HSUB Date: Wed, 18 Oct 2023 14:51:26 -0700 Message-Id: <20231018215135.1561375-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018215135.1561375-1-richard.henderson@linaro.org> References: <20231018215135.1561375-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32a.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 bbf216fcde..97d27cb2a9 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) {