Skip to content

Commit 44add9e

Browse files
committed
tests/tcg/ppc64: Add mffsce test
Add mffsce test to check both the return value and the new fpscr stored in the cpu. Signed-off-by: Víctor Colombo <[email protected]>
1 parent f564391 commit 44add9e

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

tests/tcg/ppc64/Makefile.target

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ endif
1111
$(PPC64_TESTS): CFLAGS += -mpower8-vector
1212

1313
PPC64_TESTS += mtfsf
14+
PPC64_TEST += mffsce
1415

1516
ifneq ($(CROSS_CC_HAS_POWER10),)
1617
PPC64_TESTS += byte_reverse sha512-vector

tests/tcg/ppc64le/Makefile.target

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ run-sha512-vector: QEMU_OPTS+=-cpu POWER10
2424
run-plugin-sha512-vector-with-%: QEMU_OPTS+=-cpu POWER10
2525

2626
PPC64LE_TESTS += mtfsf
27+
PPC64LE_TESTS += mffsce
2728
PPC64LE_TESTS += signal_save_restore_xer
2829
PPC64LE_TESTS += xxspltw
2930

tests/tcg/ppc64le/mffsce.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <stdlib.h>
2+
#include <stdint.h>
3+
#include <assert.h>
4+
5+
#define MTFSF(FLM, FRB) asm volatile ("mtfsf %0, %1" :: "i" (FLM), "f" (FRB))
6+
#define MFFS(FRT) asm("mffs %0" : "=f" (FRT))
7+
#define MFFSCE(FRT) asm("mffsce %0" : "=f" (FRT))
8+
9+
#define PPC_BIT_NR(nr) (63 - (nr))
10+
11+
#define FP_VE (1ull << PPC_BIT_NR(56))
12+
#define FP_OE (1ull << PPC_BIT_NR(57))
13+
#define FP_UE (1ull << PPC_BIT_NR(58))
14+
#define FP_ZE (1ull << PPC_BIT_NR(59))
15+
#define FP_XE (1ull << PPC_BIT_NR(60))
16+
#define FP_NI (1ull << PPC_BIT_NR(61))
17+
#define FP_RN0 (1ull << PPC_BIT_NR(62))
18+
#define FP_RN1 (1ull << PPC_BIT_NR(63))
19+
20+
int main(void)
21+
{
22+
uint64_t frt, fpscr;
23+
uint64_t last_8_bits = FP_VE | FP_UE | FP_ZE |
24+
FP_XE | FP_NI | FP_RN1;
25+
MTFSF(0b11111111, last_8_bits); // set test value to cpu fpscr
26+
MFFSCE(frt);
27+
MFFS(fpscr);
28+
29+
// in the returned value
30+
// should be as the cpu fpscr was before
31+
assert((frt & 0xff) == last_8_bits);
32+
33+
// in the cpu fpscr
34+
// last 3 bits should be unchanged and enable bits should be unset
35+
assert((fpscr & 0xff) == (FP_NI | FP_RN1));
36+
37+
return 0;
38+
}

0 commit comments

Comments
 (0)