mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
Hexagon (target/hexagon) Additional instructions handled by idef-parser
**** Changes in v3 **** Fix bugs exposed by dpmpyss_rnd_s0 instruction Set correct size/signedness for constants Test cases added to tests/tcg/hexagon/misc.c **** Changes in v2 **** Fix bug in imm_print identified in clang build Currently, idef-parser skips all floating point instructions. However, there are some floating point instructions that can be handled. The following instructions are now parsed F2_sfimm_p F2_sfimm_n F2_dfimm_p F2_dfimm_n F2_dfmpyll F2_dfmpylh To make these instructions work, we fix some bugs in parser-helpers.c gen_rvalue_extend gen_cast_op imm_print lexer properly sets size/signedness of constants Test cases added to tests/tcg/hexagon/fpstuff.c Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> Tested-by: Anton Johansson <anjo@rev.ng> Reviewed-by: Anton Johansson <anjo@rev.ng> Message-Id: <20230501203125.4025991-1-tsimpson@quicinc.com>
This commit is contained in:
parent
0fc56c4375
commit
163e5fa38e
7 changed files with 160 additions and 41 deletions
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <float.h>
|
||||
|
||||
const int FPINVF_BIT = 1; /* Invalid */
|
||||
const int FPINVF = 1 << FPINVF_BIT;
|
||||
|
@ -706,6 +707,57 @@ static void check_float2int_convs()
|
|||
check_fpstatus(usr, FPINVF);
|
||||
}
|
||||
|
||||
static void check_float_consts(void)
|
||||
{
|
||||
int res32;
|
||||
unsigned long long res64;
|
||||
|
||||
asm("%0 = sfmake(#%1):neg\n\t" : "=r"(res32) : "i"(0xf));
|
||||
check32(res32, 0xbc9e0000);
|
||||
|
||||
asm("%0 = sfmake(#%1):pos\n\t" : "=r"(res32) : "i"(0xf));
|
||||
check32(res32, 0x3c9e0000);
|
||||
|
||||
asm("%0 = dfmake(#%1):neg\n\t" : "=r"(res64) : "i"(0xf));
|
||||
check64(res64, 0xbf93c00000000000ULL);
|
||||
|
||||
asm("%0 = dfmake(#%1):pos\n\t" : "=r"(res64) : "i"(0xf));
|
||||
check64(res64, 0x3f93c00000000000ULL);
|
||||
}
|
||||
|
||||
static inline unsigned long long dfmpyll(double x, double y)
|
||||
{
|
||||
unsigned long long res64;
|
||||
asm("%0 = dfmpyll(%1, %2)" : "=r"(res64) : "r"(x), "r"(y));
|
||||
return res64;
|
||||
}
|
||||
|
||||
static inline unsigned long long dfmpylh(double acc, double x, double y)
|
||||
{
|
||||
unsigned long long res64 = *(unsigned long long *)&acc;
|
||||
asm("%0 += dfmpylh(%1, %2)" : "+r"(res64) : "r"(x), "r"(y));
|
||||
return res64;
|
||||
}
|
||||
|
||||
static void check_dfmpyxx(void)
|
||||
{
|
||||
unsigned long long res64;
|
||||
|
||||
res64 = dfmpyll(DBL_MIN, DBL_MIN);
|
||||
check64(res64, 0ULL);
|
||||
res64 = dfmpyll(-1.0, DBL_MIN);
|
||||
check64(res64, 0ULL);
|
||||
res64 = dfmpyll(DBL_MAX, DBL_MAX);
|
||||
check64(res64, 0x1fffffffdULL);
|
||||
|
||||
res64 = dfmpylh(DBL_MIN, DBL_MIN, DBL_MIN);
|
||||
check64(res64, 0x10000000000000ULL);
|
||||
res64 = dfmpylh(-1.0, DBL_MAX, DBL_MIN);
|
||||
check64(res64, 0xc00fffffffe00000ULL);
|
||||
res64 = dfmpylh(DBL_MAX, 0.0, -1.0);
|
||||
check64(res64, 0x7fefffffffffffffULL);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
check_compare_exception();
|
||||
|
@ -718,6 +770,8 @@ int main()
|
|||
check_sffixupd();
|
||||
check_sffms();
|
||||
check_float2int_convs();
|
||||
check_float_consts();
|
||||
check_dfmpyxx();
|
||||
|
||||
puts(err ? "FAIL" : "PASS");
|
||||
return err ? 1 : 0;
|
||||
|
|
|
@ -391,6 +391,39 @@ void test_count_trailing_zeros_ones(void)
|
|||
check(ct1p(0xffffff0fffffffffULL), 36);
|
||||
}
|
||||
|
||||
static inline int dpmpyss_rnd_s0(int x, int y)
|
||||
{
|
||||
int res;
|
||||
asm("%0 = mpy(%1, %2):rnd\n\t" : "=r"(res) : "r"(x), "r"(y));
|
||||
return res;
|
||||
}
|
||||
|
||||
void test_dpmpyss_rnd_s0(void)
|
||||
{
|
||||
check(dpmpyss_rnd_s0(-1, 0x80000000), 1);
|
||||
check(dpmpyss_rnd_s0(0, 0x80000000), 0);
|
||||
check(dpmpyss_rnd_s0(1, 0x80000000), 0);
|
||||
check(dpmpyss_rnd_s0(0x7fffffff, 0x80000000), 0xc0000001);
|
||||
check(dpmpyss_rnd_s0(0x80000000, -1), 1);
|
||||
check(dpmpyss_rnd_s0(-1, -1), 0);
|
||||
check(dpmpyss_rnd_s0(0, -1), 0);
|
||||
check(dpmpyss_rnd_s0(1, -1), 0);
|
||||
check(dpmpyss_rnd_s0(0x7fffffff, -1), 0);
|
||||
check(dpmpyss_rnd_s0(0x80000000, 0), 0);
|
||||
check(dpmpyss_rnd_s0(-1, 0), 0);
|
||||
check(dpmpyss_rnd_s0(0, 0), 0);
|
||||
check(dpmpyss_rnd_s0(1, 0), 0);
|
||||
check(dpmpyss_rnd_s0(-1, -1), 0);
|
||||
check(dpmpyss_rnd_s0(0, -1), 0);
|
||||
check(dpmpyss_rnd_s0(1, -1), 0);
|
||||
check(dpmpyss_rnd_s0(0x7fffffff, 1), 0);
|
||||
check(dpmpyss_rnd_s0(0x80000000, 0x7fffffff), 0xc0000001);
|
||||
check(dpmpyss_rnd_s0(-1, 0x7fffffff), 0);
|
||||
check(dpmpyss_rnd_s0(0, 0x7fffffff), 0);
|
||||
check(dpmpyss_rnd_s0(1, 0x7fffffff), 0);
|
||||
check(dpmpyss_rnd_s0(0x7fffffff, 0x7fffffff), 0x3fffffff);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int res;
|
||||
|
@ -534,6 +567,8 @@ int main()
|
|||
|
||||
test_count_trailing_zeros_ones();
|
||||
|
||||
test_dpmpyss_rnd_s0();
|
||||
|
||||
puts(err ? "FAIL" : "PASS");
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue