From patchwork Thu May 2 16:55:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 794115 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp353491wrr; Thu, 2 May 2024 09:56:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV9XlPAOpLH8/Jl2EkmU7Ao9UeW8kkvBmrW4VEdZNYdigsF4ktGIA9v3IwMmAvXJBlID58t50/nB9hEnepE42lq X-Google-Smtp-Source: AGHT+IEKBj6Erj6fRFNJwROuCAp2g8BEFNOu8Oq0+FfmRl7kdn2r73KkYABc8rgRahwSoxXm6MTO X-Received: by 2002:a05:6871:5213:b0:23d:6440:fd7d with SMTP id ht19-20020a056871521300b0023d6440fd7dmr528180oac.19.1714668977847; Thu, 02 May 2024 09:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714668977; cv=none; d=google.com; s=arc-20160816; b=yxIfcK/1eUCxmbreQyiof6H32nc/7ndQLFZBgtbwH5Ehvs+22O6h2i1vlXCWeQ7eX3 dlMiw7Lxm1tQFSvOU7Aqr1NW3A9A92XimWV+dnrWU9bLGlYoxjbQYgH6SiTl7DO3Elv3 ti2qHjsxajpI8HVhoSbNoCUvgc6IjrANO3uJ6b9egOtjKc3QWeMIjC42JB9avWFoAdLr HlmA/YttTQ0X1SCKZizrtiDfXfdMjWHdQ21AMI07FqYa7mG6g4jAguTgg04ZTkLP/c09 Y11jVLapfB+nDSfJxM6wUXkMFyRa8igbw+JzbVS+Ta9AUVksFISXw06Ry59ICXKAg1+M EeOA== 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=jgzvSrD01ShseB2w23SZ5Lugpibg8re+4HHYOhUXpgk=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=DUh36xEAFOb/oOmTy5Tnz/SXQpxpFmLF8zM/Mjqmpz4X66qXN0rNzlQYVUrWLoR4hy Yk+h+7Sl500kRa/5vGIPqdwgfSobXSTpJSOG59LD0whInRYC0W/xSeCir0sdQzcbcZYA VSbU3MLuYa70MuCD0ZXJepBXBPPiYDeFueig0P+A6D7Ba1Y/QHLS6IBl0Vpo9nKPqMj/ mN5Ay57HchSBGtOJTVu7PzL5XlTi2SZYHJXfydj/zCI1uO26J+3uigmEeCW703BFr4hO S9++XE8CjpYbWfeP+4Ji8KcIvEt198gWkAkGjhZ64fNwQaUFQfuQ+IEOey3GMHh1PeOC tx9Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nMKwkHNU; 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 u10-20020a05620a454a00b00790fc2e8fbasi1490858qkp.195.2024.05.02.09.56.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 09:56: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=pass header.i=@linaro.org header.s=google header.b=nMKwkHNU; 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 1s2Zis-0001Az-BP; Thu, 02 May 2024 12:55:54 -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 1s2Zia-0000uB-U2 for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:37 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2ZiY-0005vD-65 for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:36 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6f3f6aa1437so4474541b3a.3 for ; Thu, 02 May 2024 09:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714668930; x=1715273730; 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=jgzvSrD01ShseB2w23SZ5Lugpibg8re+4HHYOhUXpgk=; b=nMKwkHNUmt2Gj+/l2gNvzY4+Ls6pPx8dF5JMf4lUTtgSwqkP4WfUbirotWD5dXkUOd e1xOjZ8HFeNkOyxAUlFwdfbMteqAcjMWSQnzhnVCAkUOVcztMsuafpXjZxx3gJY47sM4 AGZZhLOvyRBTilBFZHTkNRqkjsQQ6LVYIe7U2bBw4OexZae5qXVitUbK2lu2aBhxy2C3 pHhf2x04Mg0acZZFD3JRHvhnOwT0Yfaauh8+a/cq0b15K7SO2kL5EUeNAR666qnymZzJ 8mrRmT9lF3Wfe88ZJHa0cr0hzSXT9TNhUEyrdnHvqJDEm8JPvuZ+Buc/sUKkXWQ4Q3K4 p7Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714668930; x=1715273730; 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=jgzvSrD01ShseB2w23SZ5Lugpibg8re+4HHYOhUXpgk=; b=K+wJKfiokr5I51fdpskERCHyw044jtu8Z/1SEDaTYaOkZWoqb5u8nQ1XiLoUoP4z9W O4VOUXVtwPhRxxoZDHWIXoleMoZNJ6xs2ddXAWoHjWHlYo6GPbjVb1pnsThXQH1uL8wP O682D0jb7uXwCg0JFnolqLNM+4iUKAoX18pCLGiBqjEulBcxkeJ4g3xw1UThrq9onZHp +gZnf63MR2bAOnks4AFY/kq2C3Hrsx4mWSN5FbQINSADLBUU6kr0jnFs8jSUgkgBz2/7 8IF3+ZsJmWBOdXfKhVFhy/yyJM1YE1m2FfaNF9Z/voqsKZmIjigHssPT/0ZEfwFGK76u n/Xw== X-Gm-Message-State: AOJu0Yx5KfTDTAtwwiz6VZwWar2zatYUeERT1pkojnZs5YzWShKk2njf x1+Q0USWimXhobtpjpDL8H4oynLLEZVqDbsvKBCek6rosbD+LHcmWy7LHs6Uz1k/5u1meaZRPDh z X-Received: by 2002:a05:6a21:2d8a:b0:1a7:4944:d49 with SMTP id ty10-20020a056a212d8a00b001a749440d49mr409898pzb.0.1714668930627; Thu, 02 May 2024 09:55:30 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id j13-20020aa783cd000000b006eb058b2703sm1464598pfn.187.2024.05.02.09.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 09:55:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 1/7] linux-user/sparc: Add more hwcap bits for sparc64 Date: Thu, 2 May 2024 09:55:22 -0700 Message-Id: <20240502165528.244004-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502165528.244004-1-richard.henderson@linaro.org> References: <20240502165528.244004-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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 Supply HWCAP_SPARC_V8PLUS, HWCAP_SPARC_MUL32, HWCAP_SPARC_DIV32, HWCAP_SPARC_POPC, HWCAP_SPARC_FSMULD, HWCAP_SPARC_VIS, HWCAP_SPARC_VIS2. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 48 +++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f9461d2844..14f08b64a1 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -968,24 +968,44 @@ const char *elf_hwcap2_str(uint32_t bit) #endif /* TARGET_ARM */ #ifdef TARGET_SPARC -#ifdef TARGET_SPARC64 -#define ELF_HWCAP (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | HWCAP_SPARC_SWAP \ - | HWCAP_SPARC_MULDIV | HWCAP_SPARC_V9) -#ifndef TARGET_ABI32 -#define elf_check_arch(x) ( (x) == EM_SPARCV9 || (x) == EM_SPARC32PLUS ) +#ifndef TARGET_SPARC64 +# define ELF_CLASS ELFCLASS32 +# define ELF_ARCH EM_SPARC +#elif defined(TARGET_ABI32) +# define ELF_CLASS ELFCLASS32 +# define elf_check_arch(x) ((x) == EM_SPARC32PLUS || (x) == EM_SPARC) #else -#define elf_check_arch(x) ( (x) == EM_SPARC32PLUS || (x) == EM_SPARC ) +# define ELF_CLASS ELFCLASS64 +# define ELF_ARCH EM_SPARCV9 #endif -#define ELF_CLASS ELFCLASS64 -#define ELF_ARCH EM_SPARCV9 -#else -#define ELF_HWCAP (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | HWCAP_SPARC_SWAP \ - | HWCAP_SPARC_MULDIV) -#define ELF_CLASS ELFCLASS32 -#define ELF_ARCH EM_SPARC -#endif /* TARGET_SPARC64 */ +#include "elf.h" + +#define ELF_HWCAP get_elf_hwcap() + +static uint32_t get_elf_hwcap(void) +{ + /* There are not many sparc32 hwcap bits -- we have all of them. */ + uint32_t r = HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | + HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV; + +#ifdef TARGET_SPARC64 + CPUSPARCState *env = cpu_env(thread_cpu); + uint32_t features = env->def.features; + + r |= HWCAP_SPARC_V9 | HWCAP_SPARC_V8PLUS; + /* 32x32 multiply and divide are efficient. */ + r |= HWCAP_SPARC_MUL32 | HWCAP_SPARC_DIV32; + /* We don't have an internal feature bit for this. */ + r |= HWCAP_SPARC_POPC; + r |= features & CPU_FEATURE_FSMULD ? HWCAP_SPARC_FSMULD : 0; + r |= features & CPU_FEATURE_VIS1 ? HWCAP_SPARC_VIS : 0; + r |= features & CPU_FEATURE_VIS2 ? HWCAP_SPARC_VIS2 : 0; +#endif + + return r; +} static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) From patchwork Thu May 2 16:55:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 794118 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp353572wrr; Thu, 2 May 2024 09:56:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU5tRwT4q397Xk+vDq2I2hV92Dl+B24ZlBhaN26ag9YGRMesZOWZfZwrvJkGt+xxKZPFUKGEyQoJgCNp2Et6K3Q X-Google-Smtp-Source: AGHT+IEiO8YxplDxmqFmGDMUPqXikBm8JxFvYXpMkV3f4ML8YS0LqVSVGLa98/BPBScZzbwUvILQ X-Received: by 2002:a05:620a:2042:b0:790:f2b2:ed2e with SMTP id d2-20020a05620a204200b00790f2b2ed2emr159049qka.64.1714668988856; Thu, 02 May 2024 09:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714668988; cv=none; d=google.com; s=arc-20160816; b=hmNC3bZUVYCWUbTqHSkd/As1V63ZPq9459uhj/wmU267EJWWrEaXhRDbC/L1/AMF0a +HGpKPiStTGNI/TU4RPvLQ7v9pYypti7mOTmcv8f13x1N5TYXcqBZdFUqlDiJn+aquke FMaHYa1retdZWUe6Rd7+EwjYmyoQ7t6+UKuNK8hAsK348nqCbaMadlmyzF3BA1uhA2rR +SNxsGFpvYHjdkQm44UIXTH1K/GFPgpiyQDqFJnsk4mczMvI2VRCs6h119ao49++uF44 tQmsleZ5gb93EmohWNtAGEGy/5llcCpCQCfyIfjUsd680T7vJxJR8V3znv3Jc3HnHTvf 1RyQ== 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=8A5wkA/c/fe0SRhmGznAw+eONAU2pb4TUE7cdCXudPo=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=vF3zkULFPsLUa2fgYR9zb+2eKTyD/4HOVpnS+hTUcj7z1wWm3blGQsD0iScNjTMlNV bdWBs7F+e9eDj6xkgLwEgUZm3tX/3ur2qnn4JjmyXDiKdHqjg3WqPzwOVU5X3G3eEKVT 0uB8VPUyzUQ5gDQsRLmgHuMnUlByC0FMRxWQUNB+ChjI4sEd7kldZ7V60Ez2f6h1ftIQ imuh6gb+PwaTiYaaWJhRi3NkRkbVgpAKX2WBS3pOTdqmjcu2B6U2R7oS5ZdAmp2vUvfz 1MmtMRq+hzoeQ7eiGXSQ9+9dY6Vky/7noXpTJAQEd1bQFKC5USA+Qo+sYrNl673iyawa QBBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="v3+ZK/54"; 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 wx7-20020a05620a5a4700b0078d5075fd8bsi1250363qkn.365.2024.05.02.09.56.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 09:56: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=pass header.i=@linaro.org header.s=google header.b="v3+ZK/54"; 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 1s2Zit-0001I7-Nn; Thu, 02 May 2024 12:55:55 -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 1s2Zic-0000vm-CV for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:43 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2ZiZ-0005vP-29 for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:38 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6f44390e328so498976b3a.2 for ; Thu, 02 May 2024 09:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714668931; x=1715273731; 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=8A5wkA/c/fe0SRhmGznAw+eONAU2pb4TUE7cdCXudPo=; b=v3+ZK/54YG6Jd5vJrBduSHUysIFBOk5xhJ/K+gchCqmbxsFOzxAnw296WazM72Qnkw pNhGYwFtj/fF/r+/O9IjHsKs6/3xsPqLdoye23Z0mzBORkP8hufaHu4S4UVu7y+DhRLl LLgXzRHQqY6cyZULTK6XZ6TdyFL7gWFIHzh92gmI0D1XgXworMOCB/U1OSYJKZDYTdd3 KyoVFJhzStyVlFV0Z+xEKC+JugUvAihaeilCrnCsH5u1tp7wxwnZ3JxXTQkyAf8pyHYz 8lNq5yZC62YqI0KHLE7gFeQ4aXsiOZ9wImHyLnN6KqwtXRRdEy0NEf2WTVDpGLAq/SuH 8cdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714668931; x=1715273731; 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=8A5wkA/c/fe0SRhmGznAw+eONAU2pb4TUE7cdCXudPo=; b=Gbnp+/bTiloy2aJF3wPLDIhZjhRF4KPojkwbsRylsByPBCfWEtcfCWc1wxyGa6p5IZ prZIWgXlV0+RXLgr9nnnd82seF/4jwaSDzuuMYDTQyfx42op5rFgMoRN8rjddB58Ak8I B4iSHQyAyxfkmclZOnOmvEBuyS9tL/gBSnEONZpkzrYqaeKeeg95oF5gzioy2JsAx+ol Ifdt2IpNTu7U2vuBO3anJl1LKr/xv0f3L4Frgue90hFmMUAgKFAVKsJuB9gFj9YFGrUo nGMDXmcKIrfuLe656pwV8Bv2Ou4v/d0q0ab6/6MP5n1+NEFikfYI6YLleHE7/04N1knD Uy6g== X-Gm-Message-State: AOJu0Yx5COxFPVhvrM2QpCXTU4KqHQyFT10o2JCrEV0+A00AMHtXP7yq 3DJElghrZYjhrwLph65bq++iOO0kbBXgWJaAhzuvWdJvGiTdXHZLi/GsVMdyHIG4eOvg0O5s40j s X-Received: by 2002:a05:6a00:9a5:b0:6ed:cd4c:cc1a with SMTP id u37-20020a056a0009a500b006edcd4ccc1amr134583pfg.8.1714668931460; Thu, 02 May 2024 09:55:31 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id j13-20020aa783cd000000b006eb058b2703sm1464598pfn.187.2024.05.02.09.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 09:55:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 2/7] target/sparc: Fix FEXPAND Date: Thu, 2 May 2024 09:55:23 -0700 Message-Id: <20240502165528.244004-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502165528.244004-1-richard.henderson@linaro.org> References: <20240502165528.244004-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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 This is a 2-operand instruction, not 3-operand. Worse, we took the source from the wrong operand. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/sparc/helper.h | 2 +- target/sparc/insns.decode | 2 +- target/sparc/translate.c | 20 +++++++++++++++++++- target/sparc/vis_helper.c | 6 +++--- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index b8087d0d2b..57ab755ffd 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -102,7 +102,7 @@ DEF_HELPER_FLAGS_2(fmul8sux16, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmul8ulx16, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmuld8sux16, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmuld8ulx16, TCG_CALL_NO_RWG_SE, i64, i64, i64) -DEF_HELPER_FLAGS_2(fexpand, TCG_CALL_NO_RWG_SE, i64, i64, i64) +DEF_HELPER_FLAGS_1(fexpand, TCG_CALL_NO_RWG_SE, i64, i32) DEF_HELPER_FLAGS_3(pdist, TCG_CALL_NO_RWG_SE, i64, i64, i64, i64) DEF_HELPER_FLAGS_2(fpack16, TCG_CALL_NO_RWG_SE, i32, i64, i64) DEF_HELPER_FLAGS_3(fpack32, TCG_CALL_NO_RWG_SE, i64, i64, i64, i64) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index 2d26404cb2..e2d8a07dc4 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -352,7 +352,7 @@ FCMPEq 10 000 cc:2 110101 rs1:5 0 0101 0111 rs2:5 FALIGNDATAg 10 ..... 110110 ..... 0 0100 1000 ..... @r_r_r FPMERGE 10 ..... 110110 ..... 0 0100 1011 ..... @r_r_r BSHUFFLE 10 ..... 110110 ..... 0 0100 1100 ..... @r_r_r - FEXPAND 10 ..... 110110 ..... 0 0100 1101 ..... @r_r_r + FEXPAND 10 ..... 110110 00000 0 0100 1101 ..... @r_r2 FSRCd 10 ..... 110110 ..... 0 0111 0100 00000 @r_r1 # FSRC1d FSRCs 10 ..... 110110 ..... 0 0111 0101 00000 @r_r1 # FSRC1s diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 571b3e3f03..dfcfe855a1 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -4358,6 +4358,25 @@ TRANS(FSQRTd, ALL, do_env_dd, a, gen_helper_fsqrtd) TRANS(FxTOd, 64, do_env_dd, a, gen_helper_fxtod) TRANS(FdTOx, 64, do_env_dd, a, gen_helper_fdtox) +static bool do_df(DisasContext *dc, arg_r_r *a, + void (*func)(TCGv_i64, TCGv_i32)) +{ + TCGv_i64 dst; + TCGv_i32 src; + + if (gen_trap_ifnofpu(dc)) { + return true; + } + + dst = tcg_temp_new_i64(); + src = gen_load_fpr_F(dc, a->rs); + func(dst, src); + gen_store_fpr_D(dc, a->rd, dst); + return advance_pc(dc); +} + +TRANS(FEXPAND, VIS1, do_df, a, gen_helper_fexpand) + static bool do_env_df(DisasContext *dc, arg_r_r *a, void (*func)(TCGv_i64, TCGv_env, TCGv_i32)) { @@ -4589,7 +4608,6 @@ TRANS(FMUL8ULx16, VIS1, do_ddd, a, gen_helper_fmul8ulx16) TRANS(FMULD8SUx16, VIS1, do_ddd, a, gen_helper_fmuld8sux16) TRANS(FMULD8ULx16, VIS1, do_ddd, a, gen_helper_fmuld8ulx16) TRANS(FPMERGE, VIS1, do_ddd, a, gen_helper_fpmerge) -TRANS(FEXPAND, VIS1, do_ddd, a, gen_helper_fexpand) TRANS(FPADD16, VIS1, do_ddd, a, tcg_gen_vec_add16_i64) TRANS(FPADD32, VIS1, do_ddd, a, tcg_gen_vec_add32_i64) diff --git a/target/sparc/vis_helper.c b/target/sparc/vis_helper.c index 7763b16c24..db2e6dd6c1 100644 --- a/target/sparc/vis_helper.c +++ b/target/sparc/vis_helper.c @@ -260,13 +260,13 @@ uint64_t helper_fmuld8ulx16(uint64_t src1, uint64_t src2) return d.ll; } -uint64_t helper_fexpand(uint64_t src1, uint64_t src2) +uint64_t helper_fexpand(uint32_t src2) { VIS32 s; VIS64 d; - s.l = (uint32_t)src1; - d.ll = src2; + s.l = src2; + d.ll = 0; d.VIS_W64(0) = s.VIS_B32(0) << 4; d.VIS_W64(1) = s.VIS_B32(1) << 4; d.VIS_W64(2) = s.VIS_B32(2) << 4; From patchwork Thu May 2 16:55:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 794122 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp353747wrr; Thu, 2 May 2024 09:56:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3tClq9RWRvY2Oa5x4ChBUSuiE40buyDonsh84raU3xHleZM6BtVJ/xVPScGdZkp0BG3vdHNAxgJ5v0erjB79C X-Google-Smtp-Source: AGHT+IFEVhBNTbrdZ5G2x5XVYMFz5837psHp1XD7CXt8d007pO/A8gtskfJ+TbwEcUwhloqD61/U X-Received: by 2002:a05:620a:4614:b0:790:bddd:dd6d with SMTP id br20-20020a05620a461400b00790bddddd6dmr243258qkb.14.1714669012051; Thu, 02 May 2024 09:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714669012; cv=none; d=google.com; s=arc-20160816; b=dHvIuC0DKXvtxh2y1PkJJu0ukNfpRkw+1qvEAHmchN1XV2czfjX2WuPLJu9IxW7IlF D+K2gUH6ShGjpgkxHsz5s3RdMM8WRXl1ZtQbpZJ776/+802nlzfrRjzZRHozYtwoCdkg qbW5CWk2LhRwsjXzfZM/8sZPrOBZ92LeCQUm/mfjJrbmTcGfZh4vnjBH8YEnfg1HNph/ jfMFscqdKDBJVsv81erCDqVa6hU/9g6QW+GIY7Fbft/hwhGvEbjYutT5IouGyQKBA3Rq r589j1Zd5ghGZH0f7TjmiUGKeJ8dBzXIKCHGl4Ansgot+RzPC9otTDxlYUwwJtYegO3K Oblw== 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=JJIohk8gDQsUtWfZD6O/rKhQO02QyqWEocuP7xflwZc=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=VEwohEwQDtv9nbGPVb+lWy0diKb8oGc+VBmYN4oI9A2xTc512f9D6YSvKLFTQXqICD djx6LUHBSDahWlAWQBbNPWb9ViOcpXwJgATJIoaT8Gn/MzxwDxyW08lB0Gcao2JWxJm7 ywCX8pgAkuZH1kXKpvjs0RGskUJKVEFW0NvRCBZDCWE0S9dt44ozACk3zxPEqYcJERpU zwCmBg5N0lEUFjEYRuHwVyNdJYvfQKbMHNTlrtM5NVJ4RlWMA+OjjrRhsFD5ok9MJEJQ 6zEdmMOpXdyxI1XgUZLY+p68ck8vzSE0XZBGqORf4JtRbZdolNxAzCvMHTxzgrZJLd+X 5x7A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g1ZAHCCI; 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 r3-20020a05620a298300b00790f77ccce6si1475203qkp.333.2024.05.02.09.56.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 09:56:52 -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=g1ZAHCCI; 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 1s2Ziu-0001Mm-NW; Thu, 02 May 2024 12:55:56 -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 1s2Zib-0000v4-Pg for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:37 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2ZiY-0005va-6M for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:37 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6f44881ad9eso137556b3a.3 for ; Thu, 02 May 2024 09:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714668932; x=1715273732; 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=JJIohk8gDQsUtWfZD6O/rKhQO02QyqWEocuP7xflwZc=; b=g1ZAHCCIwa/+S5xgikjaoA9LLxIIklzgdOBm0ef0Z1IFhquytgD/wntaT7snt1SzSA g8X6XXPqT9EVi60a3KS6eWWgYMhyJZ8ZRj+XryNFzhQ6fHOzLArZGUThZb/jCjJst3xG S9ZVvY/dU8nnpoL/h44v1lYmFPw9QLrkrHkMuBqnynZ9EcHFlQlkiVwoOQ4qLBmU992r f9nQ6Q1Q1fpnOHo/lNewC0KGWj1IE8VtRNlKLBCNMnQ9EVe+UK+tsKL3SPBHOXJCMeFH mauaxQ+hP1yORzaQj/ZzpdyFwqZ0WLxc3hwet+PwWmDEdU1KDJgfdeDQ0KEVnw99Pl3v A/ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714668932; x=1715273732; 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=JJIohk8gDQsUtWfZD6O/rKhQO02QyqWEocuP7xflwZc=; b=Jb0tHozbqrOP1G6/cy4NzU12d4UetdSU3wmmp8cIAGErjWx0yBrndMmq24Rl4n/E7l zZzDAcn/07xC4G/bt5J5OWxmRByaGtiwez6jRDKzv2x3kRvGKWaZBT0clMOUqwcuOxOO GNKn9toUgijbv/OWH6xx/MHXbveUMP76KIPewvZ32OADwRZT4DQ/0BtG8ohSrTu+jPR+ U1RppTuYNG4yUsLoF1eUxrf4QSZV+Go50zhuTfxL2/5LA29RppSsE0I3Fx4fJeVb7tAd 03ppXGhpxAER+3lJovwpDTN9FZxITFcogwCKMeUwo5c9J6+K2I3hwX1WKjU73ohzOk1V b5Fw== X-Gm-Message-State: AOJu0YwrpVHmfEtWb76M/0fMOPHttZDMH7EfSGBAP5HZEFVZDhEMunOT o8dr3SjStYNNYeaelmMh065H2su+aHvyTAHalppyEyw+Gem1YmH4HOolrnx7GqvP484uhJ5krj8 H X-Received: by 2002:a05:6a20:d428:b0:1a7:427b:8216 with SMTP id il40-20020a056a20d42800b001a7427b8216mr217697pzb.55.1714668932275; Thu, 02 May 2024 09:55:32 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id j13-20020aa783cd000000b006eb058b2703sm1464598pfn.187.2024.05.02.09.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 09:55:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 3/7] target/sparc: Fix FMUL8x16 Date: Thu, 2 May 2024 09:55:24 -0700 Message-Id: <20240502165528.244004-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502165528.244004-1-richard.henderson@linaro.org> References: <20240502165528.244004-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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 This instruction has f32 as source1, which alters the decoding of the register number, which means we've been passing the wrong data for odd register numbers. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/sparc/helper.h | 2 +- target/sparc/translate.c | 21 ++++++++++++++++++++- target/sparc/vis_helper.c | 9 +++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index 57ab755ffd..27dc604cac 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -95,7 +95,7 @@ DEF_HELPER_FLAGS_2(fdtox, TCG_CALL_NO_WG, s64, env, f64) DEF_HELPER_FLAGS_2(fqtox, TCG_CALL_NO_WG, s64, env, i128) DEF_HELPER_FLAGS_2(fpmerge, TCG_CALL_NO_RWG_SE, i64, i64, i64) -DEF_HELPER_FLAGS_2(fmul8x16, TCG_CALL_NO_RWG_SE, i64, i64, i64) +DEF_HELPER_FLAGS_2(fmul8x16, TCG_CALL_NO_RWG_SE, i64, i32, i64) DEF_HELPER_FLAGS_2(fmul8x16al, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmul8x16au, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmul8sux16, TCG_CALL_NO_RWG_SE, i64, i64, i64) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index dfcfe855a1..c4adc148d2 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -4583,6 +4583,26 @@ TRANS(FSUBs, ALL, do_env_fff, a, gen_helper_fsubs) TRANS(FMULs, ALL, do_env_fff, a, gen_helper_fmuls) TRANS(FDIVs, ALL, do_env_fff, a, gen_helper_fdivs) +static bool do_dfd(DisasContext *dc, arg_r_r_r *a, + void (*func)(TCGv_i64, TCGv_i32, TCGv_i64)) +{ + TCGv_i64 dst, src2; + TCGv_i32 src1; + + if (gen_trap_ifnofpu(dc)) { + return true; + } + + dst = gen_dest_fpr_D(dc, a->rd); + src1 = gen_load_fpr_F(dc, a->rs1); + src2 = gen_load_fpr_D(dc, a->rs2); + func(dst, src1, src2); + gen_store_fpr_D(dc, a->rd, dst); + return advance_pc(dc); +} + +TRANS(FMUL8x16, VIS1, do_dfd, a, gen_helper_fmul8x16) + static bool do_ddd(DisasContext *dc, arg_r_r_r *a, void (*func)(TCGv_i64, TCGv_i64, TCGv_i64)) { @@ -4600,7 +4620,6 @@ static bool do_ddd(DisasContext *dc, arg_r_r_r *a, return advance_pc(dc); } -TRANS(FMUL8x16, VIS1, do_ddd, a, gen_helper_fmul8x16) TRANS(FMUL8x16AU, VIS1, do_ddd, a, gen_helper_fmul8x16au) TRANS(FMUL8x16AL, VIS1, do_ddd, a, gen_helper_fmul8x16al) TRANS(FMUL8SUx16, VIS1, do_ddd, a, gen_helper_fmul8sux16) diff --git a/target/sparc/vis_helper.c b/target/sparc/vis_helper.c index db2e6dd6c1..7728ffe9c6 100644 --- a/target/sparc/vis_helper.c +++ b/target/sparc/vis_helper.c @@ -94,16 +94,17 @@ uint64_t helper_fpmerge(uint64_t src1, uint64_t src2) return d.ll; } -uint64_t helper_fmul8x16(uint64_t src1, uint64_t src2) +uint64_t helper_fmul8x16(uint32_t src1, uint64_t src2) { - VIS64 s, d; + VIS64 d; + VIS32 s; uint32_t tmp; - s.ll = src1; + s.l = src1; d.ll = src2; #define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B64(r); \ + tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B32(r); \ if ((tmp & 0xff) > 0x7f) { \ tmp += 0x100; \ } \ From patchwork Thu May 2 16:55:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 794121 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp353735wrr; Thu, 2 May 2024 09:56:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwChEHqSGpzXT4FeTGK6qWEnAozxqZnn///htuP285BtvAms0kNNgAOY2b+Vty7IggOLE4kesci0AXjjRYTRPX X-Google-Smtp-Source: AGHT+IHsBHPH9fiR537wvRt2XL81nHi7FSA4S9GzlQRBCMejXADpkVHHfi5aLkyZH2zsp/SgqcxF X-Received: by 2002:a05:622a:5b8f:b0:43a:df01:167d with SMTP id ec15-20020a05622a5b8f00b0043adf01167dmr6497243qtb.4.1714669011138; Thu, 02 May 2024 09:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714669011; cv=none; d=google.com; s=arc-20160816; b=jxHFdxYTLxTiDSAOLL3YlupwQ2y5EVDgNPvmnUShQSB+FmzaVXsHNr+YDUry4KRELM dXCC0mWqIwhlLtwiHIGbb+YxWRN5pENEN5e0rIoik3PKxO+0Ms3fumW4X5ZGHVeZCJtn IDpPxq+QK47ojXMFkXHF5CCBNjXxV+1g8s3wxKv4qTESVUIHGqBFnb0xBgvs29s/FGSy 3d7AZISQgdwmZPxG+6Kw3OHcFTdfp8RSQhWyurCrc5LgtUaMY/mTbt45wmyy5Eis9op3 Q7Cwf/AnWtpenjB9Nu+oPzcu3SjIxpbpkgHtk1ItOc8maYrI8dA7otsa5jmR/z6dHIsK GxCQ== 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=yEdMLu3Ijs29bOc2sbKAHOskO1hQNx6lqTdpxrxbtzI=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=dl5fb3Dw+v22QD3neAM+SuY+zc/DbNq5fU/2jLHp5FyJ+7H7sPr+g6i0qqy6+zRkGZ jE1/Je3slBs6ZN1RisxwOyHVlYYewK02k9Gjbr7YVWZCYzrJwRvUrN5y1831G77k1JGK cfST4ObJ6VuD/Vz2SRbyFtaXwlfsZtonqxDDBw8K8uGY/toYL5dBvS36ydtFuToxB46r rOBSFwmDXItzvOVEHAIc2GXMlVj/lxpl806Nd6W4aMYWsnxEVU2JYC7/AliVY0sBNRvx FB+7UtOL5zfhmjZ77ihLzaieqjeWq/oSdAbOR03cB3uxJa2BSTZ/j+SJW4C5ozSEbvOi L+aA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u5caEhtO; 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 c1-20020a05622a024100b0043ad3e63efdsi1260437qtx.383.2024.05.02.09.56.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 09:56:51 -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=u5caEhtO; 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 1s2Ziu-0001K8-4v; Thu, 02 May 2024 12:55:56 -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 1s2Zic-0000wm-Mc for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:43 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2ZiZ-0005vo-J0 for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:38 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6f0aeee172dso1528844b3a.1 for ; Thu, 02 May 2024 09:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714668934; x=1715273734; 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=yEdMLu3Ijs29bOc2sbKAHOskO1hQNx6lqTdpxrxbtzI=; b=u5caEhtO6eV//YXuIQyeqLevrhBIxCnclRJ5Sox1G8yp1xZwcp4Z/UtNDrLowVygPB j+snj21CxJmR3/u40J2vk1VsK3q/0RkoNja9vyYTt0TUYPpToYiV9o0up9Z14ItPOqDI hNGAIqXdfR5/bx1aMuftq59awiOXt2iAi7f/5glbMzKfnMI3+ntQma6bTtFsXfwQEquC SpeQG3a/vCJG1mPoVOmwTNXk6+/jMEW1Tz82jgWzjWfjenNzePlBRGaE/f4imdcEeufl RFfP7o2I46uy7dUzQForWwem84VCEtFQkBgexeMdusfwb3pCr4EnvivKF93xOva0C1na JKdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714668934; x=1715273734; 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=yEdMLu3Ijs29bOc2sbKAHOskO1hQNx6lqTdpxrxbtzI=; b=shzsV5H5Mf90RpUYPtlR+9YenDP5Fevs/7Mbjzyp6o6efIID92sbYTnCluwTpgjFmf S443ZphspXs7aOuN8w0Pg/7IDY9gRBZidk2D3Wi9V/KfR4vFNxeIeHt8YLf6ABFzSD4N oOeKkuNDzYqO9sM4D0vaH6YyeZqHf3Nn8IgP/c4qGxCEH53bU93ub02xgxPjerFNQdir 9Qpc7OkxbqeNVkW7EDecjv6vlQZziw6k1tBPMltmFLkS8UXzY9UPBU79defg4qlbEOXj cgviJV1a+zfY85yiYGibmkGkvd1mmo1KbCtlBocGBk3Xdn6pCrdnKubQi7ZJsVI/loKo M93g== X-Gm-Message-State: AOJu0YxMzvv0U+lM38biSnw+pG3uMzsbwUKs6akyoMO8dYkRvIXFzwc5 q8rfMIdb8hkZ3j6O7WtnldC6rOtwRI9TPZXLfqYF+YcB2ML/uhCnVjGFd18LiGk/eHgqNMYL8Sx V X-Received: by 2002:a05:6a00:92a5:b0:6f3:8468:8bb with SMTP id jw37-20020a056a0092a500b006f3846808bbmr390342pfb.17.1714668933080; Thu, 02 May 2024 09:55:33 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id j13-20020aa783cd000000b006eb058b2703sm1464598pfn.187.2024.05.02.09.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 09:55:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 4/7] target/sparc: Fix FMUL8x16A{U,L} Date: Thu, 2 May 2024 09:55:25 -0700 Message-Id: <20240502165528.244004-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502165528.244004-1-richard.henderson@linaro.org> References: <20240502165528.244004-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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 These instructions have f32 inputs, which changes the decode of the register numbers. While we're fixing things, use a common helper for both insns, extracting the 16-bit scalar in tcg beforehand. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/sparc/helper.h | 3 +-- target/sparc/translate.c | 38 +++++++++++++++++++++++++++---- target/sparc/vis_helper.c | 47 +++++++++++---------------------------- 3 files changed, 48 insertions(+), 40 deletions(-) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index 27dc604cac..9cde2b69a5 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -96,8 +96,7 @@ DEF_HELPER_FLAGS_2(fqtox, TCG_CALL_NO_WG, s64, env, i128) DEF_HELPER_FLAGS_2(fpmerge, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmul8x16, TCG_CALL_NO_RWG_SE, i64, i32, i64) -DEF_HELPER_FLAGS_2(fmul8x16al, TCG_CALL_NO_RWG_SE, i64, i64, i64) -DEF_HELPER_FLAGS_2(fmul8x16au, TCG_CALL_NO_RWG_SE, i64, i64, i64) +DEF_HELPER_FLAGS_2(fmul8x16a, TCG_CALL_NO_RWG_SE, i64, i32, s32) DEF_HELPER_FLAGS_2(fmul8sux16, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmul8ulx16, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmuld8sux16, TCG_CALL_NO_RWG_SE, i64, i64, i64) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index c4adc148d2..a8ada6934a 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -45,6 +45,7 @@ # define gen_helper_clear_softint(E, S) qemu_build_not_reached() # define gen_helper_done(E) qemu_build_not_reached() # define gen_helper_flushw(E) qemu_build_not_reached() +# define gen_helper_fmul8x16a(D, S1, S2) qemu_build_not_reached() # define gen_helper_rdccr(D, E) qemu_build_not_reached() # define gen_helper_rdcwp(D, E) qemu_build_not_reached() # define gen_helper_restored(E) qemu_build_not_reached() @@ -72,8 +73,6 @@ # define gen_helper_fexpand ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fmul8sux16 ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fmul8ulx16 ({ qemu_build_not_reached(); NULL; }) -# define gen_helper_fmul8x16al ({ qemu_build_not_reached(); NULL; }) -# define gen_helper_fmul8x16au ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fmul8x16 ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fmuld8sux16 ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fmuld8ulx16 ({ qemu_build_not_reached(); NULL; }) @@ -719,6 +718,18 @@ static void gen_op_bshuffle(TCGv_i64 dst, TCGv_i64 src1, TCGv_i64 src2) #endif } +static void gen_op_fmul8x16al(TCGv_i64 dst, TCGv_i32 src1, TCGv_i32 src2) +{ + tcg_gen_ext16s_i32(src2, src2); + gen_helper_fmul8x16a(dst, src1, src2); +} + +static void gen_op_fmul8x16au(TCGv_i64 dst, TCGv_i32 src1, TCGv_i32 src2) +{ + tcg_gen_sari_i32(src2, src2, 16); + gen_helper_fmul8x16a(dst, src1, src2); +} + static void finishing_insn(DisasContext *dc) { /* @@ -4583,6 +4594,27 @@ TRANS(FSUBs, ALL, do_env_fff, a, gen_helper_fsubs) TRANS(FMULs, ALL, do_env_fff, a, gen_helper_fmuls) TRANS(FDIVs, ALL, do_env_fff, a, gen_helper_fdivs) +static bool do_dff(DisasContext *dc, arg_r_r_r *a, + void (*func)(TCGv_i64, TCGv_i32, TCGv_i32)) +{ + TCGv_i64 dst; + TCGv_i32 src1, src2; + + if (gen_trap_ifnofpu(dc)) { + return true; + } + + dst = gen_dest_fpr_D(dc, a->rd); + src1 = gen_load_fpr_F(dc, a->rs1); + src2 = gen_load_fpr_F(dc, a->rs2); + func(dst, src1, src2); + gen_store_fpr_D(dc, a->rd, dst); + return advance_pc(dc); +} + +TRANS(FMUL8x16AU, VIS1, do_dff, a, gen_op_fmul8x16au) +TRANS(FMUL8x16AL, VIS1, do_dff, a, gen_op_fmul8x16al) + static bool do_dfd(DisasContext *dc, arg_r_r_r *a, void (*func)(TCGv_i64, TCGv_i32, TCGv_i64)) { @@ -4620,8 +4652,6 @@ static bool do_ddd(DisasContext *dc, arg_r_r_r *a, return advance_pc(dc); } -TRANS(FMUL8x16AU, VIS1, do_ddd, a, gen_helper_fmul8x16au) -TRANS(FMUL8x16AL, VIS1, do_ddd, a, gen_helper_fmul8x16al) TRANS(FMUL8SUx16, VIS1, do_ddd, a, gen_helper_fmul8sux16) TRANS(FMUL8ULx16, VIS1, do_ddd, a, gen_helper_fmul8ulx16) TRANS(FMULD8SUx16, VIS1, do_ddd, a, gen_helper_fmuld8sux16) diff --git a/target/sparc/vis_helper.c b/target/sparc/vis_helper.c index 7728ffe9c6..ff2f43c23f 100644 --- a/target/sparc/vis_helper.c +++ b/target/sparc/vis_helper.c @@ -119,44 +119,23 @@ uint64_t helper_fmul8x16(uint32_t src1, uint64_t src2) return d.ll; } -uint64_t helper_fmul8x16al(uint64_t src1, uint64_t src2) +uint64_t helper_fmul8x16a(uint32_t src1, int32_t src2) { - VIS64 s, d; + VIS32 s; + VIS64 d; uint32_t tmp; - s.ll = src1; - d.ll = src2; + s.l = src1; + d.ll = 0; -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(1) * (int32_t)s.VIS_B64(r); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; - - PMUL(0); - PMUL(1); - PMUL(2); - PMUL(3); -#undef PMUL - - return d.ll; -} - -uint64_t helper_fmul8x16au(uint64_t src1, uint64_t src2) -{ - VIS64 s, d; - uint32_t tmp; - - s.ll = src1; - d.ll = src2; - -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; +#define PMUL(r) \ + do { \ + tmp = src2 * (int32_t)s.VIS_B32(r); \ + if ((tmp & 0xff) > 0x7f) { \ + tmp += 0x100; \ + } \ + d.VIS_W64(r) = tmp >> 8; \ + } while (0) PMUL(0); PMUL(1); From patchwork Thu May 2 16:55:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 794120 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp353661wrr; Thu, 2 May 2024 09:56:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVhdi4CMhZeA7ZS/zs5jobAGflUAmgyfhjVL4KL4jz9pQspdFH6dygphQL6VlUpyp+0SadDCVsMJ/KadTAq4mcI X-Google-Smtp-Source: AGHT+IFmY6vf2u46165qtcO6Q93QCUqUd6QMN7srAIrJU+yzbSnr6ms4mvyw1DLymWdWY6sXC6rD X-Received: by 2002:a05:6808:7d1:b0:3c8:42ee:7920 with SMTP id f17-20020a05680807d100b003c842ee7920mr439713oij.56.1714669000350; Thu, 02 May 2024 09:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714669000; cv=none; d=google.com; s=arc-20160816; b=ZgMEKa2bB96zfsnOQVWAd/jM6lvsGIBvnHD2NXN5+fS233aR/gf4/tGOTi/Svf47mv VadpGS+KWdJZ80YhTY0FvPhstT2sT3+mLbyHpMs32wP26NOKldsbDXLCss+Bb6mj2C1Y 2d7pA7E2wG9hy0AeQwREF8d9RqW6toRpc5qwO67wF7AVaLVvsA8OtmWWjYMQ0QkyHk7i zINZtNC3gmxD+gNnB4vSLiWp/3JfSu8Wg4gtv+aQgKYUtk+b30FIwrlDFR2bQFQ+L8wM BEDvZeyZvoaExfwud9pB8OtLPOZd6rKkBu9WTnohs44Qoyjm2hUq/05nZQNMLfwZ0LMx wVTg== 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=fMR2OW95a+er7mlGlAcae8r7qmSgirTok885mixb5OA=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=o+tzypJwyg4AE+HOnVpcdgLu9KRdBNkCxSvAQMnpCAgffLxZKaSIQn2JFIaBMRxXtF VJ7PguyhwqS5nAP8RpnvbjdLt+QbHNIsJLt/lfx/7jYMOHKVQ8PAzRK2yA5c6QCazy44 +esOEjEK1d/96D4g6OOR32mgmTt99sOJpuWAbgGM3WG4f1IRRgQ5//JRZmysDMzEmzgK wGpeNrj14ZYeVwQCiRQtnDGqIc7lrbgfq2VIwP8A3W6jtYll/pXimcDhi6ieKEUSfN6u qDBgbDhC9eDc7qIh6rX0tfDSPbiFXtqxN4ckBZA3rHPUCbw/MYb/2RieVd8EJJECb/RW vaHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EuuUqSuq; 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 p12-20020a05621421ec00b006a0cb4012a8si1260981qvj.243.2024.05.02.09.56.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 09:56: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=pass header.i=@linaro.org header.s=google header.b=EuuUqSuq; 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 1s2Ziv-0001Pl-KH; Thu, 02 May 2024 12:55:57 -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 1s2Zic-0000wn-Mx for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:43 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2ZiZ-0005vk-5O for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:38 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6eff2be3b33so7579414b3a.2 for ; Thu, 02 May 2024 09:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714668934; x=1715273734; 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=fMR2OW95a+er7mlGlAcae8r7qmSgirTok885mixb5OA=; b=EuuUqSuqrendao7At5lK3nRKslyXYEr8L0RpDlDQ0XNKV+yRzX50/Bdpp/mKs8bMN1 jY/kTEDB1XEzSNDWPCcOmPWvTRwritC8YWmV7ezSkob5Lci6ehBIA59WgMd89ycksSBI 5fcgnyGS9HqBKWwaLphCRGNXOmwgAqm9EeJQXgYlxrvZHMlGoE+Zq+mnGsMT4zGl6VSE FVefRgmXeH7KcitYRFdzUhdiNGkqX3NxOgrkyOZ9BF0DCJb/pQDO7cjVDDveWDL1hMRN nyu0TjNctGnHFtGp1jh4ppE6Dz2mplvg2MWsh1hDy+6EJG+/2sOwYP1fyXBkTMTYkO31 1xIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714668934; x=1715273734; 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=fMR2OW95a+er7mlGlAcae8r7qmSgirTok885mixb5OA=; b=OijBysMf3xtbFKAX3TG4hfRqoxQ21Oii+16T/22FWkoAkEGfb2RbVidMzkju5Lyu2x 1AQG80geTd/1Gul3pOyxWEZF31BUlwTyGUbrRrohMjvExmCjPQYZlAwxAr+jwwj17ErU Y7zHYXkyAi+v8wk2sTdgFPUzUObF8Mo6DKKnNJJowIsltol7Si0VjiRr6DlcKZBIoZHg 8sB8tAOvj6JE+UBgzmRth6RWdv5AD300odTpFPPzqm35Nz1fuZHEAso1Rvo+6QfRKUbU w6Ga7M7Ah/ZKVX3TOzbm7asNAa4t3T/3K/qdnW6P2Nau88QqfP28Bc3xfT2hWxuZ1F4Z c5gQ== X-Gm-Message-State: AOJu0YzAsj5ncYN10g6HEMld8Ut4Sciz4whHlros+2ahHntnfHjqcwx/ o2bExwY/KO/P6Rc0Kjq0v8cs41laXrmI+xEtpbyIiMRbRggZ3quoxAAttw4X4dpGdWNx7mOiTyy Q X-Received: by 2002:a05:6a21:3991:b0:1ad:7e82:c091 with SMTP id ad17-20020a056a21399100b001ad7e82c091mr278128pzc.10.1714668933914; Thu, 02 May 2024 09:55:33 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id j13-20020aa783cd000000b006eb058b2703sm1464598pfn.187.2024.05.02.09.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 09:55:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 5/7] target/sparc: Fix FMULD8*X16 Date: Thu, 2 May 2024 09:55:26 -0700 Message-Id: <20240502165528.244004-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502165528.244004-1-richard.henderson@linaro.org> References: <20240502165528.244004-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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 Not only do these instructions have f32 inputs, they also do not perform rounding. Since these are relatively simple, implement them properly inline. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/sparc/helper.h | 2 -- target/sparc/translate.c | 48 +++++++++++++++++++++++++++++++++++---- target/sparc/vis_helper.c | 46 ------------------------------------- 3 files changed, 44 insertions(+), 52 deletions(-) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index 9cde2b69a5..fcb9c617b7 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -99,8 +99,6 @@ DEF_HELPER_FLAGS_2(fmul8x16, TCG_CALL_NO_RWG_SE, i64, i32, i64) DEF_HELPER_FLAGS_2(fmul8x16a, TCG_CALL_NO_RWG_SE, i64, i32, s32) DEF_HELPER_FLAGS_2(fmul8sux16, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmul8ulx16, TCG_CALL_NO_RWG_SE, i64, i64, i64) -DEF_HELPER_FLAGS_2(fmuld8sux16, TCG_CALL_NO_RWG_SE, i64, i64, i64) -DEF_HELPER_FLAGS_2(fmuld8ulx16, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_1(fexpand, TCG_CALL_NO_RWG_SE, i64, i32) DEF_HELPER_FLAGS_3(pdist, TCG_CALL_NO_RWG_SE, i64, i64, i64, i64) DEF_HELPER_FLAGS_2(fpack16, TCG_CALL_NO_RWG_SE, i32, i64, i64) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index a8ada6934a..8a2894bb9f 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -74,8 +74,6 @@ # define gen_helper_fmul8sux16 ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fmul8ulx16 ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fmul8x16 ({ qemu_build_not_reached(); NULL; }) -# define gen_helper_fmuld8sux16 ({ qemu_build_not_reached(); NULL; }) -# define gen_helper_fmuld8ulx16 ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fpmerge ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fqtox ({ qemu_build_not_reached(); NULL; }) # define gen_helper_fstox ({ qemu_build_not_reached(); NULL; }) @@ -730,6 +728,48 @@ static void gen_op_fmul8x16au(TCGv_i64 dst, TCGv_i32 src1, TCGv_i32 src2) gen_helper_fmul8x16a(dst, src1, src2); } +static void gen_op_fmuld8ulx16(TCGv_i64 dst, TCGv_i32 src1, TCGv_i32 src2) +{ + TCGv_i32 t0 = tcg_temp_new_i32(); + TCGv_i32 t1 = tcg_temp_new_i32(); + TCGv_i32 t2 = tcg_temp_new_i32(); + + tcg_gen_ext8u_i32(t0, src1); + tcg_gen_ext16s_i32(t1, src2); + tcg_gen_mul_i32(t0, t0, t1); + + tcg_gen_extract_i32(t1, src1, 16, 8); + tcg_gen_sextract_i32(t2, src2, 16, 16); + tcg_gen_mul_i32(t1, t1, t2); + + tcg_gen_concat_i32_i64(dst, t0, t1); +} + +static void gen_op_fmuld8sux16(TCGv_i64 dst, TCGv_i32 src1, TCGv_i32 src2) +{ + TCGv_i32 t0 = tcg_temp_new_i32(); + TCGv_i32 t1 = tcg_temp_new_i32(); + TCGv_i32 t2 = tcg_temp_new_i32(); + + /* + * The insn description talks about extracting the upper 8 bits + * of the signed 16-bit input rs1, performing the multiply, then + * shifting left by 8 bits. Instead, zap the lower 8 bits of + * the rs1 input, which avoids the need for two shifts. + */ + tcg_gen_ext16s_i32(t0, src1); + tcg_gen_andi_i32(t0, t0, ~0xff); + tcg_gen_ext16s_i32(t1, src2); + tcg_gen_mul_i32(t0, t0, t1); + + tcg_gen_sextract_i32(t1, src1, 16, 16); + tcg_gen_andi_i32(t1, t1, ~0xff); + tcg_gen_sextract_i32(t2, src2, 16, 16); + tcg_gen_mul_i32(t1, t1, t2); + + tcg_gen_concat_i32_i64(dst, t0, t1); +} + static void finishing_insn(DisasContext *dc) { /* @@ -4614,6 +4654,8 @@ static bool do_dff(DisasContext *dc, arg_r_r_r *a, TRANS(FMUL8x16AU, VIS1, do_dff, a, gen_op_fmul8x16au) TRANS(FMUL8x16AL, VIS1, do_dff, a, gen_op_fmul8x16al) +TRANS(FMULD8SUx16, VIS1, do_dff, a, gen_op_fmuld8sux16) +TRANS(FMULD8ULx16, VIS1, do_dff, a, gen_op_fmuld8ulx16) static bool do_dfd(DisasContext *dc, arg_r_r_r *a, void (*func)(TCGv_i64, TCGv_i32, TCGv_i64)) @@ -4654,8 +4696,6 @@ static bool do_ddd(DisasContext *dc, arg_r_r_r *a, TRANS(FMUL8SUx16, VIS1, do_ddd, a, gen_helper_fmul8sux16) TRANS(FMUL8ULx16, VIS1, do_ddd, a, gen_helper_fmul8ulx16) -TRANS(FMULD8SUx16, VIS1, do_ddd, a, gen_helper_fmuld8sux16) -TRANS(FMULD8ULx16, VIS1, do_ddd, a, gen_helper_fmuld8ulx16) TRANS(FPMERGE, VIS1, do_ddd, a, gen_helper_fpmerge) TRANS(FPADD16, VIS1, do_ddd, a, tcg_gen_vec_add16_i64) diff --git a/target/sparc/vis_helper.c b/target/sparc/vis_helper.c index ff2f43c23f..61c61c7fea 100644 --- a/target/sparc/vis_helper.c +++ b/target/sparc/vis_helper.c @@ -194,52 +194,6 @@ uint64_t helper_fmul8ulx16(uint64_t src1, uint64_t src2) return d.ll; } -uint64_t helper_fmuld8sux16(uint64_t src1, uint64_t src2) -{ - VIS64 s, d; - uint32_t tmp; - - s.ll = src1; - d.ll = src2; - -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_L64(r) = tmp; - - /* Reverse calculation order to handle overlap */ - PMUL(1); - PMUL(0); -#undef PMUL - - return d.ll; -} - -uint64_t helper_fmuld8ulx16(uint64_t src1, uint64_t src2) -{ - VIS64 s, d; - uint32_t tmp; - - s.ll = src1; - d.ll = src2; - -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_L64(r) = tmp; - - /* Reverse calculation order to handle overlap */ - PMUL(1); - PMUL(0); -#undef PMUL - - return d.ll; -} - uint64_t helper_fexpand(uint32_t src2) { VIS32 s; From patchwork Thu May 2 16:55:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 794119 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp353647wrr; Thu, 2 May 2024 09:56:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVR1LMQBRjTpo6rlGyjwpv8ktCh0R5DzgbEhCSKp525VpAyyCsY8du5KmOCcoYmvHeERYf47JhAYs4dzbbO78zb X-Google-Smtp-Source: AGHT+IG5rcnPIF+J876okExD8U3OqsxPHXeRb17ZZV3NqrJRmjHl10oRzvJVI8gkX9kIrVrnnqgO X-Received: by 2002:a05:6830:22fa:b0:6ef:a0a4:b60e with SMTP id t26-20020a05683022fa00b006efa0a4b60emr535738otc.13.1714668997863; Thu, 02 May 2024 09:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714668997; cv=none; d=google.com; s=arc-20160816; b=BJO1LRKLpyJmRxSkgP7VnghAWBBEstEoLr0vLWavcOz5FMI6RupF09KIDPl/QhBTBi WzZTdphmNvYX7nhmoPsu8mdovojB/Auz+uCUJXbp0Y+a0QYQSxjkHCQW57GuLuC7ZIzk kNvf3XgyTfUYi6W3NSVNC9KRnpZEUy8kbXwBmVnk3AawsyI1sZi9QSzc9S4343LCOl7u 838vkZ3lY3cuK3Ricar2utF3pzE6bsGh7l27mB+7MERV3RwnOCi15QEPy2Czr2KE/zzR E+kU6ZuP5o6LbyF4RO/fxAj3qorrfxQZv7P3AGaKG16peMQlM8O+xKdVn4CMi5VdUOEa MuHg== 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=qq22xznEO4fQ2ADySN036W1Iaw759n3OSnbVrtPpfGU=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=o2NcLbRuNLHFihIbLlQR4YOM1YvrwcpUlpD75/IJGvx5nNuA4vG2qE3uEnOYf6y/S1 +OWXHbAtq4EMPibFbAQcrrJrkX8wZjZQc0k4RDAWpbU8UoPCa3wqCvZ/yAmC4MRGWYUy V3eVzHXgJszck7WUEvpBBs71nQUE3Te4Yis+1Tb3TNF18/4o0o0tviBC3vpkgoPuGiI5 xXGXLbcRVPpEz5BfQ+1LNjGdI+/oNXNLJgPiV4cWqXLBBnb2K/o4h4jFZFq/LdZsGwVw IWSmsULWqZE88nR1KYNfuK+GrvpOKBjXmzjE8ADZMcn5MYUtFwaGRCmj7YrkQetlT6zh kWIw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZaGVLQsY; 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 v10-20020a05620a440a00b00789e8e8f04esi1461456qkp.454.2024.05.02.09.56.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 09:56:37 -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=ZaGVLQsY; 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 1s2Zir-00017X-Fv; Thu, 02 May 2024 12:55: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 1s2Zid-0000wr-I1 for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:43 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2Zia-0005wC-D4 for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:39 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6ed3cafd766so7387732b3a.0 for ; Thu, 02 May 2024 09:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714668935; x=1715273735; 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=qq22xznEO4fQ2ADySN036W1Iaw759n3OSnbVrtPpfGU=; b=ZaGVLQsYuCqKZjXEwtbFQUlyEDLD3hKf6MkjXqrjTkkxv1NlwANnz7WMQBOCOkEa9a uCk3I8WCvdVHhmUFP9Ng9myK4dSPs/6yZde2q5TBmufYvvOZiywoJ/PLOOCYxwu43jG1 R7fiiI1mU7aBBz4MqVRj/gYa1NYvEIzROjmHMkc8Re6QseQ3/W3fVi+lvITPNUf4sCRB ynLo8gZAiH09QEbNe/IkMvWAp+wlhhSr+T8C7DZeYl4ZTSTVeM13Z13hFrLIZX/B8/NX AAPYQ2N34OyfXt7XRtyQlFCJlGuqmxt5crqy8hh3WCIkLlYVM27gyX3l519Q1fWRO6/Q Z2xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714668935; x=1715273735; 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=qq22xznEO4fQ2ADySN036W1Iaw759n3OSnbVrtPpfGU=; b=wk5LftnFE+5rByVAj95xSVf4qJWVV8Yqs4GgWONeqf/GtDa8ByTiC15h/aIwHQZ3fj ABYyzB+hHQOAebptKFj4B9rllOWOHPPnTEJ3PW9b7zusONKWYjU/QnY5kP7SrjXG2iYx 6tS4n8j4K8zj9ok/HTnEtVt7gFXY7XqJii3N3uz2HvfhahemPdFLrFdY2x74LM+DHSZy toSUm7fR3q1KR3ff4d8sn96r4G2QOcpwnG0LHpoaqM3V/NphoPjJSNxwcs4QEHclpsZI pG23nbg0ViEbmgskWjJ6rHaoVbrDOJVdzxjr9rEyaT+I2O/NhmuhbjVYkVQG3An/FiIN yBOQ== X-Gm-Message-State: AOJu0Yx9HfYcmfC9FtZozWLU2p2z1PyARxibpMaPStFnVVk8cxXODEjX 2MBIHcfxL+GyoCzHv77l4/c56spFNe1+x6miLCP/UJR5hmz9xOVUSH3Fi8RjWOHQklltjU9AZfo 2 X-Received: by 2002:a05:6a00:464e:b0:6ec:db05:36c3 with SMTP id kp14-20020a056a00464e00b006ecdb0536c3mr165058pfb.4.1714668934821; Thu, 02 May 2024 09:55:34 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id j13-20020aa783cd000000b006eb058b2703sm1464598pfn.187.2024.05.02.09.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 09:55:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 6/7] target/sparc: Fix FPMERGE Date: Thu, 2 May 2024 09:55:27 -0700 Message-Id: <20240502165528.244004-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502165528.244004-1-richard.henderson@linaro.org> References: <20240502165528.244004-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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 This instruction has f32 inputs, which changes the decode of the register numbers. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/sparc/helper.h | 2 +- target/sparc/translate.c | 2 +- target/sparc/vis_helper.c | 27 ++++++++++++++------------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index fcb9c617b7..97fbf6f66c 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -94,7 +94,7 @@ DEF_HELPER_FLAGS_2(fstox, TCG_CALL_NO_WG, s64, env, f32) DEF_HELPER_FLAGS_2(fdtox, TCG_CALL_NO_WG, s64, env, f64) DEF_HELPER_FLAGS_2(fqtox, TCG_CALL_NO_WG, s64, env, i128) -DEF_HELPER_FLAGS_2(fpmerge, TCG_CALL_NO_RWG_SE, i64, i64, i64) +DEF_HELPER_FLAGS_2(fpmerge, TCG_CALL_NO_RWG_SE, i64, i32, i32) DEF_HELPER_FLAGS_2(fmul8x16, TCG_CALL_NO_RWG_SE, i64, i32, i64) DEF_HELPER_FLAGS_2(fmul8x16a, TCG_CALL_NO_RWG_SE, i64, i32, s32) DEF_HELPER_FLAGS_2(fmul8sux16, TCG_CALL_NO_RWG_SE, i64, i64, i64) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 8a2894bb9f..99c6f3cc72 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -4656,6 +4656,7 @@ TRANS(FMUL8x16AU, VIS1, do_dff, a, gen_op_fmul8x16au) TRANS(FMUL8x16AL, VIS1, do_dff, a, gen_op_fmul8x16al) TRANS(FMULD8SUx16, VIS1, do_dff, a, gen_op_fmuld8sux16) TRANS(FMULD8ULx16, VIS1, do_dff, a, gen_op_fmuld8ulx16) +TRANS(FPMERGE, VIS1, do_dff, a, gen_helper_fpmerge) static bool do_dfd(DisasContext *dc, arg_r_r_r *a, void (*func)(TCGv_i64, TCGv_i32, TCGv_i64)) @@ -4696,7 +4697,6 @@ static bool do_ddd(DisasContext *dc, arg_r_r_r *a, TRANS(FMUL8SUx16, VIS1, do_ddd, a, gen_helper_fmul8sux16) TRANS(FMUL8ULx16, VIS1, do_ddd, a, gen_helper_fmul8ulx16) -TRANS(FPMERGE, VIS1, do_ddd, a, gen_helper_fpmerge) TRANS(FPADD16, VIS1, do_ddd, a, tcg_gen_vec_add16_i64) TRANS(FPADD32, VIS1, do_ddd, a, tcg_gen_vec_add32_i64) diff --git a/target/sparc/vis_helper.c b/target/sparc/vis_helper.c index 61c61c7fea..14c665cad6 100644 --- a/target/sparc/vis_helper.c +++ b/target/sparc/vis_helper.c @@ -74,22 +74,23 @@ typedef union { float32 f; } VIS32; -uint64_t helper_fpmerge(uint64_t src1, uint64_t src2) +uint64_t helper_fpmerge(uint32_t src1, uint32_t src2) { - VIS64 s, d; + VIS32 s1, s2; + VIS64 d; - s.ll = src1; - d.ll = src2; + s1.l = src1; + s2.l = src2; + d.ll = 0; - /* Reverse calculation order to handle overlap */ - d.VIS_B64(7) = s.VIS_B64(3); - d.VIS_B64(6) = d.VIS_B64(3); - d.VIS_B64(5) = s.VIS_B64(2); - d.VIS_B64(4) = d.VIS_B64(2); - d.VIS_B64(3) = s.VIS_B64(1); - d.VIS_B64(2) = d.VIS_B64(1); - d.VIS_B64(1) = s.VIS_B64(0); - /* d.VIS_B64(0) = d.VIS_B64(0); */ + d.VIS_B64(7) = s1.VIS_B32(3); + d.VIS_B64(6) = s2.VIS_B32(3); + d.VIS_B64(5) = s1.VIS_B32(2); + d.VIS_B64(4) = s2.VIS_B32(2); + d.VIS_B64(3) = s1.VIS_B32(1); + d.VIS_B64(2) = s2.VIS_B32(1); + d.VIS_B64(1) = s1.VIS_B32(0); + d.VIS_B64(0) = s2.VIS_B32(0); return d.ll; } From patchwork Thu May 2 16:55:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 794116 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp353505wrr; Thu, 2 May 2024 09:56:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzo58I3nNhK9nyFKuKF3E9B+VVF8isr2tE5dCS6xdCcL9ljwwFLHij/4mVSn4LmR8C7TRChsZWEimKIivJgLZ7 X-Google-Smtp-Source: AGHT+IFVqGzxu5ioPFVDBD5Tb1iRYlV+AfXBC0QX2PUV07EC1BNe9NvqHsJYf60OPVAcY2WXzfAY X-Received: by 2002:ac8:5f48:0:b0:439:d0ed:39e4 with SMTP id y8-20020ac85f48000000b00439d0ed39e4mr123528qta.4.1714668980728; Thu, 02 May 2024 09:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714668980; cv=none; d=google.com; s=arc-20160816; b=QD03Zpo9ByfvyMmviDh0/WpYoO1vg08k51TQk+et28bcYHg7RVTt3jloorR3twFJFH uhah9BOScYMG6r4VEvi2AA2RVvyXuOxIkpDYSAcnL3dtpoeb/tc+0goGTB8HtArNonLo 0mitafHbM6ml4gIyb6hNQRM8nwRzFudHSUWz1ceTNRxNSDuoZmbAvXnLVXHFkkg5sMmU Ro2UV8sBATCr1gZqppe0WapZAiqm9U8Sv/Qck6gjEL2AU+nzc2Bl7+8wSdw3dFsm3HUF GsUuNnAZGEekvBfMJqNpPtZueeE9sqloJAa/DdZBZ1FBnTMV0u+aNO9D0p+uJq8M44w4 eHQw== 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=/SGeZv/4hYREHrq3/2i2w291gTT4MaAZ/Mhj+P3eA68=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=hTac1VglJMAl0B9b97kuznb29lDnuPDg/Xq3gTXna+LY3ndtUs3wafxIXrCOh6XZhw dj92sQ6+qppyNh/geQlo8+C69I0Z2RERVt1YK/NkGTvjv+ki5IiMZfgu9gKZ3TysWhJB 4Qd8ELvdavyRAFtSt443OeQmlpgIzyM+ikux/x4TyiNmYAGG8Tz09UTvK/ELWSBQalfW omiS/FSPysnbwFdUR4OBtQqWk+9TERq9UCVT9z/UtRgLVf1alQCxzpww5gX4KHMEh/Gz aaqgkI4rCg33NF2tuddyRabUWZfxtZVwUrflaJ9+aby8bZ44dyXnvLpjUHRvoEz6tcIq Vj5Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g6UbyFPX; 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 hc8-20020a05622a2a0800b0043af8d3965csi1236557qtb.779.2024.05.02.09.56.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 09:56: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=pass header.i=@linaro.org header.s=google header.b=g6UbyFPX; 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 1s2Ziv-0001No-19; Thu, 02 May 2024 12:55:57 -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 1s2Zid-0000ws-RM for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:43 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2Zib-0005wV-O9 for qemu-devel@nongnu.org; Thu, 02 May 2024 12:55:39 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ee13f19e7eso7521374b3a.1 for ; Thu, 02 May 2024 09:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714668936; x=1715273736; 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=/SGeZv/4hYREHrq3/2i2w291gTT4MaAZ/Mhj+P3eA68=; b=g6UbyFPX9QAkgvfquYp7rJutN74RjLnOVpZoz1Ssw/4X9AFbp57Crz4y8E/z7jaKaz WG5GXtOnFldbAH0zf0dr21W9Ac26oa5wOEesIR9moQ76uZGyvQZoD19Ny9eSL9pdEIUy q7p18AQAZRzpCMoNsuvEwlB/e6VNjQPe/v09GWILIVJ2rimp7f1deACm8oPLrX42Be6Z TXTRAqbcbcHsQKWMJjoXdG17hBDJH8+oqaMlB4FvqflYFOD6t79TIiKLQKo3iPi0AjOQ W/W6qUIc9aI7t1KIEDQQhTl6BAsZku2VShuKE3elNJQGfnER/X4+VNE3Hg9WPH41b2l0 z0Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714668936; x=1715273736; 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=/SGeZv/4hYREHrq3/2i2w291gTT4MaAZ/Mhj+P3eA68=; b=IIdm+w4XV10H4R/+UR6Jvj5w1X+T7TdXDS11x0JS2miDTLWJj2bV2iQomaEABEIetW 1+/v6R8W2+xgmIVNsxEF6sZhNlsWfNpSIdInLplbf1Dcgrp8hwS+mFnYcHQ7gDO16Iw3 nuCuUuU9Dur7RGmE5OuTHmibZUfEiW2wLOGjbBFcw1Qep6Oi949hQ879zLlPZN+NSyD7 Nu2yivfDH2ZXKbC0o45di6i6Z+m0fP9IokbrHYc/vgom/vwXivYhYukkFNta6S/w/6sL gwmr6/WoXATeg5xJaJjQ3nXA0JNmP7O9ebFo3679qJMH9nprj4z7fX6dyrX+C0zuX5FX GEmw== X-Gm-Message-State: AOJu0Yw564DE9JxsGQpEgWahtxrNtCdpBM8I8oz09eQNIWclAom9WqJZ 2gY3/8BdevI6ZJfspO7f1ePytQj4xae1zH4Ks4u6tiPMdkSRW3Bm1nvGoSeIpX1JdX4XefkVe4m G X-Received: by 2002:a05:6a00:1904:b0:6ed:d5f5:869 with SMTP id y4-20020a056a00190400b006edd5f50869mr153919pfi.3.1714668935866; Thu, 02 May 2024 09:55:35 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id j13-20020aa783cd000000b006eb058b2703sm1464598pfn.187.2024.05.02.09.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 09:55:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 7/7] target/sparc: Split out do_ms16b Date: Thu, 2 May 2024 09:55:28 -0700 Message-Id: <20240502165528.244004-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502165528.244004-1-richard.henderson@linaro.org> References: <20240502165528.244004-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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 The unit operation for fmul8x16 and friends is described in the manual as "MS16b". Split that out for clarity. Improve rounding with an unconditional addition of 0.5 as a fixed-point integer. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/sparc/vis_helper.c | 78 ++++++++++++--------------------------- 1 file changed, 24 insertions(+), 54 deletions(-) diff --git a/target/sparc/vis_helper.c b/target/sparc/vis_helper.c index 14c665cad6..e15c6bb34e 100644 --- a/target/sparc/vis_helper.c +++ b/target/sparc/vis_helper.c @@ -44,6 +44,7 @@ target_ulong helper_array8(target_ulong pixel_addr, target_ulong cubesize) #if HOST_BIG_ENDIAN #define VIS_B64(n) b[7 - (n)] +#define VIS_SB64(n) sb[7 - (n)] #define VIS_W64(n) w[3 - (n)] #define VIS_SW64(n) sw[3 - (n)] #define VIS_L64(n) l[1 - (n)] @@ -51,6 +52,7 @@ target_ulong helper_array8(target_ulong pixel_addr, target_ulong cubesize) #define VIS_W32(n) w[1 - (n)] #else #define VIS_B64(n) b[n] +#define VIS_SB64(n) sb[n] #define VIS_W64(n) w[n] #define VIS_SW64(n) sw[n] #define VIS_L64(n) l[n] @@ -60,6 +62,7 @@ target_ulong helper_array8(target_ulong pixel_addr, target_ulong cubesize) typedef union { uint8_t b[8]; + int8_t sb[8]; uint16_t w[4]; int16_t sw[4]; uint32_t l[2]; @@ -95,27 +98,23 @@ uint64_t helper_fpmerge(uint32_t src1, uint32_t src2) return d.ll; } +static inline int do_ms16b(int x, int y) +{ + return ((x * y) + 0x80) >> 8; +} + uint64_t helper_fmul8x16(uint32_t src1, uint64_t src2) { VIS64 d; VIS32 s; - uint32_t tmp; s.l = src1; d.ll = src2; -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B32(r); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; - - PMUL(0); - PMUL(1); - PMUL(2); - PMUL(3); -#undef PMUL + d.VIS_W64(0) = do_ms16b(s.VIS_B32(0), d.VIS_SW64(0)); + d.VIS_W64(1) = do_ms16b(s.VIS_B32(1), d.VIS_SW64(1)); + d.VIS_W64(2) = do_ms16b(s.VIS_B32(2), d.VIS_SW64(2)); + d.VIS_W64(3) = do_ms16b(s.VIS_B32(3), d.VIS_SW64(3)); return d.ll; } @@ -124,25 +123,14 @@ uint64_t helper_fmul8x16a(uint32_t src1, int32_t src2) { VIS32 s; VIS64 d; - uint32_t tmp; s.l = src1; d.ll = 0; -#define PMUL(r) \ - do { \ - tmp = src2 * (int32_t)s.VIS_B32(r); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; \ - } while (0) - - PMUL(0); - PMUL(1); - PMUL(2); - PMUL(3); -#undef PMUL + d.VIS_W64(0) = do_ms16b(s.VIS_B32(0), src2); + d.VIS_W64(1) = do_ms16b(s.VIS_B32(1), src2); + d.VIS_W64(2) = do_ms16b(s.VIS_B32(2), src2); + d.VIS_W64(3) = do_ms16b(s.VIS_B32(3), src2); return d.ll; } @@ -150,23 +138,14 @@ uint64_t helper_fmul8x16a(uint32_t src1, int32_t src2) uint64_t helper_fmul8sux16(uint64_t src1, uint64_t src2) { VIS64 s, d; - uint32_t tmp; s.ll = src1; d.ll = src2; -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; - - PMUL(0); - PMUL(1); - PMUL(2); - PMUL(3); -#undef PMUL + d.VIS_W64(0) = do_ms16b(s.VIS_SB64(1), d.VIS_SW64(0)); + d.VIS_W64(1) = do_ms16b(s.VIS_SB64(3), d.VIS_SW64(1)); + d.VIS_W64(2) = do_ms16b(s.VIS_SB64(5), d.VIS_SW64(2)); + d.VIS_W64(3) = do_ms16b(s.VIS_SB64(7), d.VIS_SW64(3)); return d.ll; } @@ -174,23 +153,14 @@ uint64_t helper_fmul8sux16(uint64_t src1, uint64_t src2) uint64_t helper_fmul8ulx16(uint64_t src1, uint64_t src2) { VIS64 s, d; - uint32_t tmp; s.ll = src1; d.ll = src2; -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; - - PMUL(0); - PMUL(1); - PMUL(2); - PMUL(3); -#undef PMUL + d.VIS_W64(0) = do_ms16b(s.VIS_B64(0), d.VIS_SW64(0)); + d.VIS_W64(1) = do_ms16b(s.VIS_B64(2), d.VIS_SW64(1)); + d.VIS_W64(2) = do_ms16b(s.VIS_B64(4), d.VIS_SW64(2)); + d.VIS_W64(3) = do_ms16b(s.VIS_B64(6), d.VIS_SW64(3)); return d.ll; }