Hexagon (target/hexagon) add F2_sfinvsqrta

Rd32,Pe4 = sfinvsqrta(Rs32)
    Square root approx

The helper packs the 2 32-bit results into a 64-bit value,
and the fGEN_TCG override unpacks them into the proper results.

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-19-git-send-email-tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Taylor Simpson 2021-04-08 20:07:46 -05:00 committed by Richard Henderson
parent d934c16d8a
commit dd8705bdf5
9 changed files with 121 additions and 1 deletions

View file

@ -441,6 +441,20 @@ static void check_canonical_NaN(void)
check_fpstatus(usr, 0);
}
static void check_invsqrta(void)
{
int result;
int predval;
asm volatile("%0,p0 = sfinvsqrta(%2)\n\t"
"%1 = p0\n\t"
: "+r"(result), "=r"(predval)
: "r"(0x7f800000)
: "p0");
check32(result, 0xff800000);
check32(predval, 0x0);
}
static void check_float2int_convs()
{
int res32;
@ -590,6 +604,7 @@ int main()
check_dfminmax();
check_recip_exception();
check_canonical_NaN();
check_invsqrta();
check_float2int_convs();
puts(err ? "FAIL" : "PASS");

View file

@ -31,6 +31,20 @@ static int sfrecipa(int Rs, int Rt, int *pred_result)
return result;
}
static int sfinvsqrta(int Rs, int *pred_result)
{
int result;
int predval;
asm volatile("%0,p0 = sfinvsqrta(%2)\n\t"
"%1 = p0\n\t"
: "+r"(result), "=r"(predval)
: "r"(Rs)
: "p0");
*pred_result = predval;
return result;
}
int err;
static void check(int val, int expect)
@ -59,9 +73,24 @@ static void test_sfrecipa()
check_p(pred_result, 0x00);
}
static void test_sfinvsqrta()
{
int res;
int pred_result;
res = sfinvsqrta(0x04030201, &pred_result);
check(res, 0x4d330000);
check_p(pred_result, 0xe0);
res = sfinvsqrta(0x0, &pred_result);
check(res, 0x3f800000);
check_p(pred_result, 0x0);
}
int main()
{
test_sfrecipa();
test_sfinvsqrta();
puts(err ? "FAIL" : "PASS");
return err;