Skip to content

Commit

Permalink
Hexagon (tests/tcg/hexagon) update overflow test
Browse files Browse the repository at this point in the history
Add a test that sets USR multiple times in a packet

Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
Message-Id: <20220210021556.9217-9-tsimpson@quicinc.com>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
taylorsimpson committed Mar 12, 2022
1 parent 2479540 commit 8576e7e
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion tests/tcg/hexagon/overflow.c
@@ -1,5 +1,5 @@
/*
* Copyright(c) 2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
* Copyright(c) 2021-2022 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
Expand Down Expand Up @@ -72,6 +72,20 @@ int read_usr_overflow(void)
return result & 1;
}

int get_usr_overflow(int usr)
{
return usr & 1;
}

int get_usr_fp_invalid(int usr)
{
return (usr >> 1) & 1;
}

int get_usr_lpcfg(int usr)
{
return (usr >> 8) & 0x3;
}

jmp_buf jmp_env;
int usr_overflow;
Expand All @@ -82,6 +96,49 @@ static void sig_segv(int sig, siginfo_t *info, void *puc)
longjmp(jmp_env, 1);
}

static void test_packet(void)
{
int convres;
int satres;
int usr;

asm("r2 = usr\n\t"
"r2 = clrbit(r2, #0)\n\t" /* clear overflow bit */
"r2 = clrbit(r2, #1)\n\t" /* clear FP invalid bit */
"usr = r2\n\t"
"{\n\t"
" %0 = convert_sf2uw(%3):chop\n\t"
" %1 = satb(%4)\n\t"
"}\n\t"
"%2 = usr\n\t"
: "=r"(convres), "=r"(satres), "=r"(usr)
: "r"(0x6a051b86), "r"(0x0410eec0)
: "r2", "usr");

check(convres, 0xffffffff);
check(satres, 0x7f);
check(get_usr_overflow(usr), 1);
check(get_usr_fp_invalid(usr), 1);

asm("r2 = usr\n\t"
"r2 = clrbit(r2, #0)\n\t" /* clear overflow bit */
"usr = r2\n\t"
"%2 = r2\n\t"
"p3 = sp3loop0(1f, #1)\n\t"
"1:\n\t"
"{\n\t"
" %0 = satb(%2)\n\t"
"}:endloop0\n\t"
"%1 = usr\n\t"
: "=r"(satres), "=r"(usr)
: "r"(0x0410eec0)
: "r2", "usr", "p3", "sa0", "lc0");

check(satres, 0x7f);
check(get_usr_overflow(usr), 1);
check(get_usr_lpcfg(usr), 2);
}

int main()
{
struct sigaction act;
Expand All @@ -102,6 +159,8 @@ int main()

check(usr_overflow, 0);

test_packet();

puts(err ? "FAIL" : "PASS");
return err ? EXIT_FAILURE : EXIT_SUCCESS;
}

0 comments on commit 8576e7e

Please sign in to comment.