mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
Hexagon (target/hexagon) add F2_sfrecipa instruction
Rd32,Pe4 = sfrecipa(Rs32, Rt32) Recripocal approx Test cases in tests/tcg/hexagon/multi_result.c FP exception tests added to tests/tcg/hexagon/fpstuff.c Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <1617930474-31979-18-git-send-email-tsimpson@quicinc.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
85580a6557
commit
d934c16d8a
10 changed files with 252 additions and 3 deletions
|
@ -39,6 +39,7 @@ HEX_TESTS = first
|
|||
HEX_TESTS += misc
|
||||
HEX_TESTS += preg_alias
|
||||
HEX_TESTS += dual_stores
|
||||
HEX_TESTS += multi_result
|
||||
HEX_TESTS += mem_noshuf
|
||||
HEX_TESTS += atomics
|
||||
HEX_TESTS += fpstuff
|
||||
|
|
|
@ -250,6 +250,87 @@ static void check_dfminmax(void)
|
|||
check_fpstatus(usr, FPINVF);
|
||||
}
|
||||
|
||||
static void check_recip_exception(void)
|
||||
{
|
||||
int result;
|
||||
int usr;
|
||||
|
||||
/*
|
||||
* Check that sfrecipa doesn't set status bits when
|
||||
* a NaN with bit 22 non-zero is passed
|
||||
*/
|
||||
asm (CLEAR_FPSTATUS
|
||||
"%0,p0 = sfrecipa(%2, %3)\n\t"
|
||||
"%1 = usr\n\t"
|
||||
: "=r"(result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
|
||||
: "r2", "p0", "usr");
|
||||
check32(result, SF_HEX_NAN);
|
||||
check_fpstatus(usr, 0);
|
||||
|
||||
asm (CLEAR_FPSTATUS
|
||||
"%0,p0 = sfrecipa(%2, %3)\n\t"
|
||||
"%1 = usr\n\t"
|
||||
: "=r"(result), "=r"(usr) : "r"(SF_ANY), "r"(SF_NaN)
|
||||
: "r2", "p0", "usr");
|
||||
check32(result, SF_HEX_NAN);
|
||||
check_fpstatus(usr, 0);
|
||||
|
||||
asm (CLEAR_FPSTATUS
|
||||
"%0,p0 = sfrecipa(%2, %2)\n\t"
|
||||
"%1 = usr\n\t"
|
||||
: "=r"(result), "=r"(usr) : "r"(SF_NaN)
|
||||
: "r2", "p0", "usr");
|
||||
check32(result, SF_HEX_NAN);
|
||||
check_fpstatus(usr, 0);
|
||||
|
||||
/*
|
||||
* Check that sfrecipa doesn't set status bits when
|
||||
* a NaN with bit 22 zero is passed
|
||||
*/
|
||||
asm (CLEAR_FPSTATUS
|
||||
"%0,p0 = sfrecipa(%2, %3)\n\t"
|
||||
"%1 = usr\n\t"
|
||||
: "=r"(result), "=r"(usr) : "r"(SF_NaN_special), "r"(SF_ANY)
|
||||
: "r2", "p0", "usr");
|
||||
check32(result, SF_HEX_NAN);
|
||||
check_fpstatus(usr, FPINVF);
|
||||
|
||||
asm (CLEAR_FPSTATUS
|
||||
"%0,p0 = sfrecipa(%2, %3)\n\t"
|
||||
"%1 = usr\n\t"
|
||||
: "=r"(result), "=r"(usr) : "r"(SF_ANY), "r"(SF_NaN_special)
|
||||
: "r2", "p0", "usr");
|
||||
check32(result, SF_HEX_NAN);
|
||||
check_fpstatus(usr, FPINVF);
|
||||
|
||||
asm (CLEAR_FPSTATUS
|
||||
"%0,p0 = sfrecipa(%2, %2)\n\t"
|
||||
"%1 = usr\n\t"
|
||||
: "=r"(result), "=r"(usr) : "r"(SF_NaN_special)
|
||||
: "r2", "p0", "usr");
|
||||
check32(result, SF_HEX_NAN);
|
||||
check_fpstatus(usr, FPINVF);
|
||||
|
||||
/*
|
||||
* Check that sfrecipa properly sets divid-by-zero
|
||||
*/
|
||||
asm (CLEAR_FPSTATUS
|
||||
"%0,p0 = sfrecipa(%2, %3)\n\t"
|
||||
"%1 = usr\n\t"
|
||||
: "=r"(result), "=r"(usr) : "r"(0x885dc960), "r"(0x80000000)
|
||||
: "r2", "p0", "usr");
|
||||
check32(result, 0x3f800000);
|
||||
check_fpstatus(usr, FPDBZF);
|
||||
|
||||
asm (CLEAR_FPSTATUS
|
||||
"%0,p0 = sfrecipa(%2, %3)\n\t"
|
||||
"%1 = usr\n\t"
|
||||
: "=r"(result), "=r"(usr) : "r"(0x7f800000), "r"(SF_ZERO)
|
||||
: "r2", "p0", "usr");
|
||||
check32(result, 0x3f800000);
|
||||
check_fpstatus(usr, 0);
|
||||
}
|
||||
|
||||
static void check_canonical_NaN(void)
|
||||
{
|
||||
int sf_result;
|
||||
|
@ -507,6 +588,7 @@ int main()
|
|||
check_compare_exception();
|
||||
check_sfminmax();
|
||||
check_dfminmax();
|
||||
check_recip_exception();
|
||||
check_canonical_NaN();
|
||||
check_float2int_convs();
|
||||
|
||||
|
|
68
tests/tcg/hexagon/multi_result.c
Normal file
68
tests/tcg/hexagon/multi_result.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static int sfrecipa(int Rs, int Rt, int *pred_result)
|
||||
{
|
||||
int result;
|
||||
int predval;
|
||||
|
||||
asm volatile("%0,p0 = sfrecipa(%2, %3)\n\t"
|
||||
"%1 = p0\n\t"
|
||||
: "+r"(result), "=r"(predval)
|
||||
: "r"(Rs), "r"(Rt)
|
||||
: "p0");
|
||||
*pred_result = predval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int err;
|
||||
|
||||
static void check(int val, int expect)
|
||||
{
|
||||
if (val != expect) {
|
||||
printf("ERROR: 0x%08x != 0x%08x\n", val, expect);
|
||||
err++;
|
||||
}
|
||||
}
|
||||
|
||||
static void check_p(int val, int expect)
|
||||
{
|
||||
if (val != expect) {
|
||||
printf("ERROR: 0x%02x != 0x%02x\n", val, expect);
|
||||
err++;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_sfrecipa()
|
||||
{
|
||||
int res;
|
||||
int pred_result;
|
||||
|
||||
res = sfrecipa(0x04030201, 0x05060708, &pred_result);
|
||||
check(res, 0x59f38001);
|
||||
check_p(pred_result, 0x00);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_sfrecipa();
|
||||
|
||||
puts(err ? "FAIL" : "PASS");
|
||||
return err;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue