From patchwork Tue Feb 27 14:38:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129799 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1467330lja; Tue, 27 Feb 2018 06:40:04 -0800 (PST) X-Google-Smtp-Source: AG47ELs9eedX/pfKnFeYeH/b+vAbEvrr/mJLf9ZKFyLYXp4zzWjDxcDRT5CwZ2SsgJr7JXHJP5xI X-Received: by 2002:a25:6e83:: with SMTP id j125-v6mr6790096ybc.107.1519742404204; Tue, 27 Feb 2018 06:40:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742404; cv=none; d=google.com; s=arc-20160816; b=nZfDqNMyzEJPm300ITq+0fxzZ/dfa8BxGwaqJZYV8z+czAsNQI9vLa8W9gX3hl+Mxk 3WlGGrWdaJgvUPMMt7OTteaFi98IG3tp75vZ4a31HicipQ76asoBwcQN39zxbimtsagN UeA/chVuNTrb/7hUFvtxqnnbEVBBbJzM4mre8acBNGdTdImLcGT35BoaOXy4uoEN3Vwm RWuiYlKXgayEsZJCU+YtS0MHwos8zzWBHWWvJ9iF2wDEVSehoO6FqqanaYqL61xxu4Z2 FkvRHLL6THBfzePD2Z03vnn1EAohwxsuxhMWQXZbjPnrunoyIA7tQjAYX4ASzJVzFzos OlVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=WrkCoShieYMDIzS/oHq6Q2ZjZ8fuWkRuW2hF8KIrtjs=; b=kJ2b+oegqG1juQO/W0q3FhrVVVhHVlnkagYEyl82ikgkqbnD+s1IPK/YHIhYJEEwQ5 pdtF0IcmlG/dVtyRjgevG8xOdogEghJ5yP71JbdDpJPCu7MOO123mQNZNuZolmHvTyw2 YJ5siHaCiIqcy+x7sMPgbaWCP5esztDMZ1UxGG/Xu9k/POdmKqHW3RR9onsXShb39i2V Kc9nq2JMV+N865n7vuHAwQky9fvhqjQ6VKHi88ylZNtxvDdJo8CtnFeOmx3NLm+YQMus P3kVzYfqtyMgz3N4ZyMQLOsNrxmjpT8d2p/mKed+JG8nj7dvFCJ9kyFa4fbj0Bx08J7l uwJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fp5EYsEv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s206si1908048ywc.625.2018.02.27.06.40.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:40:04 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fp5EYsEv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgQF-000494-I9 for patch@linaro.org; Tue, 27 Feb 2018 09:40:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPF-0003ZC-Jp for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPA-0007tk-Ua for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:01 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:37467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPA-0007tF-OS for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:38:56 -0500 Received: by mail-wm0-x243.google.com with SMTP id 139so11088222wmn.2 for ; Tue, 27 Feb 2018 06:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WrkCoShieYMDIzS/oHq6Q2ZjZ8fuWkRuW2hF8KIrtjs=; b=fp5EYsEveVdV3P+mgNIEsB7qy/hxOhh76f/UgKpkoeRR4XEtcKqG743jnWn94ReYrR EfjYPRcpWN8b37SgXXR3ioUcDroQsef0uhIp6kBOKq88y78HHNtOxWzUIqLX19wWaKtX 4K1FysaPpETi9X7ChqBUmwPksp6RT6ztNMozk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WrkCoShieYMDIzS/oHq6Q2ZjZ8fuWkRuW2hF8KIrtjs=; b=OU5lPmcKdtiKPw3LXhA1Fekvn7b8ql35m/bB9NcKCz2JXvnvsKszyPjSi70bH+YIjh eHBXEOM+MJiATAfHq4KV1KIUzqX4ah8fii99FyNsSB6o6Kq400whTUY0+4mxeZN9El+I MKTmtvVZB4l5kDVV6n1Fbd6H2teD+fokuLxrWlslIW6Ml0aOHNUjqwkMnuxp11HOemHR RXI0Zg/JgQhKJhGz3RAMnM2HIsuOo73YyzGLt7ipWwo95VYDUDS8S0fEsjKF/upJ9/IB mA2XMRAP1+Rc06TG4IEphZZrnVUUb30CUSYwFvSCFo9QhR5HWmQVGWr0cXHn6UDykER9 9jVg== X-Gm-Message-State: APf1xPDWvtj7FOuDS9+exZqs2mYr9pJi/jj4uWvfD2CVOeZHzGkYMLue P1pIxv3p+UHzbFVSLXIclBN7GQ== X-Received: by 10.28.105.65 with SMTP id e62mr7979388wmc.126.1519742335596; Tue, 27 Feb 2018 06:38:55 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p21sm8962891wmc.28.2018.02.27.06.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:54 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E755B3E025C; Tue, 27 Feb 2018 14:38:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:22 +0000 Message-Id: <20180227143852.11175-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH v4 01/31] include/exec/helper-head.h: support f16 in helper calls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Crosthwaite , richard.henderson@linaro.org, qemu-devel@nongnu.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This allows us to explicitly pass float16 to helpers rather than assuming uint32_t and dealing with the result. Of course they will be passed in i32 sized registers by default. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- include/exec/helper-head.h | 3 +++ 1 file changed, 3 insertions(+) -- 2.15.1 diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h index e1fd08f2ba..15b6a68de3 100644 --- a/include/exec/helper-head.h +++ b/include/exec/helper-head.h @@ -26,6 +26,7 @@ #define dh_alias_int i32 #define dh_alias_i64 i64 #define dh_alias_s64 i64 +#define dh_alias_f16 i32 #define dh_alias_f32 i32 #define dh_alias_f64 i64 #define dh_alias_ptr ptr @@ -38,6 +39,7 @@ #define dh_ctype_int int #define dh_ctype_i64 uint64_t #define dh_ctype_s64 int64_t +#define dh_ctype_f16 float16 #define dh_ctype_f32 float32 #define dh_ctype_f64 float64 #define dh_ctype_ptr void * @@ -94,6 +96,7 @@ #define dh_is_signed_s32 1 #define dh_is_signed_i64 0 #define dh_is_signed_s64 1 +#define dh_is_signed_f16 0 #define dh_is_signed_f32 0 #define dh_is_signed_f64 0 #define dh_is_signed_tl 0 From patchwork Tue Feb 27 14:38:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129803 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1471876lja; Tue, 27 Feb 2018 06:44:54 -0800 (PST) X-Google-Smtp-Source: AH8x224HC5TIT7iVZk9X0SMZFzuX/73vQrhHac5hhdjzxcJcevvopoU8y5cBgwqfdhyI8TLeaXh6 X-Received: by 10.129.74.139 with SMTP id x133mr9509521ywa.400.1519742693913; Tue, 27 Feb 2018 06:44:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742693; cv=none; d=google.com; s=arc-20160816; b=ankgH8B2LPCk5IbT0Yq0X0H3I+ZOeCU2Q8shZxLxnZyDOvWsJLJMjIahhqgIT1S0ii OzQG0ije3zfC2oC3pFVkwlpGcluCNYni49odRip6a/Jic2bw9APv+VyGUxvTgc11/USL MJzaglARFTfU5hIhqrgCgKdiivFdCcjYreY3LEMh0GjTNJS45sgIc77aqwwYU46/vd7a bo9hVDhW8sgE7Ea3A+KSOqeEUvT+55K1LimlGIrFyVL0tCNy7Csw7aQb7FbMqFIgfQA0 Cb3hW/e6Dbj1CAxNWDKXw4RUOlNfZX5b9r9aMTrAzDPLPLlFcG2ZRXCG00xi6xG8EJjS R8Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=5EXyTx7MtxQK2QtkQBD3MH1PJ+dwkjzleS7LmpbyAHo=; b=iBG03KbFkPUbZuVbtjEYR9pK+Wm/7jn2uCT79UmM39kuhSgYvyoGU8CTcMFPZRxs1P OvZG2Cv9eJqKysMhp6Y+9R238wdIDR2jSLPej4e/th0hXXSXfEc6DZgjP1aEK75lIDiN zozA704TtPA+E+Dm1k1cpEv67RzPaOgysimzOarjJI+KLTG3xoR3zpjUeTR7+2mOcKSy I8iIGTecSGUJgG2brNr5Q2QD323HENGPZd73F579Ls3597ipA6lXLSQN6y5kS4HT5aXw qilfKNC/sZWSFf8M8QiC4MrLaN331b/k/nVOIuXf6w2dewb9GPO3+ZMP31IfB9OX7xT+ S6Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UjQ/Rook; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l25si1938209ywk.294.2018.02.27.06.44.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:44:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UjQ/Rook; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37688 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgUv-0007xK-92 for patch@linaro.org; Tue, 27 Feb 2018 09:44:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPF-0003ZH-L2 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPB-0007uK-SU for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:01 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:39900) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPB-0007tq-LE for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:38:57 -0500 Received: by mail-wr0-x242.google.com with SMTP id w77so25076417wrc.6 for ; Tue, 27 Feb 2018 06:38:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5EXyTx7MtxQK2QtkQBD3MH1PJ+dwkjzleS7LmpbyAHo=; b=UjQ/Rook63aJeeHVrF31K1NG4osaIGKRah7NX4YBlthhy/sRTKB0YGw4kpm6tVBIYt rwt1cFd/K6TfjMhlxQ4sJWQj9GMc5CYyT4mno09IgoqJKsGuM+31jhReiE0v4Z/OCzCs nIFpnhQ0zHic9Y87vn7KmoRaMX9wHxK36rRWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5EXyTx7MtxQK2QtkQBD3MH1PJ+dwkjzleS7LmpbyAHo=; b=hG4VG02aPqeZHkqgOPe+yHfL1N6thu2FhhYoeigTprJ72auEcrEkEJTbkFeWrkqxEc efR4koSjkFL3rod0WxiDL2ZYO/nrSaQ4TK4Cjkel6ESiQ+r4rdA+xq5WO2TX5OuKFvta M/abj3ca/nF0py5kFlbPd1ct2S3pc+szvai4Qo+3X5cr2Bv8mCma5dCClPvMZhSdETy9 Yn2Hqlt48EVupLyrontfBQ1yaQX2DtSXyzxykb8BRzNxL6pOkrdjUtnmzIzphmJchlf1 rRDT3OSLqYB/OkUsCS37y94rBfMYEfu48cC01tOvEaPrmiNWUowIVzpDZS5l1jjNoKSV NYCg== X-Gm-Message-State: APf1xPBMdgGQBZH2KtJmzES4A8+hc5WZJ6dREICaTYzv09vyN7Xdte9a sxy1mHe4tZIkYp9ejQ6Ax5J+rg== X-Received: by 10.223.190.134 with SMTP id i6mr12838204wrh.157.1519742336550; Tue, 27 Feb 2018 06:38:56 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t135sm5435699wmt.44.2018.02.27.06.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:54 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 05E243E030F; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:23 +0000 Message-Id: <20180227143852.11175-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 02/31] target/arm/cpu64: introduce ARM_V8_FP16 feature bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/cpu.h | 1 + target/arm/cpu64.c | 1 + 2 files changed, 2 insertions(+) -- 2.15.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 8c839faa8f..267a9d7e2f 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1408,6 +1408,7 @@ enum arm_features { ARM_FEATURE_V8_SHA3, /* implements SHA3 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SM3, /* implements SM3 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SM4, /* implements SM4 part of v8 Crypto Extensions */ + ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ }; static inline int arm_feature(CPUARMState *env, int feature) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 1c330adc28..9743bdc8c3 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -230,6 +230,7 @@ static void aarch64_any_initfn(Object *obj) set_feature(&cpu->env, ARM_FEATURE_V8_SM4); set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); set_feature(&cpu->env, ARM_FEATURE_CRC); + set_feature(&cpu->env, ARM_FEATURE_V8_FP16); cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ cpu->dcz_blocksize = 7; /* 512 bytes */ } From patchwork Tue Feb 27 14:38:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129798 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1466988lja; Tue, 27 Feb 2018 06:39:38 -0800 (PST) X-Google-Smtp-Source: AG47ELua4zTzElVBE1dLemnw5VEiBXnA6F9EDfLSjwOGHq2M29ekIehKu3k8UwIUnOeCKvlz4TT7 X-Received: by 10.13.210.68 with SMTP id u65mr3415232ywd.410.1519742378657; Tue, 27 Feb 2018 06:39:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742378; cv=none; d=google.com; s=arc-20160816; b=XTk56EN8l+ncyihnfR9OhUAga3CLGuu0Oa+GrORg5ZKyzcgfpbCHlFWywjvyaJk82D 3C6igdupK3buhRFQWZ+GDBLfaHhMSi+e7kadSqQy1LmgDigRKn1J2jNdH5i71isMCHcN KL8ay3tp9yFbAnZGPBbyR9Pl27p+tj9uSOW+kowhExRrhAV/twzrKUS/jAUU8dvWAvke wb3K1h4C3inDle0Y7DFr/ULcWbNXpL7GJ4ragQQAQZLIjxHWmfWpME+1V4JQuu2aTgfl eCPNeXMsDG5Y/vTvRDVMmss72vTc73WpvxY1yaWqAtIEjPHf5QioeJDePLJeAPGMDRu0 UG2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=61++FvsPdKtMj6Nb+J9xfpHdw01KNL2Ks949pdJD05I=; b=S4/zG7h6uDBiQPR3xzVxMfmwBRL7E9TY8gQuFy2CPw7c/jPep980xBfuHFU3DHpJoH m0LNqgufnnowLeQYSXCXUOKwhWJRKR7HpmC/TDS8Ws42nTTPX3x0AEtr1boA0rjeAy+1 +5YK/gotDtOAHMpIRjiHM1wK92Q2Zlg51MphgqZDmG9i1+WZ3Ev88/KswiwoLo5gYx2P rEuotewBkqK9+AmKpudVC3C7Sse/orLBpvb1Eo2O4xLJ+sUI5G1JWXET5edYAKGEoIaP m7Ma4VV4PhFMNBZaFYnBnaEjljoJLqcrWFmnbUhuRSZ8f15WB2kuCVUrrNWLvLsF67hx lDGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jbAxBOIK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r18si1545033ywc.324.2018.02.27.06.39.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:39:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jbAxBOIK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPp-0003j7-Us for patch@linaro.org; Tue, 27 Feb 2018 09:39:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPF-0003ZB-JV for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPC-0007uw-TH for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:01 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPC-0007uT-MN for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:38:58 -0500 Received: by mail-wm0-x242.google.com with SMTP id 188so23612239wme.1 for ; Tue, 27 Feb 2018 06:38:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=61++FvsPdKtMj6Nb+J9xfpHdw01KNL2Ks949pdJD05I=; b=jbAxBOIKkEQ8WuDXUSuHjmFVw5W8rVvB10Z6utpiMwc+oCl3XK1ZePii2OyVEC6iF0 hfZD7+coBz7tlyhh4t3qVL+kGXHnIikRhFYOVe8HoQ2qqp4OVUPQA6DhH18gF7zprXiU kM51rU1EWxlrkdiEuruEHlxxMVKKAXp9z+lC0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=61++FvsPdKtMj6Nb+J9xfpHdw01KNL2Ks949pdJD05I=; b=uCy5vX9cVOJMkR2DuwAY3wr1DZq/NRZy65MRRSiIW0no5MUoZ8peF9siKkSJs9mRFt VWvjfH7BOMIqWMPZw/kJAzC4AiJbloShjamvEwFY6+pnS1Jp570YVuDh+OOuarUSfD1Z PVHvw5m1ueVLQiSKAnY0F+FD92qQobJE7ECCmaxV2JWAiikAM+bF22zgUyG9U6yXKPb5 fxh9fBHdwSn4MjImiFTwNAlf5uY/08DAnZdZo6OOU2DsLSttSBYc6R77MepIGKGGCcGJ 8CEU4f6QFDhzOQ3pjk10ry8pPfuPAmpAuEYCoxXHvMqtxim+yNCW6W+npq8VyyHRBKzH +ahQ== X-Gm-Message-State: APf1xPCZv4zH/I/LvSfd9q1Wxgt+6fvnmCgC2NDm/V/kDOEfxV96v5Gu ffvRQO+e6wiu/okIBdSxHAl8kA== X-Received: by 10.28.54.98 with SMTP id d95mr12230272wma.104.1519742337577; Tue, 27 Feb 2018 06:38:57 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x190sm13299933wme.27.2018.02.27.06.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:54 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 174F93E033B; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:24 +0000 Message-Id: <20180227143852.11175-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v4 03/31] target/arm/cpu.h: update comment for half-precision values X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - fix comment --- target/arm/cpu.h | 1 + 1 file changed, 1 insertion(+) -- 2.15.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 267a9d7e2f..25f31a4e21 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -168,6 +168,7 @@ typedef struct { * Qn = regs[n].d[1]:regs[n].d[0] * Dn = regs[n].d[0] * Sn = regs[n].d[0] bits 31..0 + * Hn = regs[n].d[0] bits 15..0 * * This corresponds to the architecturally defined mapping between * the two execution states, and means we do not need to explicitly From patchwork Tue Feb 27 14:38:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129804 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1472319lja; Tue, 27 Feb 2018 06:45:22 -0800 (PST) X-Google-Smtp-Source: AG47ELtlcFSBm10OFeN7zbxU76hMYpGVeJPw1u0VbTQsBnEzb69ylihdwersR2m2NWBLyMCmcZfU X-Received: by 2002:a25:8005:: with SMTP id m5-v6mr685109ybk.382.1519742722242; Tue, 27 Feb 2018 06:45:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742722; cv=none; d=google.com; s=arc-20160816; b=D3lga3pC1nKj1jYZG6OtwRlAFNKfv1y6dUjzJP5EjpH6iWw7fv8WR3ViqJvkYva0ff Czeg/H2ekpv3Ywy4CYBWDyAkklBNk+xmmI3A70RroB4RijVUuq27vI0hqy51VMonuiqX Jwzl3Iq0FcvEVzif9hA0+msx7f+8SThxEXPjuASmtjzw+Its1/wu12fV8ORI4Veiud+j WEawQDjOBBJYy/iuCXqIdrqLptIqUDTQouUnAiz91e4qp0vL9HzbYMHcMYz5ZbSqsMTr YUlewiFH2bv+DKzfoD2YiX/YoDYIqTS1m+J0k5M7Tn6zKDcBXEzY7p2TO1vOpcQ3tjQ/ QVsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=qTLAtU1u3hArQcelrSmFDOt7WYKCmbuWbDvRicoQ+pU=; b=VFgxLlAN3VkzXyLeJTePHzgaUVCtV0tOq9NBTZFPjc6BCVnJ9CY+NtrTf1meXo33Ng WpTya6gkxa8Kk0qQhpKnSmHkpDZIA6ETmRqAJmu/1XR5TEklcCJJQ/iD63lhVTBxNwBX ezM8I2hAHLEsqmJ3e7BdU7ES7eY01W6EEkLToQs44BCjqk9RFEcwE6PJNkYgxvezZYkO +3gtweXsAkiGpreojeOlpNTHbzdjZt+/AvSyNVReX00MOI0sD9K+5sNtVLLpRFAt7jK/ fBx8LWqV6TkolbbgsWRRHPx2YS8YL5GVqKbYROVaHMDgxhEyS4mPZSvr2OY0RkWGGtg+ HtAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LtCnNROx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u14-v6si1262009ybu.383.2018.02.27.06.45.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:45:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LtCnNROx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgVN-0000nD-L1 for patch@linaro.org; Tue, 27 Feb 2018 09:45:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPK-0003dd-Bi for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPE-0007wZ-Ro for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:06 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:55604) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPE-0007vK-HD for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:00 -0500 Received: by mail-wm0-x241.google.com with SMTP id q83so24621046wme.5 for ; Tue, 27 Feb 2018 06:39:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qTLAtU1u3hArQcelrSmFDOt7WYKCmbuWbDvRicoQ+pU=; b=LtCnNROxNRofeECGCdw1Q4KTr/TQOCz0YW4d822AGrGL6jmEP5I4403ci3FPpZOGM7 uhkpMEyk5Y78LY3AiT7oWm6bruXhww3j/mo9BcpkibgaFTccTRrOHfTwz4hHRwcwLSFE znnVVnVDX10WHZJL4qpyZMlXsKMavnWsB7hiM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qTLAtU1u3hArQcelrSmFDOt7WYKCmbuWbDvRicoQ+pU=; b=aTY8wCgLP96pCqBf+9Bkf16kODmppSJidYuu5gpMkojIC7X8tVLlRj0QPGNsOR19rX NaNLpCkDe1Yazn0xq849/vxm0tcAs3W8AYAtXFqd0fmE1MIUB/JQVGEE27WATkDoyrf6 zVY6nYLgMhAvcqUkReb6ZAOF4FeVO73eozzfLnBFZDP1m1AbFviX2RFTqhmgk4qDuEHs +xGJSMHTTBYVt7OUe0ZS2nJ3zbHwDxfHiq1Ryt1wh47U1KnqzPtGtiTFMkk17U06nL2k J2xH0fFjocuEBgtA99bl6FPTZDOrW9E/3C4kYgPWZLwAYJp6yR2pZyNWX3FmztvKTHdg 4sDQ== X-Gm-Message-State: APf1xPAjVDclQBjF8eefpd07pl0lV5dNMtgJSvDiaI1Sx47k8rIzO34q ppXRGNtq9WI6KGpg8xmtr07kOA== X-Received: by 10.28.63.81 with SMTP id m78mr12425748wma.102.1519742339165; Tue, 27 Feb 2018 06:38:59 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k38sm10667323wrk.39.2018.02.27.06.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:54 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 2BC5B3E0946; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:25 +0000 Message-Id: <20180227143852.11175-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH v4 04/31] target/arm/cpu.h: add additional float_status flags X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Half-precision flush to zero behaviour is controlled by a separate FZ16 bit in the FPCR. To handle this we pass a pointer to fp_status_fp16 when working on half-precision operations. The value of the presented FPCR is calculated from an amalgam of the two when read. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - add FPCR_[FZ/FZ16/DN] defines to cpu.h and use - only propagate flag status to fp_status as they are ored later - ensure dnan and round mode propagated to fp_status_fp16 --- target/arm/cpu.h | 32 ++++++++++++++++++++++------ target/arm/helper.c | 26 ++++++++++++++++++----- target/arm/translate-a64.c | 53 +++++++++++++++++++++++++--------------------- 3 files changed, 75 insertions(+), 36 deletions(-) -- 2.15.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 25f31a4e21..2b9740878b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -538,19 +538,29 @@ typedef struct CPUARMState { /* scratch space when Tn are not sufficient. */ uint32_t scratch[8]; - /* fp_status is the "normal" fp status. standard_fp_status retains - * values corresponding to the ARM "Standard FPSCR Value", ie - * default-NaN, flush-to-zero, round-to-nearest and is used by - * any operations (generally Neon) which the architecture defines - * as controlled by the standard FPSCR value rather than the FPSCR. + /* There are a number of distinct float control structures: + * + * fp_status: is the "normal" fp status. + * fp_status_fp16: used for half-precision calculations + * standard_fp_status : the ARM "Standard FPSCR Value" + * + * Half-precision operations are governed by a separate + * flush-to-zero control bit in FPSCR:FZ16. We pass a separate + * status structure to control this. + * + * The "Standard FPSCR", ie default-NaN, flush-to-zero, + * round-to-nearest and is used by any operations (generally + * Neon) which the architecture defines as controlled by the + * standard FPSCR value rather than the FPSCR. * * To avoid having to transfer exception bits around, we simply * say that the FPSCR cumulative exception flags are the logical - * OR of the flags in the two fp statuses. This relies on the + * OR of the flags in the three fp statuses. This relies on the * only thing which needs to read the exception flags being * an explicit FPSCR read. */ float_status fp_status; + float_status fp_status_f16; float_status standard_fp_status; /* ZCR_EL[1-3] */ @@ -1190,12 +1200,20 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) uint32_t vfp_get_fpscr(CPUARMState *env); void vfp_set_fpscr(CPUARMState *env, uint32_t val); -/* For A64 the FPSCR is split into two logically distinct registers, +/* FPCR, Floating Point Control Register + * FPSR, Floating Poiht Status Register + * + * For A64 the FPSCR is split into two logically distinct registers, * FPCR and FPSR. However since they still use non-overlapping bits * we store the underlying state in fpscr and just mask on read/write. */ #define FPSR_MASK 0xf800009f #define FPCR_MASK 0x07f79f00 + +#define FPCR_FZ16 (1 << 19) /* ARMv8.2+, FP16 flush-to-zero */ +#define FPCR_FZ (1 << 24) /* Flush-to-zero enable bit */ +#define FPCR_DN (1 << 25) /* Default NaN enable bit */ + static inline uint32_t vfp_get_fpsr(CPUARMState *env) { return vfp_get_fpscr(env) & FPSR_MASK; diff --git a/target/arm/helper.c b/target/arm/helper.c index c5bc69b961..f450eb200f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11103,6 +11103,7 @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | (env->vfp.vec_stride << 20); i = get_float_exception_flags(&env->vfp.fp_status); i |= get_float_exception_flags(&env->vfp.standard_fp_status); + i |= get_float_exception_flags(&env->vfp.fp_status_f16); fpscr |= vfp_exceptbits_from_host(i); return fpscr; } @@ -11160,16 +11161,31 @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) break; } set_float_rounding_mode(i, &env->vfp.fp_status); + set_float_rounding_mode(i, &env->vfp.fp_status_f16); } - if (changed & (1 << 24)) { - set_flush_to_zero((val & (1 << 24)) != 0, &env->vfp.fp_status); - set_flush_inputs_to_zero((val & (1 << 24)) != 0, &env->vfp.fp_status); + if (changed & FPCR_FZ16) { + bool ftz_enabled = val & FPCR_FZ16; + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16); + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16); + } + if (changed & FPCR_FZ) { + bool ftz_enabled = val & FPCR_FZ; + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status); + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status); + } + if (changed & FPCR_DN) { + bool dnan_enabled = val & FPCR_DN; + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status); + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); } - if (changed & (1 << 25)) - set_default_nan_mode((val & (1 << 25)) != 0, &env->vfp.fp_status); + /* The exception flags are ORed together when we read fpscr so we + * only need to preserve the current state in one of our + * float_status values. + */ i = vfp_exceptbits_to_host(val); set_float_exception_flags(i, &env->vfp.fp_status); + set_float_exception_flags(0, &env->vfp.fp_status_f16); set_float_exception_flags(0, &env->vfp.standard_fp_status); } diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 1c88539d62..2c64d2b3fe 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -637,16 +637,21 @@ static void write_fp_sreg(DisasContext *s, int reg, TCGv_i32 v) tcg_temp_free_i64(tmp); } -static TCGv_ptr get_fpstatus_ptr(void) +static TCGv_ptr get_fpstatus_ptr(bool is_f16) { TCGv_ptr statusptr = tcg_temp_new_ptr(); int offset; - /* In A64 all instructions (both FP and Neon) use the FPCR; - * there is no equivalent of the A32 Neon "standard FPSCR value" - * and all operations use vfp.fp_status. + /* In A64 all instructions (both FP and Neon) use the FPCR; there + * is no equivalent of the A32 Neon "standard FPSCR value". + * However half-precision operations operate under a different + * FZ16 flag and use vfp.fp_status_f16 instead of vfp.fp_status. */ - offset = offsetof(CPUARMState, vfp.fp_status); + if (is_f16) { + offset = offsetof(CPUARMState, vfp.fp_status_f16); + } else { + offset = offsetof(CPUARMState, vfp.fp_status); + } tcg_gen_addi_ptr(statusptr, cpu_env, offset); return statusptr; } @@ -4423,7 +4428,7 @@ static void handle_fp_compare(DisasContext *s, bool is_double, bool cmp_with_zero, bool signal_all_nans) { TCGv_i64 tcg_flags = tcg_temp_new_i64(); - TCGv_ptr fpst = get_fpstatus_ptr(); + TCGv_ptr fpst = get_fpstatus_ptr(false); if (is_double) { TCGv_i64 tcg_vn, tcg_vm; @@ -4598,7 +4603,7 @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) TCGv_i32 tcg_op; TCGv_i32 tcg_res; - fpst = get_fpstatus_ptr(); + fpst = get_fpstatus_ptr(false); tcg_op = read_fp_sreg(s, rn); tcg_res = tcg_temp_new_i32(); @@ -4660,7 +4665,7 @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn) return; } - fpst = get_fpstatus_ptr(); + fpst = get_fpstatus_ptr(false); tcg_op = read_fp_dreg(s, rn); tcg_res = tcg_temp_new_i64(); @@ -4840,7 +4845,7 @@ static void handle_fp_2src_single(DisasContext *s, int opcode, TCGv_ptr fpst; tcg_res = tcg_temp_new_i32(); - fpst = get_fpstatus_ptr(); + fpst = get_fpstatus_ptr(false); tcg_op1 = read_fp_sreg(s, rn); tcg_op2 = read_fp_sreg(s, rm); @@ -4893,7 +4898,7 @@ static void handle_fp_2src_double(DisasContext *s, int opcode, TCGv_ptr fpst; tcg_res = tcg_temp_new_i64(); - fpst = get_fpstatus_ptr(); + fpst = get_fpstatus_ptr(false); tcg_op1 = read_fp_dreg(s, rn); tcg_op2 = read_fp_dreg(s, rm); @@ -4979,7 +4984,7 @@ static void handle_fp_3src_single(DisasContext *s, bool o0, bool o1, { TCGv_i32 tcg_op1, tcg_op2, tcg_op3; TCGv_i32 tcg_res = tcg_temp_new_i32(); - TCGv_ptr fpst = get_fpstatus_ptr(); + TCGv_ptr fpst = get_fpstatus_ptr(false); tcg_op1 = read_fp_sreg(s, rn); tcg_op2 = read_fp_sreg(s, rm); @@ -5017,7 +5022,7 @@ static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1, { TCGv_i64 tcg_op1, tcg_op2, tcg_op3; TCGv_i64 tcg_res = tcg_temp_new_i64(); - TCGv_ptr fpst = get_fpstatus_ptr(); + TCGv_ptr fpst = get_fpstatus_ptr(false); tcg_op1 = read_fp_dreg(s, rn); tcg_op2 = read_fp_dreg(s, rm); @@ -5158,7 +5163,7 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, TCGv_ptr tcg_fpstatus; TCGv_i32 tcg_shift; - tcg_fpstatus = get_fpstatus_ptr(); + tcg_fpstatus = get_fpstatus_ptr(false); tcg_shift = tcg_const_i32(64 - scale); @@ -5870,7 +5875,7 @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn) TCGv_i32 tcg_elt1 = tcg_temp_new_i32(); TCGv_i32 tcg_elt2 = tcg_temp_new_i32(); TCGv_i32 tcg_elt3 = tcg_temp_new_i32(); - TCGv_ptr fpst = get_fpstatus_ptr(); + TCGv_ptr fpst = get_fpstatus_ptr(false); assert(esize == 32); assert(elements == 4); @@ -6372,7 +6377,7 @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn) } size = extract32(size, 0, 1) ? 3 : 2; - fpst = get_fpstatus_ptr(); + fpst = get_fpstatus_ptr(false); break; default: unallocated_encoding(s); @@ -6864,7 +6869,7 @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn, int fracbits, int size) { bool is_double = size == 3 ? true : false; - TCGv_ptr tcg_fpst = get_fpstatus_ptr(); + TCGv_ptr tcg_fpst = get_fpstatus_ptr(false); TCGv_i32 tcg_shift = tcg_const_i32(fracbits); TCGv_i64 tcg_int = tcg_temp_new_i64(); TCGMemOp mop = size | (is_signed ? MO_SIGN : 0); @@ -6980,7 +6985,7 @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, tcg_rmode = tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO)); gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); - tcg_fpstatus = get_fpstatus_ptr(); + tcg_fpstatus = get_fpstatus_ptr(false); tcg_shift = tcg_const_i32(fracbits); if (is_double) { @@ -7326,7 +7331,7 @@ static void handle_3same_float(DisasContext *s, int size, int elements, int fpopcode, int rd, int rn, int rm) { int pass; - TCGv_ptr fpst = get_fpstatus_ptr(); + TCGv_ptr fpst = get_fpstatus_ptr(false); for (pass = 0; pass < elements; pass++) { if (size) { @@ -7790,7 +7795,7 @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, return; } - fpst = get_fpstatus_ptr(); + fpst = get_fpstatus_ptr(false); if (is_double) { TCGv_i64 tcg_op = tcg_temp_new_i64(); @@ -7897,7 +7902,7 @@ static void handle_2misc_reciprocal(DisasContext *s, int opcode, int size, int rn, int rd) { bool is_double = (size == 3); - TCGv_ptr fpst = get_fpstatus_ptr(); + TCGv_ptr fpst = get_fpstatus_ptr(false); if (is_double) { TCGv_i64 tcg_op = tcg_temp_new_i64(); @@ -8296,7 +8301,7 @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn) if (is_fcvt) { tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode)); gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); - tcg_fpstatus = get_fpstatus_ptr(); + tcg_fpstatus = get_fpstatus_ptr(false); } else { tcg_rmode = NULL; tcg_fpstatus = NULL; @@ -9516,7 +9521,7 @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode, /* Floating point operations need fpst */ if (opcode >= 0x58) { - fpst = get_fpstatus_ptr(); + fpst = get_fpstatus_ptr(false); } else { fpst = NULL; } @@ -10676,7 +10681,7 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) } if (need_fpstatus) { - tcg_fpstatus = get_fpstatus_ptr(); + tcg_fpstatus = get_fpstatus_ptr(false); } else { tcg_fpstatus = NULL; } @@ -11056,7 +11061,7 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) } if (is_fp) { - fpst = get_fpstatus_ptr(); + fpst = get_fpstatus_ptr(false); } else { fpst = NULL; } From patchwork Tue Feb 27 14:38:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129802 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1469528lja; Tue, 27 Feb 2018 06:42:21 -0800 (PST) X-Google-Smtp-Source: AG47ELu4p/oTZzCGFm4jPEY7JrqpwUoNNYga12MubQdosn6FuSCYjp8BArt2qyBR68RxVpx6qppm X-Received: by 2002:a25:bdd1:: with SMTP id g17-v6mr830146ybk.84.1519742540970; Tue, 27 Feb 2018 06:42:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742540; cv=none; d=google.com; s=arc-20160816; b=zrqFmDqV7XskboqQhrFlQhRz6e4m5rbXjUfe3iFy1qgCUtjh9QTsXr1pI5wa9Zt9q+ NydnUk1zN3/05FHcFsrwNcOi8/pMcQI9ABydOXyWbg0Xthp956oeHTdbFllsTo+4Sxd9 fup6mFXcI5P7mZzbMbwv81TMe5IvrjAdJu6734W7uESKYgvv6V8BYKqEWPxzO865S43V i+8rH9DP6TMoyztUHNdRcq0SET9gbXVm4W/cLEKe7lDxytPsl+g+2Xdi3PCODhrYLRGB +UtZCKSC/IaRHiAE974xGHtVb9Kc9g2lcJu8oCxdGN1ZXJlHR2UPKaanCWqIXtjTo6AB Q8JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=LJUErzFkgq9BGjZ2PKmulrYADuCBwuUQ20W84XZ+HPc=; b=TDMrVrDj3CyMOdb4S6X0MfOUhCV/y6fZF2D3gda88zdGF7RjiGy+lOweEBkrN6VoX7 PLk8mLgnMF/Ve+CcPyN2SKM6tJmZdP0gljNYobwcdwVgVs4+MaxKhoKeVFG5e9nuU/zf cXQVGWtc+Dc8mk20qRA3zQcO/RcrW8C9/L8IvyPgh5QorF6qZof8m0kIVAy7ydgiDJm5 K1aBiNJ56JDtV7tFcLXh++w6BdemaYUjLEH74qTgEsx14+78ZIr5DBpyFTRLvZRq5MdC azW0kRUpnV71r2xXAc5Vw+y5U5I/ev2l+D6fyns5XQYQP8ItfewdQZc/SJ3vs3GfrWFU QHZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cwnTELqL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q6si1875174ywd.739.2018.02.27.06.42.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:42:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cwnTELqL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgSS-0006LQ-AV for patch@linaro.org; Tue, 27 Feb 2018 09:42:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPJ-0003d3-Kk for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPI-0007yX-08 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:05 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:38865) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPH-0007yB-M1 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:03 -0500 Received: by mail-wr0-x241.google.com with SMTP id n7so25120068wrn.5 for ; Tue, 27 Feb 2018 06:39:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LJUErzFkgq9BGjZ2PKmulrYADuCBwuUQ20W84XZ+HPc=; b=cwnTELqLYnNynVfzLquAzfiEp6Kgr0ciFSZRA7WepPxXj32qA9fQ41Lsu6XG+SpFTI M3p7VNdkPbhouMsgUxpACHpdDrNEZp2rt7auAAe3hsY+nQhZWTrr7jKvPWTA5rr3V1U+ ruk2x8ScZ+CrNFKJratBTNpRL65gSHY+CG9Oo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LJUErzFkgq9BGjZ2PKmulrYADuCBwuUQ20W84XZ+HPc=; b=T7My6Gi4KiaUabLbOQG4tKCcrscqrF5zyvtLfAWTpTsY7Z8puhNskfYna1KY4S2TSM 3iqtHPqTxz2Q0QHCinRv3Pg+zWQN2XezXeoAiESM+vbkIZPqNwd7fW6t+udAmnTEVMFN KxR6XDvnii/lbzuSHFsIpHl7c5ld+dLrCqL+PkM5woy7WpWSuhB6xHdwJhUAjH53W3OX 8HSPoAhLFb0dsH8YiPwSkWMT666WxT+ud3lCg0wvB6h6jZ83EsFo4GHCpjEaYX3c8tJx dZg3k4SU4eI/M8oWIEjl7rRvIwhJycVOYjBA4CjJdHCt1p/UbLZjxGT5vTjCb/f2SItA Kx/A== X-Gm-Message-State: APf1xPDLlAYqVJPF553FBYRQudejWCZwkvWOFLXjd9YhIicnbtGpqTwV O0MGY32MmJbBqWgM3F/yMLmorA== X-Received: by 10.223.178.232 with SMTP id g95mr13946311wrd.35.1519742342469; Tue, 27 Feb 2018 06:39:02 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m55sm13757785wrf.38.2018.02.27.06.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:59 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 410D23E0962; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:26 +0000 Message-Id: <20180227143852.11175-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH v4 05/31] target/arm/helper: pass explicit fpst to set_rmode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As the rounding mode is now split between FP16 and the rest of floating point we need to be explicit when tweaking it. Instead of passing the CPU env we now pass the appropriate fpst pointer directly. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/helper.c | 4 ++-- target/arm/helper.h | 2 +- target/arm/translate-a64.c | 26 +++++++++++++------------- target/arm/translate.c | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) -- 2.15.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index f450eb200f..303cd1eaf9 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11393,9 +11393,9 @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) /* Set the current fp rounding mode and return the old one. * The argument is a softfloat float_round_ value. */ -uint32_t HELPER(set_rmode)(uint32_t rmode, CPUARMState *env) +uint32_t HELPER(set_rmode)(uint32_t rmode, void *fpstp) { - float_status *fp_status = &env->vfp.fp_status; + float_status *fp_status = fpstp; uint32_t prev_rmode = get_float_rounding_mode(fp_status); set_float_rounding_mode(rmode, fp_status); diff --git a/target/arm/helper.h b/target/arm/helper.h index 6383d7d09e..81ecb319b3 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -167,7 +167,7 @@ DEF_HELPER_3(vfp_uhtod, f64, i64, i32, ptr) DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr) DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr) -DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, env) +DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr) DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env) DEF_HELPER_2(vfp_fcvt_f16_to_f32, f32, i32, env) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2c64d2b3fe..91c2b8ed11 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -4628,10 +4628,10 @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) { TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); gen_helper_rints(tcg_res, tcg_op, fpst); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); tcg_temp_free_i32(tcg_rmode); break; } @@ -4687,10 +4687,10 @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn) { TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); gen_helper_rintd(tcg_res, tcg_op, fpst); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); tcg_temp_free_i32(tcg_rmode); break; } @@ -5217,7 +5217,7 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); if (is_double) { TCGv_i64 tcg_double = read_fp_dreg(s, rn); @@ -5264,7 +5264,7 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, tcg_temp_free_i32(tcg_single); } - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); tcg_temp_free_i32(tcg_rmode); if (!sf) { @@ -6984,8 +6984,8 @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, assert(!(is_scalar && is_q)); tcg_rmode = tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); tcg_fpstatus = get_fpstatus_ptr(false); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); tcg_shift = tcg_const_i32(fracbits); if (is_double) { @@ -7029,7 +7029,7 @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, tcg_temp_free_ptr(tcg_fpstatus); tcg_temp_free_i32(tcg_shift); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); tcg_temp_free_i32(tcg_rmode); } @@ -8300,8 +8300,8 @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn) if (is_fcvt) { tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); tcg_fpstatus = get_fpstatus_ptr(false); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); } else { tcg_rmode = NULL; tcg_fpstatus = NULL; @@ -8366,7 +8366,7 @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn) } if (is_fcvt) { - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); tcg_temp_free_i32(tcg_rmode); tcg_temp_free_ptr(tcg_fpstatus); } @@ -10680,14 +10680,14 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) return; } - if (need_fpstatus) { + if (need_fpstatus || need_rmode) { tcg_fpstatus = get_fpstatus_ptr(false); } else { tcg_fpstatus = NULL; } if (need_rmode) { tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); } else { tcg_rmode = NULL; } @@ -10929,7 +10929,7 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) clear_vec_high(s, is_q, rd); if (need_rmode) { - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); tcg_temp_free_i32(tcg_rmode); } if (need_fpstatus) { diff --git a/target/arm/translate.c b/target/arm/translate.c index 1270022289..aa6dcaa577 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3143,7 +3143,7 @@ static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, TCGv_i32 tcg_rmode; tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); if (dp) { TCGv_i64 tcg_op; @@ -3167,7 +3167,7 @@ static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, tcg_temp_free_i32(tcg_res); } - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); tcg_temp_free_i32(tcg_rmode); tcg_temp_free_ptr(fpst); @@ -3184,7 +3184,7 @@ static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, tcg_shift = tcg_const_i32(0); tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding)); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); if (dp) { TCGv_i64 tcg_double, tcg_res; @@ -3222,7 +3222,7 @@ static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, tcg_temp_free_i32(tcg_single); } - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); tcg_temp_free_i32(tcg_rmode); tcg_temp_free_i32(tcg_shift); @@ -3892,13 +3892,13 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) TCGv_ptr fpst = get_fpstatus_ptr(0); TCGv_i32 tcg_rmode; tcg_rmode = tcg_const_i32(float_round_to_zero); - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); if (dp) { gen_helper_rintd(cpu_F0d, cpu_F0d, fpst); } else { gen_helper_rints(cpu_F0s, cpu_F0s, fpst); } - gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); tcg_temp_free_i32(tcg_rmode); tcg_temp_free_ptr(fpst); break; From patchwork Tue Feb 27 14:38:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129801 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1469509lja; Tue, 27 Feb 2018 06:42:20 -0800 (PST) X-Google-Smtp-Source: AG47ELuW7MzTd41w94qmtDYuT+AsCf0LG8UtIpu7ARbFx015IxyMdFPboFfnsvOOGZdTxaKAmV3W X-Received: by 2002:a25:bd1:: with SMTP id 200-v6mr1275177ybl.68.1519742540037; Tue, 27 Feb 2018 06:42:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742540; cv=none; d=google.com; s=arc-20160816; b=HhGOXNUUlfabbQreSbDHQsmNViDuR6tzeU6cgasB1vpecargY8zLY7aGOynrSOmqqt QMnONV5SrbYHWesmo4BR/ybOwCP1DwlJpcVc2tRrljCg29orDl6cSEpkCgqXnkMM7KzD nL513iczh7FJwZhJv47a07JE+E0F0UuAN8HUm/1kKVX+MWJFZyB7vg8Obi8H+4hwP+DZ 5CoxYCISYxe92gAwGUlMrmt6yEYUOdBaPUek/ZM+V5I/mdXhZhXzjiU11CObfdvkt+Q2 0I9GZe2JWADSaND0mlREJ8sDS/iln8ttHVZlXsbqQF+NNa5c2HzNg+P2Xxg+3RHr9I/U 6Rew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=tIJ5d2GcFeAwMZmYlpoC01XfdO99ce2ZsNfJkGnJ5JY=; b=rX/i6eOHUZ6N/JLw55p7WBcOkzeuYca4Q1mcGEJg7ZtyI6a0tHSohRX33neaCzUWT5 pKxbdoXDWriKxoasepiQeRHhG52m7yWOzBpucZTuPmMLU12Qq3c/hmGakjHC5+cN8jjH tha5tZp1rgzJDjsMbQIS3GAYZhelJ0W4f7x0WloCrfQVt+FyYKhAZZj7WGDOlqFdwGNu DHDKERXxB07vRTJ+5Sc5VlKBq6YIVfYcMrgL3O2HO0oi9U6fsTgjxrmBsvNqDaiP7IDS zMjuHvLRVrDo3ZN3WqDuRzfbpUFAp5mnk/MIz19XisMdDlWFXJ+yikaHSmAK7kb+gnjJ Y33Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KkQWuRd/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h124-v6si285949ybh.573.2018.02.27.06.42.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:42:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KkQWuRd/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgSR-0006KI-D7 for patch@linaro.org; Tue, 27 Feb 2018 09:42:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPK-0003dT-5N for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPI-0007yi-Ow for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:06 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:33642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPI-0007yL-FX for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:04 -0500 Received: by mail-wr0-x242.google.com with SMTP id s5so25128497wra.0 for ; Tue, 27 Feb 2018 06:39:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tIJ5d2GcFeAwMZmYlpoC01XfdO99ce2ZsNfJkGnJ5JY=; b=KkQWuRd/h+1bQqMFVUmV9aTzPQCzDJUhNLPUDs3IGWiHknIxOI5bONHI1RmPcZyzUm jJpjzE10Skf9tL8Tf906YAyvtjHljhISE9Jmy9l9dLYSmdh011Z4VY6KSzYhpjuXGAae JmpauHa3t0hHCUdWjNDEpxYvF6Lnml98KLA2w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tIJ5d2GcFeAwMZmYlpoC01XfdO99ce2ZsNfJkGnJ5JY=; b=GgO0R7WQl+p4Kiaepwf7+br0CXCi7oo+nH3O3a65NoGWuhn8D3w2gYD/WyzkKkiA+W 8jJLJlM+T7XYCv+xEZqfaNeOhyASmG2FEDCgp6wxfmeqoZDhzq47997pPE2kQyQ2HIcr e4FZflQAm4kLNGnJ4X/yStSb0kJSEmOQ5C0UDUD13pNir0dyi9DHipxEFlJzIOi3y7ou thNpDh53ZjG2nCqGmPIr5AcC0VlSRyt7FCJUv5dBSjzqMTh9LfNFSos6gK/zZaD+x9qX zZ/a01kHx1ekJtOWyn6yM0Zvt7MFfr/iRQgsa+S7sKT+V07swC3URbsgMFAXzEFvQzZ/ QX9g== X-Gm-Message-State: APf1xPD1/raeTk4x9puLeKcR9ojzzqJNPOWCQsnc9JYk714Pie4A7Fe8 SOig7MxneRnU9isjPNShdIFKvA== X-Received: by 10.223.132.103 with SMTP id 94mr3527188wrf.275.1519742343323; Tue, 27 Feb 2018 06:39:03 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 35sm1475647wra.4.2018.02.27.06.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:59 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 566303E0971; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:27 +0000 Message-Id: <20180227143852.11175-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 06/31] arm/translate-a64: implement half-precision F(MIN|MAX)(V|NMV) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This implements the half-precision variants of the across vector reduction operations. This involves a re-factor of the reduction code which more closely matches the ARM ARM order (and handles 8 element reductions). Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson -- v1 - dropped the advsimd_2a stuff v2 - fixed up checkpatch v3 - add TCG_CALL_NO_RWG to helper definitions --- target/arm/helper-a64.c | 18 ++++++ target/arm/helper-a64.h | 4 ++ target/arm/translate-a64.c | 142 ++++++++++++++++++++++++++++----------------- 3 files changed, 110 insertions(+), 54 deletions(-) -- 2.15.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 10e08bdc1f..fddd5d242b 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -572,3 +572,21 @@ uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr, { return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, true, GETPC()); } + +/* + * AdvSIMD half-precision + */ + +#define ADVSIMD_HELPER(name, suffix) HELPER(glue(glue(advsimd_, name), suffix)) + +#define ADVSIMD_HALFOP(name) \ +float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \ +{ \ + float_status *fpst = fpstp; \ + return float16_ ## name(a, b, fpst); \ +} + +ADVSIMD_HALFOP(min) +ADVSIMD_HALFOP(max) +ADVSIMD_HALFOP(minnum) +ADVSIMD_HALFOP(maxnum) diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 85d86741db..cb2a73124d 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -48,3 +48,7 @@ DEF_HELPER_FLAGS_4(paired_cmpxchg64_le_parallel, TCG_CALL_NO_WG, DEF_HELPER_FLAGS_4(paired_cmpxchg64_be, TCG_CALL_NO_WG, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_4(paired_cmpxchg64_be_parallel, TCG_CALL_NO_WG, i64, env, i64, i64, i64) +DEF_HELPER_FLAGS_3(advsimd_maxh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) +DEF_HELPER_FLAGS_3(advsimd_minh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) +DEF_HELPER_FLAGS_3(advsimd_maxnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) +DEF_HELPER_FLAGS_3(advsimd_minnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 91c2b8ed11..ebaf4571ac 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5741,26 +5741,75 @@ static void disas_simd_zip_trn(DisasContext *s, uint32_t insn) tcg_temp_free_i64(tcg_resh); } -static void do_minmaxop(DisasContext *s, TCGv_i32 tcg_elt1, TCGv_i32 tcg_elt2, - int opc, bool is_min, TCGv_ptr fpst) -{ - /* Helper function for disas_simd_across_lanes: do a single precision - * min/max operation on the specified two inputs, - * and return the result in tcg_elt1. - */ - if (opc == 0xc) { - if (is_min) { - gen_helper_vfp_minnums(tcg_elt1, tcg_elt1, tcg_elt2, fpst); - } else { - gen_helper_vfp_maxnums(tcg_elt1, tcg_elt1, tcg_elt2, fpst); - } +/* + * do_reduction_op helper + * + * This mirrors the Reduce() pseudocode in the ARM ARM. It is + * important for correct NaN propagation that we do these + * operations in exactly the order specified by the pseudocode. + * + * This is a recursive function, TCG temps should be freed by the + * calling function once it is done with the values. + */ +static TCGv_i32 do_reduction_op(DisasContext *s, int fpopcode, int rn, + int esize, int size, int vmap, TCGv_ptr fpst) +{ + if (esize == size) { + int element; + TCGMemOp msize = esize == 16 ? MO_16 : MO_32; + TCGv_i32 tcg_elem; + + /* We should have one register left here */ + assert(ctpop8(vmap) == 1); + element = ctz32(vmap); + assert(element < 8); + + tcg_elem = tcg_temp_new_i32(); + read_vec_element_i32(s, tcg_elem, rn, element, msize); + return tcg_elem; } else { - assert(opc == 0xf); - if (is_min) { - gen_helper_vfp_mins(tcg_elt1, tcg_elt1, tcg_elt2, fpst); - } else { - gen_helper_vfp_maxs(tcg_elt1, tcg_elt1, tcg_elt2, fpst); + int bits = size / 2; + int shift = ctpop8(vmap) / 2; + int vmap_lo = (vmap >> shift) & vmap; + int vmap_hi = (vmap & ~vmap_lo); + TCGv_i32 tcg_hi, tcg_lo, tcg_res; + + tcg_hi = do_reduction_op(s, fpopcode, rn, esize, bits, vmap_hi, fpst); + tcg_lo = do_reduction_op(s, fpopcode, rn, esize, bits, vmap_lo, fpst); + tcg_res = tcg_temp_new_i32(); + + switch (fpopcode) { + case 0x0c: /* fmaxnmv half-precision */ + gen_helper_advsimd_maxnumh(tcg_res, tcg_lo, tcg_hi, fpst); + break; + case 0x0f: /* fmaxv half-precision */ + gen_helper_advsimd_maxh(tcg_res, tcg_lo, tcg_hi, fpst); + break; + case 0x1c: /* fminnmv half-precision */ + gen_helper_advsimd_minnumh(tcg_res, tcg_lo, tcg_hi, fpst); + break; + case 0x1f: /* fminv half-precision */ + gen_helper_advsimd_minh(tcg_res, tcg_lo, tcg_hi, fpst); + break; + case 0x2c: /* fmaxnmv */ + gen_helper_vfp_maxnums(tcg_res, tcg_lo, tcg_hi, fpst); + break; + case 0x2f: /* fmaxv */ + gen_helper_vfp_maxs(tcg_res, tcg_lo, tcg_hi, fpst); + break; + case 0x3c: /* fminnmv */ + gen_helper_vfp_minnums(tcg_res, tcg_lo, tcg_hi, fpst); + break; + case 0x3f: /* fminv */ + gen_helper_vfp_mins(tcg_res, tcg_lo, tcg_hi, fpst); + break; + default: + g_assert_not_reached(); } + + tcg_temp_free_i32(tcg_hi); + tcg_temp_free_i32(tcg_lo); + return tcg_res; } } @@ -5802,16 +5851,21 @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn) break; case 0xc: /* FMAXNMV, FMINNMV */ case 0xf: /* FMAXV, FMINV */ - if (!is_u || !is_q || extract32(size, 0, 1)) { - unallocated_encoding(s); - return; - } - /* Bit 1 of size field encodes min vs max, and actual size is always - * 32 bits: adjust the size variable so following code can rely on it + /* Bit 1 of size field encodes min vs max and the actual size + * depends on the encoding of the U bit. If not set (and FP16 + * enabled) then we do half-precision float instead of single + * precision. */ is_min = extract32(size, 1, 1); is_fp = true; - size = 2; + if (!is_u && arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + size = 1; + } else if (!is_u || !is_q || extract32(size, 0, 1)) { + unallocated_encoding(s); + return; + } else { + size = 2; + } break; default: unallocated_encoding(s); @@ -5868,38 +5922,18 @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn) } } else { - /* Floating point ops which work on 32 bit (single) intermediates. + /* Floating point vector reduction ops which work across 32 + * bit (single) or 16 bit (half-precision) intermediates. * Note that correct NaN propagation requires that we do these * operations in exactly the order specified by the pseudocode. */ - TCGv_i32 tcg_elt1 = tcg_temp_new_i32(); - TCGv_i32 tcg_elt2 = tcg_temp_new_i32(); - TCGv_i32 tcg_elt3 = tcg_temp_new_i32(); - TCGv_ptr fpst = get_fpstatus_ptr(false); - - assert(esize == 32); - assert(elements == 4); - - read_vec_element(s, tcg_elt, rn, 0, MO_32); - tcg_gen_extrl_i64_i32(tcg_elt1, tcg_elt); - read_vec_element(s, tcg_elt, rn, 1, MO_32); - tcg_gen_extrl_i64_i32(tcg_elt2, tcg_elt); - - do_minmaxop(s, tcg_elt1, tcg_elt2, opcode, is_min, fpst); - - read_vec_element(s, tcg_elt, rn, 2, MO_32); - tcg_gen_extrl_i64_i32(tcg_elt2, tcg_elt); - read_vec_element(s, tcg_elt, rn, 3, MO_32); - tcg_gen_extrl_i64_i32(tcg_elt3, tcg_elt); - - do_minmaxop(s, tcg_elt2, tcg_elt3, opcode, is_min, fpst); - - do_minmaxop(s, tcg_elt1, tcg_elt2, opcode, is_min, fpst); - - tcg_gen_extu_i32_i64(tcg_res, tcg_elt1); - tcg_temp_free_i32(tcg_elt1); - tcg_temp_free_i32(tcg_elt2); - tcg_temp_free_i32(tcg_elt3); + TCGv_ptr fpst = get_fpstatus_ptr(size == MO_16); + int fpopcode = opcode | is_min << 4 | is_u << 5; + int vmap = (1 << elements) - 1; + TCGv_i32 tcg_res32 = do_reduction_op(s, fpopcode, rn, esize, + (is_q ? 128 : 64), vmap, fpst); + tcg_gen_extu_i32_i64(tcg_res, tcg_res32); + tcg_temp_free_i32(tcg_res32); tcg_temp_free_ptr(fpst); } From patchwork Tue Feb 27 14:38:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129797 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1466976lja; Tue, 27 Feb 2018 06:39:37 -0800 (PST) X-Google-Smtp-Source: AG47ELuvx/8DshHAUTGWxiBR/b6cqyPHGEvnPbLemV0lChdP0tbetEqlhvnPK5R/1e2Gg4kMnPeA X-Received: by 10.129.154.200 with SMTP id r191mr9479641ywg.311.1519742377831; Tue, 27 Feb 2018 06:39:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742377; cv=none; d=google.com; s=arc-20160816; b=VzsYY+1nzFpZXpLTfZPQyUxvYcfNm64A1YZvhSES0D83PjC8zwXbYR/nBhTefeXMBH w4msvxCEm7BFNDuZYMkY6ewhZFXhUQXVNaJ4mfSF1O9uCqEjs3ObBdPBXsg20ZdVc5Hn UOiJ+UVVx1ewHeZPoFcG9zgE0PxXZQEZLF9t2xbgzGGErddwCeB1ZCIbzaXNNN3WsML4 6JOrq8iIu/olvIWqjVSscFVkaqj7pvEdrHh8TCSUzDqiEYzeGWj7ztp5ElzTmOYLtalE GkbUK+hNo4WKYvM88NBVGJdE3pibGT7DsikWHvEITYJeaJQfaAMP3QGpq6rJQ2Xwv5ih 9Tvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Iw0vC7G/Fdearlly0m3YmrmwA6Bs9KCNgEwTL/OBByU=; b=Y/jquZB60UYZnYT6HKx1tWOaQeIXP+BMM09zsvI5yU9COuKDLEjMVioS0IfaeO/rL/ 8GCnoMpbRfLHnGJGFHLmGGBReZ+V0KhtqfWxXlgyvjOUhNP+44grLJ6ga04mtKLhIYub 37FR9bDpkGWfIv2mLKfOeftiEeWnYLtbKogLWwBntBDz4DcpHDxBejrs5p0tPBj1n2/8 kJ4c07DLT7HqCkiYF/+a6jNWi1ziHXPqWwg1mBAef3kPaAOZgtLTJ/PL7v68+aCAZQXX nHwZckUKgXtOAv3WrwyT5Uiv+iIqNSIupRdPVX8cbTCcBi3l8q1fJPLCyqSGIkGsfsTU ppJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=J4T5iLoY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l124-v6si870804ybf.358.2018.02.27.06.39.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:39:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=J4T5iLoY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPp-0003hH-5W for patch@linaro.org; Tue, 27 Feb 2018 09:39:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPK-0003eC-OH for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPJ-0007zN-Rs for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:06 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:42655) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPJ-0007z0-Lk for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:05 -0500 Received: by mail-wr0-x244.google.com with SMTP id k9so25124640wre.9 for ; Tue, 27 Feb 2018 06:39:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Iw0vC7G/Fdearlly0m3YmrmwA6Bs9KCNgEwTL/OBByU=; b=J4T5iLoYt1aBoQWdKG7HhHsoCu1uEEfa6bn3uvHqAUOgHEBICSZC5j8XNKWLuXDWJ5 vI5L/WoR15aE1hYhc5hUXej3GCaQOvF7a9Z6LEjpAYZ1G8wUlY7Rlci7fuZ8n0ciD7fH zbVo3TUuggrIiJVl5eNs6jBnfTgObWCrSg8SU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Iw0vC7G/Fdearlly0m3YmrmwA6Bs9KCNgEwTL/OBByU=; b=ZtqqpD3zN/FusgEdhPwJ/soh0NEiFI+NakGCArqNkHPv5zT4ud85ILrRIT9EYCl9Tl NUHWJp2YKzee/undm3G1OTvvwBIa4WJ+Xhkbjui1Sy/WjGsz6D1Bw3JMGDKCr8COQUnG tagz7xEsMetbpyJR3MIdZGh9e3nbXHFkRRd74G+XX5K/endzj+5Cf7lQrxgx6gSjYepe /xv2QR9QP7si6unvCfegm7nZq64BXwKP0Er5coSdEepddGAEGgUGPbVY7We1ItpRwWF4 vDzxcn2A8SesQS3LHBovhqHH6M3rFQquMMM7X/LOtGEC1P7bsbU2fjkBG2nzc/Yp5wzt rJag== X-Gm-Message-State: APf1xPDa2HP3aczvK0nMHpqRLW+tSpFL/AIOiDGkKEnhQm4ocEPEyr6M 4j7KtAh+734GMHwEHnaBDVuZPA== X-Received: by 10.223.183.43 with SMTP id l43mr13761937wre.265.1519742344571; Tue, 27 Feb 2018 06:39:04 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d8sm851953wmd.20.2018.02.27.06.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:59 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 673943E0980; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:28 +0000 Message-Id: <20180227143852.11175-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PATCH v4 07/31] arm/translate-a64: handle_3same_64 comment fix X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We do implement all the opcodes. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/translate-a64.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index ebaf4571ac..5dd54b7ac4 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -7278,8 +7278,7 @@ static void handle_3same_64(DisasContext *s, int opcode, bool u, /* Handle 64x64->64 opcodes which are shared between the scalar * and vector 3-same groups. We cover every opcode where size == 3 * is valid in either the three-reg-same (integer, not pairwise) - * or scalar-three-reg-same groups. (Some opcodes are not yet - * implemented.) + * or scalar-three-reg-same groups. */ TCGCond cond; From patchwork Tue Feb 27 14:38:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129811 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp366754edc; Tue, 27 Feb 2018 06:52:05 -0800 (PST) X-Google-Smtp-Source: AG47ELs0ReHQpQkZ0Q4VhQdDaAbPY930+OneOjv5u9xzyRdzQFmLzybi+XSpmj3cEIk2G/n3a/G3 X-Received: by 10.129.175.86 with SMTP id x22mr9601827ywj.158.1519743125493; Tue, 27 Feb 2018 06:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743125; cv=none; d=google.com; s=arc-20160816; b=qJr3B0ltyrulf+RLe99Vf2bUAAv/OzSooD/mKE4T1Ja0jRcHYthpp+ea0VeDb9IUHE 5Xr0NoMSEXYff8siCEmK2zhJSjC8oqMmYqSrGqw4tsblDKijZS1isgaHATkYEaImbSL+ RMvUtAT5c2ff1/M91nEnE4dNqjJmJdqFEjZnKXXtZAQ25DJH4VHnpftqjGR5gMTzNjo8 AGTyLR+GRv3ja8q23q2w6ttgMnWE6cwPbe/MOTHrUt6BYIYMrNuvMf/ousPg9HuotjVq +wwOz6pKgPe5A87PsgI7MIxqtZEo1Vc6rF7Zm3wjYECdTrHcLkxeXxCvuDgRiS/GUjaI KC7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=5e92OlfPhH3uuKn8l58mdAFexdWXszJjfX8UyDvWKY8=; b=r1LwYlglwcXyrZJvVCuZP4oelhdJ5YRrg72+tC+2QBSjE50HHgr67V+K9UC3X3wp6h r986hmOsFswqJ6oFk8za8NzODTncP801nZsiIGl/MqmNE+jBfwc2fU6rhMEaQYGXvxzS 0BJxhM4gbpPJeVN9/kkMQXlvb07ODdu09oU6aRDlIO664L7G9LcWK1CpCo59e4SBry1S LVaUUrReHJu9vX5cQV79E2o3HE7Rz9Hc6moLaZj1QFEIG/Ci+qIrR/7Jz/P1EqWasyJ0 BjJpYNABJqkvnffR8KPuKCdj2VlcDwDeVMrC8ZaDXs52eHaQygHwlF9xrDBTszJlphFU inng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YJnHlfrc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v2-v6si1776162ybe.51.2018.02.27.06.52.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:52:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YJnHlfrc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgbt-0006ZF-0N for patch@linaro.org; Tue, 27 Feb 2018 09:52:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPQ-0003jz-0h for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPK-00080I-UV for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:11 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:54154) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPK-0007zo-Ms for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:06 -0500 Received: by mail-wm0-x241.google.com with SMTP id t74so24667384wme.3 for ; Tue, 27 Feb 2018 06:39:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5e92OlfPhH3uuKn8l58mdAFexdWXszJjfX8UyDvWKY8=; b=YJnHlfrcjafYkR01bXNZrJLJdkk/F+dMvu0MAtpVmdccbti55gNYUF7D6LrdnM8YQf jgPBiQDR+cpkhY9K/lJRbAK1kRvDNv0ntHABfVIGcdjGRj8xbZWYwuv5J9VSOGhF6Yrf WbDWBab27xJ3jLtvg9GJ9lLG6wL3ptA9i2Ih8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5e92OlfPhH3uuKn8l58mdAFexdWXszJjfX8UyDvWKY8=; b=m6amURBh1LCN4vSff7nRSDBqJj+k+KR+1EAhk0IYEAK6k/315+eH6IGnU363XK4wip aqifQi6ERRKmfw5keHdSeI6eWb/58LQtaWmixi/ZyQfzmrW9/x/vLs8eTGLEhQac1QaC ybkLerVMWTc+RjTvBJ1Euh0l0W0Z4y+8Ud6yipNsI2bUbqgrdI/KHygXeDlrWbpJtQfA vw9vueoU3bUZP03t8EBUGUVfpAmHzwZEohyaA/FhUpwGVsAWgGnaT3Nr/UWomgcvDxN+ KJroSVN/WpPDYM7F9O7HpoTIJaHuzh/xl0apwnMna5HH9W49H3QrgP6AlHg5urfHziWf UgbQ== X-Gm-Message-State: APf1xPAq1EQ66r7BSN83GdvvD803KXuVdoHVQgV1cfLRO1CuRJYzF/eF 940+OUs14HPWOdWPkhReXWadWy7qsM4= X-Received: by 10.28.230.68 with SMTP id d65mr9259191wmh.13.1519742345562; Tue, 27 Feb 2018 06:39:05 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c1sm10230586wre.10.2018.02.27.06.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:59 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 790BC3E0990; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:29 +0000 Message-Id: <20180227143852.11175-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH v4 08/31] arm/translate-a64: initial decode for simd_three_reg_same_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is the initial decode skeleton for the Advanced SIMD three same instruction group. The fprintf is purely to aid debugging as the additional instructions are added. It will be removed once the group is complete. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/translate-a64.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 5dd54b7ac4..4828457b5b 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10228,6 +10228,78 @@ static void disas_simd_three_reg_same(DisasContext *s, uint32_t insn) } } +/* + * Advanced SIMD three same (ARMv8.2 FP16 variants) + * + * 31 30 29 28 24 23 22 21 20 16 15 14 13 11 10 9 5 4 0 + * +---+---+---+-----------+---------+------+-----+--------+---+------+------+ + * | 0 | Q | U | 0 1 1 1 0 | a | 1 0 | Rm | 0 0 | opcode | 1 | Rn | Rd | + * +---+---+---+-----------+---------+------+-----+--------+---+------+------+ + * + * This includes FMULX, FCMEQ (register), FRECPS, FRSQRTS, FCMGE + * (register), FACGE, FABD, FCMGT (register) and FACGT. + * + */ +static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) +{ + int opcode, fpopcode; + int is_q, u, a, rm, rn, rd; + int datasize, elements; + int pass; + TCGv_ptr fpst; + + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + unallocated_encoding(s); + return; + } + + if (!fp_access_check(s)) { + return; + } + + /* For these floating point ops, the U, a and opcode bits + * together indicate the operation. + */ + opcode = extract32(insn, 11, 3); + u = extract32(insn, 29, 1); + a = extract32(insn, 23, 1); + is_q = extract32(insn, 30, 1); + rm = extract32(insn, 16, 5); + rn = extract32(insn, 5, 5); + rd = extract32(insn, 0, 5); + + fpopcode = opcode | (a << 3) | (u << 4); + datasize = is_q ? 128 : 64; + elements = datasize / 16; + + fpst = get_fpstatus_ptr(true); + + for (pass = 0; pass < elements; pass++) { + TCGv_i32 tcg_op1 = tcg_temp_new_i32(); + TCGv_i32 tcg_op2 = tcg_temp_new_i32(); + TCGv_i32 tcg_res = tcg_temp_new_i32(); + + read_vec_element_i32(s, tcg_op1, rn, pass, MO_16); + read_vec_element_i32(s, tcg_op2, rm, pass, MO_16); + + switch (fpopcode) { + default: + fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n", + __func__, insn, fpopcode, s->pc); + g_assert_not_reached(); + } + + write_vec_element_i32(s, tcg_res, rd, pass, MO_16); + tcg_temp_free_i32(tcg_res); + tcg_temp_free_i32(tcg_op1); + tcg_temp_free_i32(tcg_op2); + } + + tcg_temp_free_ptr(fpst); + + clear_vec_high(s, is_q, rd); +} + static void handle_2misc_widening(DisasContext *s, int opcode, bool is_q, int size, int rn, int rd) { @@ -11975,6 +12047,7 @@ static const AArch64DecodeTable data_proc_simd[] = { { 0xce000000, 0xff808000, disas_crypto_four_reg }, { 0xce800000, 0xffe00000, disas_crypto_xar }, { 0xce408000, 0xffe0c000, disas_crypto_three_reg_imm2 }, + { 0x0e400400, 0x9f60c400, disas_simd_three_reg_same_fp16 }, { 0x00000000, 0x00000000, NULL } }; From patchwork Tue Feb 27 14:38:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129808 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1475382lja; Tue, 27 Feb 2018 06:48:49 -0800 (PST) X-Google-Smtp-Source: AG47ELu3TsLjA8Gxg3DhZFEqU6Jfi6nsTQlsNrOR0Kd7SNybnHI/y18xuUX6fJh9nCGIb6q5WsGj X-Received: by 10.129.112.19 with SMTP id l19mr9560095ywc.200.1519742928976; Tue, 27 Feb 2018 06:48:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742928; cv=none; d=google.com; s=arc-20160816; b=TnTsDwQUJGmsdJFq269HwDZlrZA6XdMWpr6dI27M7GpPzo4FrdegG+A01zRmloP0/i 8jhi6V1XA408SbrRcvEkH3bTfEowVPdnULiWItK01qReFsGJwSpQi7EBngfFuTapgKVV VfOdF6KPTkSAvatQA1cfonx7XYwf52Z/6m3u+2731hLG3hBrk36Vlu3pt5kr9cuhm+Wt /jyA9UAnbLBWDjKsbbW/RgA4PLrAvbcLg/sS6p/Icyq2NHYv8Zl82P3ej6eAA8p9I7zj VctzOXUrJUxg2ihBFSGvubiurk03zTW6uykdNY7W6wdiq3jVVzJWYyzu/EKy0ITxZUh+ 37hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=o5+6wz+aEOUl6k83db9fdFtzMNltkGU6ZiUGBUHl+ho=; b=YaO0/KAXQoXcyuoUmOvQwFTn6+6E1oKgm5DWFFOEWudefKb8UWwH/UL9RW6So0dghf jltFn+lpAZAH8eh0swafH7qH4ZltNlIuBk7XAvbqlqANDpZDMZfz+799+qwAiqt3Vd33 LK3ILNmP/ebfjnIlXeZ15c+OhqYorPF488xXN30SJk96FyfpSeVs/Zy2skaA0rcTkhr6 Jzq/vJCPbOLbDoCcRog7+Yu+KzF5L+MMbARxKEZhv+ERKaZvZxzK7SWTAnxFFgUmr5js nd6p57o1IwXiZG8OJnu8nuMB5QjtCidCNQJDeoobFqF2/s+hvW1oQYOSikvlffu5HCTF rLMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AJD9xc4x; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x127si476951ywf.256.2018.02.27.06.48.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:48:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AJD9xc4x; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYh-0003km-Hn for patch@linaro.org; Tue, 27 Feb 2018 09:48:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPQ-0003jw-0e for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPN-00081c-3d for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:11 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:40640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPM-00081L-TG for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:09 -0500 Received: by mail-wm0-x242.google.com with SMTP id t6so15916270wmt.5 for ; Tue, 27 Feb 2018 06:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o5+6wz+aEOUl6k83db9fdFtzMNltkGU6ZiUGBUHl+ho=; b=AJD9xc4xOmbNXtMDHY/7Mm9YvZmP8yY+5RBPf61Su8Eq9QD6A07f8/lwVLCnUCTWnH GZS+xU5uLufjcStYJabV4gv8tQuOwFAau1ndHbj706Qs+Ris7jEQwxlmnbO2K6OIk2L/ KB/dap1G987MI9JW5NI3EMZdaAIhLqn23j0bg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o5+6wz+aEOUl6k83db9fdFtzMNltkGU6ZiUGBUHl+ho=; b=hhibqgrwwaQElMZR1mnxWyN9le4AqvkL/VfNV0aZzhjb39ZqgjsrriAnXSGycpsXlJ 80yOww2ockYDNTdkEWVoSfrfZS+M+yoz6/lrqbM0lnieaq4SFuhYVCEHjuDaYtPhQdsT f2QPf2sir9ObRso2osf6d0w+6NtUEVJrVG/zVZppaEWoOjwrCyg5cbsmiAvGdtrHmh1a +nMnbAM12zfwZ4TbGry8dS15N2JTTG/wBXhvTTYqYD1hG4KhxLQdQQasR+lo2U87fMha vQ8wYo3WWOJTRX+Fmk2rlgRhNk/0srEcmCaZj7jo/P7PD0foOcxf+lQQFDGGkCK370XH tNLw== X-Gm-Message-State: APf1xPAeI0Gj0YusmSv0boqcu+hGZzOQ9WLaFHwwFLuqPNVa9pmTTIxT V3xQVZEeXCX8p7XxdTJaPuD8OA== X-Received: by 10.28.148.130 with SMTP id w124mr11565794wmd.124.1519742347812; Tue, 27 Feb 2018 06:39:07 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x190sm13300059wme.27.2018.02.27.06.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:59 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 8D4553E099E; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:30 +0000 Message-Id: <20180227143852.11175-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v4 09/31] arm/translate-a64: add FP16 FADD/FABD/FSUB/FMUL/FDIV to simd_three_reg_same_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The fprintf is only there for debugging as the skeleton is added to, it will be removed once the skeleton is complete. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 - add absh helper - fix checkpatch violation - make abs a bitwise operation --- target/arm/helper-a64.c | 4 ++++ target/arm/helper-a64.h | 4 ++++ target/arm/translate-a64.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) -- 2.15.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index fddd5d242b..931a6d3c34 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -586,6 +586,10 @@ float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \ return float16_ ## name(a, b, fpst); \ } +ADVSIMD_HALFOP(add) +ADVSIMD_HALFOP(sub) +ADVSIMD_HALFOP(mul) +ADVSIMD_HALFOP(div) ADVSIMD_HALFOP(min) ADVSIMD_HALFOP(max) ADVSIMD_HALFOP(minnum) diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index cb2a73124d..bac9469426 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -52,3 +52,7 @@ DEF_HELPER_FLAGS_3(advsimd_maxh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(advsimd_minh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(advsimd_maxnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(advsimd_minnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) +DEF_HELPER_3(advsimd_addh, f16, f16, f16, ptr) +DEF_HELPER_3(advsimd_subh, f16, f16, f16, ptr) +DEF_HELPER_3(advsimd_mulh, f16, f16, f16, ptr) +DEF_HELPER_3(advsimd_divh, f16, f16, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 4828457b5b..f8770ee1e9 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10283,6 +10283,34 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) read_vec_element_i32(s, tcg_op2, rm, pass, MO_16); switch (fpopcode) { + case 0x0: /* FMAXNM */ + gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x2: /* FADD */ + gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x6: /* FMAX */ + gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x8: /* FMINNM */ + gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0xa: /* FSUB */ + gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0xe: /* FMIN */ + gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x13: /* FMUL */ + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x17: /* FDIV */ + gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x1a: /* FABD */ + gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); + tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff); + break; default: fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n", __func__, insn, fpopcode, s->pc); From patchwork Tue Feb 27 14:38:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129818 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp375007edc; Tue, 27 Feb 2018 06:59:49 -0800 (PST) X-Google-Smtp-Source: AH8x225Z4AJq7apxkTPU0cBbhPa8frOpFAYS2Zi2SkNZA/7GTIRRw2yDDRi6gEhng1WyU9J83pOP X-Received: by 10.129.172.67 with SMTP id z3mr9485513ywj.274.1519743589157; Tue, 27 Feb 2018 06:59:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743589; cv=none; d=google.com; s=arc-20160816; b=WqApF8Trxc2fffki2a4xBA/A9b9/coZAOF+5AggNS9AfpNZdb/rFdPCOS49Uey4Jda O+ou7zjIcz6nPyc96wl+VrW1iX8t8S4qe3YmxSnHn2Sx9wwGDohQ13mElebZ4cawLwU9 A6tE2cAq58/zw7qMaakKppp1HxBtXnnhqAp5uT4e6qpZMOR+dvja0VjDlfpRidCcmEqF HfHCZ3n5u6X44pCCM9zBIdANkEcumfttDvMKgefudtot/hbE0W8O+lNae9GUl/qklLVA 698ydO/zZNJ1wFW+6xtfzrqRRW2Bq94Z/XJPVVxBMKg9XOmuVr88m0QJJ/jSOmpKvuWN wAWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=aMF5EFMIfmgDHcAcUtJQ+mMjaKQoI6swhZLrjQq1RZc=; b=kzlV5fvbq5oEthLP7YpyKTgN+DQFrj3KO8XKTW8wzqpwN73MJ8s4DNFWPWg2ozspaC 7Ul8Mxco8mnCuJBK3IQ9NL9SIOE1dvyf9HUf3Ept7v6rAFf8qcbgKaxvsmElRgU2r5I6 IRgFayua8CAqnsnGlzwNKdmwTi9QWITHCbuIPZ8u6KknkQXDEbvytQy/Ow25hdnSbdDZ 3L/t2TAvqAeneHYPY82s9yuXdkTV1rvYzs702b2lfOBULaHFBR9C2HiXscRggGcFSlWX BA4nzIIt1ri2GijzDSK/QgQQwGYjKrkjnZgnUlcp1Oe8DXjovq14U3vWorgyG08al4SA zcDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GGh6e7qw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c11-v6si1759717ybg.350.2018.02.27.06.59.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:59:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GGh6e7qw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgjM-0004Oh-Gk for patch@linaro.org; Tue, 27 Feb 2018 09:59:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPQ-0003jy-0o for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPM-00081E-5X for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:11 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:40031) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPL-00080Y-T5 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:08 -0500 Received: by mail-wr0-x241.google.com with SMTP id o76so25127916wrb.7 for ; Tue, 27 Feb 2018 06:39:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aMF5EFMIfmgDHcAcUtJQ+mMjaKQoI6swhZLrjQq1RZc=; b=GGh6e7qwo3MQ7GOw3iDo52e3aXdaOEbl254mkGm/6Q64FbHvcs3FwM273MPO4vCzfc UzWMIU+j2uLd8hCYpdp8RTkX9QFxpp9eAbhdqzGucTTE4lgT3byiBDCqI1pmYizgwSBm g4n2Qq9bTDDCTg077CcPaIDC7ruKEjRT2o4jY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aMF5EFMIfmgDHcAcUtJQ+mMjaKQoI6swhZLrjQq1RZc=; b=UUfvoyxpVFqn3OUT4miFOeY5wx5hvShQaiC1L05mobOAMCH4h28Hb/IXwU3XjR5l7X aTbyhahUbRL2MOhUD2sEzuKTbNe+d53ILH/nLfkhvXLt/GNGEQMdOVVl6fVOoFc3sXYl wLpRDebNmT+/tF+MzGkCDAmycDRxcruC/nmjBABY7EGdwf2DgarcAiMXJis4Zz7oAfQ0 2/kv17/VnMOikSSf2cwz5Ej0NgLvDL9WhubyiRihzPjyjJOxLEaYJh4jYkfeTXomPtuL lkbUQrBZ/l3sO2PSewrTIPOCW8jhQL1+B/UyVO0unr6qNY7EvQM3z7oJ4XM7BbEAWsjn fecg== X-Gm-Message-State: APf1xPBa2XSElJ49Kq9cHgTqjXYlW8zBBu9K9VBGNBLh9kEJqNH6ZMOg dw+Yew17hgKHSKk9TRiV//9G9Q== X-Received: by 10.223.136.71 with SMTP id e7mr12429297wre.252.1519742346716; Tue, 27 Feb 2018 06:39:06 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 55sm17210536wrw.87.2018.02.27.06.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:59 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A1B613E09C4; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:31 +0000 Message-Id: <20180227143852.11175-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH v4 10/31] arm/translate-a64: add FP16 F[A]C[EQ/GE/GT] to simd_three_reg_same_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These use the generic float16_compare functionality which in turn uses the common float_compare code from the softfloat re-factor. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/helper-a64.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ target/arm/helper-a64.h | 5 +++++ target/arm/translate-a64.c | 15 ++++++++++++++ 3 files changed, 69 insertions(+) -- 2.15.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 931a6d3c34..d0b284fec4 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -594,3 +594,52 @@ ADVSIMD_HALFOP(min) ADVSIMD_HALFOP(max) ADVSIMD_HALFOP(minnum) ADVSIMD_HALFOP(maxnum) + +/* + * Floating point comparisons produce an integer result. Softfloat + * routines return float_relation types which we convert to the 0/-1 + * Neon requires. + */ + +#define ADVSIMD_CMPRES(test) (test) ? 0xffff : 0 + +uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + int compare = float16_compare_quiet(a, b, fpst); + return ADVSIMD_CMPRES(compare == float_relation_equal); +} + +uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + int compare = float16_compare(a, b, fpst); + return ADVSIMD_CMPRES(compare == float_relation_greater || + compare == float_relation_equal); +} + +uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + int compare = float16_compare(a, b, fpst); + return ADVSIMD_CMPRES(compare == float_relation_greater); +} + +uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + float16 f0 = float16_abs(a); + float16 f1 = float16_abs(b); + int compare = float16_compare(f0, f1, fpst); + return ADVSIMD_CMPRES(compare == float_relation_greater || + compare == float_relation_equal); +} + +uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + float16 f0 = float16_abs(a); + float16 f1 = float16_abs(b); + int compare = float16_compare(f0, f1, fpst); + return ADVSIMD_CMPRES(compare == float_relation_greater); +} diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index bac9469426..1cf40bda5e 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -56,3 +56,8 @@ DEF_HELPER_3(advsimd_addh, f16, f16, f16, ptr) DEF_HELPER_3(advsimd_subh, f16, f16, f16, ptr) DEF_HELPER_3(advsimd_mulh, f16, f16, f16, ptr) DEF_HELPER_3(advsimd_divh, f16, f16, f16, ptr) +DEF_HELPER_3(advsimd_ceq_f16, i32, f16, f16, ptr) +DEF_HELPER_3(advsimd_cge_f16, i32, f16, f16, ptr) +DEF_HELPER_3(advsimd_cgt_f16, i32, f16, f16, ptr) +DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr) +DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index f8770ee1e9..fb74dc1c45 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10289,6 +10289,9 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) case 0x2: /* FADD */ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0x4: /* FCMEQ */ + gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; case 0x6: /* FMAX */ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); break; @@ -10304,6 +10307,12 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) case 0x13: /* FMUL */ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0x14: /* FCMGE */ + gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x15: /* FACGE */ + gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; case 0x17: /* FDIV */ gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst); break; @@ -10311,6 +10320,12 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff); break; + case 0x1c: /* FCMGT */ + gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x1d: /* FACGT */ + gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; default: fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n", __func__, insn, fpopcode, s->pc); From patchwork Tue Feb 27 14:38:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129819 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp376626edc; Tue, 27 Feb 2018 07:00:59 -0800 (PST) X-Google-Smtp-Source: AH8x225JZgQCNjBTkbsBWgKifULjxsDDvX2TxOTJK7qru/lUAB1KKsULlucoqOB9dLw3N2Dd8KTA X-Received: by 10.13.238.69 with SMTP id x66mr9802097ywe.1.1519743659078; Tue, 27 Feb 2018 07:00:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743659; cv=none; d=google.com; s=arc-20160816; b=kuoS1HUHWOjef0hIF64F+jR8oftjhPdfs0R3/pRnnXPinHtFqvI6QsaIYMUgNPW2Sr 0iM2wGJmGyO1CY1D2P7bgWk9+RsubRVHvzqmsb5zW9C90o7W0DM87IQUV6d/qc54U0ZG vgxTSzI9mtWKDmvLpDiYVoeUZBC/5r9VfRwzaE+OLtBLCeSeE0QFrHYDVmEohNAg5Noh 7zxpTXmJir1HfyoH7loHOa6lsJRrV8DyoU/Jn6JXZHgu/t8L5I/wOAmpIbtQCR2ASHyU LP4dzB5wyW6mBPpyKjo4PZHNDRj7TzfV3LZplTVLW5TfWMhPPyUd42QkuSn++GEx+A60 JyuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=LKAZFc3rihLsNwzpvrBqYrmTrGRYoEULslG1Yu5iQhs=; b=iBqH45SlFBObnvwfLPHwxoabm4TR09xPqJ3hh9QJl+39EW8ZdOWXq8vJHNGI57wpjm A+rsH0xJ1TCnrftpEJ9+zYkcRYxYd7G1YshA0dfFo9hGWbGhCYcWX2kpUpVFjOLGfmFx n5fw/lJ8X1UtfToou6dB3YfVHMsqtnAHobe+Sk8f5r4frsDYHptqg0VVPtpt6nin7hn5 Al6DW2MXitZ5dvk8f2mrb74iOgnpCHnVpHSmmRtuPqIcKxhRfn7Hr/MXmssZ29rh6evl rMgqBzUHeWmIcOtAqJ1NhzczgJpgSql32OuM+05/5HqzboM4TeD7HOBvb18kqQ6LWR0O Bx2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aSGhOc95; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h1si1891474ywd.378.2018.02.27.07.00.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:00:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aSGhOc95; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgkU-0006LV-F4 for patch@linaro.org; Tue, 27 Feb 2018 10:00:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgY4-0003Wv-4c for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY1-0001Fs-Rk for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:08 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:38942) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgY1-0001Bh-H2 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:05 -0500 Received: by mail-wr0-x244.google.com with SMTP id w77so25110384wrc.6 for ; Tue, 27 Feb 2018 06:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LKAZFc3rihLsNwzpvrBqYrmTrGRYoEULslG1Yu5iQhs=; b=aSGhOc95PbBOORCWn33+A4HtJQgce3qZxlSBEmhxM6/hpXgu8xbDVloZXDPZ/JxQqj fg1IjpCGgadhtf1QlYQS4iWSzm5BIzuq8lPCGByhnZSgnkHwKa1csXO8334o3xYaCwka 7aIwhTKUgKheRsA5XVzgLwIisGJOD2ZelbhC0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LKAZFc3rihLsNwzpvrBqYrmTrGRYoEULslG1Yu5iQhs=; b=OVdzQCD7Mfbj1Equgs8uE4TUc7YviI2t6vgsTj2oFVDjYWSzWc54+50JEqibZYFGLT fNrpHdnQa5ZvDh3ju825GDdmjBdPSaDgQQjve4/X8nBsbWqbrkTxnajM3jxRNrhi/bl8 ykgP2n5kirRc/3lqLpy10YGHrSNvNnQUdOyTr4FaGId73UYZRxrj5cAWhGDGckoh9TTf Gn37WcCOWo0aeY/Ih/z3vDvvFDS0xnhdik/9HQ4Yk5D1swSuOiUB/1wc6Iqd2zInN6yE ZylElvpkLzrzmT3Sxrw0D+bthJIEC34Ilr+GrHdIEdQJ/C5XpIFu4Yvomzt5NgDlh1Co UZPA== X-Gm-Message-State: APf1xPDyxzxO9nB028DBYfR3cifvp1yZ8jbZCv7lJwL9Sw2LFDp2uXr+ syi+y6Q6UZRB7xgxOdJ5dupcjA== X-Received: by 10.223.182.16 with SMTP id f16mr12563089wre.51.1519742884379; Tue, 27 Feb 2018 06:48:04 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 142sm5623865wmq.47.2018.02.27.06.48.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:00 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B5F653E0A1A; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:32 +0000 Message-Id: <20180227143852.11175-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PATCH v4 11/31] arm/translate-a64: add FP16 FMULA/X/S to simd_three_reg_same_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/helper-a64.c | 24 ++++++++++++++++++++++++ target/arm/helper-a64.h | 2 ++ target/arm/translate-a64.c | 15 +++++++++++++++ 3 files changed, 41 insertions(+) -- 2.15.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index d0b284fec4..1ef13abd76 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -595,6 +595,30 @@ ADVSIMD_HALFOP(max) ADVSIMD_HALFOP(minnum) ADVSIMD_HALFOP(maxnum) +/* Data processing - scalar floating-point and advanced SIMD */ +float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + + a = float16_squash_input_denormal(a, fpst); + b = float16_squash_input_denormal(b, fpst); + + if ((float16_is_zero(a) && float16_is_infinity(b)) || + (float16_is_infinity(a) && float16_is_zero(b))) { + /* 2.0 with the sign bit set to sign(A) XOR sign(B) */ + return make_float16((1U << 14) | + ((float16_val(a) ^ float16_val(b)) & (1U << 15))); + } + return float16_mul(a, b, fpst); +} + +/* fused multiply-accumulate */ +float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp) +{ + float_status *fpst = fpstp; + return float16_muladd(a, b, c, 0, fpst); +} + /* * Floating point comparisons produce an integer result. Softfloat * routines return float_relation types which we convert to the 0/-1 diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 1cf40bda5e..9c1a95594c 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -61,3 +61,5 @@ DEF_HELPER_3(advsimd_cge_f16, i32, f16, f16, ptr) DEF_HELPER_3(advsimd_cgt_f16, i32, f16, f16, ptr) DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr) DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr) +DEF_HELPER_3(advsimd_mulxh, f16, f16, f16, ptr) +DEF_HELPER_4(advsimd_muladdh, f16, f16, f16, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index fb74dc1c45..0e2d298687 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10286,9 +10286,17 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) case 0x0: /* FMAXNM */ gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0x1: /* FMLA */ + read_vec_element_i32(s, tcg_res, rd, pass, MO_16); + gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res, + fpst); + break; case 0x2: /* FADD */ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0x3: /* FMULX */ + gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst); + break; case 0x4: /* FCMEQ */ gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst); break; @@ -10298,6 +10306,13 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) case 0x8: /* FMINNM */ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0x9: /* FMLS */ + /* As usual for ARM, separate negation for fused multiply-add */ + tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000); + read_vec_element_i32(s, tcg_res, rd, pass, MO_16); + gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res, + fpst); + break; case 0xa: /* FSUB */ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); break; From patchwork Tue Feb 27 14:38:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129805 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1472369lja; Tue, 27 Feb 2018 06:45:24 -0800 (PST) X-Google-Smtp-Source: AG47ELtTUA3D/m80p4+I9s4XKEinkfSn7WG+/P3+LhkOEIWtPUcf/fb+nFM2VtYJLrOlzIPZ7PGn X-Received: by 2002:a25:2e0c:: with SMTP id u12-v6mr1646683ybu.369.1519742724460; Tue, 27 Feb 2018 06:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742724; cv=none; d=google.com; s=arc-20160816; b=itwOhCS6/GnnQ7BKB6+0urGYG0Auddja3qS20ktozITel731vfPDkgAv0ghOpErteQ xOOtv+mjyj7k3rFDnEWKop0D86LlHBMVPcumZS5rM4mguamyGCOHofscttTL/eeT7ARD AAabn9HwqNp7phsf2charnE0JH5WU9B9AFASHVa3XAmPiH7zalGV1kv3YUEhak9NB4Vs UzgS0VJta1oAKyaPvChsxm71SBTXyf6xlz8VhFErSFj6Ekf22ebHdd9q4LrS4Dvs6FkA c+1sWCONX81ZVwvNyYHCUzr3tC2l7Y7qGKIIYfCkGGzojPZxVZyn+ClCi4Edq2snmhyb l6Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=0Gxj1BXYbejC+76cCVLk/dtD7VuEACO0eicBwCehGSY=; b=0PwValX2TOzKZz0bz6StUdmZRvty2T/5yeLbxl1bO4hCIDF70surrd8PsOQirfOr0E E6hqHWhTO+awaM7w+wA3YSMbgiRbTRDPCfNXSfP5bA5qKqHOdgWZSjgqo/jHvWsD1+Ix XJIS6BKbQm3X7JAvqQ6Bon+BkGvtlYAhg/B/OTY8ZmluyxnYJ0YS+MPRCnyLCwaTjRXt 2YzC2bAX6F90qF6WbfIwJe3OLvuHz/DBomZlMRECNrpNEwoH6sxNYHmxFGmjj25d0gx2 iqtdDZkLegVyAlqt17pBpOTV0BAv6WEPfOHFSaqLt1tji7kb6RG+UaI8X6BccQYiKPUK zNtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QrRVqNEj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n127si1906544ywd.536.2018.02.27.06.45.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:45:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QrRVqNEj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgVP-0008Rg-Qr for patch@linaro.org; Tue, 27 Feb 2018 09:45:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPT-0003mg-D2 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPO-00082L-BC for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:15 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:32978) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPO-00081r-1c for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:10 -0500 Received: by mail-wm0-x243.google.com with SMTP id s206so21986441wme.0 for ; Tue, 27 Feb 2018 06:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0Gxj1BXYbejC+76cCVLk/dtD7VuEACO0eicBwCehGSY=; b=QrRVqNEj+tNoL2bxhf7cH/TMJz+bJQr0TcpetplijW5OPg6MnI4Ogtx0SrNm3tWPG3 T7JH7Na4hfl5sH7/K2lSJS4icGT7LShJbfMgFzqBCUZB1mhpPhw1Yd2rU+RbSqbTmwrt yns55oml9fhGNX4jpgyGVIWiSJ79AXWGHRXkQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0Gxj1BXYbejC+76cCVLk/dtD7VuEACO0eicBwCehGSY=; b=OIJhXN9BFvLQQrzBExDXQRR2tt0XbkeqEZRDDQi4SdEdBLHMYl3Qm6LrKUbvIaEObe aEv5jh2R8BowjJir5cj1sderPeChuBYyyQRdClPDWwOUeCufQxrgdS+mKFLgp67FelOh EykIo5WqlXh1iIXhlXZLHSzKJIszWGluPfo7rXSLVx8UPk9Ctg42pWyrwCcZ9XmWtS58 bN530gUILou5VaRDU7jMn7D+uAourP0J5w96QOnNJ31hWNoJvRyCG56HPDQytj8fkCFe fmBONfr3wCvuHzWW+fxoJ/N9ckqckkJetrXnn+eSsYD4oJ4ApKKK+pFI6RuzATFbgPqD VwNw== X-Gm-Message-State: APf1xPBoFRfH9q6sYBrHwbwCpwhGZrbDQJip3gGlkJy9NrDHX/2EIRAi TvZ4gaGz3hhDSgJYWYXvHQxzJw== X-Received: by 10.28.138.143 with SMTP id m137mr4901927wmd.85.1519742348904; Tue, 27 Feb 2018 06:39:08 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m7sm15900547wrm.35.2018.02.27.06.38.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:59 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id CA9BA3E0AA3; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:33 +0000 Message-Id: <20180227143852.11175-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH v4 12/31] arm/translate-a64: add FP16 FR[ECP/SQRT]S to simd_three_reg_same_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Aurelien Jarno , Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As some of the constants here will also be needed elsewhere (specifically for the upcoming SVE support) we move them out to softfloat.h. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - move constants used for estimate to softfloat.h --- include/fpu/softfloat.h | 16 ++++++++++++---- target/arm/helper-a64.c | 34 ++++++++++++++++++++++++++++++++++ target/arm/helper-a64.h | 2 ++ target/arm/translate-a64.c | 6 ++++++ 4 files changed, 54 insertions(+), 4 deletions(-) -- 2.15.1 diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 9b7b5e34e2..27876e711c 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -306,8 +306,11 @@ static inline float16 float16_set_sign(float16 a, int sign) } #define float16_zero make_float16(0) -#define float16_one make_float16(0x3c00) #define float16_half make_float16(0x3800) +#define float16_one make_float16(0x3c00) +#define float16_one_point_five make_float16(0x3e00) +#define float16_two make_float16(0x4000) +#define float16_three make_float16(0x4200) #define float16_infinity make_float16(0x7c00) /*---------------------------------------------------------------------------- @@ -415,11 +418,13 @@ static inline float32 float32_set_sign(float32 a, int sign) } #define float32_zero make_float32(0) -#define float32_one make_float32(0x3f800000) #define float32_half make_float32(0x3f000000) +#define float32_one make_float32(0x3f800000) +#define float32_one_point_five make_float32(0x3fc00000) +#define float32_two make_float32(0x40000000) +#define float32_three make_float32(0x40400000) #define float32_infinity make_float32(0x7f800000) - /*---------------------------------------------------------------------------- | The pattern for a default generated single-precision NaN. *----------------------------------------------------------------------------*/ @@ -526,9 +531,12 @@ static inline float64 float64_set_sign(float64 a, int sign) } #define float64_zero make_float64(0) +#define float64_half make_float64(0x3fe0000000000000LL) #define float64_one make_float64(0x3ff0000000000000LL) +#define float64_one_point_five make_float64(0x3FF8000000000000ULL) +#define float64_two make_float64(0x4000000000000000ULL) +#define float64_three make_float64(0x4008000000000000ULL) #define float64_ln2 make_float64(0x3fe62e42fefa39efLL) -#define float64_half make_float64(0x3fe0000000000000LL) #define float64_infinity make_float64(0x7ff0000000000000LL) /*---------------------------------------------------------------------------- diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 1ef13abd76..8fdbe034f3 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -192,6 +192,10 @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp) * versions, these do a fully fused multiply-add or * multiply-add-and-halve. */ +#define float16_two make_float16(0x4000) +#define float16_three make_float16(0x4200) +#define float16_one_point_five make_float16(0x3e00) + #define float32_two make_float32(0x40000000) #define float32_three make_float32(0x40400000) #define float32_one_point_five make_float32(0x3fc00000) @@ -200,6 +204,21 @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp) #define float64_three make_float64(0x4008000000000000ULL) #define float64_one_point_five make_float64(0x3FF8000000000000ULL) +float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + + a = float16_squash_input_denormal(a, fpst); + b = float16_squash_input_denormal(b, fpst); + + a = float16_chs(a); + if ((float16_is_infinity(a) && float16_is_zero(b)) || + (float16_is_infinity(b) && float16_is_zero(a))) { + return float16_two; + } + return float16_muladd(a, b, float16_two, 0, fpst); +} + float32 HELPER(recpsf_f32)(float32 a, float32 b, void *fpstp) { float_status *fpst = fpstp; @@ -230,6 +249,21 @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp) return float64_muladd(a, b, float64_two, 0, fpst); } +float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + + a = float16_squash_input_denormal(a, fpst); + b = float16_squash_input_denormal(b, fpst); + + a = float16_chs(a); + if ((float16_is_infinity(a) && float16_is_zero(b)) || + (float16_is_infinity(b) && float16_is_zero(a))) { + return float16_one_point_five; + } + return float16_muladd(a, b, float16_three, float_muladd_halve_result, fpst); +} + float32 HELPER(rsqrtsf_f32)(float32 a, float32 b, void *fpstp) { float_status *fpst = fpstp; diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 9c1a95594c..79012eee9d 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -29,8 +29,10 @@ DEF_HELPER_FLAGS_3(vfp_mulxd, TCG_CALL_NO_RWG, f64, f64, f64, ptr) DEF_HELPER_FLAGS_3(neon_ceq_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr) DEF_HELPER_FLAGS_3(neon_cge_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr) DEF_HELPER_FLAGS_3(neon_cgt_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr) +DEF_HELPER_FLAGS_3(recpsf_f16, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(recpsf_f32, TCG_CALL_NO_RWG, f32, f32, f32, ptr) DEF_HELPER_FLAGS_3(recpsf_f64, TCG_CALL_NO_RWG, f64, f64, f64, ptr) +DEF_HELPER_FLAGS_3(rsqrtsf_f16, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(rsqrtsf_f32, TCG_CALL_NO_RWG, f32, f32, f32, ptr) DEF_HELPER_FLAGS_3(rsqrtsf_f64, TCG_CALL_NO_RWG, f64, f64, f64, ptr) DEF_HELPER_FLAGS_1(neon_addlp_s8, TCG_CALL_NO_RWG_SE, i64, i64) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 0e2d298687..217e73ef58 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10303,6 +10303,9 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) case 0x6: /* FMAX */ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0x7: /* FRECPS */ + gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; case 0x8: /* FMINNM */ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); break; @@ -10319,6 +10322,9 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) case 0xe: /* FMIN */ gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0xf: /* FRSQRTS */ + gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; case 0x13: /* FMUL */ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); break; From patchwork Tue Feb 27 14:38:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129810 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp366531edc; Tue, 27 Feb 2018 06:51:52 -0800 (PST) X-Google-Smtp-Source: AG47ELt4CpNDomDTjvDNYDdiTwuEXHo9D4ZWTIcKDk6dk8zONpUESL+EJcYFLKV24X1igmKp+p5/ X-Received: by 10.13.222.129 with SMTP id h123mr754721ywe.331.1519743005961; Tue, 27 Feb 2018 06:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743005; cv=none; d=google.com; s=arc-20160816; b=Un3ecPyzjXD718ezEkuUFUdKnoCEx/u/Ghd3w4MJNf6JU7wUzE8HAz4knllGgwGjha vujZXSiYh9UXaMBDk3hGF/3m6rio1xaTqkalB5WNTA3d3FVq6J1m7N902dQ14rd8T93j aubC+ox8XmJlOyd/M84LGOhREee5tq4/YfAzbZHhkUBg2TLfPVBsT733cdQHCu4BpLkc WYNwecYgSpPhqG7vxE2NBctbSfFXbnS2E5bqsevaeQOAI6Dlyahg9ZVOu9QzuGsvR1uz osaOuADrak/fWVjDu7Fah8FrQO34U0qXc6gYObstCRsC9fYmn9WQvmLZiODykKYOiiZ+ YlxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=GQXV3TC9+KMLyPcEmdYfCQdxuiTncenQXyFMoWidaAk=; b=rUaFVeyLBMqLvXutL4Xy/O+YKNj0jnHWSYshRbEEOlZ+b/1Tfzup9nccoXYbzx+jbD QM56+SxvvSiFYedsolcPbXoW9qOgcNThfR8aMRIHTTrRcsW3eeURTTh7PMFEuLCzXn89 KKmGoIEpG4txpSS9wwLs3p55sWQrVcPhHBtZZz4K95T0uly4JX1WY/KMyn40EZbQGEEI 5cIzQLBR0rk+vh9t2n2qjr1Agoy/4i+d4zIE3W2tWEPRTGM68ntE+iN3ZJSnfq4j6nZy N2gz7beX01lSRyxZT6spza1NUdE8xLa7zp6hZ0qHHvJ+FHlWYbicAzOMfy9hlMKOh/Wr oUCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cEHbLTwd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k134-v6si1536805ybf.586.2018.02.27.06.50.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:50:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cEHbLTwd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgZw-0004pa-Pg for patch@linaro.org; Tue, 27 Feb 2018 09:50:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYA-0003cd-UZ for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY6-0001cH-QR for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:14 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:33697) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgY6-0001XC-6X for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:10 -0500 Received: by mail-wr0-x241.google.com with SMTP id s5so25161787wra.0 for ; Tue, 27 Feb 2018 06:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GQXV3TC9+KMLyPcEmdYfCQdxuiTncenQXyFMoWidaAk=; b=cEHbLTwdMDhpc9g3ebr0E8dmccGdZJEV1FahLRmx4q/O/lgOxNE1vnGXyTMkHb27ru govRS4hnm+hUV+MubaCcuoArqx75SNOCVjTy44CjQDRrxJxgoC9YUxo9QGnSQc7+SF1H RKTLNkVmdLiePRbuvF26lxO5uIl0wCyzgKI9c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GQXV3TC9+KMLyPcEmdYfCQdxuiTncenQXyFMoWidaAk=; b=CskHErQM5HOkck4VAfcYGzHJkkDPqUCfc9n1SRFHhysEIgBRwvmchhkhkMdziqZdv1 sY0o7JLFqFapz470vyteIIp/e12cl9HYCtrKtBdPGKAi4NolUVU0fcEU26dny8nltvq7 nFuFr7sgeqffCQ23OeYHd1HuHfofym39nAAdj6rShSKHNzdusmIZzXsiO0k6E5kglM6v NyaJnvDqDELJ2hA6BZtkFEi28mhDhDPeMaLx+GFUvxlHckazAp9mWA/r4SYmaDNj38dz SUOO6sh0c24Rf90A2pjvKjrMeZevqBk1TLYGpjaFwKOn/XY/cqTzVr01RHDcNclSlV43 5PUw== X-Gm-Message-State: APf1xPDRcNsrL6jUC+2LJrehgptXjHF6fZhrEWI+4lt/VRfvPMTF1hQa Mz9maNZhu6pWKkzE73ppdlQ2qQ== X-Received: by 10.223.161.144 with SMTP id u16mr13420101wru.137.1519742888945; Tue, 27 Feb 2018 06:48:08 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p21sm8981036wmc.28.2018.02.27.06.48.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id DBF473E0B56; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:34 +0000 Message-Id: <20180227143852.11175-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH v4 13/31] arm/translate-a64: add FP16 pairwise ops simd_three_reg_same_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes FMAXNMP, FADDP, FMAXP, FMINNMP, FMINP. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 - checkpatch fixes --- target/arm/translate-a64.c | 208 +++++++++++++++++++++++++++++---------------- 1 file changed, 133 insertions(+), 75 deletions(-) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 217e73ef58..e96e6cdd15 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10247,6 +10247,7 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) int datasize, elements; int pass; TCGv_ptr fpst; + bool pairwise = false; if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { unallocated_encoding(s); @@ -10272,91 +10273,148 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) datasize = is_q ? 128 : 64; elements = datasize / 16; + switch (fpopcode) { + case 0x10: /* FMAXNMP */ + case 0x12: /* FADDP */ + case 0x16: /* FMAXP */ + case 0x18: /* FMINNMP */ + case 0x1e: /* FMINP */ + pairwise = true; + break; + } + fpst = get_fpstatus_ptr(true); - for (pass = 0; pass < elements; pass++) { + if (pairwise) { + int maxpass = is_q ? 8 : 4; TCGv_i32 tcg_op1 = tcg_temp_new_i32(); TCGv_i32 tcg_op2 = tcg_temp_new_i32(); - TCGv_i32 tcg_res = tcg_temp_new_i32(); + TCGv_i32 tcg_res[8]; - read_vec_element_i32(s, tcg_op1, rn, pass, MO_16); - read_vec_element_i32(s, tcg_op2, rm, pass, MO_16); + for (pass = 0; pass < maxpass; pass++) { + int passreg = pass < (maxpass / 2) ? rn : rm; + int passelt = (pass << 1) & (maxpass - 1); - switch (fpopcode) { - case 0x0: /* FMAXNM */ - gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x1: /* FMLA */ - read_vec_element_i32(s, tcg_res, rd, pass, MO_16); - gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res, - fpst); - break; - case 0x2: /* FADD */ - gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x3: /* FMULX */ - gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x4: /* FCMEQ */ - gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x6: /* FMAX */ - gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x7: /* FRECPS */ - gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x8: /* FMINNM */ - gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x9: /* FMLS */ - /* As usual for ARM, separate negation for fused multiply-add */ - tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000); - read_vec_element_i32(s, tcg_res, rd, pass, MO_16); - gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res, - fpst); - break; - case 0xa: /* FSUB */ - gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0xe: /* FMIN */ - gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0xf: /* FRSQRTS */ - gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x13: /* FMUL */ - gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x14: /* FCMGE */ - gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x15: /* FACGE */ - gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x17: /* FDIV */ - gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x1a: /* FABD */ - gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); - tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff); - break; - case 0x1c: /* FCMGT */ - gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x1d: /* FACGT */ - gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst); - break; - default: - fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n", - __func__, insn, fpopcode, s->pc); - g_assert_not_reached(); + read_vec_element_i32(s, tcg_op1, passreg, passelt, MO_16); + read_vec_element_i32(s, tcg_op2, passreg, passelt + 1, MO_16); + tcg_res[pass] = tcg_temp_new_i32(); + + switch (fpopcode) { + case 0x10: /* FMAXNMP */ + gen_helper_advsimd_maxnumh(tcg_res[pass], tcg_op1, tcg_op2, + fpst); + break; + case 0x12: /* FADDP */ + gen_helper_advsimd_addh(tcg_res[pass], tcg_op1, tcg_op2, fpst); + break; + case 0x16: /* FMAXP */ + gen_helper_advsimd_maxh(tcg_res[pass], tcg_op1, tcg_op2, fpst); + break; + case 0x18: /* FMINNMP */ + gen_helper_advsimd_minnumh(tcg_res[pass], tcg_op1, tcg_op2, + fpst); + break; + case 0x1e: /* FMINP */ + gen_helper_advsimd_minh(tcg_res[pass], tcg_op1, tcg_op2, fpst); + break; + default: + g_assert_not_reached(); + } + } + + for (pass = 0; pass < maxpass; pass++) { + write_vec_element_i32(s, tcg_res[pass], rd, pass, MO_16); + tcg_temp_free_i32(tcg_res[pass]); } - write_vec_element_i32(s, tcg_res, rd, pass, MO_16); - tcg_temp_free_i32(tcg_res); tcg_temp_free_i32(tcg_op1); tcg_temp_free_i32(tcg_op2); + + } else { + for (pass = 0; pass < elements; pass++) { + TCGv_i32 tcg_op1 = tcg_temp_new_i32(); + TCGv_i32 tcg_op2 = tcg_temp_new_i32(); + TCGv_i32 tcg_res = tcg_temp_new_i32(); + + read_vec_element_i32(s, tcg_op1, rn, pass, MO_16); + read_vec_element_i32(s, tcg_op2, rm, pass, MO_16); + + switch (fpopcode) { + case 0x0: /* FMAXNM */ + gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x1: /* FMLA */ + read_vec_element_i32(s, tcg_res, rd, pass, MO_16); + gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res, + fpst); + break; + case 0x2: /* FADD */ + gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x3: /* FMULX */ + gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x4: /* FCMEQ */ + gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x6: /* FMAX */ + gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x7: /* FRECPS */ + gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x8: /* FMINNM */ + gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x9: /* FMLS */ + /* As usual for ARM, separate negation for fused multiply-add */ + tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000); + read_vec_element_i32(s, tcg_res, rd, pass, MO_16); + gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res, + fpst); + break; + case 0xa: /* FSUB */ + gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0xe: /* FMIN */ + gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0xf: /* FRSQRTS */ + gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x13: /* FMUL */ + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x14: /* FCMGE */ + gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x15: /* FACGE */ + gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x17: /* FDIV */ + gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x1a: /* FABD */ + gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); + tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff); + break; + case 0x1c: /* FCMGT */ + gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x1d: /* FACGT */ + gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + default: + fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n", + __func__, insn, fpopcode, s->pc); + g_assert_not_reached(); + } + + write_vec_element_i32(s, tcg_res, rd, pass, MO_16); + tcg_temp_free_i32(tcg_res); + tcg_temp_free_i32(tcg_op1); + tcg_temp_free_i32(tcg_op2); + } } tcg_temp_free_ptr(fpst); From patchwork Tue Feb 27 14:38:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129822 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp384147edc; Tue, 27 Feb 2018 07:06:08 -0800 (PST) X-Google-Smtp-Source: AG47ELv4VNJ3l3rOypXZrqIpNsgT8nlWaMLQOswD3V10UY52StONgzYKgLNrFsUvGSxa4XEy2Beq X-Received: by 10.129.87.75 with SMTP id l72mr9357084ywb.417.1519743968131; Tue, 27 Feb 2018 07:06:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743968; cv=none; d=google.com; s=arc-20160816; b=jUeCxcJfcKsLZSQnV15Vpklkamz21Be5e2JSEA0UdVfOkNLotikcdhE7HqLs2QM0hz vAg+fh2vviUN7sCS4Z3GL0kTlxgOtqPzJJ70PF9DVe3RZyNuujTA1Dme0SefUus8heNf msD6fcZ6x4PMHqMvfU4Vy226zjYGSe7JwzxxnmaRbLWs/UVfS+ucwdSYc/t1x4ZkD1cc WpN0uJJm4ExOHTmhjppMtee+vzsYuc3v0n8QOGuOsSxtIo+XMYaqG3HdZDKHmKPZ/87V XbWrQIh7/IJWbxrKIZAK52wr1zY1G1DVhGlVvVQpX2VIeYl4XutKKTpvT8a4HXitxab1 pqeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=efGvMqVzPF9U0N64rfXjXKacBTZpJqDSzWRXqL1Omv8=; b=vspnXpAAjj0koNo+W9RAKWYX7bniPBNKOiJTcaKVphE22uLJDUbwuHFjsi9XIg9L78 2bFwWV0yKMkCGfKQsZXzjG6mdeSDs7IcLBQO6o5yyzwdPW6+VyJqfwH/NKlPjUywHCke HIVEJD6ovrykP2AA6J89lrY+fblocJR3numkMOneq/EeBtvdFNlFmHYpXDtrcS/TFi8u RLcVrM/42YXq+JZ/iCS7eTOppVBMZqbddS7dj8KNLaaHGz+MktUwk+rRdrFfJ0hBg7Ww kbJb8PR+vQBSH1qrz0xUHN0/yPB/hO2V9dxuUf26fGP5YV8SWoPvbyKMwbNjv5mW8EtY xjxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O6Fex1eu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z21si1960744ywz.214.2018.02.27.07.06.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:06:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O6Fex1eu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgpT-00011M-G9 for patch@linaro.org; Tue, 27 Feb 2018 10:06:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYF-0003im-FQ for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgYC-0001xc-7K for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:19 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:37905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgYB-0001tS-P5 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:16 -0500 Received: by mail-wr0-x242.google.com with SMTP id n7so25153336wrn.5 for ; Tue, 27 Feb 2018 06:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=efGvMqVzPF9U0N64rfXjXKacBTZpJqDSzWRXqL1Omv8=; b=O6Fex1eu9qFEg4q0nXrpyhFfLkml/x6aL+MIIgtupR5/i7StkTqdHHcKJYdP7MlJK/ hb4TGIi99lKeUW1hOD2vAy4RWQgx9y981bPhcyDu/rEzKW2Sll6LMqUQk7j1hgqmZ0hn PJnnPvOAlRAvMpqyxnuRy0WSrz15F5ExfacAw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=efGvMqVzPF9U0N64rfXjXKacBTZpJqDSzWRXqL1Omv8=; b=ASytrDDM04bcXNP0DI/qP2MWEnwNqdOX2wtJYwtw/y2TrX+ib4yflFvjsXUK61DdYo DTkKb3+fwbim9A+o3Z0MkZ8mwNHQrhX9u1bgh66Qe+Iv/XZcKSvnCxYmQtr3dnjrD3lT o5XuWFndNOYEhGolnDCn+L7L9aZjwOxLhentjanNN86gmDpdNa/4bJkClZZeGJqFde3w 2FHGi8BWOKm2/StfH0tJIbvWIXZgopK4zs/002LAPzr1iuB1sXTt/BiQTcAmprCLUWT0 lAWYkhYAZ67neqeyzYwTPBdzP1ARqwuteVnFtZzoPF4tNuCF+D532myvrOhoIuIP5wIl Dhkg== X-Gm-Message-State: APf1xPDvX5IPxIEsWzNiTLRN5jVFVN1lDX/XS0kFQOfort5irspTVG2g QbjQ/uRX0ygT2MINZ6eleJVPsQ== X-Received: by 10.223.134.12 with SMTP id 12mr12461953wrv.193.1519742894536; Tue, 27 Feb 2018 06:48:14 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id e67sm32845917wmf.7.2018.02.27.06.48.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:08 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id ED75B3E0BDF; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:35 +0000 Message-Id: <20180227143852.11175-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 14/31] arm/translate-a64: add FP16 FMULX/MLS/FMLA to simd_indexed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The helpers use the new re-factored muladd support in SoftFloat for the float16 work. Signed-off-by: Alex Bennée --- v3 - re-jigged switch statement to fall-through for unalloc - added is_fp16 bool for fpst - fixed up some long lines v4 - don't double-check for feature bit --- target/arm/translate-a64.c | 82 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 16 deletions(-) -- 2.15.1 Reviewed-by: Richard Henderson diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index e96e6cdd15..6a264bc134 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11198,6 +11198,7 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) int rd = extract32(insn, 0, 5); bool is_long = false; bool is_fp = false; + bool is_fp16 = false; int index; TCGv_ptr fpst; @@ -11244,7 +11245,7 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) } /* fall through */ case 0x9: /* FMUL, FMULX */ - if (!extract32(size, 1, 1)) { + if (size == 1) { unallocated_encoding(s); return; } @@ -11256,18 +11257,34 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) } if (is_fp) { - /* low bit of size indicates single/double */ - size = extract32(size, 0, 1) ? 3 : 2; - if (size == 2) { + /* convert insn encoded size to TCGMemOp size */ + switch (size) { + case 2: /* single precision */ + size = MO_32; index = h << 1 | l; - } else { + rm |= (m << 4); + break; + case 3: /* double precision */ + size = MO_64; if (l || !is_q) { unallocated_encoding(s); return; } index = h; + rm |= (m << 4); + break; + case 0: /* half precision */ + size = MO_16; + index = h << 2 | l << 1 | m; + is_fp16 = true; + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + break; + } + /* fallthru */ + default: /* unallocated */ + unallocated_encoding(s); + return; } - rm |= (m << 4); } else { switch (size) { case 1: @@ -11288,7 +11305,7 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) } if (is_fp) { - fpst = get_fpstatus_ptr(false); + fpst = get_fpstatus_ptr(is_fp16); } else { fpst = NULL; } @@ -11390,18 +11407,51 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) break; } case 0x5: /* FMLS */ - /* As usual for ARM, separate negation for fused multiply-add */ - gen_helper_vfp_negs(tcg_op, tcg_op); - /* fall through */ case 0x1: /* FMLA */ - read_vec_element_i32(s, tcg_res, rd, pass, MO_32); - gen_helper_vfp_muladds(tcg_res, tcg_op, tcg_idx, tcg_res, fpst); + read_vec_element_i32(s, tcg_res, rd, pass, + is_scalar ? size : MO_32); + switch (size) { + case 1: + if (opcode == 0x5) { + /* As usual for ARM, separate negation for fused + * multiply-add */ + tcg_gen_xori_i32(tcg_op, tcg_op, 0x80008000); + } + gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx, + tcg_res, fpst); + break; + case 2: + if (opcode == 0x5) { + /* As usual for ARM, separate negation for + * fused multiply-add */ + tcg_gen_xori_i32(tcg_op, tcg_op, 0x80000000); + } + gen_helper_vfp_muladds(tcg_res, tcg_op, tcg_idx, + tcg_res, fpst); + break; + default: + g_assert_not_reached(); + } break; case 0x9: /* FMUL, FMULX */ - if (u) { - gen_helper_vfp_mulxs(tcg_res, tcg_op, tcg_idx, fpst); - } else { - gen_helper_vfp_muls(tcg_res, tcg_op, tcg_idx, fpst); + switch (size) { + case 1: + if (u) { + gen_helper_advsimd_mulxh(tcg_res, tcg_op, tcg_idx, + fpst); + } else { + g_assert_not_reached(); + } + break; + case 2: + if (u) { + gen_helper_vfp_mulxs(tcg_res, tcg_op, tcg_idx, fpst); + } else { + gen_helper_vfp_muls(tcg_res, tcg_op, tcg_idx, fpst); + } + break; + default: + g_assert_not_reached(); } break; case 0xc: /* SQDMULH */ From patchwork Tue Feb 27 14:38:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129806 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1472792lja; Tue, 27 Feb 2018 06:45:54 -0800 (PST) X-Google-Smtp-Source: AG47ELsYXiw1swfsuI46ZgV9exSTzm88Fjlm73GC0PXMYR0jkUit6uvRxeG/txbtvqniYIVwLpSq X-Received: by 2002:a25:f608:: with SMTP id t8-v6mr9363110ybd.403.1519742753927; Tue, 27 Feb 2018 06:45:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742753; cv=none; d=google.com; s=arc-20160816; b=u+e7hR66f3aor4bdDtwX9FiNo351lrNfuzye/6wna7GGHf3PdyO44/vN1EF7NXhIGB 6Hf6jTwuzmeWekpfBzcjqLQVz7LbZYz9hs+Y7pCdWq+mEq3gNrn05zrbB5SowCQoToMe CLTChONLyV5XA6/fHBCX3lbATaEe0ocrqzsAvxML1UlqOQQuHU7bwx3SjXGdflsp2dvN MPVeQsU+NE3WGUxjYA93wtpquNQpngVC5j1axnac6Hfe2batqdxFgz3T9rXBX/Ggaby8 HE2NhE2Met/cz5N3uSvQiVvQECVCONGrdbmi8Jp2dkWx362SegRSDbIMV2tqbCfclCiP +1QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Udvn+v2EYmidmut+a91fqRC7Q2kSoODnzfg5Opg6GRg=; b=Z2gCPBvniNGQd/n8Olt/TuESSmncmYIDwuQn+ZcnXLG4sCLV3sdBXb/ilNsO4jwlca cUXmiTl4wcgqQ51LeuPufTURChApLeHqeLlI2gZx4AicbV66pcRfRimDO1moR498AVSp VYRucSkMjF14yB/exxSkMuDE3BNG94ivl3qV3uT23A2yfMnLS8WnnUfdVru6neeq03iN ErBVxfeiEBUjfviecpm/6N6Ew3oGYYX1TrU6lPifB3oBazlxa/Zrb/cdwzQKv4tqegF7 q5BO72BEVEgSGv2upu/ONLFTCpXp4qRsSeRNYQ6D7uNZHtd93S6Ju43YlhrLYId7pWuv FyEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JACcwsAi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o9-v6si1909431ybk.791.2018.02.27.06.45.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:45:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JACcwsAi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgVt-0001PG-7g for patch@linaro.org; Tue, 27 Feb 2018 09:45:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPT-0003mm-Ez for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPS-00084l-2Z for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:15 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:40641) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPR-000845-Ns for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:13 -0500 Received: by mail-wm0-x241.google.com with SMTP id t6so15916780wmt.5 for ; Tue, 27 Feb 2018 06:39:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Udvn+v2EYmidmut+a91fqRC7Q2kSoODnzfg5Opg6GRg=; b=JACcwsAiNZKGApW7Dcb4GLKau5DtPTRtV2EkuoS5iDl2OW2fUIe2IJJSKFmKzEZChs Ap5uzoOIGDzsWhsd/JQl+DMGB8T930gkwEwFEghxqbuxCcLXEIdf+P1mVuk889lcKKAY 82KrVjcpci3wv5/XriHQ5nzhNNPGsZgbGpDyQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Udvn+v2EYmidmut+a91fqRC7Q2kSoODnzfg5Opg6GRg=; b=gRiKOmadKXke3+B+LpKtTU6/CUetuANW9NkmoBdGWBXJjiJjM6jRzbZfUbz+/8I+c4 S0NMyUvPJRkdTIuEu2RYVKaBSyebx9JVDn/DaqgwlD8HiNrdTMLvcj/JnFJz8kKaOL65 61/1QY3k3h436vyplQTW8zSU3Mk+76p6741jQJ1Rg3oIQphm21iv3Hd3S2sA3gV35Ahr SZAwhSD9dZxxXIjo/0kQ21dup+OfYSKy0jhvMW7p/GGvyZ3Xvv1qdULHRbnyPSPYFOZ/ QV2qArR4L91zboaOvNHncyxnjnuDQWbN8+hD+XFNpH85RjzSLXEQisZJm+j3Ie9/aOQR I/Sg== X-Gm-Message-State: APf1xPCUqJ1Q0bIpc351DpMbzVtBrZIj/hI2980Wr1EyWWLq5cxqYYkE A2ehmux6DUpS0wWu3y0WT6QCyZzm7oY= X-Received: by 10.28.95.139 with SMTP id t133mr11439936wmb.88.1519742352582; Tue, 27 Feb 2018 06:39:12 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o6sm6457262wmo.38.2018.02.27.06.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:39:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 0D1063E0BFD; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:36 +0000 Message-Id: <20180227143852.11175-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH v4 15/31] arm/translate-a64: add FP16 x2 ops for simd_indexed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A bunch of the vectorised bitwise operations just operate on larger chunks at a time. We can do the same for the new half-precision operations by introducing some TWOHALFOP helpers which work on each half of a pair of half-precision operations at once. Hopefully all this hoop jumping will get simpler once we have generically vectorised helpers here. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 - checkpatch fixes --- target/arm/helper-a64.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- target/arm/helper-a64.h | 10 ++++++++++ target/arm/translate-a64.c | 26 +++++++++++++++++++++----- 3 files changed, 76 insertions(+), 6 deletions(-) -- 2.15.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 8fdbe034f3..4d5ae96d8f 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -629,8 +629,32 @@ ADVSIMD_HALFOP(max) ADVSIMD_HALFOP(minnum) ADVSIMD_HALFOP(maxnum) +#define ADVSIMD_TWOHALFOP(name) \ +uint32_t ADVSIMD_HELPER(name, 2h)(uint32_t two_a, uint32_t two_b, void *fpstp) \ +{ \ + float16 a1, a2, b1, b2; \ + uint32_t r1, r2; \ + float_status *fpst = fpstp; \ + a1 = extract32(two_a, 0, 16); \ + a2 = extract32(two_a, 16, 16); \ + b1 = extract32(two_b, 0, 16); \ + b2 = extract32(two_b, 16, 16); \ + r1 = float16_ ## name(a1, b1, fpst); \ + r2 = float16_ ## name(a2, b2, fpst); \ + return deposit32(r1, 16, 16, r2); \ +} + +ADVSIMD_TWOHALFOP(add) +ADVSIMD_TWOHALFOP(sub) +ADVSIMD_TWOHALFOP(mul) +ADVSIMD_TWOHALFOP(div) +ADVSIMD_TWOHALFOP(min) +ADVSIMD_TWOHALFOP(max) +ADVSIMD_TWOHALFOP(minnum) +ADVSIMD_TWOHALFOP(maxnum) + /* Data processing - scalar floating-point and advanced SIMD */ -float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp) +static float16 float16_mulx(float16 a, float16 b, void *fpstp) { float_status *fpst = fpstp; @@ -646,6 +670,9 @@ float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp) return float16_mul(a, b, fpst); } +ADVSIMD_HALFOP(mulx) +ADVSIMD_TWOHALFOP(mulx) + /* fused multiply-accumulate */ float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp) { @@ -653,6 +680,23 @@ float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp) return float16_muladd(a, b, c, 0, fpst); } +uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b, + uint32_t two_c, void *fpstp) +{ + float_status *fpst = fpstp; + float16 a1, a2, b1, b2, c1, c2; + uint32_t r1, r2; + a1 = extract32(two_a, 0, 16); + a2 = extract32(two_a, 16, 16); + b1 = extract32(two_b, 0, 16); + b2 = extract32(two_b, 16, 16); + c1 = extract32(two_c, 0, 16); + c2 = extract32(two_c, 16, 16); + r1 = float16_muladd(a1, b1, c1, 0, fpst); + r2 = float16_muladd(a2, b2, c2, 0, fpst); + return deposit32(r1, 16, 16, r2); +} + /* * Floating point comparisons produce an integer result. Softfloat * routines return float_relation types which we convert to the 0/-1 diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 79012eee9d..003ffa582f 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -65,3 +65,13 @@ DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr) DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr) DEF_HELPER_3(advsimd_mulxh, f16, f16, f16, ptr) DEF_HELPER_4(advsimd_muladdh, f16, f16, f16, f16, ptr) +DEF_HELPER_3(advsimd_add2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_sub2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_mul2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_div2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_max2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_min2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_maxnum2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_minnum2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr) +DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 6a264bc134..3487c0430f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11417,8 +11417,13 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) * multiply-add */ tcg_gen_xori_i32(tcg_op, tcg_op, 0x80008000); } - gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx, - tcg_res, fpst); + if (is_scalar) { + gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx, + tcg_res, fpst); + } else { + gen_helper_advsimd_muladd2h(tcg_res, tcg_op, tcg_idx, + tcg_res, fpst); + } break; case 2: if (opcode == 0x5) { @@ -11437,10 +11442,21 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) switch (size) { case 1: if (u) { - gen_helper_advsimd_mulxh(tcg_res, tcg_op, tcg_idx, - fpst); + if (is_scalar) { + gen_helper_advsimd_mulxh(tcg_res, tcg_op, + tcg_idx, fpst); + } else { + gen_helper_advsimd_mulx2h(tcg_res, tcg_op, + tcg_idx, fpst); + } } else { - g_assert_not_reached(); + if (is_scalar) { + gen_helper_advsimd_mulh(tcg_res, tcg_op, + tcg_idx, fpst); + } else { + gen_helper_advsimd_mul2h(tcg_res, tcg_op, + tcg_idx, fpst); + } } break; case 2: From patchwork Tue Feb 27 14:38:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129809 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp366183edc; Tue, 27 Feb 2018 06:51:33 -0800 (PST) X-Google-Smtp-Source: AG47ELtjyLEAoQLGD8KXu8xchydQzgOPouLSFETyJjkj1KsqiZQ1MOYg9DZXhtix+BRYjqG/5X2s X-Received: by 10.13.247.2 with SMTP id h2mr9773969ywf.23.1519743092968; Tue, 27 Feb 2018 06:51:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743092; cv=none; d=google.com; s=arc-20160816; b=WO0xr6K68i4WcF3RVtLiE2fZ53pHM151AAcHEzR4xhf38VQcBVGsYZ83yBouLzxkUY ZzzzJoMGbVUZqlChBKGukju0LmDmwu6vfxooWn+zavacfb2FFrhFnFugOSBbH2EzYBDt zK/1k6GxVzCHKogAgxxHSfPVRE5vURellrabFrnYL93IAye29ZRBadd8s8F4cr5FnSFA gcRULRYi8rjV8EqBWsWBOFkvfzsBafObv8m7wuBexnIBBtroAgbR+J0hMhTWsni6Hpgy irSgXHITtv3La/5ekyalOT3PSydWFh5GP7ANP+c8aDz7nxVRbtckTUA5NPpRA+s5A3IY 1gtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=mEsuHeARpZCu6I78SZuzHFH/Yo4lg3kr6uQ6N0s+YNY=; b=sluky5vCfUq38Gg6X5705mE5lVhO4Ba/Rms5IE9Ve3Qavf8bFTTalRxiF+3PH8J45U 5eDOshb5XGex+V1kBmvN43lazPUXETf1mnUxMYWNEbbtycW+vboCgYdh8mHXoOMy98i9 08yAVAXplFG39azR8xb9nGypfYBx5CqfvMqS7DLZoipEuwKGpNWthDPhCbSFSImXofR3 NE/g29a1LrOnf9JZYS36R80b6ToSYcm/5UscYtxgXl8H0fcvPJusJf0bnSe79mfHVwte 8OG7vDuFOwMTyeeLUh4kWUqTyhROUqg/iokgZK3SqGzQUks6Ca4aCb3XZaFpD1aWeZ+B 4ypA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=k2s1kq5Y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f78si1960799ywb.236.2018.02.27.06.51.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:51:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=k2s1kq5Y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgbM-0005Ek-Cm for patch@linaro.org; Tue, 27 Feb 2018 09:51:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPS-0003lS-99 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPQ-00083y-Ue for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:14 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:38867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPQ-00083G-M2 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:12 -0500 Received: by mail-wr0-x241.google.com with SMTP id n7so25120637wrn.5 for ; Tue, 27 Feb 2018 06:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mEsuHeARpZCu6I78SZuzHFH/Yo4lg3kr6uQ6N0s+YNY=; b=k2s1kq5YIl7Pid/fIAuIe0w7h9mjtRm2DLEhmbkoIy/s4siALHTPz7P5AANM4JuWWF V5quuXElMR77H8jj/fzoWRBPY6yD432wRA0EKzKL5OivOxwd3JvWtNiRzsHNUGSee4b7 lNWKvmcDDvAptt/tt22OHmENGeaF3YNcALYo0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mEsuHeARpZCu6I78SZuzHFH/Yo4lg3kr6uQ6N0s+YNY=; b=O9LgYODVi2UMpCSrFkyrWcC4p8LnPvqDw0oeUax/35ZjBZAHNGFAg/jqIQrWPznD9W PpbM/5lLAx1GZTnmTqpdeMiZuJxt/VqSxishhMbv2c0rjjKvrHWIlEojmVA2q0+LdR0X ikczajGU+XvYKMV2HPNRiPgX2AJf4xtQ96EzlfbquyVBzgc5qXcSo8hKmKfISpJttKTb WXSULjQgtAaUpxXv3irzEZZ3mgGsCq3ZND8H+sgzNCalqLPZ3o3+eL7RAiQCH4Ke6wlm M9Kym8p47ABxFWUNSvJvTCJm0rxH9k1cB7TxGBaat3MQU4PcMPCivkeC5/qI8RxRIgGN Kh4Q== X-Gm-Message-State: APf1xPCSP0sNJELUclUKecmFvGunNT55AiQg1OlEjf+wbQFdf0qce8rE bRuYpkNEx1990ODeoaN2nywBB0SLah8= X-Received: by 10.223.157.131 with SMTP id p3mr12546611wre.278.1519742351526; Tue, 27 Feb 2018 06:39:11 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v8sm9188933wmh.25.2018.02.27.06.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:39:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 1DF473E0C29; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:37 +0000 Message-Id: <20180227143852.11175-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH v4 16/31] arm/translate-a64: initial decode for simd_two_reg_misc_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This actually covers two different sections of the encoding table: Advanced SIMD scalar two-register miscellaneous FP16 Advanced SIMD two-register miscellaneous (FP16) The difference between the two is covered by a combination of Q (bit 30) and S (bit 28). Notably the FRINTx instructions are only available in the vector form. This is just the decode skeleton which will be filled out by later patches. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 - checkpatch cleanups v3 - update comment on group from following patches. - rm left over debug fpf --- target/arm/translate-a64.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 3487c0430f..9c1892c49a 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11164,6 +11164,45 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) } } +/* AdvSIMD [scalar] two register miscellaneous (FP16) + * + * 31 30 29 28 27 24 23 22 21 17 16 12 11 10 9 5 4 0 + * +---+---+---+---+---------+---+-------------+--------+-----+------+------+ + * | 0 | Q | U | S | 1 1 1 0 | a | 1 1 1 1 0 0 | opcode | 1 0 | Rn | Rd | + * +---+---+---+---+---------+---+-------------+--------+-----+------+------+ + * mask: 1000 1111 0111 1110 0000 1100 0000 0000 0x8f7e 0c00 + * val: 0000 1110 0111 1000 0000 1000 0000 0000 0x0e78 0800 + * + * This actually covers two groups where scalar access is governed by + * bit 28. A bunch of the instructions (float to integral) only exist + * in the vector form and are un-allocated for the scalar decode. Also + * in the scalar decode Q is always 1. + */ +static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) +{ + int fpop, opcode, a; + + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + unallocated_encoding(s); + return; + } + + if (!fp_access_check(s)) { + return; + } + + opcode = extract32(insn, 12, 4); + a = extract32(insn, 23, 1); + fpop = deposit32(opcode, 5, 1, a); + + switch (fpop) { + default: + fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop); + g_assert_not_reached(); + } + +} + /* AdvSIMD scalar x indexed element * 31 30 29 28 24 23 22 21 20 19 16 15 12 11 10 9 5 4 0 * +-----+---+-----------+------+---+---+------+-----+---+---+------+------+ @@ -12236,6 +12275,7 @@ static const AArch64DecodeTable data_proc_simd[] = { { 0xce800000, 0xffe00000, disas_crypto_xar }, { 0xce408000, 0xffe0c000, disas_crypto_three_reg_imm2 }, { 0x0e400400, 0x9f60c400, disas_simd_three_reg_same_fp16 }, + { 0x0e780800, 0x8f7e0c00, disas_simd_two_reg_misc_fp16 }, { 0x00000000, 0x00000000, NULL } }; From patchwork Tue Feb 27 14:38:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129813 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp367124edc; Tue, 27 Feb 2018 06:52:24 -0800 (PST) X-Google-Smtp-Source: AH8x226LLPyUSivyFYmRbdgmgAnaRKf62rXhWVyOHMEjaXiLU4x0g6gk9L3zObvQM7djmMw71sKz X-Received: by 10.129.131.145 with SMTP id t139mr9429147ywf.485.1519743144715; Tue, 27 Feb 2018 06:52:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743144; cv=none; d=google.com; s=arc-20160816; b=xr6KFMMlSW3mCK1Xcy9U9nrwyWIcgeDsKODxCMHiaDXUhSqg041lUIE0V7cHa4bYYl V87QvbONwr4F6/ZLudytHZ2ZkIuBCbz2eov4V2eWEUK/cJWnyDOug0laglLH62jAe6Wg zEMmWjXn9sYjP8NDrmTys3V8cDpW5Mca1Gr86uRLweuU/S3nmg+U7+dQnsgap2FnWKIb nGi8Q69pK0fYGXzib2i3C0uf/lvOQoMSq1iElCYW5OPNmYujHIESVa7y3D8M6PInOYlw hR0Szyw7wilTaeFnr2DMmg6yk6LZbbqRdfLs8Sddx6U7RcZM3+yUrlMLUllh4o2zvH4P /UqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Bl22trqCCot2t1qsY/piZDhddSgLLnWogqUeo0yFsDc=; b=aFT8zVIyv3dDeeG9aGCIFqBkTovlIvH/XGigPJyElIdqasir3ycFW/hRfdQ+TI2qYh wX2zKup4pTyo/X8BN30CGlnmHKs2iWCAvU49+4M3owQOt0PGagpeD//dlOVdkH/PGSzk 7O4if1dzxcNDh2/U6jUWc+xumnNMJrtaoPLEadXBARKqzlpp1sT69sp0oAbXDPyYJrBk t9H9ksdD2+xif3Lv1eV1Fgm4XAbeyULtPfZrYU7xqTBWdwz0+27ZwXxcH3xV8QpW1kJC iOZcJDoRhbkWUZRLL3KZaWygW9ha32nlhM9NiLh7Rmunjve0mTdTKdxo2QRujPPSNFjf szJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pk8ECuoS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u1-v6si1955706ybm.628.2018.02.27.06.52.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:52:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pk8ECuoS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgcC-0006pQ-3o for patch@linaro.org; Tue, 27 Feb 2018 09:52:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPV-0003pX-DZ for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPU-000866-46 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:17 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:40643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPT-00085a-RG for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:16 -0500 Received: by mail-wm0-x242.google.com with SMTP id t6so15916985wmt.5 for ; Tue, 27 Feb 2018 06:39:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bl22trqCCot2t1qsY/piZDhddSgLLnWogqUeo0yFsDc=; b=Pk8ECuoS1nEv7uuuLmHTb22n3vSvDzqMxr5d+nEAUczS5s1cTXYCNsr6UU+Gv+jOo1 7HkBLdvKho09D2e5M2v+nWdWUoja9X/MCgHqH/XdUUjkiyqJn/zJzgz2I6W18Dgw0Crk rfblZmGBijg7Ng5G7fxSbBwZXe3IPvXaIQlPY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bl22trqCCot2t1qsY/piZDhddSgLLnWogqUeo0yFsDc=; b=CEtPizZWpps5ASQ4XoAoic/m4EiUNJ5wcidhhWqyIg8zdQznJR7Me6V2nroMBz74Fc F4Nz61PVI6UmJdTJNbrgz28lo2EVfI2Kh98Fcsu9DW6JEc8fnOKXJLS/OLSonlxjBOIG jK/rWiylWeVayQ07kWsylz4lbH/3+Kb9e9DgrUsvxpj0crq7W/RlTXjtCSULQdK7J+FY HATilLerzK0tna6Sig+lqGGFUBhAIBb2K1RYpc0WK1haiUJIhMxqQzBjfnlovCBuVIgo MMQ3+4euq9Kdku4rdvJ9DoYXVB5UpvRKjzOUXwoE/PxJ9/7wDfGaYGBqjJzN6syBTJKM iVoA== X-Gm-Message-State: APf1xPBuE0mxyynNCUp+sy3Y3lvH2oxA7Nsy1BplOsBo29CR1aQ4RLi5 WINCKExRJ/DeBmfWw6UKMyO0Pg== X-Received: by 10.28.237.23 with SMTP id l23mr12062739wmh.113.1519742354694; Tue, 27 Feb 2018 06:39:14 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y145sm11336117wmd.43.2018.02.27.06.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:39:08 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 326783E0C5D; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:38 +0000 Message-Id: <20180227143852.11175-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v4 17/31] arm/translate-a64: add FP16 FPRINTx to simd_two_reg_misc_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds the full range of half-precision floating point to integral instructions. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - fix re-base conflicts - move comment to previous commit - don't double test is_scalar in unallocated checks --- target/arm/helper-a64.c | 22 ++++++++ target/arm/helper-a64.h | 2 + target/arm/translate-a64.c | 123 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 142 insertions(+), 5 deletions(-) -- 2.15.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 4d5ae96d8f..4fd28fdf48 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -745,3 +745,25 @@ uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) int compare = float16_compare(f0, f1, fpst); return ADVSIMD_CMPRES(compare == float_relation_greater); } + +/* round to integral */ +float16 HELPER(advsimd_rinth_exact)(float16 x, void *fp_status) +{ + return float16_round_to_int(x, fp_status); +} + +float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) +{ + int old_flags = get_float_exception_flags(fp_status), new_flags; + float16 ret; + + ret = float16_round_to_int(x, fp_status); + + /* Suppress any inexact exceptions the conversion produced */ + if (!(old_flags & float_flag_inexact)) { + new_flags = get_float_exception_flags(fp_status); + set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status); + } + + return ret; +} diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 003ffa582f..bc8d5b105b 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -75,3 +75,5 @@ DEF_HELPER_3(advsimd_maxnum2h, i32, i32, i32, ptr) DEF_HELPER_3(advsimd_minnum2h, i32, i32, i32, ptr) DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr) DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr) +DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr) +DEF_HELPER_2(advsimd_rinth, f16, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9c1892c49a..3c37eb99ff 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11180,27 +11180,140 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) */ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) { - int fpop, opcode, a; + int fpop, opcode, a, u; + int rn, rd; + bool is_q; + bool is_scalar; + bool only_in_vector = false; + + int pass; + TCGv_i32 tcg_rmode = NULL; + TCGv_ptr tcg_fpstatus = NULL; + bool need_rmode = false; + int rmode; if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { unallocated_encoding(s); return; } - if (!fp_access_check(s)) { - return; - } + rd = extract32(insn, 0, 5); + rn = extract32(insn, 5, 5); - opcode = extract32(insn, 12, 4); a = extract32(insn, 23, 1); + u = extract32(insn, 29, 1); + is_scalar = extract32(insn, 28, 1); + is_q = extract32(insn, 30, 1); + + opcode = extract32(insn, 12, 5); fpop = deposit32(opcode, 5, 1, a); + fpop = deposit32(fpop, 6, 1, u); switch (fpop) { + case 0x18: /* FRINTN */ + need_rmode = true; + only_in_vector = true; + rmode = FPROUNDING_TIEEVEN; + break; + case 0x19: /* FRINTM */ + need_rmode = true; + only_in_vector = true; + rmode = FPROUNDING_NEGINF; + break; + case 0x38: /* FRINTP */ + need_rmode = true; + only_in_vector = true; + rmode = FPROUNDING_POSINF; + break; + case 0x39: /* FRINTZ */ + need_rmode = true; + only_in_vector = true; + rmode = FPROUNDING_ZERO; + break; + case 0x58: /* FRINTA */ + need_rmode = true; + only_in_vector = true; + rmode = FPROUNDING_TIEAWAY; + break; + case 0x59: /* FRINTX */ + case 0x79: /* FRINTI */ + only_in_vector = true; + /* current rounding mode */ + break; default: fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop); g_assert_not_reached(); } + + /* Check additional constraints for the scalar encoding */ + if (is_scalar) { + if (!is_q) { + unallocated_encoding(s); + return; + } + /* FRINTxx is only in the vector form */ + if (only_in_vector) { + unallocated_encoding(s); + return; + } + } + + if (!fp_access_check(s)) { + return; + } + + if (need_rmode) { + tcg_fpstatus = get_fpstatus_ptr(true); + } + + if (need_rmode) { + tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode)); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + } + + if (is_scalar) { + /* no operations yet */ + } else { + for (pass = 0; pass < (is_q ? 8 : 4); pass++) { + TCGv_i32 tcg_op = tcg_temp_new_i32(); + TCGv_i32 tcg_res = tcg_temp_new_i32(); + + read_vec_element_i32(s, tcg_op, rn, pass, MO_16); + + switch (fpop) { + case 0x18: /* FRINTN */ + case 0x19: /* FRINTM */ + case 0x38: /* FRINTP */ + case 0x39: /* FRINTZ */ + case 0x58: /* FRINTA */ + case 0x79: /* FRINTI */ + gen_helper_advsimd_rinth(tcg_res, tcg_op, tcg_fpstatus); + break; + case 0x59: /* FRINTX */ + gen_helper_advsimd_rinth_exact(tcg_res, tcg_op, tcg_fpstatus); + break; + default: + g_assert_not_reached(); + } + + write_vec_element_i32(s, tcg_res, rd, pass, MO_16); + + tcg_temp_free_i32(tcg_res); + tcg_temp_free_i32(tcg_op); + } + + clear_vec_high(s, is_q, rd); + } + + if (tcg_rmode) { + gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + tcg_temp_free_i32(tcg_rmode); + } + + if (tcg_fpstatus) { + tcg_temp_free_ptr(tcg_fpstatus); + } } /* AdvSIMD scalar x indexed element From patchwork Tue Feb 27 14:38:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129807 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1475171lja; Tue, 27 Feb 2018 06:48:33 -0800 (PST) X-Google-Smtp-Source: AH8x225657b4K6zgnAJAj3xJoIjsLeBE/YPjTYu0aHUST2bd39jrxwzL2Kzl1yC3bQvifvg16a1v X-Received: by 10.129.181.68 with SMTP id c4mr9463030ywk.338.1519742913359; Tue, 27 Feb 2018 06:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742913; cv=none; d=google.com; s=arc-20160816; b=TnX2GfomQ7lv0K0DMBnguWi4sK3zmpmIYxdBz1Lh9QjI1VmezZN60jfmoItGLacfz5 FwO68Hi0xb9qGa4V3jMuapts/1DLuAX7pxEcjkEcQpVGSx1drdLdJ/dFBqm36FnFkaZQ 6Q4vETFrmyRSG07chgNw1ZaS+qM5KtRJJfN2lfcK8mcNERlZxUkB1UKKlUrRAxHW80rl Drx5RcSNaqNefn2+R+XFosqo7K3FFsa/z3FCH1S3+538te5Jrnsxdru6EZfu891SdAZY Rsgjj2FKnFOmMH5U1llL+WBO+2MGXXTibjPI3bLZnuOBb2QwyCCuQ647PIEezU5h6wi6 tSgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=SYe81JmCa69AGdz9POFr4xojLPka4BisynWWhclkIAo=; b=orFJJXVSjn6rafOGrIE5uh4m1bIFr3qLHi7GUkvfdBiV1bUMd4Z9MP8Oc0uuPhgMv0 rizKJccdFR4mQ67rbp/+eq9/bF2igrsETTW/Nktxfa3p/0eJTXFAgSC5QcGon+hki0am TDE7qUhei7Yfa79r7n7Xx7Xp3Ay+OKlPwwX9oTycRIGac+HwsCismkPuXfEOYTJ9IiJR 7Oua/u/u/C0A4N20tbEXZdZ+2M8H/MeeKBevD9quexKkBwZWgFyofy74QMaRugt79NF5 OFI/Im58f9duuVs9CxU40Jm8bYO0Bhojy6tR6fFrW8QutCccMC7YhxCWcUAr3yWDlwdL BsAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=G+mgGkAb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f1si1900952ywd.449.2018.02.27.06.48.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:48:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=G+mgGkAb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYS-0002m4-Kh for patch@linaro.org; Tue, 27 Feb 2018 09:48:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPR-0003lQ-W1 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPQ-00083j-CF for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:13 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35973) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPP-00082l-VG for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:12 -0500 Received: by mail-wm0-x243.google.com with SMTP id 188so23613694wme.1 for ; Tue, 27 Feb 2018 06:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SYe81JmCa69AGdz9POFr4xojLPka4BisynWWhclkIAo=; b=G+mgGkAb8iz5V6a06nIfGYNNOHN9CvAvhE6BqqMkjQiU27vemZIZ1RhlVE8TW+374d DI5YRcSA5W36Jy9As/N3hiG8iIbpGXkSTmVWmV0khqjrrZyQvykDOm9fQ4Gedv5ihvSJ kxx7UBUmFgHUf3zAV6EImUHSqRpkfGf/NgIWA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SYe81JmCa69AGdz9POFr4xojLPka4BisynWWhclkIAo=; b=cx7TEUEOHujhRM+akhBHNIg0sAWT5UBuMAFPW8AiDDwiggshgZLR7BD2iUhcSc8L+q 4b3fhjEMAZbqT+0Ci7Bkmt5Q1CXpRmypQm3xZD3Gz7d66rIotHJbwAltos3HFfq8dQLT h3kJGte1I0Yp7xJRxwCAJpEGCnWZUT9LiMdst0342UTp0xaLgdPvNxKIAQcKV2cFcOv2 dJgSADP9IZOC1+vcXohPOgj1yOja69E0wvSraTZJUVLgWC0JVKf3FhuWff29/2oz3gQt CuNeR44EEfYZHf62oBgEJTEW5E1j5c4nBMp8Kxvj/micKr+ZSF32pfmGvIyeiwAPpQi9 weZw== X-Gm-Message-State: APf1xPAEJxMiMGjjOOJiQJhXE+WD58Ds6z8NoodAJajYkTX8HgnOSnpM 5n+njj/qonso4cN+TnAm1Zqc3Q== X-Received: by 10.28.6.83 with SMTP id 80mr5953071wmg.12.1519742350788; Tue, 27 Feb 2018 06:39:10 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 78sm10437782wmb.25.2018.02.27.06.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:39:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 46B163E0CC8; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:39 +0000 Message-Id: <20180227143852.11175-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH v4 18/31] arm/translate-a64: add FCVTxx to simd_two_reg_misc_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This covers all the floating point convert operations. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/helper-a64.c | 32 +++++++++++++++++ target/arm/helper-a64.h | 2 ++ target/arm/translate-a64.c | 85 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 118 insertions(+), 1 deletion(-) -- 2.15.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 4fd28fdf48..722fff2349 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -767,3 +767,35 @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) return ret; } + +/* + * Half-precision floating point conversion functions + * + * There are a multitude of conversion functions with various + * different rounding modes. This is dealt with by the calling code + * setting the mode appropriately before calling the helper. + */ + +uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) +{ + float_status *fpst = fpstp; + + /* Invalid if we are passed a NaN */ + if (float16_is_any_nan(a)) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_int16(a, fpst); +} + +uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) +{ + float_status *fpst = fpstp; + + /* Invalid if we are passed a NaN */ + if (float16_is_any_nan(a)) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_uint16(a, fpst); +} diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index bc8d5b105b..32931b17c6 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -77,3 +77,5 @@ DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr) DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr) DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr) DEF_HELPER_2(advsimd_rinth, f16, f16, ptr) +DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr) +DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 3c37eb99ff..046079b1b3 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11240,6 +11240,46 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) only_in_vector = true; /* current rounding mode */ break; + case 0x1a: /* FCVTNS */ + need_rmode = true; + rmode = FPROUNDING_TIEEVEN; + break; + case 0x1b: /* FCVTMS */ + need_rmode = true; + rmode = FPROUNDING_NEGINF; + break; + case 0x1c: /* FCVTAS */ + need_rmode = true; + rmode = FPROUNDING_TIEAWAY; + break; + case 0x3a: /* FCVTPS */ + need_rmode = true; + rmode = FPROUNDING_POSINF; + break; + case 0x3b: /* FCVTZS */ + need_rmode = true; + rmode = FPROUNDING_ZERO; + break; + case 0x5a: /* FCVTNU */ + need_rmode = true; + rmode = FPROUNDING_TIEEVEN; + break; + case 0x5b: /* FCVTMU */ + need_rmode = true; + rmode = FPROUNDING_NEGINF; + break; + case 0x5c: /* FCVTAU */ + need_rmode = true; + rmode = FPROUNDING_TIEAWAY; + break; + case 0x7a: /* FCVTPU */ + need_rmode = true; + rmode = FPROUNDING_POSINF; + break; + case 0x7b: /* FCVTZU */ + need_rmode = true; + rmode = FPROUNDING_ZERO; + break; default: fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop); g_assert_not_reached(); @@ -11273,7 +11313,36 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) } if (is_scalar) { - /* no operations yet */ + TCGv_i32 tcg_op = tcg_temp_new_i32(); + TCGv_i32 tcg_res = tcg_temp_new_i32(); + + read_vec_element_i32(s, tcg_op, rn, 0, MO_16); + + switch (fpop) { + case 0x1a: /* FCVTNS */ + case 0x1b: /* FCVTMS */ + case 0x1c: /* FCVTAS */ + case 0x3a: /* FCVTPS */ + case 0x3b: /* FCVTZS */ + gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus); + break; + case 0x5a: /* FCVTNU */ + case 0x5b: /* FCVTMU */ + case 0x5c: /* FCVTAU */ + case 0x7a: /* FCVTPU */ + case 0x7b: /* FCVTZU */ + gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus); + break; + default: + g_assert_not_reached(); + } + + /* limit any sign extension going on */ + tcg_gen_andi_i32(tcg_res, tcg_res, 0xffff); + write_fp_sreg(s, rd, tcg_res); + + tcg_temp_free_i32(tcg_res); + tcg_temp_free_i32(tcg_op); } else { for (pass = 0; pass < (is_q ? 8 : 4); pass++) { TCGv_i32 tcg_op = tcg_temp_new_i32(); @@ -11282,6 +11351,20 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) read_vec_element_i32(s, tcg_op, rn, pass, MO_16); switch (fpop) { + case 0x1a: /* FCVTNS */ + case 0x1b: /* FCVTMS */ + case 0x1c: /* FCVTAS */ + case 0x3a: /* FCVTPS */ + case 0x3b: /* FCVTZS */ + gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus); + break; + case 0x5a: /* FCVTNU */ + case 0x5b: /* FCVTMU */ + case 0x5c: /* FCVTAU */ + case 0x7a: /* FCVTPU */ + case 0x7b: /* FCVTZU */ + gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus); + break; case 0x18: /* FRINTN */ case 0x19: /* FRINTM */ case 0x38: /* FRINTP */ From patchwork Tue Feb 27 14:38:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129820 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp379305edc; Tue, 27 Feb 2018 07:02:36 -0800 (PST) X-Google-Smtp-Source: AG47ELsupp/iH/PWlRzyUJwqoKf214RmgLMTn1a3gIoJAE4K7rS4FPUTIiufILla1fAX3mwspJ60 X-Received: by 2002:a25:c0d5:: with SMTP id c204-v6mr9579560ybf.133.1519743756456; Tue, 27 Feb 2018 07:02:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743756; cv=none; d=google.com; s=arc-20160816; b=cxOsVXUkGc4AsDUaNFEuOTkmoLox8Z0Sn5DmwvUWxQYv35cN5m3wsclBNMh95WS4Db OxKx9/7+B/POfKQFC9izabFqwLFxJBzmQfvvMh34tb1beyohlIhRccxi3hkzevP4D+GA 3qdrn57pzbFxnQugeHsHWrDIByJcjsiHKBpckpZVbcfCSxftbU3IGAvDVSqVasZIoW0I Lm04UHwI5ja/aTLxtUdmoPBjAsMXpzSgbkHai5u8WJIS2ERQQAvr1OUr8CGjXEcktxQK fkgTPVes0UcUYtK20bq2jJzz2hI7b2cJKVGY3uXlUBYUtOXYLjPYwmiF5cvZ7qC98tvP C6qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=wtsGLpj5HYnjdS0RuBsM84gfH0NjXM9FmLJOGGTxHHM=; b=id9W2iQz/2eQnN8FoYC5py1bEX4MG4XhBXTNZ/QuFAgyHOUDGxEabGVo3KMZgBGV4y xyFDGguK9dOCMvTCON0vENdnD75Mq5fi/YzneeKEEspLvcvwoNafJtWvWh1JKzieobOf eyalYNCsX2itRHN8mZ//YUvQBOHOJtUFiDU1KiUw5KG1de4zuczuu3nPPHMaGI+4YpMU Tbs3c/vOfKyCP8XLbWuxUSgyLUfPpEgqQW2BgmV8E9dvCS8TDivTTZaZHx9AbW3HtmHu KrfkeeTpUjuOlNfOShG28V52hUUGS3BQuzfAYmE3Vg0nyz1j0s3Ejfxk9U51ljmaF6tu nw4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UN+21Uju; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d28-v6si1205309ybe.129.2018.02.27.07.02.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:02:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UN+21Uju; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgm3-0006hq-Ru for patch@linaro.org; Tue, 27 Feb 2018 10:02:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgY6-0003Z1-76 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY3-0001MZ-2t for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:10 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:33907) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgY2-0001Gv-Jn for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:06 -0500 Received: by mail-wr0-x244.google.com with SMTP id m5so25156792wrg.1 for ; Tue, 27 Feb 2018 06:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wtsGLpj5HYnjdS0RuBsM84gfH0NjXM9FmLJOGGTxHHM=; b=UN+21UjuhuCcSTmii2pUiOCt+C8AZ3En6Qo8dXRDtuz9MCwimHPHxveycaQl2ne4FU Juof6HEpb+La1d6hv4eG8wRT9rWxo9IYiESurYl97/es3fQUCnFgKAjfk/Eu8QF+DB3K RjWWFNi+RQp+DjgzzfjTtdAirvVlLzl5SzfeU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wtsGLpj5HYnjdS0RuBsM84gfH0NjXM9FmLJOGGTxHHM=; b=J06e/HtnTg8xrzjQEXoqDCNjDEMsXuQIq9XeWg4omKtg5TUsaIvLmcrmrzEEkc0izA He0aOvJ2T0YyUcXX7x1GHB5otsYm+++BaMSKpNao9mNjT49x4ggI20yhnCJfyF6tjLSm pnJbRmb46Lj1BpXOjjIAfKsP28iL0VhyoObKIbUDpPJszY2ENqDFzXXLcgqYKCWWT7oR hqfD25Wt/Ye0s5YW3kuMKlSVLaf8X8uO1Ux4Om6Xoyse294zyX8GWsWYyKF3TYvQ+9CF WogFO+MRbQTOOoY9SBE+rOuIq/PoUvLARDQmj/GqSeIMzWBEDGvzgg40ySbgQGk9ul1Y pHWg== X-Gm-Message-State: APf1xPBbjaFtfUzmIIyo///lVCiUxFqPYCqDj74perxSWcKQaDDwfjEY h09Nq4toRbpvd/RGwRbuBAJttxW1GB8= X-Received: by 10.223.161.144 with SMTP id u16mr13419932wru.137.1519742885350; Tue, 27 Feb 2018 06:48:05 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l11sm8843624wrg.71.2018.02.27.06.48.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:00 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 57FFB3E15D4; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:40 +0000 Message-Id: <20180227143852.11175-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PATCH v4 19/31] arm/translate-a64: add FP16 FCMxx (zero) to simd_two_reg_misc_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" I re-use the existing handle_2misc_fcmp_zero handler and tweak it slightly to deal with the half-precision case. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - use size directly wuth read/write_vec_element - drop unneeded break - WIP: mess with calculating maxpasses --- target/arm/translate-a64.c | 80 +++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 23 deletions(-) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 046079b1b3..9c02f1e23c 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -7821,14 +7821,14 @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, bool is_scalar, bool is_u, bool is_q, int size, int rn, int rd) { - bool is_double = (size == 3); + bool is_double = (size == MO_64); TCGv_ptr fpst; if (!fp_access_check(s)) { return; } - fpst = get_fpstatus_ptr(false); + fpst = get_fpstatus_ptr(size == MO_16); if (is_double) { TCGv_i64 tcg_op = tcg_temp_new_i64(); @@ -7880,34 +7880,57 @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, bool swap = false; int pass, maxpasses; - switch (opcode) { - case 0x2e: /* FCMLT (zero) */ - swap = true; - /* fall through */ - case 0x2c: /* FCMGT (zero) */ - genfn = gen_helper_neon_cgt_f32; - break; - case 0x2d: /* FCMEQ (zero) */ - genfn = gen_helper_neon_ceq_f32; - break; - case 0x6d: /* FCMLE (zero) */ - swap = true; - /* fall through */ - case 0x6c: /* FCMGE (zero) */ - genfn = gen_helper_neon_cge_f32; - break; - default: - g_assert_not_reached(); + if (size == MO_16) { + switch (opcode) { + case 0x2e: /* FCMLT (zero) */ + swap = true; + /* fall through */ + case 0x2c: /* FCMGT (zero) */ + genfn = gen_helper_advsimd_cgt_f16; + break; + case 0x2d: /* FCMEQ (zero) */ + genfn = gen_helper_advsimd_ceq_f16; + break; + case 0x6d: /* FCMLE (zero) */ + swap = true; + /* fall through */ + case 0x6c: /* FCMGE (zero) */ + genfn = gen_helper_advsimd_cge_f16; + break; + default: + g_assert_not_reached(); + } + } else { + switch (opcode) { + case 0x2e: /* FCMLT (zero) */ + swap = true; + /* fall through */ + case 0x2c: /* FCMGT (zero) */ + genfn = gen_helper_neon_cgt_f32; + break; + case 0x2d: /* FCMEQ (zero) */ + genfn = gen_helper_neon_ceq_f32; + break; + case 0x6d: /* FCMLE (zero) */ + swap = true; + /* fall through */ + case 0x6c: /* FCMGE (zero) */ + genfn = gen_helper_neon_cge_f32; + break; + default: + g_assert_not_reached(); + } } if (is_scalar) { maxpasses = 1; } else { - maxpasses = is_q ? 4 : 2; + int vector_size = 8 << is_q; + maxpasses = vector_size >> size; } for (pass = 0; pass < maxpasses; pass++) { - read_vec_element_i32(s, tcg_op, rn, pass, MO_32); + read_vec_element_i32(s, tcg_op, rn, pass, size); if (swap) { genfn(tcg_res, tcg_zero, tcg_op, fpst); } else { @@ -7916,7 +7939,7 @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, if (is_scalar) { write_fp_sreg(s, rd, tcg_res); } else { - write_vec_element_i32(s, tcg_res, rd, pass, MO_32); + write_vec_element_i32(s, tcg_res, rd, pass, size); } } tcg_temp_free_i32(tcg_res); @@ -11209,7 +11232,18 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) fpop = deposit32(opcode, 5, 1, a); fpop = deposit32(fpop, 6, 1, u); + rd = extract32(insn, 0, 5); + rn = extract32(insn, 5, 5); + switch (fpop) { + break; + case 0x2c: /* FCMGT (zero) */ + case 0x2d: /* FCMEQ (zero) */ + case 0x2e: /* FCMLT (zero) */ + case 0x6c: /* FCMGE (zero) */ + case 0x6d: /* FCMLE (zero) */ + handle_2misc_fcmp_zero(s, fpop, is_scalar, 0, is_q, MO_16, rn, rd); + return; case 0x18: /* FRINTN */ need_rmode = true; only_in_vector = true; From patchwork Tue Feb 27 14:38:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129825 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp385226edc; Tue, 27 Feb 2018 07:07:01 -0800 (PST) X-Google-Smtp-Source: AG47ELu29iBSZIbN24LB8ZJd8wlFOm6xyqtzmbtczNmSVE01FUmXXj5jCyhtAOjN9qBsgnxMP56K X-Received: by 2002:a25:c8c2:: with SMTP id y185-v6mr3410287ybf.94.1519744021619; Tue, 27 Feb 2018 07:07:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519744021; cv=none; d=google.com; s=arc-20160816; b=a/I52YCimIelYICwJ03Oike0fZTLrERF73X6Mxppp+rRYsMl7p3OLLNe/ffqM3ekLa Qn4T4hQoDA0BiZIpWMS4PFvk/OWs3f+4LXgF0Wo+I3A3KYXZCM4LH6m93xIa3crEFb+L zpNnpL8xEArmUulgfnanP9AG5YuOXMwa1o/8TNubPrd3sZ55csU3P3vMMD7kg0rReWyx jaaOurWJ8sCDESsmiWjh8MAuOG+52RXhzZw0xvokrF994SHhhk94KJ7NR9+vHYXK9sG1 4dKHiiqwU/yyBMy1Ly3cHSv5uPCtlGZAduJ8qwXtcaz4fV29m6QrkmN84KfD5ip2/ZqF 1eEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=WW5W8z9MItaE0KqpoYIgIPEx/0pUcIrykYOR6JKcE1s=; b=hyvqttZCPP1fUDPTuMKLXtYw7dmtWYAyziWjlPyYlOuzVRDtjfH/8shLCOWDYPvFf0 ae5bxw91ULLFHiEUg4LN2H5ZBLFY7rmtbeZWoGFJ/shxhZNRjKr6XRkIGabi6bow97QD JBMIx1m6LrjtAvK7fGKDLJdZXAnlhWldnDiwTKVTxj7TtjCH4bZMdmPfu1BpDDmb4yOs JD/FgSjoyLrNaGtrqcMJfQrua0HFJdfvvJp/MD7mZjI34QOBM+R0xY2bE1uT/OK+DOrV 5BTxZT3djgmUdArJxY8FCA52IsxoqN1CjIhw701lh9RA/LAtttRHwaavtf+UX2UYofp5 qTjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IvpcYGd2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j13si1697323ywi.337.2018.02.27.07.07.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:07:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IvpcYGd2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgqK-0002Y8-T3 for patch@linaro.org; Tue, 27 Feb 2018 10:07:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYD-0003g7-Jf for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY9-0001lI-4e for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:17 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:35656) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgY8-0001hS-LT for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:12 -0500 Received: by mail-wr0-x242.google.com with SMTP id l43so25176430wrc.2 for ; Tue, 27 Feb 2018 06:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WW5W8z9MItaE0KqpoYIgIPEx/0pUcIrykYOR6JKcE1s=; b=IvpcYGd2SEVes5jUWHkyeAsuQkz/EZPK2NsqJUnX5LMOFwhjQDKRkvarv5SR3Xxlg7 I3P6R++vOopruqtWQwBLed+p7H1iyEj5Jbmpc6UdCdt5denoJrcdRXzmSvPbHsOFFr8W gIVZ5nb/I6Nlq9Z1XwsPy5uDlQRVGjJNYt+3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WW5W8z9MItaE0KqpoYIgIPEx/0pUcIrykYOR6JKcE1s=; b=C2MJJBOg4ADq3ywehOiFvwDNGtwPJesKBObfXNO7qSeeJzJw4upaEFbpvs9NVb+xEo C4rwaOjXy7FD4wrLm978kxfQmsZ1RJVjhlKK3I+jgZ/mtXg/y6g3j1NW+P2WyhBRDj2v RXMtWkiu4mWrxlp8Q1Q2B0KPKj3V6swqSjyn7NP3WjOCq3K6JNwQd6EnZGTPGvk61glF YN9Qq0br0Zwf4QS3dKt+beoba0t9dbCVFAvUFaMTe2qA1hy/wqE35nN4G11bdnpQGAK+ 6QPz78DBRR32dcNGYeGc6k9EisuFWbVa2uh1msyOmXPBWaISIIEwHwF+kloIcXrCcdmU gCcA== X-Gm-Message-State: APf1xPAU5Shf2NfU9ngnUGBsgcbq40TQS72csuaCiNoCahVLyTFTHAvp Pc4carSXfWlkL5goF4sPiqtyEQ== X-Received: by 10.223.136.44 with SMTP id d41mr13630048wrd.127.1519742891315; Tue, 27 Feb 2018 06:48:11 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a67sm27138299wrc.13.2018.02.27.06.48.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 6BB113E15E1; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:41 +0000 Message-Id: <20180227143852.11175-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 20/31] arm/translate-a64: add FP16 SCVTF/UCVFT to simd_two_reg_misc_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" I've re-factored the handle_simd_intfp_conv helper to properly handle half-precision as well as call plain conversion helpers when we are not doing fixed point conversion. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/helper.c | 4 ++ target/arm/helper.h | 10 ++++ target/arm/translate-a64.c | 114 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 104 insertions(+), 24 deletions(-) -- 2.15.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 303cd1eaf9..6e3dadb754 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11302,8 +11302,10 @@ CONV_ITOF(vfp_##name##to##p, fsz, sign) \ CONV_FTOI(vfp_to##name##p, fsz, sign, ) \ CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero) +FLOAT_CONVS(si, h, 16, ) FLOAT_CONVS(si, s, 32, ) FLOAT_CONVS(si, d, 64, ) +FLOAT_CONVS(ui, h, 16, u) FLOAT_CONVS(ui, s, 32, u) FLOAT_CONVS(ui, d, 64, u) @@ -11386,6 +11388,8 @@ VFP_CONV_FIX_A64(sq, s, 32, 64, int64) VFP_CONV_FIX(uh, s, 32, 32, uint16) VFP_CONV_FIX(ul, s, 32, 32, uint32) VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) +VFP_CONV_FIX_A64(sl, h, 16, 32, int32) +VFP_CONV_FIX_A64(ul, h, 16, 32, uint32) #undef VFP_CONV_FIX #undef VFP_CONV_FIX_FLOAT #undef VFP_CONV_FLOAT_FIX_ROUND diff --git a/target/arm/helper.h b/target/arm/helper.h index 81ecb319b3..c0f35592ff 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -120,17 +120,23 @@ DEF_HELPER_3(vfp_cmped, void, f64, f64, env) DEF_HELPER_2(vfp_fcvtds, f64, f32, env) DEF_HELPER_2(vfp_fcvtsd, f32, f64, env) +DEF_HELPER_2(vfp_uitoh, f16, i32, ptr) DEF_HELPER_2(vfp_uitos, f32, i32, ptr) DEF_HELPER_2(vfp_uitod, f64, i32, ptr) +DEF_HELPER_2(vfp_sitoh, f16, i32, ptr) DEF_HELPER_2(vfp_sitos, f32, i32, ptr) DEF_HELPER_2(vfp_sitod, f64, i32, ptr) +DEF_HELPER_2(vfp_touih, i32, f16, ptr) DEF_HELPER_2(vfp_touis, i32, f32, ptr) DEF_HELPER_2(vfp_touid, i32, f64, ptr) +DEF_HELPER_2(vfp_touizh, i32, f16, ptr) DEF_HELPER_2(vfp_touizs, i32, f32, ptr) DEF_HELPER_2(vfp_touizd, i32, f64, ptr) +DEF_HELPER_2(vfp_tosih, i32, f16, ptr) DEF_HELPER_2(vfp_tosis, i32, f32, ptr) DEF_HELPER_2(vfp_tosid, i32, f64, ptr) +DEF_HELPER_2(vfp_tosizh, i32, f16, ptr) DEF_HELPER_2(vfp_tosizs, i32, f32, ptr) DEF_HELPER_2(vfp_tosizd, i32, f64, ptr) @@ -142,6 +148,8 @@ DEF_HELPER_3(vfp_toshd_round_to_zero, i64, f64, i32, ptr) DEF_HELPER_3(vfp_tosld_round_to_zero, i64, f64, i32, ptr) DEF_HELPER_3(vfp_touhd_round_to_zero, i64, f64, i32, ptr) DEF_HELPER_3(vfp_tould_round_to_zero, i64, f64, i32, ptr) +DEF_HELPER_3(vfp_toulh, i32, f16, i32, ptr) +DEF_HELPER_3(vfp_toslh, i32, f16, i32, ptr) DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr) DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr) DEF_HELPER_3(vfp_tosqs, i64, f32, i32, ptr) @@ -166,6 +174,8 @@ DEF_HELPER_3(vfp_sqtod, f64, i64, i32, ptr) DEF_HELPER_3(vfp_uhtod, f64, i64, i32, ptr) DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr) DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr) +DEF_HELPER_3(vfp_sltoh, f16, i32, i32, ptr) +DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr) DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr) DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9c02f1e23c..6f33783a11 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -6902,23 +6902,28 @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn, int elements, int is_signed, int fracbits, int size) { - bool is_double = size == 3 ? true : false; - TCGv_ptr tcg_fpst = get_fpstatus_ptr(false); - TCGv_i32 tcg_shift = tcg_const_i32(fracbits); - TCGv_i64 tcg_int = tcg_temp_new_i64(); + TCGv_ptr tcg_fpst = get_fpstatus_ptr(size == MO_16); + TCGv_i32 tcg_shift = NULL; + TCGMemOp mop = size | (is_signed ? MO_SIGN : 0); int pass; - for (pass = 0; pass < elements; pass++) { - read_vec_element(s, tcg_int, rn, pass, mop); + if (fracbits || size == MO_64) { + tcg_shift = tcg_const_i32(fracbits); + } + + if (size == MO_64) { + TCGv_i64 tcg_int64 = tcg_temp_new_i64(); + TCGv_i64 tcg_double = tcg_temp_new_i64(); + + for (pass = 0; pass < elements; pass++) { + read_vec_element(s, tcg_int64, rn, pass, mop); - if (is_double) { - TCGv_i64 tcg_double = tcg_temp_new_i64(); if (is_signed) { - gen_helper_vfp_sqtod(tcg_double, tcg_int, + gen_helper_vfp_sqtod(tcg_double, tcg_int64, tcg_shift, tcg_fpst); } else { - gen_helper_vfp_uqtod(tcg_double, tcg_int, + gen_helper_vfp_uqtod(tcg_double, tcg_int64, tcg_shift, tcg_fpst); } if (elements == 1) { @@ -6926,28 +6931,72 @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn, } else { write_vec_element(s, tcg_double, rd, pass, MO_64); } - tcg_temp_free_i64(tcg_double); - } else { - TCGv_i32 tcg_single = tcg_temp_new_i32(); - if (is_signed) { - gen_helper_vfp_sqtos(tcg_single, tcg_int, - tcg_shift, tcg_fpst); - } else { - gen_helper_vfp_uqtos(tcg_single, tcg_int, - tcg_shift, tcg_fpst); + } + + tcg_temp_free_i64(tcg_int64); + tcg_temp_free_i64(tcg_double); + + } else { + TCGv_i32 tcg_int32 = tcg_temp_new_i32(); + TCGv_i32 tcg_float = tcg_temp_new_i32(); + + for (pass = 0; pass < elements; pass++) { + read_vec_element_i32(s, tcg_int32, rn, pass, mop); + + switch (size) { + case MO_32: + if (fracbits) { + if (is_signed) { + gen_helper_vfp_sltos(tcg_float, tcg_int32, + tcg_shift, tcg_fpst); + } else { + gen_helper_vfp_ultos(tcg_float, tcg_int32, + tcg_shift, tcg_fpst); + } + } else { + if (is_signed) { + gen_helper_vfp_sitos(tcg_float, tcg_int32, tcg_fpst); + } else { + gen_helper_vfp_uitos(tcg_float, tcg_int32, tcg_fpst); + } + } + break; + case MO_16: + if (fracbits) { + if (is_signed) { + gen_helper_vfp_sltoh(tcg_float, tcg_int32, + tcg_shift, tcg_fpst); + } else { + gen_helper_vfp_ultoh(tcg_float, tcg_int32, + tcg_shift, tcg_fpst); + } + } else { + if (is_signed) { + gen_helper_vfp_sitoh(tcg_float, tcg_int32, tcg_fpst); + } else { + gen_helper_vfp_uitoh(tcg_float, tcg_int32, tcg_fpst); + } + } + break; + default: + g_assert_not_reached(); } + if (elements == 1) { - write_fp_sreg(s, rd, tcg_single); + write_fp_sreg(s, rd, tcg_float); } else { - write_vec_element_i32(s, tcg_single, rd, pass, MO_32); + write_vec_element_i32(s, tcg_float, rd, pass, size); } - tcg_temp_free_i32(tcg_single); } + + tcg_temp_free_i32(tcg_int32); + tcg_temp_free_i32(tcg_float); } - tcg_temp_free_i64(tcg_int); tcg_temp_free_ptr(tcg_fpst); - tcg_temp_free_i32(tcg_shift); + if (tcg_shift) { + tcg_temp_free_i32(tcg_shift); + } clear_vec_high(s, elements << size == 16, rd); } @@ -11236,6 +11285,23 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) rn = extract32(insn, 5, 5); switch (fpop) { + case 0x1d: /* SCVTF */ + case 0x5d: /* UCVTF */ + { + int elements; + + if (is_scalar) { + elements = 1; + } else { + elements = (is_q ? 8 : 4); + } + + if (!fp_access_check(s)) { + return; + } + handle_simd_intfp_conv(s, rd, rn, elements, !u, 0, MO_16); + return; + } break; case 0x2c: /* FCMGT (zero) */ case 0x2d: /* FCMEQ (zero) */ From patchwork Tue Feb 27 14:38:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129816 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp371410edc; Tue, 27 Feb 2018 06:56:19 -0800 (PST) X-Google-Smtp-Source: AH8x226Rv74uBMahWnKRst/HqUaH37AQjCflrdkjSMoAzo2nnZ3x8tPow5Hn4ypfB4d9nB5P7Nrq X-Received: by 10.129.91.193 with SMTP id p184mr8717616ywb.434.1519743379872; Tue, 27 Feb 2018 06:56:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743379; cv=none; d=google.com; s=arc-20160816; b=fE2y1qMkzMssSiqsClf1VzdYdw/dDGp0QGjv9E5KIZN+EN1JYpWuWnzBlEQrvFbc90 4+MCyUn2GWh0bXQQkxwWRBVmmB9V6u1eVyTnjC0fzxzPXM6CiRE2RQrbMELmF546Japf EYcuqG3+CM5qZsR2vPq14YzGSPTBatTrREsTsZ/0wS3r9eMlFIdD/gvrziSoLBKVP3mY fhe2Qun9xyGp2Cy2AW5mKI5eTMnz1cHHGzfGVSpAWktYMi3poV67a+yi/JmJDbBoTzkG fW/WK46eLaTU7nFD3p0Z6pt1goeNZ9J1+Fq/sUimrcgmlE+VSCc1wYyfrgDBlPGOc3jD nUfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=2e7aJXQxh9u/kBr+CG6HEHolwVuMtqX68/ZiwUSBI0c=; b=NeOHyDNBhQYUf8HajuFwIRWBQuOQmolmsbvC2ApL/WxRVfhiVIjp4J8oAnVEzUrUSa 84GELSgdSAb982Y6st3pYQ6PvhKng91kSAkfh5zA0V0NXhaFfekQBSNoLKS6JgeQpXu6 YTjvinP1clGWZ8xYFl010LUe7ddVV8LVa4ooFnV44rGtutNaZaT3J3NlRQOFekbTuZFo Na7NCudSudhze/nkkADRr+Ot9UWAimXTHhreVgo1sQYZN7ICwH/Pe6NhlJGuc6OPkmJh erv1rX7OXOUU/u2vie7AJXGyZMeMWEj/sSouDNV8kS86ua+/B8brzKD/fT5QQTHZUAs0 tKag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CqbEJ+UN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s187si1886212ywe.527.2018.02.27.06.56.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:56:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CqbEJ+UN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgfz-000243-6g for patch@linaro.org; Tue, 27 Feb 2018 09:56:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYD-0003gF-LG for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY9-0001on-Uy for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:17 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:46039) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgY9-0001kq-IF for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:13 -0500 Received: by mail-wr0-x242.google.com with SMTP id p104so25107917wrc.12 for ; Tue, 27 Feb 2018 06:48:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2e7aJXQxh9u/kBr+CG6HEHolwVuMtqX68/ZiwUSBI0c=; b=CqbEJ+UNYvwxmQhoiFPW6A0d5cKSeVLWv/UDElWx5Sz0TXzmkKLI0yWAHAaUp8Imo3 MMWXgY19pzTqtH4KVd4SSXQd3avi188E5frMLKBvEO+GzRc3fzs4qox/CkILv038LLNE DJvJjsVH+00S3/URFUpq0IfExViw+a31kJXiE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2e7aJXQxh9u/kBr+CG6HEHolwVuMtqX68/ZiwUSBI0c=; b=jgDIvLsoeZ64lx000C6I+Q2SaEbdzaKdoWlBrMilxOCcvGxQeMcFbReMw1INj9EgwO VTnE4dBriIUIHAbDXGununoKeixaCQJU4E/6UYY6xZlveYZq8hs1KEiToMYzO1SDFmhQ sj2d2wivn8SY9YGdY288bay/VRLalitEOUbfF9afkXdQT3Q7K99J0MXdaIFAOLwkXIK9 RAOmlf4HfDncFwMRc/ZMici8ENuBzrxKtUu8Hj3wFNQlBaIlQQ42mvRNgVm4VTSt/DK7 TSUdOA+QUJkMHB8XqmSLyTI6uQWLqkfh/trIQclLhtHdVjK8t/32HMhyJwuBbBW6cBMX 7sng== X-Gm-Message-State: APf1xPAq/eCdVzedB7RYAmZLzILThyURwfqZl55bcHHtEzkGjYs7YN3M h+TZ5nLtogc0ETbvhB+sYkKA7g== X-Received: by 10.223.138.130 with SMTP id y2mr12074227wry.242.1519742892356; Tue, 27 Feb 2018 06:48:12 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y34sm27892743wry.19.2018.02.27.06.48.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7D2053E1615; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:42 +0000 Message-Id: <20180227143852.11175-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 21/31] arm/translate-a64: add FP16 FNEG/FABS to simd_two_reg_misc_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Neither of these operations alter the floating point status registers so we can do a pure bitwise operation, either squashing any sign bit (ABS) or inverting it (NEG). Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - fixup re-base conflicts - make both operations pure bitwise TCG --- target/arm/translate-a64.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 6f33783a11..9f2c3682dc 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11262,6 +11262,7 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) TCGv_i32 tcg_rmode = NULL; TCGv_ptr tcg_fpstatus = NULL; bool need_rmode = false; + bool need_fpst = true; int rmode; if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { @@ -11380,6 +11381,10 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) need_rmode = true; rmode = FPROUNDING_ZERO; break; + case 0x2f: /* FABS */ + case 0x6f: /* FNEG */ + need_fpst = false; + break; default: fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop); g_assert_not_reached(); @@ -11403,7 +11408,7 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) return; } - if (need_rmode) { + if (need_rmode || need_fpst) { tcg_fpstatus = get_fpstatus_ptr(true); } @@ -11433,6 +11438,9 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x7b: /* FCVTZU */ gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus); break; + case 0x6f: /* FNEG */ + tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); + break; default: g_assert_not_reached(); } @@ -11476,6 +11484,12 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x59: /* FRINTX */ gen_helper_advsimd_rinth_exact(tcg_res, tcg_op, tcg_fpstatus); break; + case 0x2f: /* FABS */ + tcg_gen_andi_i32(tcg_res, tcg_op, 0x7fff); + break; + case 0x6f: /* FNEG */ + tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); + break; default: g_assert_not_reached(); } From patchwork Tue Feb 27 14:38:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129827 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp389805edc; Tue, 27 Feb 2018 07:10:46 -0800 (PST) X-Google-Smtp-Source: AH8x225rDVJVt97lMW524zVUwhf4XyR9knhMQePAP/cy8wkNtCJt92VJ+lsEa3MUPRoMgKXRGkqd X-Received: by 10.129.161.66 with SMTP id y63mr9416410ywg.403.1519744246056; Tue, 27 Feb 2018 07:10:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519744246; cv=none; d=google.com; s=arc-20160816; b=gjhVWzk/cFtdc9Ago2xHDJm3L4xa14Dx1IIiLSa+6AbrnAPkucgAz8gjmXGGqIZUWx bdh2LCaTJAdekKeBHh5zxfUNDQhOhINcmaMZaS9nXMlfNbtvhfCOUcaZNn/Di+Urkk2r vujMAMDjvObTM/+yCgTYzfXPyF6ejCHfgS/3fP45FuP5YcAUPEfmh4oDvAVwjkkNcIZY UCQAhaxw18OChtJJxL9bSjQh9DfzMnhwq7KLXY7fAb898471LvFTloL1U+DL0+KZwWTJ pjXFf5OCoP85pjIIt3uRJ/WfNIt0akY3r+66gF8Vw4J9uygwovJbBL4qyVp69FKvgR+0 k+NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=VqNMHCBLlpAoDxm4NJYKswAHT6Lza2sEWQaxgRhBLiU=; b=m+45K5DLJybHj0614hKuYDDfH16RbnwRBDisdCzLmOALwLhgVxgPvnOS+HzIyYOPQh pfTY9NZZBz1IE4DNMP+NFNfIGwebcCNQnxcxo/Xb1oio5T5eJXUAr1FsOuxar0jFITyr 5/iaiBXSdwIlSkd27J+PlVawQmqtSAytK4FjQcaPrY+D/wQwX7e7At6IArXoSGrgFiFV YNnX+6B78QX2/ujX3xSTO5m7FMxLLvnIjGD144i7cMX133Cuz376qPgBZl3Ggf3PWfg9 dorUFLmKIpj+vlQazJPa4hvkaa9H+lSLLJYPJJi6LDf0XwCyotjOoO2CdrFmhq/TIcdj itPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Db87JNHr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x83-v6si2006529ybb.549.2018.02.27.07.10.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:10:46 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Db87JNHr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgtx-0005qa-1U for patch@linaro.org; Tue, 27 Feb 2018 10:10:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYM-0003rH-UT for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgYE-000282-Ml for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:26 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:44621) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgYE-00023m-5M for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:18 -0500 Received: by mail-wr0-x242.google.com with SMTP id v65so25110877wrc.11 for ; Tue, 27 Feb 2018 06:48:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VqNMHCBLlpAoDxm4NJYKswAHT6Lza2sEWQaxgRhBLiU=; b=Db87JNHrNs9W2S87DCknPzGf8oQFFVQXyGfaTrRzsGiPoYStrgxGuUlb5W+DHVJiDu SoomDPcaAO83n7o6J/51X4+9Jvy2Tz8GmxZ9QXnbO0MSItRffkld5uorOmh7n5mEBFbJ ELBZTH2hCfadPo1v34wW3ANXEGiEXrfavAYPg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VqNMHCBLlpAoDxm4NJYKswAHT6Lza2sEWQaxgRhBLiU=; b=a4pDyH6Saj2exrX7Dhkr6YN56R6kJKE1BsZjjd75b3vmY3NGWazoMcuOwiL7zhO9Xe fnFnG4VpZzWxp1uSCfwEw2X45khEVZIP06nDau7hEr4P6wpW5ks7JvxOtghnZ5X23os0 J3zMvW/4qv6ak5wwCI0k8P7HjnbBgea4QNIxTrPM88DAa5hTxVCgseCXbhszkv7Ne6KX XpBYfxPCwLPBylO9ES7WlhctGpglLjpT2SrQRDVG7fdDBQ3WSwOnFIlWTt0+oyku4VtH B6UHNZ0rMNQ9JL+FBTm3af9s7iOpArDaKoXskT/Bn/NGLdnIU6UQFB6iIKBRAgKbrvqs mp1g== X-Gm-Message-State: APf1xPAUZKZoXEQ/AdiWLlsFZsovu2bi5w2ecuckISUDG77Xn0skfYx3 KSwrzHYk0xdzs33r4cLglJUmCQ== X-Received: by 10.223.178.26 with SMTP id u26mr13536597wra.63.1519742896738; Tue, 27 Feb 2018 06:48:16 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id r126sm5819145wmd.29.2018.02.27.06.48.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 903F93E1621; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:43 +0000 Message-Id: <20180227143852.11175-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 22/31] arm/helper.c: re-factor recpe and add recepe_f16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" It looks like the ARM ARM has simplified the pseudo code for the calculation which is done on a fixed point 9 bit integer maths. So while adding f16 we can also clean this up to be a little less heavy on the floating point and just return the fractional part and leave the calle's to do the final packing of the result. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - fix comment 2.0^-16 - f16_exp >= 29 (biased) - remove confusing comment about fpst --- target/arm/helper.c | 224 +++++++++++++++++++++++++++++----------------------- target/arm/helper.h | 1 + 2 files changed, 128 insertions(+), 97 deletions(-) -- 2.15.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 6e3dadb754..e2d0ff0b4c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11523,80 +11523,75 @@ float32 HELPER(rsqrts_f32)(float32 a, float32 b, CPUARMState *env) * int->float conversions at run-time. */ #define float64_256 make_float64(0x4070000000000000LL) #define float64_512 make_float64(0x4080000000000000LL) +#define float16_maxnorm make_float16(0x7bff) #define float32_maxnorm make_float32(0x7f7fffff) #define float64_maxnorm make_float64(0x7fefffffffffffffLL) /* Reciprocal functions * * The algorithm that must be used to calculate the estimate - * is specified by the ARM ARM, see FPRecipEstimate() + * is specified by the ARM ARM, see FPRecipEstimate()/RecipEstimate */ -static float64 recip_estimate(float64 a, float_status *real_fp_status) -{ - /* These calculations mustn't set any fp exception flags, - * so we use a local copy of the fp_status. - */ - float_status dummy_status = *real_fp_status; - float_status *s = &dummy_status; - /* q = (int)(a * 512.0) */ - float64 q = float64_mul(float64_512, a, s); - int64_t q_int = float64_to_int64_round_to_zero(q, s); - - /* r = 1.0 / (((double)q + 0.5) / 512.0) */ - q = int64_to_float64(q_int, s); - q = float64_add(q, float64_half, s); - q = float64_div(q, float64_512, s); - q = float64_div(float64_one, q, s); - - /* s = (int)(256.0 * r + 0.5) */ - q = float64_mul(q, float64_256, s); - q = float64_add(q, float64_half, s); - q_int = float64_to_int64_round_to_zero(q, s); +/* See RecipEstimate() + * + * input is a 9 bit fixed point number + * input range 256 .. 511 for a number from 0.5 <= x < 1.0. + * result range 256 .. 511 for a number from 1.0 to 511/256. + */ - /* return (double)s / 256.0 */ - return float64_div(int64_to_float64(q_int, s), float64_256, s); +static int recip_estimate(int input) +{ + int a, b, r; + assert(256 <= input && input < 512); + a = (input * 2) + 1; + b = (1 << 19) / a; + r = (b + 1) >> 1; + assert(256 <= r && r < 512); + return r; } -/* Common wrapper to call recip_estimate */ -static float64 call_recip_estimate(float64 num, int off, float_status *fpst) +/* + * Common wrapper to call recip_estimate + * + * The parameters are exponent and 64 bit fraction (without implicit + * bit) where the binary point is nominally at bit 52. Returns a + * float64 which can then be rounded to the appropriate size by the + * callee. + */ + +static uint64_t call_recip_estimate(int *exp, int exp_off, uint64_t frac) { - uint64_t val64 = float64_val(num); - uint64_t frac = extract64(val64, 0, 52); - int64_t exp = extract64(val64, 52, 11); - uint64_t sbit; - float64 scaled, estimate; + uint32_t scaled, estimate; + uint64_t result_frac; + int result_exp; - /* Generate the scaled number for the estimate function */ - if (exp == 0) { + /* Handle sub-normals */ + if (*exp == 0) { if (extract64(frac, 51, 1) == 0) { - exp = -1; - frac = extract64(frac, 0, 50) << 2; + *exp = -1; + frac <<= 2; } else { - frac = extract64(frac, 0, 51) << 1; + frac <<= 1; } } - /* scaled = '0' : '01111111110' : fraction<51:44> : Zeros(44); */ - scaled = make_float64((0x3feULL << 52) - | extract64(frac, 44, 8) << 44); - - estimate = recip_estimate(scaled, fpst); + /* scaled = UInt('1':fraction<51:44>) */ + scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); + estimate = recip_estimate(scaled); - /* Build new result */ - val64 = float64_val(estimate); - sbit = 0x8000000000000000ULL & val64; - exp = off - exp; - frac = extract64(val64, 0, 52); - - if (exp == 0) { - frac = 1ULL << 51 | extract64(frac, 1, 51); - } else if (exp == -1) { - frac = 1ULL << 50 | extract64(frac, 2, 50); - exp = 0; + result_exp = exp_off - *exp; + result_frac = deposit64(0, 44, 8, estimate); + if (result_exp == 0) { + result_frac = deposit64(result_frac >> 1, 51, 1, 1); + } else if (result_exp == -1) { + result_frac = deposit64(result_frac >> 2, 50, 2, 1); + result_exp = 0; } - return make_float64(sbit | (exp << 52) | frac); + *exp = result_exp; + + return result_frac; } static bool round_to_inf(float_status *fpst, bool sign_bit) @@ -11615,18 +11610,63 @@ static bool round_to_inf(float_status *fpst, bool sign_bit) g_assert_not_reached(); } +float16 HELPER(recpe_f16)(float16 input, void *fpstp) +{ + float_status *fpst = fpstp; + float16 f16 = float16_squash_input_denormal(input, fpst); + uint32_t f16_val = float16_val(f16); + uint32_t f16_sign = float16_is_neg(f16); + int f16_exp = extract32(f16_val, 10, 5); + uint32_t f16_frac = extract32(f16_val, 0, 10); + uint64_t f64_frac; + + if (float16_is_any_nan(f16)) { + float16 nan = f16; + if (float16_is_signaling_nan(f16, fpst)) { + float_raise(float_flag_invalid, fpst); + nan = float16_maybe_silence_nan(f16, fpst); + } + if (fpst->default_nan_mode) { + nan = float16_default_nan(fpst); + } + return nan; + } else if (float16_is_infinity(f16)) { + return float16_set_sign(float16_zero, float16_is_neg(f16)); + } else if (float16_is_zero(f16)) { + float_raise(float_flag_divbyzero, fpst); + return float16_set_sign(float16_infinity, float16_is_neg(f16)); + } else if (float16_abs(f16) < (1 << 8)) { + /* Abs(value) < 2.0^-16 */ + float_raise(float_flag_overflow | float_flag_inexact, fpst); + if (round_to_inf(fpst, f16_sign)) { + return float16_set_sign(float16_infinity, f16_sign); + } else { + return float16_set_sign(float16_maxnorm, f16_sign); + } + } else if (f16_exp >= 29 && fpst->flush_to_zero) { + float_raise(float_flag_underflow, fpst); + return float16_set_sign(float16_zero, float16_is_neg(f16)); + } + + f64_frac = call_recip_estimate(&f16_exp, 29, + ((uint64_t) f16_frac) << (52 - 10)); + + /* result = sign : result_exp<4:0> : fraction<51:42> */ + f16_val = deposit32(0, 15, 1, f16_sign); + f16_val = deposit32(f16_val, 10, 5, f16_exp); + f16_val = deposit32(f16_val, 0, 10, extract64(f64_frac, 52 - 10, 10)); + return make_float16(f16_val); +} + float32 HELPER(recpe_f32)(float32 input, void *fpstp) { float_status *fpst = fpstp; float32 f32 = float32_squash_input_denormal(input, fpst); uint32_t f32_val = float32_val(f32); - uint32_t f32_sbit = 0x80000000ULL & f32_val; - int32_t f32_exp = extract32(f32_val, 23, 8); + bool f32_sign = float32_is_neg(f32); + int f32_exp = extract32(f32_val, 23, 8); uint32_t f32_frac = extract32(f32_val, 0, 23); - float64 f64, r64; - uint64_t r64_val; - int64_t r64_exp; - uint64_t r64_frac; + uint64_t f64_frac; if (float32_is_any_nan(f32)) { float32 nan = f32; @@ -11643,30 +11683,27 @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp) } else if (float32_is_zero(f32)) { float_raise(float_flag_divbyzero, fpst); return float32_set_sign(float32_infinity, float32_is_neg(f32)); - } else if ((f32_val & ~(1ULL << 31)) < (1ULL << 21)) { + } else if (float32_abs(f32) < (1ULL << 21)) { /* Abs(value) < 2.0^-128 */ float_raise(float_flag_overflow | float_flag_inexact, fpst); - if (round_to_inf(fpst, f32_sbit)) { - return float32_set_sign(float32_infinity, float32_is_neg(f32)); + if (round_to_inf(fpst, f32_sign)) { + return float32_set_sign(float32_infinity, f32_sign); } else { - return float32_set_sign(float32_maxnorm, float32_is_neg(f32)); + return float32_set_sign(float32_maxnorm, f32_sign); } } else if (f32_exp >= 253 && fpst->flush_to_zero) { float_raise(float_flag_underflow, fpst); return float32_set_sign(float32_zero, float32_is_neg(f32)); } + f64_frac = call_recip_estimate(&f32_exp, 253, + ((uint64_t) f32_frac) << (52 - 23)); - f64 = make_float64(((int64_t)(f32_exp) << 52) | (int64_t)(f32_frac) << 29); - r64 = call_recip_estimate(f64, 253, fpst); - r64_val = float64_val(r64); - r64_exp = extract64(r64_val, 52, 11); - r64_frac = extract64(r64_val, 0, 52); - - /* result = sign : result_exp<7:0> : fraction<51:29>; */ - return make_float32(f32_sbit | - (r64_exp & 0xff) << 23 | - extract64(r64_frac, 29, 24)); + /* result = sign : result_exp<7:0> : fraction<51:29> */ + f32_val = deposit32(0, 31, 1, f32_sign); + f32_val = deposit32(f32_val, 23, 8, f32_exp); + f32_val = deposit32(f32_val, 0, 23, extract64(f64_frac, 52 - 23, 23)); + return make_float32(f32_val); } float64 HELPER(recpe_f64)(float64 input, void *fpstp) @@ -11674,12 +11711,9 @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) float_status *fpst = fpstp; float64 f64 = float64_squash_input_denormal(input, fpst); uint64_t f64_val = float64_val(f64); - uint64_t f64_sbit = 0x8000000000000000ULL & f64_val; - int64_t f64_exp = extract64(f64_val, 52, 11); - float64 r64; - uint64_t r64_val; - int64_t r64_exp; - uint64_t r64_frac; + bool f64_sign = float64_is_neg(f64); + int f64_exp = extract64(f64_val, 52, 11); + uint64_t f64_frac = extract64(f64_val, 0, 52); /* Deal with any special cases */ if (float64_is_any_nan(f64)) { @@ -11700,25 +11734,23 @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) } else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) { /* Abs(value) < 2.0^-1024 */ float_raise(float_flag_overflow | float_flag_inexact, fpst); - if (round_to_inf(fpst, f64_sbit)) { - return float64_set_sign(float64_infinity, float64_is_neg(f64)); + if (round_to_inf(fpst, f64_sign)) { + return float64_set_sign(float64_infinity, f64_sign); } else { - return float64_set_sign(float64_maxnorm, float64_is_neg(f64)); + return float64_set_sign(float64_maxnorm, f64_sign); } } else if (f64_exp >= 2045 && fpst->flush_to_zero) { float_raise(float_flag_underflow, fpst); return float64_set_sign(float64_zero, float64_is_neg(f64)); } - r64 = call_recip_estimate(f64, 2045, fpst); - r64_val = float64_val(r64); - r64_exp = extract64(r64_val, 52, 11); - r64_frac = extract64(r64_val, 0, 52); + f64_frac = call_recip_estimate(&f64_exp, 2045, f64_frac); - /* result = sign : result_exp<10:0> : fraction<51:0> */ - return make_float64(f64_sbit | - ((r64_exp & 0x7ff) << 52) | - r64_frac); + /* result = sign : result_exp<10:0> : fraction<51:0>; */ + f64_val = deposit64(0, 63, 1, f64_sign); + f64_val = deposit64(f64_val, 52, 11, f64_exp); + f64_val = deposit64(f64_val, 0, 52, f64_frac); + return make_float64(f64_val); } /* The algorithm that must be used to calculate the estimate @@ -11907,19 +11939,17 @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp) { - float_status *s = fpstp; - float64 f64; + /* float_status *s = fpstp; */ + int input, estimate; if ((a & 0x80000000) == 0) { return 0xffffffff; } - f64 = make_float64((0x3feULL << 52) - | ((int64_t)(a & 0x7fffffff) << 21)); - - f64 = recip_estimate(f64, s); + input = extract32(a, 23, 9); + estimate = recip_estimate(input); - return 0x80000000 | ((float64_val(f64) >> 21) & 0x7fffffff); + return deposit32(0, (32 - 9), 9, estimate); } uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp) diff --git a/target/arm/helper.h b/target/arm/helper.h index c0f35592ff..81d7baed6d 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -192,6 +192,7 @@ DEF_HELPER_4(vfp_muladds, f32, f32, f32, f32, ptr) DEF_HELPER_3(recps_f32, f32, f32, f32, env) DEF_HELPER_3(rsqrts_f32, f32, f32, f32, env) +DEF_HELPER_FLAGS_2(recpe_f16, TCG_CALL_NO_RWG, f16, f16, ptr) DEF_HELPER_FLAGS_2(recpe_f32, TCG_CALL_NO_RWG, f32, f32, ptr) DEF_HELPER_FLAGS_2(recpe_f64, TCG_CALL_NO_RWG, f64, f64, ptr) DEF_HELPER_FLAGS_2(rsqrte_f32, TCG_CALL_NO_RWG, f32, f32, ptr) From patchwork Tue Feb 27 14:38:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129812 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp366845edc; Tue, 27 Feb 2018 06:52:10 -0800 (PST) X-Google-Smtp-Source: AH8x226QFXyP/ltHZRw5oN1JnqNF5kvajo7BfGPJ/cfOm1OusolMjKQEDX+oMZn67TYEYmsy+uSD X-Received: by 10.129.182.71 with SMTP id h7mr9526944ywk.120.1519743130373; Tue, 27 Feb 2018 06:52:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743130; cv=none; d=google.com; s=arc-20160816; b=H+NZFV9kZ+R8DTzYzrARrINuSxEF9RQc1wK1rsCReQ+awBuB+aQ9oD5HqOvQCfFt3q 35IE695UF/IFmZVYa1Lot1Zaw/B2DvqKx29hIFSzRPsxsgmzQUll39uzUt/2hOhZpGbS KuWmIOsjEnyoguWSFpxf9UnsW/4Z64ZcAdeRXHwaecxc1abqb57CExRRjnehMvhe90cN eoxChGkTNf15scHzLctiy19eGxg+g5kGmF6JOPtG8HLdH2xS6DkFpR4fOsZ1Fg97BZLn OtIgNFZvlXH32U1XysTfbVdsIHQ48QKFY7vTbCZT83Z59LpfXXeKLtGsjngNH/KJ/bw3 joFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=tB+U32aeV9mjLtNqJ7NzXf7kQICTubiGR34mAS3zI2k=; b=KrHzr9aU3CND9Qjtns003p/FIESMOlyE+QtmgDBKNkpvDyfeS8TpR7ad/KECLETv0Z cT5mNYRREn8KY7jedHeanm+mYvRnnsEGX0vqYYDY4jvtCw0pa1poKMdYa5obQVBw2Xf8 uItKSgeqFgxO3y66t1vEQJk0VBByUS9tHWjLh6gIEANW/7ZAHIyBJR+HpXsPQReqoVTg 0Y609sYQCdVk4IslPolL19q1biAwbpjtBXJ+hQe1Ke+j2+olH8Zqq1doMfyb+Ev4VDUS KS0m7F6FQa6gXVx+LT6s1oyNCD/yJQUK68s1dHZYMSUXKSNcU02nge7AKa2iRkShpT0k Vf1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ExnYZ1Nw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d67si1898825ywf.217.2018.02.27.06.52.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:52:10 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ExnYZ1Nw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgbx-0006di-Pt for patch@linaro.org; Tue, 27 Feb 2018 09:52:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgY3-0003Vr-8o for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY0-0001Ai-Oz for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:07 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:55736) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgY0-000163-GK for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:04 -0500 Received: by mail-wm0-x244.google.com with SMTP id q83so24679729wme.5 for ; Tue, 27 Feb 2018 06:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tB+U32aeV9mjLtNqJ7NzXf7kQICTubiGR34mAS3zI2k=; b=ExnYZ1NwykKKoDPhe4Kgn82lIM1fLs3mGQCPW9mHgEZU2yHdOrewEVugFtacUDrsLK 9UlBk/QgznQhC0Ovx+60qB3CmouZikh5Rk0xJlgNML4m2FqIIMPYZeRUyUWI/A5eSsIR jm85rVJBN/s0NhsxbtflPJTlL8TguRbqyTsXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tB+U32aeV9mjLtNqJ7NzXf7kQICTubiGR34mAS3zI2k=; b=J3GXVZFCSnPEiDBfEF8zWSK8jTZ/HTQNXLMp5XCvViSi/eoaMzikEiJ47su1CU98EW 6miAD4qTV0kCSpqLZypzTTZKy1WxHFlyBq81wdUUVPsVGxQvXHIvW+oid4oo6HnHV7By sJAp0/r1vVZRgOtje85lVfClnIm++9B5wMq02ng90zVMU846EbAyxzXHYECnpKbfFB4z SfNDCKOLGNXHYDjhGLuI8V+flAJHRIVRTpLlsxQS61sDTrwKwdozxqH16YeRLuAJ9WYb 029rjBuNrTLBonFxzjbbmycON8NifSQc2SK2zuBpjpIxIYvWsv8GuwpjHwS6treE8D6Q wLrg== X-Gm-Message-State: APf1xPAXDAYhnj15T5Rl2Ep2e2S9MxoWqc4RVvBmEYfZCoxBdthlK7ph bAalGX85jRuvgECvTI5C4Vm3jw== X-Received: by 10.28.54.220 with SMTP id y89mr12246527wmh.138.1519742883349; Tue, 27 Feb 2018 06:48:03 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c14sm23241003wmh.2.2018.02.27.06.48.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:00 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A1C9D3E1630; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:44 +0000 Message-Id: <20180227143852.11175-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH v4 23/31] arm/translate-a64: add FP16 FRECPE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now we have added f16 during the re-factoring we can simply call the helper. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/translate-a64.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9f2c3682dc..50b4fa4ce4 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11311,6 +11311,8 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x6d: /* FCMLE (zero) */ handle_2misc_fcmp_zero(s, fpop, is_scalar, 0, is_q, MO_16, rn, rd); return; + case 0x3d: /* FRECPE */ + break; case 0x18: /* FRINTN */ need_rmode = true; only_in_vector = true; @@ -11431,6 +11433,9 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x3b: /* FCVTZS */ gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus); break; + case 0x3d: /* FRECPE */ + gen_helper_recpe_f16(tcg_res, tcg_op, tcg_fpstatus); + break; case 0x5a: /* FCVTNU */ case 0x5b: /* FCVTMU */ case 0x5c: /* FCVTAU */ @@ -11466,6 +11471,9 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x3b: /* FCVTZS */ gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus); break; + case 0x3d: /* FRECPE */ + gen_helper_recpe_f16(tcg_res, tcg_op, tcg_fpstatus); + break; case 0x5a: /* FCVTNU */ case 0x5b: /* FCVTMU */ case 0x5c: /* FCVTAU */ From patchwork Tue Feb 27 14:38:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129824 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp384926edc; Tue, 27 Feb 2018 07:06:44 -0800 (PST) X-Google-Smtp-Source: AG47ELuDKaFHndkArLbmcHHHy7tISBEDzRtoCiHWkWdikzPxpQzFi671uTewhgBFGq7/p/pTiT+z X-Received: by 2002:a25:f808:: with SMTP id u8-v6mr9873474ybd.0.1519744003164; Tue, 27 Feb 2018 07:06:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519744003; cv=none; d=google.com; s=arc-20160816; b=JvZ9rD1jtsUNGLM0g8rqAPJBnaEz2T2KjrvXF0n68kwWEPLLSFPb+e48omSpKHl1Fj uNzo14XnWeSzjpD0WPL+xLssQ818f2MZ/xp5jnYV3alPZBhA7mIi6X5NvKK2RgsGFkJ9 Ar63maCcXLvIHKzJtT71wB7AHGiH4evgg7vndumrgOSUJ+6RZN+PgyR7VbEPKNkYSNiN 6uljJagxyFCsy5AxsNe4qJr3uX6WFEDROiKwyGMHV9NJeHIN2trJdfSA5ZlQjwgsK0VH 7ToFqv9WCn0nWyz8jyqVn5emgI3lkv9kgOIWb5fJpZOeVdil374vA4ANmwk3kIadnopI P3nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=/VOmrW+DMNJTkgKs8tQhoqEyE0ii2loGX7asVSBBLbg=; b=YNuKzefjiwQruGnLgtUX2lfqLwXys8ia/ukhqAHKWd4MDMi6ujbncUOQxbdZrDZDNG CpSdzJyi5VkMY3BfszVqzRcvJoDJOys2xSXarpyTs0s2T6XnIY9JORnrvuR94/Uy7Q8v N3mxvDRYsZOvKb0yiiC5OmB8lSD3EJ78vVYJo18PXm3KUnXY8WCSwwN7xiRuaX8n7r77 T/GXS9KV2R0VPrLMBAfu+ju1pb5Ej+UNfcVdHfOV15qcBBxMzxa9g3j2ADTBkiN9KIwq wCQt778YbmOcgdXNjGjei7DSBhNx3uu369fcGOPLJXSR0qpwLPKLmFSgXkCc4f0oA0sI ZvkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=auzLsPgv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v68si1882914ywd.370.2018.02.27.07.06.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:06:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=auzLsPgv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgq2-0002KN-H0 for patch@linaro.org; Tue, 27 Feb 2018 10:06:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgY7-0003ZH-Gx for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY4-0001SU-HE for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:11 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:51333) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgY4-0001OA-4f for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:08 -0500 Received: by mail-wm0-x243.google.com with SMTP id h21so24575179wmd.1 for ; Tue, 27 Feb 2018 06:48:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/VOmrW+DMNJTkgKs8tQhoqEyE0ii2loGX7asVSBBLbg=; b=auzLsPgvLnOl5VIlA4/irO0dM/S8jTEDRZ2cojrNOX1Kx6VHympHCeR7Wa/5GvTt2X 9J7XrZBEIihRs6nWdEk6+oCdGoJs2Afl7O8vM6u8hzM/dNB8JfqfSsqmeNiKNep3og+E gXh0BQixqivGVi4zWAS295I5cM04xKX4Fndzw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/VOmrW+DMNJTkgKs8tQhoqEyE0ii2loGX7asVSBBLbg=; b=LAPXRA9ZN52jQSaxKF4BNRGXT+HVM7yFp6mg11JDnrCm1NPMDP/vvp482zX+0eTckZ vsP7l9w0AzM6kw02aGb/hHh/FxqWa82SM37q9dGMz9s9l/gCoVbZ+x3jEDS8/AxlZaTA wJTkVL6FF66aHMXSLZnZG+xk/63IPWQ3h18qMaL0OA9EVfEHWSZpnvTZYJ6cUWtRjU0F VJudRf33tQBiWChAGsXUBngJC1Fn9PQIRBh99caLGb05LbG5QsSNcP7AmWoR1Pdg78Po rGkE93jRoYf+34Hw+Cp/0TUg9JEnR4NBK86iU0LSahfoxQnz4Rh2LsLUKH7590OG1oQ7 P8mQ== X-Gm-Message-State: APf1xPAlHp+7H/fgiemS7dXdDe1Gmh2Oo11smArZi8vUBTcygZvi48FQ YBgbKHrAVW3Ts3nly+BoWv/3Zw== X-Received: by 10.28.239.8 with SMTP id n8mr9078040wmh.120.1519742886918; Tue, 27 Feb 2018 06:48:06 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 69sm12715775wmw.32.2018.02.27.06.48.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B60A23E021C; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:45 +0000 Message-Id: <20180227143852.11175-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH v4 24/31] arm/translate-a64: add FP16 FRCPX to simd_two_reg_misc_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We go with the localised helper. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/helper-a64.c | 29 +++++++++++++++++++++++++++++ target/arm/helper-a64.h | 1 + target/arm/translate-a64.c | 4 ++++ 3 files changed, 34 insertions(+) -- 2.15.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 722fff2349..92a0d55a9c 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -356,6 +356,35 @@ uint64_t HELPER(neon_addlp_u16)(uint64_t a) } /* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */ +float16 HELPER(frecpx_f16)(float16 a, void *fpstp) +{ + float_status *fpst = fpstp; + uint16_t val16, sbit; + int16_t exp; + + if (float16_is_any_nan(a)) { + float16 nan = a; + if (float16_is_signaling_nan(a, fpst)) { + float_raise(float_flag_invalid, fpst); + nan = float16_maybe_silence_nan(a, fpst); + } + if (fpst->default_nan_mode) { + nan = float16_default_nan(fpst); + } + return nan; + } + + val16 = float16_val(a); + sbit = 0x8000 & val16; + exp = extract32(val16, 10, 5); + + if (exp == 0) { + return make_float16(deposit32(sbit, 10, 5, 0x1e)); + } else { + return make_float16(deposit32(sbit, 10, 5, ~exp)); + } +} + float32 HELPER(frecpx_f32)(float32 a, void *fpstp) { float_status *fpst = fpstp; diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 32931b17c6..339323fc3d 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -41,6 +41,7 @@ DEF_HELPER_FLAGS_1(neon_addlp_s16, TCG_CALL_NO_RWG_SE, i64, i64) DEF_HELPER_FLAGS_1(neon_addlp_u16, TCG_CALL_NO_RWG_SE, i64, i64) DEF_HELPER_FLAGS_2(frecpx_f64, TCG_CALL_NO_RWG, f64, f64, ptr) DEF_HELPER_FLAGS_2(frecpx_f32, TCG_CALL_NO_RWG, f32, f32, ptr) +DEF_HELPER_FLAGS_2(frecpx_f16, TCG_CALL_NO_RWG, f16, f16, ptr) DEF_HELPER_FLAGS_2(fcvtx_f64_to_f32, TCG_CALL_NO_RWG, f32, f64, env) DEF_HELPER_FLAGS_3(crc32_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) DEF_HELPER_FLAGS_3(crc32c_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 50b4fa4ce4..715dc4333d 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11312,6 +11312,7 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) handle_2misc_fcmp_zero(s, fpop, is_scalar, 0, is_q, MO_16, rn, rd); return; case 0x3d: /* FRECPE */ + case 0x3f: /* FRECPX */ break; case 0x18: /* FRINTN */ need_rmode = true; @@ -11436,6 +11437,9 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x3d: /* FRECPE */ gen_helper_recpe_f16(tcg_res, tcg_op, tcg_fpstatus); break; + case 0x3f: /* FRECPX */ + gen_helper_frecpx_f16(tcg_res, tcg_op, tcg_fpstatus); + break; case 0x5a: /* FCVTNU */ case 0x5b: /* FCVTMU */ case 0x5c: /* FCVTAU */ From patchwork Tue Feb 27 14:38:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129828 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp391367edc; Tue, 27 Feb 2018 07:12:07 -0800 (PST) X-Google-Smtp-Source: AH8x224YCrNDhJiTfAXFpYSVSW3Qe+fdlCmSC/lBbDxGUBmo/PQ/PoyVHPW59Ed7by8OPiF0EN7V X-Received: by 10.129.163.71 with SMTP id a68mr9763134ywh.114.1519744327476; Tue, 27 Feb 2018 07:12:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519744327; cv=none; d=google.com; s=arc-20160816; b=PH+QikxlnTnBV5TFBCfIyfkr3ZmVT7qNyvXtf3RiIiOzn7BuUjS3mXWKxAfvuBRK7r 4wBQKBA+uTyt+AFv5PodcBCsOvwZlCB4iBF+tbtb1BE5cJDt47Kj8tZREKlP+zaC4HU0 4jMkYzRefjVrNMNvDkJgteaos0EsR60GUuC9+GhTPhzScHfxOQm0XRkE9mQD/IfNJvUG L7Gwz1EB4LnXGWa+EfdG1CeR/O5mTE5zuMLH6qdBoD3TW8j2YesKxA5zhi9DuWbnTRjf yt4CjzAyFGFBxLJexBaGLnYq5rr37c0sYubCHgIUylrZjhR9thPD3WUMMlLNn4DV7YBC t1HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=k24EPpxfkC7uO77BrQWE6saAm7KOayTqw1vYAwuG0Ak=; b=hEkb9iRlm76Lp+hZ/XnupnK7gvuiH3fy7plWYIeQ+POzKjpHFMtMKp/ZNUMfrvcLrm uJj6E8/Hqi17Nhcju4Z3LleBmo2uWA1tI+3eBiD5xw37nlYaXNjxLBuFHe377MC+Vhc7 gusp9qK0vX7g2wdx83r0xHRTsQGg4Wp6hU5TfzaSbQ+o6tgXlsvDP6wLG9mtFf6gT9xT 7KkNGx/zwbc8AdbzbLfaaMBl5T1N+UU0i2AYFpGS/2yjPnIdfCZWTJ22MlChqHBqc6B9 cEJcZTspL5xRKtDDJki7NJO3Nf5dN14tYyvi3BAbNrriH6wIp/N/y6hJRL1CDIXZz2Hz NrKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dtPvEtpj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l26si1960618ywh.771.2018.02.27.07.12.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:12:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dtPvEtpj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgvG-0006KX-Sw for patch@linaro.org; Tue, 27 Feb 2018 10:12:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYH-0003lZ-LH for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgYD-00023p-KJ for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:21 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:51338) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgYD-0001zA-2x for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:17 -0500 Received: by mail-wm0-x243.google.com with SMTP id h21so24576175wmd.1 for ; Tue, 27 Feb 2018 06:48:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k24EPpxfkC7uO77BrQWE6saAm7KOayTqw1vYAwuG0Ak=; b=dtPvEtpj9+MFTXEpOLoUngdWv7brmw2pXoATBAzcAUZ9JaTd3tXoQiO4UoiTPYpQ4o NankfbeyFyCTbZ5cmA4nzDhFxAQV17X67qCyp3vvGy4g+en0faV3TavTa13tYePgyegC AxsnwTYgSdMf2wGjQwhBhd1bSYQb4y1VDxPrc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k24EPpxfkC7uO77BrQWE6saAm7KOayTqw1vYAwuG0Ak=; b=SnTj+MmUgNLzM5WrqGEWGdrmdRri/KQFO50lN3TQXKESMOrzI30HZoorsv2oG62wFK tAjawcykH0Dt3GQlkF7ZGHzbA30F/CS2sLCDNXyDfvQO0QJrfQ4jEsmazoZUay2XWrCE HKidszCcyz/Wcn0HDB6IYIzbZ+sP0l9mf4C31GgslEH8EFf4BRnHKVynVC1p6qYCGMy+ l918gcBoxaIz6X023zzfUNFSAOALX5hEB+rrpGAZnTp6cTgWvza1SzjvW8mEqMsnkGZS jwWbc3lNDdUMHYRTtfXbjh9snwgTRv/P7H6PTbWq65uqYmW+T3vzJxMZVbYDfb363ea7 zQCg== X-Gm-Message-State: APf1xPB9JFpArScQ5JmRcbodWR3UqNKT+OD3Vz4531Yy4uDEtXyxsVXm kVFxzz6mYndKo4z+gRZBar1L2Q== X-Received: by 10.28.230.79 with SMTP id d76mr8326021wmh.161.1519742895912; Tue, 27 Feb 2018 06:48:15 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b30sm24543206wra.34.2018.02.27.06.48.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id C972C3E163C; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:46 +0000 Message-Id: <20180227143852.11175-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH v4 25/31] arm/translate-a64: add FP16 FSQRT to simd_two_reg_misc_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 remove superfluous helpers --- target/arm/helper-a64.c | 13 +++++++++++++ target/arm/helper-a64.h | 1 + target/arm/translate-a64.c | 5 +++++ 3 files changed, 19 insertions(+) -- 2.15.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 92a0d55a9c..afb25ad20c 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -828,3 +828,16 @@ uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) } return float16_to_uint16(a, fpst); } + +/* + * Square Root and Reciprocal square root + */ + +float16 HELPER(sqrt_f16)(float16 a, void *fpstp) +{ + float_status *s = fpstp; + + return float16_sqrt(a, s); +} + + diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 339323fc3d..ef4ddfe9d8 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -80,3 +80,4 @@ DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr) DEF_HELPER_2(advsimd_rinth, f16, f16, ptr) DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr) DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) +DEF_HELPER_2(sqrt_f16, f16, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 715dc4333d..1096ff48ac 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11388,6 +11388,8 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x6f: /* FNEG */ need_fpst = false; break; + case 0x7f: /* FSQRT (vector) */ + break; default: fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop); g_assert_not_reached(); @@ -11502,6 +11504,9 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x6f: /* FNEG */ tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); break; + case 0x7f: /* FSQRT */ + gen_helper_sqrt_f16(tcg_res, tcg_op, tcg_fpstatus); + break; default: g_assert_not_reached(); } From patchwork Tue Feb 27 14:38:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129815 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp370972edc; Tue, 27 Feb 2018 06:55:51 -0800 (PST) X-Google-Smtp-Source: AG47ELsrh2opxnfE5E1q34hxGRWsf+WCRLC9ZKkxr8E27XU1vxTS1aCF61dY3b3cIivTEdGLCXUC X-Received: by 2002:a25:2d4a:: with SMTP id s10-v6mr9647735ybe.354.1519743351334; Tue, 27 Feb 2018 06:55:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743351; cv=none; d=google.com; s=arc-20160816; b=Gq3RjVEOJjMSW+Evbpk4tjlzer3PbdT490D4IP1DYuaWdcfzg0TtQE0InMa93j1vhv nq/S2OU/uJRrnxasBbHmwAsArLLOz+IkQ6c/O3is1Y6FvXlVCDpfsbUfBvyK1SCs/OeX gu+PuXRbI2VeMy01tAI/5bTQz40oXQs0RLX8uJxym8JIcgoeJTLBdD1Y2562Gni2RLV3 ST/PH3J3SqiZs1LOEsIc9gSngHZcH8VWVZTr2UXwWwMYxcviEO6n2ncb8YeCNn/iWpE3 sK6URYMeJmrxvaZOcN6t/WZqfcFUAD7tUNDs2OJn/Gjnl7DxUcRliMi3U1vCDU+NEjWb 4Iaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=BgahG73tkqG0tC2b6+gKAAuvzzecpl1XrnbvPjhZc3Q=; b=ZIDAp01PCBYKfKh8MtT71W84KUR63APWlhChFGkpYuQ0F681S0abQykCyVkd7Uy5g5 cO1Jq5OuNY+sSnGayM0MSc8cfEiSCXa6bCPn58Wjwwerehc1mJMCy1d/c5VQdkYCIDXd MqmlJUvejOUFbHrhht1VP6qZHSxDGRX0qai6WxeauC/Zeh0KAvd0SfzKvSlchkfpWPmD bMrQe52nsDrF6A918iOxSmmBnGJK0a4CB2ME0DaNFsKAJOM9l6ZHWMstSfJACqQgRVEL rVrN7hPN+lEsSUUqNtqGhOc8BHuIymy8Qk2ort8gAxxC50dmwT1FDUXbrffhkxkIiHhD xlEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HAsSJGDd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c188-v6si1969699ybb.461.2018.02.27.06.55.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:55:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HAsSJGDd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgfW-0000jx-JK for patch@linaro.org; Tue, 27 Feb 2018 09:55:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYD-0003gD-Jr for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY5-0001XZ-Ns for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:17 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:40967) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgY5-0001So-3f for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:09 -0500 Received: by mail-wr0-x242.google.com with SMTP id f14so25125914wre.8 for ; Tue, 27 Feb 2018 06:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BgahG73tkqG0tC2b6+gKAAuvzzecpl1XrnbvPjhZc3Q=; b=HAsSJGDdkc+MgFYRwcjqGM99EZHmTgLZdYK0CvxgitBZmb61/ERtloO4YRf1HC1BBy WO8hwU9b8K0MwZ1etZhkSZoUSFW3EYBI1fMKyUSfi1qwTj1OWyutNg9YTfCPx286jWJW zQT9uFLDpRirUQXG13kHFhO4rFfQR2qf9OzyE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BgahG73tkqG0tC2b6+gKAAuvzzecpl1XrnbvPjhZc3Q=; b=cbF4x9/YYrr6kPSLBjxMx9tBC7GXjUALTQSDJmdVJvG3lruhMp3oT5eEIqFbZc2XbP Umfc11piWBawoLIJOK+M+AjlKfVhxaoullesHzACB0HOHJqm9wRiNbEaVf4Vsbk1tb7N jGegWNuyVA4XoIuVQ0ABBwYOgUratOLl4Fq0PBc8mRg+SaRWChlQcENdnAJ5zfD3oNlA +mpfD2l8JVHezQEFsJCqzOHxiGstNySAopCvbLmVb8C00ad1xsXrvsYyIMDCMsbHkqTR ig/7OGfaRB+i1Le1CkZzm/VCAnb5stRxloaG5djjY1e5EfhIOPWL3GwoeFM3MbSiHieB cOnw== X-Gm-Message-State: APf1xPASmJYwKH0/7ZopM3Hgkt26LuZGjw+DNg6KC/MzRh/hBdGSeUsZ +1GvTdBtnmWFvuq0Mefv9VPqDg== X-Received: by 10.223.139.68 with SMTP id v4mr13466126wra.23.1519742887815; Tue, 27 Feb 2018 06:48:07 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u48sm11091448wrb.85.2018.02.27.06.48.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id DC2C43E1647; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:47 +0000 Message-Id: <20180227143852.11175-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 26/31] arm/helper.c: re-factor rsqrte and add rsqrte_f16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Much like recpe the ARM ARM has simplified the pseudo code for the calculation which is done on a fixed point 9 bit integer maths. So while adding f16 we can also clean this up to be a little less heavy on the floating point and just return the fractional part and leave the calle's to do the final packing of the result. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 - checkpatch fixes --- target/arm/helper.c | 221 ++++++++++++++++++++++++---------------------------- target/arm/helper.h | 1 + 2 files changed, 104 insertions(+), 118 deletions(-) -- 2.15.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index e2d0ff0b4c..c82f63d440 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11756,56 +11756,97 @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) /* The algorithm that must be used to calculate the estimate * is specified by the ARM ARM. */ -static float64 recip_sqrt_estimate(float64 a, float_status *real_fp_status) -{ - /* These calculations mustn't set any fp exception flags, - * so we use a local copy of the fp_status. - */ - float_status dummy_status = *real_fp_status; - float_status *s = &dummy_status; - float64 q; - int64_t q_int; - - if (float64_lt(a, float64_half, s)) { - /* range 0.25 <= a < 0.5 */ - - /* a in units of 1/512 rounded down */ - /* q0 = (int)(a * 512.0); */ - q = float64_mul(float64_512, a, s); - q_int = float64_to_int64_round_to_zero(q, s); - - /* reciprocal root r */ - /* r = 1.0 / sqrt(((double)q0 + 0.5) / 512.0); */ - q = int64_to_float64(q_int, s); - q = float64_add(q, float64_half, s); - q = float64_div(q, float64_512, s); - q = float64_sqrt(q, s); - q = float64_div(float64_one, q, s); + +static int do_recip_sqrt_estimate(int a) +{ + int b, estimate; + + assert(128 <= a && a < 512); + if (a < 256) { + a = a * 2 + 1; } else { - /* range 0.5 <= a < 1.0 */ + a = (a >> 1) << 1; + a = (a + 1) * 2; + } + b = 512; + while (a * (b + 1) * (b + 1) < (1 << 28)) { + b += 1; + } + estimate = (b + 1) / 2; + assert(256 <= estimate && estimate < 512); + + return estimate; +} + - /* a in units of 1/256 rounded down */ - /* q1 = (int)(a * 256.0); */ - q = float64_mul(float64_256, a, s); - int64_t q_int = float64_to_int64_round_to_zero(q, s); +static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac) +{ + int estimate; + uint32_t scaled; - /* reciprocal root r */ - /* r = 1.0 /sqrt(((double)q1 + 0.5) / 256); */ - q = int64_to_float64(q_int, s); - q = float64_add(q, float64_half, s); - q = float64_div(q, float64_256, s); - q = float64_sqrt(q, s); - q = float64_div(float64_one, q, s); + if (*exp == 0) { + while (extract64(frac, 51, 1) == 0) { + frac = frac << 1; + *exp -= 1; + } + frac = extract64(frac, 0, 51) << 1; } - /* r in units of 1/256 rounded to nearest */ - /* s = (int)(256.0 * r + 0.5); */ - q = float64_mul(q, float64_256,s ); - q = float64_add(q, float64_half, s); - q_int = float64_to_int64_round_to_zero(q, s); + if (*exp & 1) { + /* scaled = UInt('01':fraction<51:45>) */ + scaled = deposit32(1 << 7, 0, 7, extract64(frac, 45, 7)); + } else { + /* scaled = UInt('1':fraction<51:44>) */ + scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); + } + estimate = do_recip_sqrt_estimate(scaled); - /* return (double)s / 256.0;*/ - return float64_div(int64_to_float64(q_int, s), float64_256, s); + *exp = (exp_off - *exp) / 2; + return extract64(estimate, 0, 8) << 44; +} + +float16 HELPER(rsqrte_f16)(float16 input, void *fpstp) +{ + float_status *s = fpstp; + float16 f16 = float16_squash_input_denormal(input, s); + uint16_t val = float16_val(f16); + bool f16_sign = float16_is_neg(f16); + int f16_exp = extract32(val, 10, 5); + uint16_t f16_frac = extract32(val, 0, 10); + uint64_t f64_frac; + + if (float16_is_any_nan(f16)) { + float16 nan = f16; + if (float16_is_signaling_nan(f16, s)) { + float_raise(float_flag_invalid, s); + nan = float16_maybe_silence_nan(f16, s); + } + if (s->default_nan_mode) { + nan = float16_default_nan(s); + } + return nan; + } else if (float16_is_zero(f16)) { + float_raise(float_flag_divbyzero, s); + return float16_set_sign(float16_infinity, f16_sign); + } else if (f16_sign) { + float_raise(float_flag_invalid, s); + return float16_default_nan(s); + } else if (float16_is_infinity(f16)) { + return float16_zero; + } + + /* Scale and normalize to a double-precision value between 0.25 and 1.0, + * preserving the parity of the exponent. */ + + f64_frac = ((uint64_t) f16_frac) << (52 - 10); + + f64_frac = recip_sqrt_estimate(&f16_exp, 44, f64_frac); + + /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(2) */ + val = deposit32(0, 15, 1, f16_sign); + val = deposit32(val, 10, 5, f16_exp); + val = deposit32(val, 2, 8, extract64(f64_frac, 52 - 8, 8)); + return make_float16(val); } float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) @@ -11813,13 +11854,10 @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) float_status *s = fpstp; float32 f32 = float32_squash_input_denormal(input, s); uint32_t val = float32_val(f32); - uint32_t f32_sbit = 0x80000000 & val; - int32_t f32_exp = extract32(val, 23, 8); + uint32_t f32_sign = float32_is_neg(f32); + int f32_exp = extract32(val, 23, 8); uint32_t f32_frac = extract32(val, 0, 23); uint64_t f64_frac; - uint64_t val64; - int result_exp; - float64 f64; if (float32_is_any_nan(f32)) { float32 nan = f32; @@ -11845,32 +11883,13 @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) * preserving the parity of the exponent. */ f64_frac = ((uint64_t) f32_frac) << 29; - if (f32_exp == 0) { - while (extract64(f64_frac, 51, 1) == 0) { - f64_frac = f64_frac << 1; - f32_exp = f32_exp-1; - } - f64_frac = extract64(f64_frac, 0, 51) << 1; - } - - if (extract64(f32_exp, 0, 1) == 0) { - f64 = make_float64(((uint64_t) f32_sbit) << 32 - | (0x3feULL << 52) - | f64_frac); - } else { - f64 = make_float64(((uint64_t) f32_sbit) << 32 - | (0x3fdULL << 52) - | f64_frac); - } - result_exp = (380 - f32_exp) / 2; + f64_frac = recip_sqrt_estimate(&f32_exp, 380, f64_frac); - f64 = recip_sqrt_estimate(f64, s); - - val64 = float64_val(f64); - - val = ((result_exp & 0xff) << 23) - | ((val64 >> 29) & 0x7fffff); + /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(15) */ + val = deposit32(0, 31, 1, f32_sign); + val = deposit32(val, 23, 8, f32_exp); + val = deposit32(val, 15, 8, extract64(f64_frac, 52 - 8, 8)); return make_float32(val); } @@ -11879,11 +11898,9 @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) float_status *s = fpstp; float64 f64 = float64_squash_input_denormal(input, s); uint64_t val = float64_val(f64); - uint64_t f64_sbit = 0x8000000000000000ULL & val; - int64_t f64_exp = extract64(val, 52, 11); + bool f64_sign = float64_is_neg(f64); + int f64_exp = extract64(val, 52, 11); uint64_t f64_frac = extract64(val, 0, 52); - int64_t result_exp; - uint64_t result_frac; if (float64_is_any_nan(f64)) { float64 nan = f64; @@ -11905,36 +11922,13 @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) return float64_zero; } - /* Scale and normalize to a double-precision value between 0.25 and 1.0, - * preserving the parity of the exponent. */ - - if (f64_exp == 0) { - while (extract64(f64_frac, 51, 1) == 0) { - f64_frac = f64_frac << 1; - f64_exp = f64_exp - 1; - } - f64_frac = extract64(f64_frac, 0, 51) << 1; - } + f64_frac = recip_sqrt_estimate(&f64_exp, 3068, f64_frac); - if (extract64(f64_exp, 0, 1) == 0) { - f64 = make_float64(f64_sbit - | (0x3feULL << 52) - | f64_frac); - } else { - f64 = make_float64(f64_sbit - | (0x3fdULL << 52) - | f64_frac); - } - - result_exp = (3068 - f64_exp) / 2; - - f64 = recip_sqrt_estimate(f64, s); - - result_frac = extract64(float64_val(f64), 0, 52); - - return make_float64(f64_sbit | - ((result_exp & 0x7ff) << 52) | - result_frac); + /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(44) */ + val = deposit64(0, 61, 1, f64_sign); + val = deposit64(val, 52, 11, f64_exp); + val = deposit64(val, 44, 8, extract64(f64_frac, 52 - 8, 8)); + return make_float64(val); } uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp) @@ -11954,24 +11948,15 @@ uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp) uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp) { - float_status *fpst = fpstp; - float64 f64; + int estimate; if ((a & 0xc0000000) == 0) { return 0xffffffff; } - if (a & 0x80000000) { - f64 = make_float64((0x3feULL << 52) - | ((uint64_t)(a & 0x7fffffff) << 21)); - } else { /* bits 31-30 == '01' */ - f64 = make_float64((0x3fdULL << 52) - | ((uint64_t)(a & 0x3fffffff) << 22)); - } - - f64 = recip_sqrt_estimate(f64, fpst); + estimate = do_recip_sqrt_estimate(extract32(a, 23, 9)); - return 0x80000000 | ((float64_val(f64) >> 21) & 0x7fffffff); + return deposit32(0, 23, 9, estimate); } /* VFPv4 fused multiply-accumulate */ diff --git a/target/arm/helper.h b/target/arm/helper.h index 81d7baed6d..6dd8504ec3 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -195,6 +195,7 @@ DEF_HELPER_3(rsqrts_f32, f32, f32, f32, env) DEF_HELPER_FLAGS_2(recpe_f16, TCG_CALL_NO_RWG, f16, f16, ptr) DEF_HELPER_FLAGS_2(recpe_f32, TCG_CALL_NO_RWG, f32, f32, ptr) DEF_HELPER_FLAGS_2(recpe_f64, TCG_CALL_NO_RWG, f64, f64, ptr) +DEF_HELPER_FLAGS_2(rsqrte_f16, TCG_CALL_NO_RWG, f16, f16, ptr) DEF_HELPER_FLAGS_2(rsqrte_f32, TCG_CALL_NO_RWG, f32, f32, ptr) DEF_HELPER_FLAGS_2(rsqrte_f64, TCG_CALL_NO_RWG, f64, f64, ptr) DEF_HELPER_2(recpe_u32, i32, i32, ptr) From patchwork Tue Feb 27 14:38:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129826 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp385796edc; Tue, 27 Feb 2018 07:07:27 -0800 (PST) X-Google-Smtp-Source: AG47ELv+SSVA2aa3aBMBD2bRl15fHcMDIQfo+Ncln0Eiftc1P6kQdsf2cNbCIQahBV4fN7WS+U8E X-Received: by 10.129.17.214 with SMTP id 205mr164785ywr.488.1519744047240; Tue, 27 Feb 2018 07:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519744047; cv=none; d=google.com; s=arc-20160816; b=MBfNfLWDweXQ2qkso/A3swRLLqwtgcegvmjJQHHbvdQFWNrIFoTNCKdMQUVVQFKlwU Zrxb6t3ebaU5PwziF4b7BM7ckcTrH0/9UX27AnkxgkIdsAF8qp7ihzsHsIfqvgl4DGlm UKJzUCRvzIlr5KZZy2NN17U3gwXZ4mL0OrBA1O8ULNIEfxSBF6K60Fu51GdXnIdbcGCO dvdtEldpGYibHaWPqR3BJ4rbEjzYF+gHwblKoRbA25SZ9dEVeZVv6jNfBoAXYKjRPNik kys+Tm6p0ibsA3UEOAnDte7W+ooRuUZ1s1IdYvPy+MMRwtQR5JIUr33xfyh0wxNc+C1g OOog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=MCdFSq22oJsD+MArBZXaJ2syHJz5rCBtupvEhH57GOE=; b=gsIuGSkcHHcgfCaNRhERq57p0gKE+CyCRAkNWzLQfJ/Pp6zdsUhPYt5J84j11WIZML Jmx4R0DSreJgSS6eKO9rTwIROr35FOae0qS2yeGsDHrzk7CiMjrR/eB7kxIndVCnFg4/ 7JMx0Oj+Dby6xldMNsLAzvZ2wViYqIi3iVARvf4QkIMWJ23FomAhnpjaZ1o2Q8mRjKSP ONV8H5E9GQTZfZ2UvaSpvdPWW4meFOMJoZuJQ11ycbwPtQz++FAZh0GTjbDMVHFUNTrw LO1y49nrTXViWfw7iFNyKWYsrYbRFbG+v0NhgzivOvrJFA+RzcFKKmBbJW7mA4lxVjtu O6QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CtvZlqQW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t132-v6si1941515yba.346.2018.02.27.07.07.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:07:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CtvZlqQW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgqk-0002vo-GZ for patch@linaro.org; Tue, 27 Feb 2018 10:07:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYD-0003g6-In for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgYB-0001se-0n for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:17 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:55746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgYA-0001pS-L6 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:14 -0500 Received: by mail-wm0-x241.google.com with SMTP id q83so24680923wme.5 for ; Tue, 27 Feb 2018 06:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MCdFSq22oJsD+MArBZXaJ2syHJz5rCBtupvEhH57GOE=; b=CtvZlqQWAo8d2brK7AtR9WRF9j6VenmX7yElJwG/dEU+7wApjGfjRl/c4rUMEOFPfC VOP0bF4bTUtWkKhAOpe1bmXPz0O7fqUwfdusl6DBiRJoeDmVLSDgRpE53xfqXGQs58rW kG+d/KVoeik/IT7ebK5c4oibzSfercQIcVEUI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MCdFSq22oJsD+MArBZXaJ2syHJz5rCBtupvEhH57GOE=; b=SYO/Z1CwOw+AvnX/Sx1MvfWflELTihfqGVKLvsKRjiXjYSkE9aLQL+z39A404XeTxx uKhFm8uEdHd4wUCPF1y1lvhKdPcZhAJygbJq2Dm7oGgbclMT0h1d9tPG3NmMwY5GU/u9 S9pS7thsSAloH6xNnq1kUWzBXqk2ZbtgNSMpqgSLWt30F6nMkDB7e7vlcU9VejzEFYww nqoLH+mH5OcbvTJtOUSajBAWJmDVxO0mtn16v3LfhMq9uP9x1VM/F1KzdM8CmUE6OEmE PdhSzRaYz76ELm1eS7gMEQFEpdz2xluPBr/tMRNbnT6wiqXDtLFXAQSTEfVhTsHFoMj4 AokQ== X-Gm-Message-State: APf1xPAossWY3FpL7J4Z5vCJAzfLxWU4ic5kE7lSnllvmZxTP80A2r2q fI4OqYpZJsbd+vkx6Qt25Fzn9A== X-Received: by 10.28.95.139 with SMTP id t133mr6270511wmb.16.1519742893474; Tue, 27 Feb 2018 06:48:13 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o12sm15625549wrb.15.2018.02.27.06.48.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:07 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id ED26D3E164D; Tue, 27 Feb 2018 14:38:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:48 +0000 Message-Id: <20180227143852.11175-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH v4 27/31] arm/translate-a64: add FP16 FRSQRTE to simd_two_reg_misc_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/translate-a64.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 1096ff48ac..86231b33bb 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11388,6 +11388,7 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x6f: /* FNEG */ need_fpst = false; break; + case 0x7d: /* FRSQRTE */ case 0x7f: /* FSQRT (vector) */ break; default: @@ -11452,6 +11453,9 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x6f: /* FNEG */ tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); break; + case 0x7d: /* FRSQRTE */ + gen_helper_rsqrte_f16(tcg_res, tcg_op, tcg_fpstatus); + break; default: g_assert_not_reached(); } @@ -11504,6 +11508,9 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) case 0x6f: /* FNEG */ tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); break; + case 0x7d: /* FRSQRTE */ + gen_helper_rsqrte_f16(tcg_res, tcg_op, tcg_fpstatus); + break; case 0x7f: /* FSQRT */ gen_helper_sqrt_f16(tcg_res, tcg_op, tcg_fpstatus); break; From patchwork Tue Feb 27 14:38:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129814 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp369751edc; Tue, 27 Feb 2018 06:54:49 -0800 (PST) X-Google-Smtp-Source: AG47ELt9JbH9Bjv/o0yGPXR7Vmlgec0GtKv4F74GdigRWprEDTA3eAAFWACNKNOsjpilmj+GV/MQ X-Received: by 2002:a25:69d1:: with SMTP id e200-v6mr9079896ybc.253.1519743289387; Tue, 27 Feb 2018 06:54:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743289; cv=none; d=google.com; s=arc-20160816; b=PlXNXAzH2Sd/tvhYcxwLk+IoGUXggXBu2kHyQC5d9EnJKb85+Hs20zYQXScbs+xNlD 7hKhkgi5kuoznxImR0KBaq2xoYatD9UYsGOepPzc+rJBmwhv4SrFCKNTUY7UFxuII6qv YU6AeuJmiIbGcezhvVPjdcQZ/ePkVMSpvtHgNCLmj1gL/k+jswOxYj1yEKl7r9IVVofQ 5qW9LDHpdAOGiZeH+VDoQPyCtLzK8nhREOEhkuPy81zpJ4u6gMKg1F0wvVNBg1K2PCvA +IK3Ktk9aT6mwrrcHU7LRKSgMhzWTPFKYVPk3/hNTPMbJZgeqF1yaEm9pVKdBNnVXR/T 6RYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=+HnaMoj4oqRgZrPNtvzv7OqJLDnl27LXHLWnw27T2VI=; b=0VekscziR+GjAq8is/vUADyGKReG3yaettVdy3YDT8eQ+aiJP1B/aKDBs7PAIURp7n tNmgxODXrKialJC0aFlJXeBRaIP/8f5CKxWaAIhptHxBg4/HUIvpl3BmuMKH8SRYQ6G4 pYeowT/G5QVUEpywbjj43v+w7cNpAUKR/vNCGzbsftF9W9KPE7pimgGPSEMb6Wtxjbum iwpJ7L/NQUf7rYsz7dyja/D3lMmo8KeksjpxB9iM5UTGqTNuZISIdsABp4kJhLHEDqCe H4D0BDNgbItvKYwDwshCYG9MfvqKfn0g2WcVW/AJdmvRJtMYjk7bHBdkLNLcIjzclEQ2 URvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FyJZC9rF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t131si820947ywb.736.2018.02.27.06.54.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:54:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FyJZC9rF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgeW-0000fQ-Qz for patch@linaro.org; Tue, 27 Feb 2018 09:54:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPU-0003nS-0x for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPT-00085V-4t for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:16 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:38868) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPS-00084v-P3 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:15 -0500 Received: by mail-wr0-x242.google.com with SMTP id n7so25120784wrn.5 for ; Tue, 27 Feb 2018 06:39:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+HnaMoj4oqRgZrPNtvzv7OqJLDnl27LXHLWnw27T2VI=; b=FyJZC9rFjwWLMTLc0Ee449KvdL40v05Bd2KzjcXu2+jK5g+wKcclOF8vAg5OZp7G7E jdds/N5KSdxpdpGDxX+mpEvOxJb+EynU+GMbTs/caZivZgyQgFB2DY+PYpalkYg4rdpk K6y4KoHbbc+QrJHnTDTK4gzJak1+kqXjE62J0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+HnaMoj4oqRgZrPNtvzv7OqJLDnl27LXHLWnw27T2VI=; b=twpHLOscEUhFY4WTcwVByDDUKepRG8BKWZcdjhN0mW+P4CDBbRv7mTvFazaXsNwPY7 Fxxc1lIYWO+lkzB3ZMLnpYxHoaG7Ip0tCnZgG+QMSIyPBXPAZlKTGlCPWKcZVxYORf7I Hk8EreWtxBOFTQcrglZYUAceTlxcMDz8jSB+ahp4daL8WLD5+wk4c/7ZL28Wx+z4Z8L1 M8mswPfuFQPa274vuwjx36AH/ld9sokqq+PgKfI86QhOyok7TSpdtp/V04dQfo0S7rmQ 4lb1ra8qhhKpZFoi+swstUYd/m8d88XM3jtU8fUQhWptrdqqQfe+dfliNk4sZdcGE5pk 5Jzg== X-Gm-Message-State: APf1xPDdnabiXe+eHhxvOuR2icB1ggqycxWeffCcl1u8KthhMzJps97s B18PtKObQqCcOWT5KY4cJGkZfA== X-Received: by 10.223.200.2 with SMTP id d2mr12614117wrh.81.1519742353674; Tue, 27 Feb 2018 06:39:13 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w29sm11239614wra.84.2018.02.27.06.39.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:39:09 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 0AF343E165A; Tue, 27 Feb 2018 14:38:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:49 +0000 Message-Id: <20180227143852.11175-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 28/31] arm/translate-a64: add FP16 FMOV to simd_mod_imm X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Only one half-precision instruction has been added to this group. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 - checkpatch fixes v3 - use vfp_expand_imm --- target/arm/translate-a64.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 86231b33bb..7c2bc05b92 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -6234,6 +6234,8 @@ static void disas_simd_copy(DisasContext *s, uint32_t insn) * MVNI - move inverted (shifted) imm into register * ORR - bitwise OR of (shifted) imm with register * BIC - bitwise clear of (shifted) imm with register + * With ARMv8.2 we also have: + * FMOV half-precision */ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) { @@ -6248,8 +6250,11 @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) uint64_t imm = 0; if (o2 != 0 || ((cmode == 0xf) && is_neg && !is_q)) { - unallocated_encoding(s); - return; + /* Check for FMOV (vector, immediate) - half-precision */ + if (!(arm_dc_feature(s, ARM_FEATURE_V8_FP16) && o2 && cmode == 0xf)) { + unallocated_encoding(s); + return; + } } if (!fp_access_check(s)) { @@ -6307,19 +6312,29 @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) imm |= 0x4000000000000000ULL; } } else { - imm = (abcdefgh & 0x3f) << 19; - if (abcdefgh & 0x80) { - imm |= 0x80000000; - } - if (abcdefgh & 0x40) { - imm |= 0x3e000000; + if (o2) { + /* FMOV (vector, immediate) - half-precision */ + imm = vfp_expand_imm(MO_16, abcdefgh); + /* now duplicate across the lanes */ + imm = bitfield_replicate(imm, 16); } else { - imm |= 0x40000000; + imm = (abcdefgh & 0x3f) << 19; + if (abcdefgh & 0x80) { + imm |= 0x80000000; + } + if (abcdefgh & 0x40) { + imm |= 0x3e000000; + } else { + imm |= 0x40000000; + } + imm |= (imm << 32); } - imm |= (imm << 32); } } break; + default: + fprintf(stderr, "%s: cmode_3_1: %x\n", __func__, cmode_3_1); + g_assert_not_reached(); } if (cmode_3_1 != 7 && is_neg) { From patchwork Tue Feb 27 14:38:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129823 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp384179edc; Tue, 27 Feb 2018 07:06:09 -0800 (PST) X-Google-Smtp-Source: AG47ELuRtVBNK6/A7sSD4+BS+I7vtGvtJpmaLkdum7+4GGoFR+IB9CxmaZ0cNSOldOC3FIqLHzR2 X-Received: by 10.129.71.9 with SMTP id u9mr4717552ywa.212.1519743969732; Tue, 27 Feb 2018 07:06:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743969; cv=none; d=google.com; s=arc-20160816; b=eF9oQ8xbvjN0dQSoChKISisDPZhQ7/ewhhjhV5+g/RIp9NoaTNS6Xs3+jo3DDmo/RA yAf/RfHAo/gdYjSAqEhdkuT19T9dLYOINtVVbneUtqAhO8m7IiC60AHJHprmuw8dHtDq Wrfuid3oHlU4WM2ZgCESS/GtlCCS3Y392QHoW866etgI7mJJ6xuZ1Wj5EQNdPwcVrxNl FTA1ix3XC0MCcdQftijo8We4CFZpbQUVt8Qpn2UVDbAXa8VewXjR9xTfS5PoFFE+oaYj RZgCIgyx381/JOlj6wPr1sjGmAZ9PLm8ukdjbSRmiIBD2dYNTXwr+9LirWobtHdbIjF9 85tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=YLjs9h74suIqkuOO0V9AaV1597gT9SirGzEVb1pIjLI=; b=PfwxgXXbyE45wo8/z0A5KJGvaMSYAJ7Hy1we2bNAYSQrbFZ1evkxdh6i+Jd3XTNK/u xTq662ERLZp2JiSGoboyOzkKDTdiuq8o8U822+Xf32F0oxbjJoz3rQnd4A8Gne5DTDro wYaS3mjFx/MBntVnTYFLSoc0rT+cp35uz997pc5c6XxjA8zqrHDMpYT6Va07LmWlq1uI S3VpDN9SiuHDK3CVGve7jguiHMShG9eh+SZJGhImzXNQJXr27YPdhJt3oVt35qmMnQHY nt1jasly+QBgQlsUZlq3+ImVYRycgfJ1zhBDZ7kyXqqaoXLfa6N3QweewFgrrMNo609z G+vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a7tiIYFF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u184-v6si1988987ybg.33.2018.02.27.07.06.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:06:09 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a7tiIYFF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgpV-00011w-2u for patch@linaro.org; Tue, 27 Feb 2018 10:06:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgY3-0003WR-Sk for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgXz-00011U-2i for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:07 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:42721) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgXy-0000xe-P4 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:02 -0500 Received: by mail-wr0-x242.google.com with SMTP id k9so25158331wre.9 for ; Tue, 27 Feb 2018 06:48:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YLjs9h74suIqkuOO0V9AaV1597gT9SirGzEVb1pIjLI=; b=a7tiIYFFZTkFVT60qavLlHdd3ZwTtT8qvIB+ozlzH9RSGXJegMuIhP1Dc88lcU2ttq O8rmK9xM1ZQ3JpefIkHnDylgoWaCoaIY13ebz4ZVW0ipwHenw4lSTpF4DoOmXc1xKL2I zIbqw8XAbenHDLjyNA9Yb1jcRNUXpBhKxKLGw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YLjs9h74suIqkuOO0V9AaV1597gT9SirGzEVb1pIjLI=; b=aI1pax1fhv6XOMnqoCv5fz4KtXPczQ8GG9cXl0huxht6RBy7IT3XQiZqcT4TGBK1h2 YF4l+ioJNCl9mq7PXtr/EPC8hs8eLzWTgR+pL9NfHV6W2rzKZRJjYEdgPukWM/rRMmsW 1JbtrMPq8MTFYmNTBM/lxHWndxj2v4PjcMPd9Bfhv5IO3fKSbsQ9r+qyKMDLi9Uyz6vF eMSHInisN+lLGSJDauZvTlhbm6Mf64Q1jJJIF1K3WrCow+MUWYcUhN8BVl18jovBXIgY Yg/4cMtfBWemJCtC0gwiElCwqs9PEtssPDLhvmzuYC0Lcz737ClZD88sZVWk0KREwTSU i0xQ== X-Gm-Message-State: APf1xPA1Kpijd1+S43kihecmJnI4G1na/WscpzdQ7zjCHAzU3EYPQq9K PSwTyqiV5Lq+Qydeq6+iwCPt+A== X-Received: by 10.223.197.200 with SMTP id v8mr12228364wrg.22.1519742881537; Tue, 27 Feb 2018 06:48:01 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 59sm6607374wro.57.2018.02.27.06.48.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:00 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 1C72D3E165C; Tue, 27 Feb 2018 14:38:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:50 +0000 Message-Id: <20180227143852.11175-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 29/31] arm/translate-a64: add all FP16 ops in simd_scalar_pairwise X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" I only needed to do a little light re-factoring to support the half-precision helpers. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- target/arm/translate-a64.c | 80 +++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 26 deletions(-) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 7c2bc05b92..9d3a6ac49f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -6416,24 +6416,30 @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn) case 0xf: /* FMAXP */ case 0x2c: /* FMINNMP */ case 0x2f: /* FMINP */ - /* FP op, size[0] is 32 or 64 bit */ + /* FP op, size[0] is 32 or 64 bit*/ if (!u) { - unallocated_encoding(s); - return; + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + unallocated_encoding(s); + return; + } else { + size = MO_16; + } + } else { + size = extract32(size, 0, 1) ? MO_64 : MO_32; } + if (!fp_access_check(s)) { return; } - size = extract32(size, 0, 1) ? 3 : 2; - fpst = get_fpstatus_ptr(false); + fpst = get_fpstatus_ptr(size == MO_16); break; default: unallocated_encoding(s); return; } - if (size == 3) { + if (size == MO_64) { TCGv_i64 tcg_op1 = tcg_temp_new_i64(); TCGv_i64 tcg_op2 = tcg_temp_new_i64(); TCGv_i64 tcg_res = tcg_temp_new_i64(); @@ -6474,27 +6480,49 @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn) TCGv_i32 tcg_op2 = tcg_temp_new_i32(); TCGv_i32 tcg_res = tcg_temp_new_i32(); - read_vec_element_i32(s, tcg_op1, rn, 0, MO_32); - read_vec_element_i32(s, tcg_op2, rn, 1, MO_32); + read_vec_element_i32(s, tcg_op1, rn, 0, size); + read_vec_element_i32(s, tcg_op2, rn, 1, size); - switch (opcode) { - case 0xc: /* FMAXNMP */ - gen_helper_vfp_maxnums(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0xd: /* FADDP */ - gen_helper_vfp_adds(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0xf: /* FMAXP */ - gen_helper_vfp_maxs(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x2c: /* FMINNMP */ - gen_helper_vfp_minnums(tcg_res, tcg_op1, tcg_op2, fpst); - break; - case 0x2f: /* FMINP */ - gen_helper_vfp_mins(tcg_res, tcg_op1, tcg_op2, fpst); - break; - default: - g_assert_not_reached(); + if (size == MO_16) { + switch (opcode) { + case 0xc: /* FMAXNMP */ + gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0xd: /* FADDP */ + gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0xf: /* FMAXP */ + gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x2c: /* FMINNMP */ + gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x2f: /* FMINP */ + gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + default: + g_assert_not_reached(); + } + } else { + switch (opcode) { + case 0xc: /* FMAXNMP */ + gen_helper_vfp_maxnums(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0xd: /* FADDP */ + gen_helper_vfp_adds(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0xf: /* FMAXP */ + gen_helper_vfp_maxs(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x2c: /* FMINNMP */ + gen_helper_vfp_minnums(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x2f: /* FMINP */ + gen_helper_vfp_mins(tcg_res, tcg_op1, tcg_op2, fpst); + break; + default: + g_assert_not_reached(); + } } write_fp_sreg(s, rd, tcg_res); From patchwork Tue Feb 27 14:38:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129817 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp372514edc; Tue, 27 Feb 2018 06:57:26 -0800 (PST) X-Google-Smtp-Source: AG47ELtDdp16gXNJwJfv9KUU6/jKoq7j2PqTrSO1/YTDQFixDFBi5n1o5Y+OWyk5XEzf7pIlNgIL X-Received: by 2002:a25:f409:: with SMTP id q9-v6mr9612740ybd.95.1519743446736; Tue, 27 Feb 2018 06:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743446; cv=none; d=google.com; s=arc-20160816; b=jsj52IUShh5WEya7fWqNhhEimhL/lEebDBiLsyKnUqnLCYrm50sXyIrKGjUCnLoTrl 9vhpnFZsNE/TP3cYjSNIdCyW/ahEcSIw6e7i46mA91AnDVLkhexH7bKh2jAayM1TJdy6 s1JCZfpJtrj3BduB3+3hSa+2rNYOOmLL0YJ6bA6YEIS7LeFTO2KPLoFWO9vf8fI57HI2 qoWtMhk1JCWAirlnQ1BRNOQfiR0XDLXCddr8u6oCsYhqNoeYPgC0RRTeC29gTZvdHjbR 7O8oTjgDLvF2hKCF2No6vXbqzribZUHWDuTtq52fHHAnlWwPjxSSFB8iRfp1syhFxZwz MgJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=nFF84gHyau8tIOz75MBzWgGQz7SBviWAi/Ej6sJGy0Y=; b=Baa1OpG7HyxjZR0y4yGLw62BZwH21+prjQy9RR8Ma3LcBnyAvy2PtVBL3DMTx0EJgu vD4p4xb04YdtbEOtuAaFWs5AIHtXU2XPqWZV9Gth4UQTfwYHnMn4jYToCM4p2sZzfICu eHwJPGCREd2dEr6cV/1pX4lVuBQTmWUmvJmnrbqci1ydwJdQ7jYW9BMPshsA4yJrDHLr qZX5PA0OYxcABlgeVi2fP5zc4IZJJsjHg9VIIqOG1mF922X7Hb3onvfbgWRk/Yqg4ker zTp7o0ABvD+DzYzP1Y2FC1qSh7XutLZHARfyfiy4oyazqZYJnMgG991COyKzPYq5JS6p k3/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FFpth2qV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b20si593282ywe.372.2018.02.27.06.57.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:57:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FFpth2qV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgh4-000359-5N for patch@linaro.org; Tue, 27 Feb 2018 09:57:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgY3-0003Vq-86 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY0-00018A-BG for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:07 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:36562) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgXz-00013P-WE for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:04 -0500 Received: by mail-wr0-x242.google.com with SMTP id v111so12921780wrb.3 for ; Tue, 27 Feb 2018 06:48:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nFF84gHyau8tIOz75MBzWgGQz7SBviWAi/Ej6sJGy0Y=; b=FFpth2qVfE6oW5MIVhXQxQ3RcR7BVX97yeiND6MjyH7lky8MqYFazqKsm+lYHAClGR +T6nDALGZFm7NS7ykhm3ft82hQ0UfPXiVarmLdpQnGcukOE+NT8iDQ5OQa/Hjd1LTAP9 4x4qunHmig95EDRzBlsmrFD8dmyuvX9JAAwTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nFF84gHyau8tIOz75MBzWgGQz7SBviWAi/Ej6sJGy0Y=; b=huRNG1IqPNlT2quGXPZjakACOBgLXp3nmimCtAaHrFAeFb5bqK4c94WDdtNG7TNbZ+ qF5OUdatbYl0R4DT+yu9EAbooNA1T6+hfsFA0miVkORYHpMBqM6CBf/WVL7wIdnU4FML gsQcWe6rVZhhALllXA1PDptc6t/uF7M98MsAxtVqWgTr9Wnxaz1xwrqBwOM8OFwPdeRF gq48DK89U+TyvLqNd8Zjs88o8zusVyGT8MmPpo/I0oeUTntStrCHfGphWP7xmCPWftG9 2GFz2JQ7yfzTIv4cIAmOeaqEvfeVYoy/161YUlFFEvahHwgYCHP+o5sUWGK8mWbjRVfe trnA== X-Gm-Message-State: APf1xPCsl9jwxLxEfstxnA97uAQDdfeBdqpDtm31GB/+wkVmAYuAG/Eh SHM0p1DrtD7vwU0WKRA8iK7Q6A== X-Received: by 10.223.135.114 with SMTP id 47mr7702447wrz.238.1519742882823; Tue, 27 Feb 2018 06:48:02 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k45sm10770888wrf.62.2018.02.27.06.48.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:00 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 2E10B3E166A; Tue, 27 Feb 2018 14:38:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:51 +0000 Message-Id: <20180227143852.11175-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH v4 30/31] arm/translate-a64: implement simd_scalar_three_reg_same_fp16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This covers the encoding group: Advanced SIMD scalar three same FP16 As all the helpers are already there it is simply a case of calling the existing helpers in the scalar context. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 - checkpatch fixes v3 - check for FP16 feature - remove stray debug - make abs a bitwise operation - checkpatch long line --- target/arm/translate-a64.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9d3a6ac49f..52cecae047 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -7802,6 +7802,104 @@ static void disas_simd_scalar_three_reg_same(DisasContext *s, uint32_t insn) tcg_temp_free_i64(tcg_rd); } +/* AdvSIMD scalar three same FP16 + * 31 30 29 28 24 23 22 21 20 16 15 14 13 11 10 9 5 4 0 + * +-----+---+-----------+---+-----+------+-----+--------+---+----+----+ + * | 0 1 | U | 1 1 1 1 0 | a | 1 0 | Rm | 0 0 | opcode | 1 | Rn | Rd | + * +-----+---+-----------+---+-----+------+-----+--------+---+----+----+ + * v: 0101 1110 0100 0000 0000 0100 0000 0000 => 5e400400 + * m: 1101 1111 0110 0000 1100 0100 0000 0000 => df60c400 + */ +static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s, + uint32_t insn) +{ + int rd = extract32(insn, 0, 5); + int rn = extract32(insn, 5, 5); + int opcode = extract32(insn, 11, 3); + int rm = extract32(insn, 16, 5); + bool u = extract32(insn, 29, 1); + bool a = extract32(insn, 23, 1); + int fpopcode = opcode | (a << 3) | (u << 4); + TCGv_ptr fpst; + TCGv_i32 tcg_op1; + TCGv_i32 tcg_op2; + TCGv_i32 tcg_res; + + switch (fpopcode) { + case 0x03: /* FMULX */ + case 0x04: /* FCMEQ (reg) */ + case 0x07: /* FRECPS */ + case 0x0f: /* FRSQRTS */ + case 0x14: /* FCMGE (reg) */ + case 0x15: /* FACGE */ + case 0x1a: /* FABD */ + case 0x1c: /* FCMGT (reg) */ + case 0x1d: /* FACGT */ + break; + default: + unallocated_encoding(s); + return; + } + + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + unallocated_encoding(s); + } + + if (!fp_access_check(s)) { + return; + } + + fpst = get_fpstatus_ptr(true); + + tcg_op1 = tcg_temp_new_i32(); + tcg_op2 = tcg_temp_new_i32(); + tcg_res = tcg_temp_new_i32(); + + read_vec_element_i32(s, tcg_op1, rn, 0, MO_16); + read_vec_element_i32(s, tcg_op2, rm, 0, MO_16); + + switch (fpopcode) { + case 0x03: /* FMULX */ + gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x04: /* FCMEQ (reg) */ + gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x07: /* FRECPS */ + gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x0f: /* FRSQRTS */ + gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x14: /* FCMGE (reg) */ + gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x15: /* FACGE */ + gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x1a: /* FABD */ + gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); + tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff); + break; + case 0x1c: /* FCMGT (reg) */ + gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x1d: /* FACGT */ + gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; + default: + g_assert_not_reached(); + } + + write_fp_sreg(s, rd, tcg_res); + + + tcg_temp_free_i32(tcg_res); + tcg_temp_free_i32(tcg_op1); + tcg_temp_free_i32(tcg_op2); + tcg_temp_free_ptr(fpst); +} + static void handle_2misc_64(DisasContext *s, int opcode, bool u, TCGv_i64 tcg_rd, TCGv_i64 tcg_rn, TCGv_i32 tcg_rmode, TCGv_ptr tcg_fpstatus) @@ -12653,6 +12751,7 @@ static const AArch64DecodeTable data_proc_simd[] = { { 0xce408000, 0xffe0c000, disas_crypto_three_reg_imm2 }, { 0x0e400400, 0x9f60c400, disas_simd_three_reg_same_fp16 }, { 0x0e780800, 0x8f7e0c00, disas_simd_two_reg_misc_fp16 }, + { 0x5e400400, 0xdf60c400, disas_simd_scalar_three_reg_same_fp16 }, { 0x00000000, 0x00000000, NULL } }; From patchwork Tue Feb 27 14:38:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129821 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp380499edc; Tue, 27 Feb 2018 07:03:26 -0800 (PST) X-Google-Smtp-Source: AG47ELuSYfpGd68kO5T7qgwoZbVIyB2qwSOR3p7lg1rvZGxbHgpgjvqELich6A+6tqpzUIgAtf4k X-Received: by 10.13.255.66 with SMTP id p63mr4999917ywf.482.1519743806735; Tue, 27 Feb 2018 07:03:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519743806; cv=none; d=google.com; s=arc-20160816; b=H9NO0a13cm6rGOmtZBvd3nrpjUkw4DtDasf2CnQzX3yAiacFsKz4FliXzJ3BllqiGp j3IJCUQ9Phs0Dcq6NbzMeRIf8nkZ9IUImFN51yJkkTlgE7yQJA4l9+6PRG6oLwEBKQ2i tmXTgdG6jshpm9C4sHFUOgo12akG6X93kOL157SXPqhK6eGTSLsnq4WiGYefCfFl9wa+ tGYNE1QV+t2fb0Vhzj8mjBtuzMmAvrsblj1QIfR2SnJaZICjzZEH+xcSj4Bcpi8NQijU CJKAZDlzCG7Fw//2w/0tI4OnqiWwDbL0cMWn51k2VbRk+GBrg0aakaVj+3lLj90oodRz 1j3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=oxx9u+IEwToSdmXpm0bYBlGbAQ1z4CJjskjDfSb+4XU=; b=Hs1ltL5vcgPqjpa3EnT+NoCALraSKXNac4e4H+74kZND2Z8bQxPEVGYHrGoCVzEJ6s 2CBr4uspYLvBiBED3NscaoqIuw5CwN+7U3oMh547rKP1Fng4lMFxXcE0o8yGFiXSIR6E alNDCJ/GJ/pQml35VbbXLS7L6dn1r0vTNzL/6ZWunQzhfp5B8A1S2FklCYzcRl5xCSPy 4okgjozFAN6+xkjZYU/Potb/2mpREJQJOzVXtAneOxYRDr9CuzZO0jALqA3PFu1qIEwe sdIFAKUkInUnvqQKI0j8uolXSOfk7gTpUWz1G1X+VYOLp0FOBpniHhoLge3M8iD+K25E 19JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jRiewoda; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w11si1933141ywc.476.2018.02.27.07.03.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 07:03:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jRiewoda; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgms-0008HR-5M for patch@linaro.org; Tue, 27 Feb 2018 10:03:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgYA-0003bg-91 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgY7-0001fL-I0 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:14 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:43634) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgY7-0001b5-55 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:48:11 -0500 Received: by mail-wr0-x244.google.com with SMTP id u49so25115733wrc.10 for ; Tue, 27 Feb 2018 06:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oxx9u+IEwToSdmXpm0bYBlGbAQ1z4CJjskjDfSb+4XU=; b=jRiewodapsjzPdInX21yxwO/SQNeadfBzUdDEsFXuS4Q1GMOHH59R5/bBibs0fDghH kG0YqzlOj2D3B/pxA3AMdXjT47b0VtzYMAkpIHDGYZGUKJeglMDu/+SJ4cJ7frSWEJBW 6o6oJ04yjTNfVbc+p62tl25RXNJVMKRXbrm64= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oxx9u+IEwToSdmXpm0bYBlGbAQ1z4CJjskjDfSb+4XU=; b=PlX1JD2y0NrxsTvHd0D80mQoxFd0HmhjpMaIsfVWY3bSKTCWKDFdf4Svfps4v8qL8F yPOWnzpHoiuQCKPKzLzV00QEK32kS2tJkn2ns+Cwoss20Cr7L6skfdU8Qlt9ZRrYgTqS R08QHAE90ONsDbdJwS8uyUabnyIlMTjTYX2nQejaFWYoJ89Jj9mAqpCdM8afEnLo3fsQ dpuy+ItWwgwkyxJ0C4Tt0dNlYH/hIv+UfaSbTR3Zcgh0Z4vP02e/2kouHD4gZ6xx4D86 sPLS5I5SLz+joYEhTV9sqjVIcK7U7M9oa6bvxyRxyK3Eii/zeQfnGhGHCfeSycn78TMA udfQ== X-Gm-Message-State: APf1xPBERT6FAqwwP4nzAkmJd4Q3e1qpctL599Rldm3Ipr8QeHTGn/Jf PYb1auZcPuWn3Un+iG/E1BmTxQ== X-Received: by 10.223.170.211 with SMTP id i19mr13469682wrc.261.1519742889980; Tue, 27 Feb 2018 06:48:09 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 69sm9102555wmp.36.2018.02.27.06.48.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:48:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 3FC1E3E166D; Tue, 27 Feb 2018 14:38:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:52 +0000 Message-Id: <20180227143852.11175-32-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PATCH v4 31/31] arm/translate-a64: add all single op FP16 to handle_fp_1src_half X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes FMOV, FABS, FNEG, FSQRT and FRINT[NPMZAXI]. We re-use existing helpers to achieve this. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - make fabs a bitwise operation - use read_vec_element_i32 to read value - properly wire into disas_fp_1rc --- target/arm/translate-a64.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) -- 2.15.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 52cecae047..32811dc8b0 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -4596,6 +4596,65 @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) tcg_temp_free_i64(t_true); } +/* Floating-point data-processing (1 source) - half precision */ +static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) +{ + TCGv_ptr fpst = NULL; + TCGv_i32 tcg_op = tcg_temp_new_i32(); + TCGv_i32 tcg_res = tcg_temp_new_i32(); + + read_vec_element_i32(s, tcg_op, rn, 0, MO_16); + + switch (opcode) { + case 0x0: /* FMOV */ + tcg_gen_mov_i32(tcg_res, tcg_op); + break; + case 0x1: /* FABS */ + tcg_gen_andi_i32(tcg_res, tcg_op, 0x7fff); + break; + case 0x2: /* FNEG */ + tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); + break; + case 0x3: /* FSQRT */ + gen_helper_sqrt_f16(tcg_res, tcg_op, cpu_env); + break; + case 0x8: /* FRINTN */ + case 0x9: /* FRINTP */ + case 0xa: /* FRINTM */ + case 0xb: /* FRINTZ */ + case 0xc: /* FRINTA */ + { + TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7)); + fpst = get_fpstatus_ptr(true); + + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst); + + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); + tcg_temp_free_i32(tcg_rmode); + break; + } + case 0xe: /* FRINTX */ + fpst = get_fpstatus_ptr(true); + gen_helper_advsimd_rinth_exact(tcg_res, tcg_op, fpst); + break; + case 0xf: /* FRINTI */ + fpst = get_fpstatus_ptr(true); + gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst); + break; + default: + abort(); + } + + write_fp_sreg(s, rd, tcg_res); + + if (fpst) { + tcg_temp_free_ptr(fpst); + } + tcg_temp_free_i32(tcg_op); + tcg_temp_free_i32(tcg_res); +} + /* Floating-point data-processing (1 source) - single precision */ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) { @@ -4825,6 +4884,18 @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) handle_fp_1src_double(s, opcode, rd, rn); break; + case 3: + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + unallocated_encoding(s); + return; + } + + if (!fp_access_check(s)) { + return; + } + + handle_fp_1src_half(s, opcode, rd, rn); + break; default: unallocated_encoding(s); }