Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / ppc64 / mffsce.c
blob20d882cb4568d05209ddff8decdaf12d46c49f33
1 #include <stdlib.h>
2 #include <stdint.h>
3 #include <assert.h>
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))
9 #define PPC_BIT_NR(nr) (63 - (nr))
11 #define FP_VE (1ull << PPC_BIT_NR(56))
12 #define FP_UE (1ull << PPC_BIT_NR(58))
13 #define FP_ZE (1ull << PPC_BIT_NR(59))
14 #define FP_XE (1ull << PPC_BIT_NR(60))
15 #define FP_NI (1ull << PPC_BIT_NR(61))
16 #define FP_RN1 (1ull << PPC_BIT_NR(63))
18 int main(void)
20 uint64_t frt, fpscr;
21 uint64_t test_value = FP_VE | FP_UE | FP_ZE |
22 FP_XE | FP_NI | FP_RN1;
23 MTFSF(0b11111111, test_value); /* set test value to cpu fpscr */
24 MFFSCE(frt);
25 MFFS(fpscr); /* read the value that mffsce stored to cpu fpscr */
27 /* the returned value should be as the cpu fpscr was before */
28 assert((frt & 0xff) == test_value);
31 * the cpu fpscr last 3 bits should be unchanged
32 * and enable bits should be unset
34 assert((fpscr & 0xff) == (test_value & 0x7));
36 return 0;