From 76ec1a2f0aba7863d5704cf56f9bf07e1435cdaf Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 2 Jul 2020 19:55:30 +1000 Subject: [PATCH] tests/fpu: Add tests for lfs and stfs instructions This exercises the single-to-double and double-to-single conversions, including denormalized cases. Signed-off-by: Paul Mackerras --- tests/fpu/fpu.c | 69 ++++++++++++++++++++++++++++++++++++- tests/test_fpu.bin | Bin 8208 -> 8384 bytes tests/test_fpu.console_out | 1 + 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/tests/fpu/fpu.c b/tests/fpu/fpu.c index d61b36e..86636b6 100644 --- a/tests/fpu/fpu.c +++ b/tests/fpu/fpu.c @@ -163,6 +163,72 @@ int fpu_test_2(void) return 0; } +struct sp_dp_equiv { + unsigned int sp; + unsigned long dp; +} sp_dp_equiv[] = { + { 0, 0 }, + { 0x80000000, 0x8000000000000000 }, + { 0x7f800000, 0x7ff0000000000000 }, + { 0xff800000, 0xfff0000000000000 }, + { 0x7f812345, 0x7ff02468a0000000 }, + { 0x456789ab, 0x40acf13560000000 }, + { 0x12345678, 0x3a468acf00000000 }, + { 0x00400000, 0x3800000000000000 }, + { 0x00200000, 0x37f0000000000000 }, + { 0x00000002, 0x36b0000000000000 }, + { 0x00000001, 0x36a0000000000000 }, +}; + +int sp_to_dp(long arg) +{ + unsigned long dp; + + __asm__("lfs 20,0(%0); stfd 20,0(%1)" + : : "b" (&sp_dp_equiv[arg].sp), "b" (&dp) : "memory"); + if (dp != sp_dp_equiv[arg].dp) { + print_hex(sp_dp_equiv[arg].sp, 8); + print_string(" "); + print_hex(dp, 16); + print_string(" "); + print_hex(sp_dp_equiv[arg].dp, 16); + print_string(" "); + } + return dp != sp_dp_equiv[arg].dp; +} + +int dp_to_sp(long arg) +{ + unsigned int sp; + + __asm__("lfd 21,0(%0); stfs 21,0(%1)" + : : "b" (&sp_dp_equiv[arg].dp), "b" (&sp) : "memory"); + return sp != sp_dp_equiv[arg].sp; +} + +int fpu_test_3(void) +{ + int i, n, ret; + + n = sizeof(sp_dp_equiv) / sizeof(sp_dp_equiv[0]); + enable_fp(); + for (i = 0; i < n; ++i) { + ret = trapit(i, sp_to_dp); + if (ret != 0) { + if (ret == 1) + ret += i; + return ret; + } + ret = trapit(i, dp_to_sp); + if (ret != 0) { + if (ret == 1) + ret += i + 0x10000; + return ret; + } + } + return 0; +} + int fail = 0; void do_test(int num, int (*test)(void)) @@ -176,7 +242,7 @@ void do_test(int num, int (*test)(void)) } else { fail = 1; print_string("FAIL "); - print_hex(ret, 4); + print_hex(ret, 5); print_string(" SRR0="); print_hex(mfspr(SRR0), 16); print_string(" SRR1="); @@ -191,6 +257,7 @@ int main(void) do_test(1, fpu_test_1); do_test(2, fpu_test_2); + do_test(3, fpu_test_3); return fail; } diff --git a/tests/test_fpu.bin b/tests/test_fpu.bin index 885368a70cc97cc929c62934658553ed4b131143..fb2de320a0017dc482942a6d0b32d6b5b480a309 100755 GIT binary patch delta 1747 zcmZuxZERCz6h8NMbQR{jZAa<4QMwNnHYYA@%)1p?tBlM}$3h6vAI8px2tyN8esrVk z-b?lah#^~ELuN8yAd;y>x5y7;g4r-J42>T|jC_C1WX;A>P_bCx^?BP{gv67a+;g7y zd7pdEdEa~c0%O6&M1g0CLLJ}chPv?FKqa9LqA;+{z%~Qhyg~0@Tr27Quhhy{T%&t_ zcw(7ilr|8>&(Cn)N?;3DjOQ9i7x=_?M5oUG^vD|9qj*XM#Rkf3o30V6Z#GkQSJ9?e9_mRFG1-q#&b6_S!aW6*Cwq#1*+} z#x;25WDd2k8K;}+1$Ej0gvHb$K9%HGr;k`{v6DD8iF_CWg*ktH#Sl1Tl=hDTpMwUY zsq5Me#A0n2Yabv!B6r6`^Jh$a1h|pLx25spCjKSxzW)x1ZFAZ~qOq%J?2cI^ZV^s5 ztZsR`S6v9M$Yta&zSFBdZsr!`JKyb9@1+M{qKaB&gZ0d>m|L9wnkj5E*k|*59!~3B zhomq&>-s#u*tn*WFVx|qP#1W67c{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V&>{ua$ukV6B9*Yl)d+9BB{$&NAc*_1VC9Bi^m*a$~)0mr}&JEx?4{&}h zAC7iuH1ETx*^T37118Mg&DXv&Hcd5dT5{4u=m%pCTDftikPi^E(#oxld@uRMA9%_l z6@@8O(s;#EU&pFC`Tqd{v YVk~s~oNZ9N9knT9X?lzBdWmtxZwLKkHUIzs diff --git a/tests/test_fpu.console_out b/tests/test_fpu.console_out index 0c39ae3..623335d 100644 --- a/tests/test_fpu.console_out +++ b/tests/test_fpu.console_out @@ -1,2 +1,3 @@ test 01:PASS test 02:PASS +test 03:PASS -- 2.30.2