Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/tcg/ppc64: Add mffsce test #86

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/tcg/ppc64/Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ endif
$(PPC64_TESTS): CFLAGS += -mpower8-vector

PPC64_TESTS += mtfsf
PPC64_TESTS += mffsce

ifneq ($(CROSS_CC_HAS_POWER10),)
PPC64_TESTS += byte_reverse sha512-vector
Expand Down
1 change: 1 addition & 0 deletions tests/tcg/ppc64le/Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ run-sha512-vector: QEMU_OPTS+=-cpu POWER10
run-plugin-sha512-vector-with-%: QEMU_OPTS+=-cpu POWER10

PPC64LE_TESTS += mtfsf
PPC64LE_TESTS += mffsce
PPC64LE_TESTS += signal_save_restore_xer
PPC64LE_TESTS += xxspltw

Expand Down
38 changes: 38 additions & 0 deletions tests/tcg/ppc64le/mffsce.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>

#define MTFSF(FLM, FRB) asm volatile ("mtfsf %0, %1" :: "i" (FLM), "f" (FRB))
#define MFFS(FRT) asm("mffs %0" : "=f" (FRT))
#define MFFSCE(FRT) asm("mffsce %0" : "=f" (FRT))

#define PPC_BIT_NR(nr) (63 - (nr))

#define FP_VE (1ull << PPC_BIT_NR(56))
#define FP_OE (1ull << PPC_BIT_NR(57))
#define FP_UE (1ull << PPC_BIT_NR(58))
#define FP_ZE (1ull << PPC_BIT_NR(59))
#define FP_XE (1ull << PPC_BIT_NR(60))
#define FP_NI (1ull << PPC_BIT_NR(61))
#define FP_RN0 (1ull << PPC_BIT_NR(62))
#define FP_RN1 (1ull << PPC_BIT_NR(63))
luporl marked this conversation as resolved.
Show resolved Hide resolved

int main(void)
{
uint64_t frt, fpscr;
uint64_t last_8_bits = FP_VE | FP_UE | FP_ZE |
FP_XE | FP_NI | FP_RN1;
MTFSF(0b11111111, last_8_bits); // set test value to cpu fpscr
luporl marked this conversation as resolved.
Show resolved Hide resolved
MFFSCE(frt);
MFFS(fpscr);

// in the returned value
// should be as the cpu fpscr was before
luporl marked this conversation as resolved.
Show resolved Hide resolved
assert((frt & 0xff) == last_8_bits);

// in the cpu fpscr
// last 3 bits should be unchanged and enable bits should be unset
assert((fpscr & 0xff) == (last_8_bits & 0x7));

return 0;
}