1 #include <assert.h> 2 #include <inttypes.h> 3 #include <string.h> 4 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; \ 11 \ 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); \ 23 } 24 25 TEST_PCADDU(pcaddi) 26 TEST_PCADDU(pcaddu12i) 27 TEST_PCADDU(pcaddu18i) 28 TEST_PCADDU(pcalau12i) 29 30 int main() 31 { 32 test_pcaddi(2); 33 test_pcaddu12i(12); 34 test_pcaddu18i(18); 35 test_pcalau12i(12); 36 37 return 0; 38 } 39