migration: Define MultifdRecvParams sooner
[qemu/ar7.git] / tests / tcg / cris / check_bound.c
blobd956ab9adec3c3ab44a8d941683d988618172bdc
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include "sys.h"
5 #include "crisutils.h"
7 static always_inline int cris_bound_b(int v, int b)
9 int r = v;
10 asm ("bound.b\t%1, %0\n" : "+r" (r) : "ri" (b));
11 return r;
14 static always_inline int cris_bound_w(int v, int b)
16 int r = v;
17 asm ("bound.w\t%1, %0\n" : "+r" (r) : "ri" (b));
18 return r;
21 static always_inline int cris_bound_d(int v, int b)
23 int r = v;
24 asm ("bound.d\t%1, %0\n" : "+r" (r) : "ri" (b));
25 return r;
28 int main(void)
30 int r;
32 cris_tst_cc_init();
33 r = cris_bound_d(-1, 2);
34 cris_tst_cc(0, 0, 0, 0);
35 if (r != 2)
36 err();
38 cris_tst_cc_init();
39 r = cris_bound_d(2, 0xffffffff);
40 cris_tst_cc(0, 0, 0, 0);
41 if (r != 2)
42 err();
44 cris_tst_cc_init();
45 r = cris_bound_d(0xffff, 0xffff);
46 cris_tst_cc(0, 0, 0, 0);
47 if (r != 0xffff)
48 err();
50 cris_tst_cc_init();
51 r = cris_bound_d(-1, 0xffffffff);
52 cris_tst_cc(1, 0, 0, 0);
53 if (r != 0xffffffff)
54 err();
56 cris_tst_cc_init();
57 r = cris_bound_d(0x78134452, 0x5432f789);
58 cris_tst_cc(0, 0, 0, 0);
59 if (r != 0x5432f789)
60 err();
62 cris_tst_cc_init();
63 r = cris_bound_w(-1, 2);
64 cris_tst_cc(0, 0, 0, 0);
65 if (r != 2)
66 err();
68 cris_tst_cc_init();
69 r = cris_bound_w(-1, 0xffff);
70 cris_tst_cc(0, 0, 0, 0);
71 if (r != 0xffff)
72 err();
74 cris_tst_cc_init();
75 r = cris_bound_w(2, 0xffff);
76 cris_tst_cc(0, 0, 0, 0);
77 if (r != 2)
78 err();
80 cris_tst_cc_init();
81 r = cris_bound_w(0xfedaffff, 0xffff);
82 cris_tst_cc(0, 0, 0, 0);
83 if (r != 0xffff)
84 err();
86 cris_tst_cc_init();
87 r = cris_bound_w(0x78134452, 0xf789);
88 cris_tst_cc(0, 0, 0, 0);
89 if (r != 0xf789)
90 err();
92 cris_tst_cc_init();
93 r = cris_bound_b(-1, 2);
94 cris_tst_cc(0, 0, 0, 0);
95 if (r != 2)
96 err();
98 cris_tst_cc_init();
99 r = cris_bound_b(2, 0xff);
100 cris_tst_cc(0, 0, 0, 0);
101 if (r != 2)
102 err();
104 cris_tst_cc_init();
105 r = cris_bound_b(-1, 0xff);
106 cris_tst_cc(0, 0, 0, 0);
107 if (r != 0xff)
108 err();
110 cris_tst_cc_init();
111 r = cris_bound_b(0xff, 0xff);
112 cris_tst_cc(0, 0, 0, 0);
113 if (r != 0xff)
114 err();
116 cris_tst_cc_init();
117 r = cris_bound_b(0xfeda49ff, 0xff);
118 cris_tst_cc(0, 0, 0, 0);
119 if (r != 0xff)
120 err();
122 cris_tst_cc_init();
123 r = cris_bound_b(0x78134452, 0x89);
124 cris_tst_cc(0, 0, 0, 0);
125 if (r != 0x89)
126 err();
128 cris_tst_cc_init();
129 r = cris_bound_w(0x78134452, 0);
130 cris_tst_cc(0, 1, 0, 0);
131 if (r != 0)
132 err();
134 cris_tst_cc_init();
135 r = cris_bound_b(0xffff, -1);
136 cris_tst_cc(0, 0, 0, 0);
137 if (r != 0xff)
138 err();
140 pass();
141 return 0;