hw/loongarch: Remove unimplemented extioi INT_encode mode
[qemu/ar7.git] / tests / tcg / loongarch64 / test_div.c
blob6c31fe97aebded9c29df6bbd61684342d6face15
1 #include <assert.h>
2 #include <inttypes.h>
3 #include <stdio.h>
5 #define TEST_DIV(N, M) \
6 static void test_div_ ##N(uint ## M ## _t rj, \
7 uint ## M ## _t rk, \
8 uint64_t rm) \
9 { \
10 uint64_t rd = 0; \
12 asm volatile("div."#N" %0,%1,%2\n\t" \
13 : "=r"(rd) \
14 : "r"(rj), "r"(rk) \
15 : ); \
16 assert(rd == rm); \
19 #define TEST_MOD(N, M) \
20 static void test_mod_ ##N(uint ## M ## _t rj, \
21 uint ## M ## _t rk, \
22 uint64_t rm) \
23 { \
24 uint64_t rd = 0; \
26 asm volatile("mod."#N" %0,%1,%2\n\t" \
27 : "=r"(rd) \
28 : "r"(rj), "r"(rk) \
29 : ); \
30 assert(rd == rm); \
33 TEST_DIV(w, 32)
34 TEST_DIV(wu, 32)
35 TEST_DIV(d, 64)
36 TEST_DIV(du, 64)
37 TEST_MOD(w, 32)
38 TEST_MOD(wu, 32)
39 TEST_MOD(d, 64)
40 TEST_MOD(du, 64)
42 int main(void)
44 test_div_w(0xffaced97, 0xc36abcde, 0x0);
45 test_div_wu(0xffaced97, 0xc36abcde, 0x1);
46 test_div_d(0xffaced973582005f, 0xef56832a358b, 0xffffffffffffffa8);
47 test_div_du(0xffaced973582005f, 0xef56832a358b, 0x11179);
48 test_mod_w(0x7cf18c32, 0xa04da650, 0x1d3f3282);
49 test_mod_wu(0x7cf18c32, 0xc04da650, 0x7cf18c32);
50 test_mod_d(0x7cf18c3200000000, 0xa04da65000000000, 0x1d3f328200000000);
51 test_mod_du(0x7cf18c3200000000, 0xc04da65000000000, 0x7cf18c3200000000);
53 return 0;