qemu-e2k/tests/tcg/ppc64/xxspltw.c
Paolo Bonzini 37b0dba45c tests/tcg: unify ppc64 and ppc64le Makefiles
Make tests/tcg/ppc64le include tests/tcg/ppc64 instead of duplicating
the rules.  Because the ppc64le vpath includes tests/tcg/ppc64 but
not vice versa, the tests have to be moved from tests/tcg/ppc64le/
to tests/tcg/ppc64.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220929114231.583801-23-alex.bennee@linaro.org>
2022-10-06 11:53:40 +01:00

47 lines
2.0 KiB
C

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <assert.h>
#define WORD_A 0xAAAAAAAAUL
#define WORD_B 0xBBBBBBBBUL
#define WORD_C 0xCCCCCCCCUL
#define WORD_D 0xDDDDDDDDUL
#define DWORD_HI (WORD_A << 32 | WORD_B)
#define DWORD_LO (WORD_C << 32 | WORD_D)
#define TEST(HI, LO, UIM, RES) \
do { \
union { \
uint64_t u; \
double f; \
} h = { .u = HI }, l = { .u = LO }; \
/* \
* Use a pair of FPRs to load the VSR avoiding insns \
* newer than xxswapd. \
*/ \
asm("xxmrghd 32, %0, %1\n\t" \
"xxspltw 32, 32, %2\n\t" \
"xxmrghd %0, 32, %0\n\t" \
"xxswapd 32, 32\n\t" \
"xxmrghd %1, 32, %1\n\t" \
: "+f" (h.f), "+f" (l.f) \
: "i" (UIM) \
: "v0"); \
printf("xxspltw(0x%016" PRIx64 "%016" PRIx64 ", %d) =" \
" %016" PRIx64 "%016" PRIx64 "\n", HI, LO, UIM, \
h.u, l.u); \
assert(h.u == (RES)); \
assert(l.u == (RES)); \
} while (0)
int main(void)
{
TEST(DWORD_HI, DWORD_LO, 0, WORD_A << 32 | WORD_A);
TEST(DWORD_HI, DWORD_LO, 1, WORD_B << 32 | WORD_B);
TEST(DWORD_HI, DWORD_LO, 2, WORD_C << 32 | WORD_C);
TEST(DWORD_HI, DWORD_LO, 3, WORD_D << 32 | WORD_D);
return 0;
}