]> git.proxmox.com Git - qemu.git/blob - tests/cris/check_addcm.c
configure: Copy test data to build directory
[qemu.git] / tests / cris / check_addcm.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include "sys.h"
5 #include "crisutils.h"
6
7 /* need to avoid acr as source here. */
8 static inline int cris_addc_m(int a, const int *b)
9 {
10 asm volatile ("addc [%1], %0\n" : "+r" (a) : "r" (b));
11 return a;
12 }
13
14 /* 'b' is a crisv32 constrain to avoid postinc with $acr. */
15 static inline int cris_addc_pi_m(int a, int **b)
16 {
17 asm volatile ("addc [%1+], %0\n" : "+r" (a), "+b" (*b));
18 return a;
19 }
20
21 #define verify_addc_m(a, b, res, n, z, v, c) \
22 { \
23 int r; \
24 r = cris_addc_m((a), (b)); \
25 cris_tst_cc((n), (z), (v), (c)); \
26 if (r != (res)) \
27 err(); \
28 }
29
30 #define verify_addc_pi_m(a, b, res, n, z, v, c) \
31 { \
32 int r; \
33 r = cris_addc_pi_m((a), (b)); \
34 cris_tst_cc((n), (z), (v), (c)); \
35 if (r != (res)) \
36 err(); \
37 }
38
39 int x[] = { 0, 0, 2, -1, 0xffff, -1, 0x5432f789};
40
41 int main(void)
42 {
43 int *p = (void *)&x[0];
44 #if 1
45 cris_tst_cc_init();
46 asm volatile ("clearf cz");
47 verify_addc_m(0, p, 0, 0, 0, 0, 0);
48
49 cris_tst_cc_init();
50 asm volatile ("setf z");
51 verify_addc_m(0, p, 0, 0, 1, 0, 0);
52
53 cris_tst_cc_init();
54 asm volatile ("setf c");
55 verify_addc_m(0, p, 1, 0, 0, 0, 0);
56
57 cris_tst_cc_init();
58 asm volatile ("clearf c");
59 verify_addc_pi_m(0, &p, 0, 0, 1, 0, 0);
60
61 p = &x[1];
62 cris_tst_cc_init();
63 asm volatile ("setf c");
64 verify_addc_pi_m(0, &p, 1, 0, 0, 0, 0);
65
66 if (p != &x[2])
67 err();
68
69 cris_tst_cc_init();
70 asm volatile ("clearf c");
71 verify_addc_pi_m(-1, &p, 1, 0, 0, 0, 1);
72
73 if (p != &x[3])
74 err();
75 #endif
76 p = &x[3];
77 /* TODO: investigate why this one fails. */
78 cris_tst_cc_init();
79 asm volatile ("setf c");
80 verify_addc_m(2, p, 2, 0, 0, 0, 1);
81 p += 4;
82
83 pass();
84 return 0;
85 }