Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / loongarch64 / test_pcadd.c
blobda2a64db82764b8bf33a575160c608a8b32aeea5
1 #include <assert.h>
2 #include <inttypes.h>
3 #include <string.h>
5 #define TEST_PCADDU(N) \
6 void test_##N(int a) \
7 { \
8 uint64_t rd1 = 0; \
9 uint64_t rd2 = 0; \
10 uint64_t rm, rn; \
12 asm volatile(""#N" %0, 0x104\n\t" \
13 ""#N" %1, 0x12345\n\t" \
14 : "=r"(rd1), "=r"(rd2) \
15 : ); \
16 rm = rd2 - rd1; \
17 if (!strcmp(#N, "pcalau12i")) { \
18 rn = ((0x12345UL - 0x104) << a) & ~0xfff; \
19 } else { \
20 rn = ((0x12345UL - 0x104) << a) + 4; \
21 } \
22 assert(rm == rn); \
25 TEST_PCADDU(pcaddi)
26 TEST_PCADDU(pcaddu12i)
27 TEST_PCADDU(pcaddu18i)
28 TEST_PCADDU(pcalau12i)
30 int main()
32 test_pcaddi(2);
33 test_pcaddu12i(12);
34 test_pcaddu18i(18);
35 test_pcalau12i(12);
37 return 0;