root / tests / tcg / cris / check_bound.c @ c09015dd
History | View | Annotate | Download (2.4 kB)
1 | dd43edf4 | ths | #include <stdio.h> |
---|---|---|---|
2 | dd43edf4 | ths | #include <stdlib.h> |
3 | dd43edf4 | ths | #include <stdint.h> |
4 | dd43edf4 | ths | #include "sys.h" |
5 | dd43edf4 | ths | #include "crisutils.h" |
6 | dd43edf4 | ths | |
7 | 4a6648f4 | Blue Swirl | static inline int cris_bound_b(int v, int b) |
8 | 4a6648f4 | Blue Swirl | { |
9 | dd43edf4 | ths | int r = v;
|
10 | dd43edf4 | ths | asm ("bound.b\t%1, %0\n" : "+r" (r) : "ri" (b)); |
11 | dd43edf4 | ths | return r;
|
12 | dd43edf4 | ths | } |
13 | dd43edf4 | ths | |
14 | 4a6648f4 | Blue Swirl | static inline int cris_bound_w(int v, int b) |
15 | 4a6648f4 | Blue Swirl | { |
16 | dd43edf4 | ths | int r = v;
|
17 | dd43edf4 | ths | asm ("bound.w\t%1, %0\n" : "+r" (r) : "ri" (b)); |
18 | dd43edf4 | ths | return r;
|
19 | dd43edf4 | ths | } |
20 | dd43edf4 | ths | |
21 | 4a6648f4 | Blue Swirl | static inline int cris_bound_d(int v, int b) |
22 | 4a6648f4 | Blue Swirl | { |
23 | dd43edf4 | ths | int r = v;
|
24 | dd43edf4 | ths | asm ("bound.d\t%1, %0\n" : "+r" (r) : "ri" (b)); |
25 | dd43edf4 | ths | return r;
|
26 | dd43edf4 | ths | } |
27 | dd43edf4 | ths | |
28 | dd43edf4 | ths | int main(void) |
29 | dd43edf4 | ths | { |
30 | dd43edf4 | ths | int r;
|
31 | dd43edf4 | ths | |
32 | dd43edf4 | ths | cris_tst_cc_init(); |
33 | dd43edf4 | ths | r = cris_bound_d(-1, 2); |
34 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
35 | dd43edf4 | ths | if (r != 2) |
36 | dd43edf4 | ths | err(); |
37 | dd43edf4 | ths | |
38 | dd43edf4 | ths | cris_tst_cc_init(); |
39 | dd43edf4 | ths | r = cris_bound_d(2, 0xffffffff); |
40 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
41 | dd43edf4 | ths | if (r != 2) |
42 | dd43edf4 | ths | err(); |
43 | dd43edf4 | ths | |
44 | dd43edf4 | ths | cris_tst_cc_init(); |
45 | dd43edf4 | ths | r = cris_bound_d(0xffff, 0xffff); |
46 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
47 | dd43edf4 | ths | if (r != 0xffff) |
48 | dd43edf4 | ths | err(); |
49 | dd43edf4 | ths | |
50 | dd43edf4 | ths | cris_tst_cc_init(); |
51 | dd43edf4 | ths | r = cris_bound_d(-1, 0xffffffff); |
52 | dd43edf4 | ths | cris_tst_cc(1, 0, 0, 0); |
53 | dd43edf4 | ths | if (r != 0xffffffff) |
54 | dd43edf4 | ths | err(); |
55 | dd43edf4 | ths | |
56 | dd43edf4 | ths | cris_tst_cc_init(); |
57 | dd43edf4 | ths | r = cris_bound_d(0x78134452, 0x5432f789); |
58 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
59 | dd43edf4 | ths | if (r != 0x5432f789) |
60 | dd43edf4 | ths | err(); |
61 | dd43edf4 | ths | |
62 | dd43edf4 | ths | cris_tst_cc_init(); |
63 | dd43edf4 | ths | r = cris_bound_w(-1, 2); |
64 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
65 | dd43edf4 | ths | if (r != 2) |
66 | dd43edf4 | ths | err(); |
67 | dd43edf4 | ths | |
68 | dd43edf4 | ths | cris_tst_cc_init(); |
69 | dd43edf4 | ths | r = cris_bound_w(-1, 0xffff); |
70 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
71 | dd43edf4 | ths | if (r != 0xffff) |
72 | dd43edf4 | ths | err(); |
73 | dd43edf4 | ths | |
74 | dd43edf4 | ths | cris_tst_cc_init(); |
75 | dd43edf4 | ths | r = cris_bound_w(2, 0xffff); |
76 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
77 | dd43edf4 | ths | if (r != 2) |
78 | dd43edf4 | ths | err(); |
79 | dd43edf4 | ths | |
80 | dd43edf4 | ths | cris_tst_cc_init(); |
81 | dd43edf4 | ths | r = cris_bound_w(0xfedaffff, 0xffff); |
82 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
83 | dd43edf4 | ths | if (r != 0xffff) |
84 | dd43edf4 | ths | err(); |
85 | dd43edf4 | ths | |
86 | dd43edf4 | ths | cris_tst_cc_init(); |
87 | dd43edf4 | ths | r = cris_bound_w(0x78134452, 0xf789); |
88 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
89 | dd43edf4 | ths | if (r != 0xf789) |
90 | dd43edf4 | ths | err(); |
91 | dd43edf4 | ths | |
92 | dd43edf4 | ths | cris_tst_cc_init(); |
93 | dd43edf4 | ths | r = cris_bound_b(-1, 2); |
94 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
95 | dd43edf4 | ths | if (r != 2) |
96 | dd43edf4 | ths | err(); |
97 | dd43edf4 | ths | |
98 | dd43edf4 | ths | cris_tst_cc_init(); |
99 | dd43edf4 | ths | r = cris_bound_b(2, 0xff); |
100 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
101 | dd43edf4 | ths | if (r != 2) |
102 | dd43edf4 | ths | err(); |
103 | dd43edf4 | ths | |
104 | dd43edf4 | ths | cris_tst_cc_init(); |
105 | dd43edf4 | ths | r = cris_bound_b(-1, 0xff); |
106 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
107 | dd43edf4 | ths | if (r != 0xff) |
108 | dd43edf4 | ths | err(); |
109 | dd43edf4 | ths | |
110 | dd43edf4 | ths | cris_tst_cc_init(); |
111 | dd43edf4 | ths | r = cris_bound_b(0xff, 0xff); |
112 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
113 | dd43edf4 | ths | if (r != 0xff) |
114 | dd43edf4 | ths | err(); |
115 | dd43edf4 | ths | |
116 | dd43edf4 | ths | cris_tst_cc_init(); |
117 | dd43edf4 | ths | r = cris_bound_b(0xfeda49ff, 0xff); |
118 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
119 | dd43edf4 | ths | if (r != 0xff) |
120 | dd43edf4 | ths | err(); |
121 | dd43edf4 | ths | |
122 | dd43edf4 | ths | cris_tst_cc_init(); |
123 | dd43edf4 | ths | r = cris_bound_b(0x78134452, 0x89); |
124 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
125 | dd43edf4 | ths | if (r != 0x89) |
126 | dd43edf4 | ths | err(); |
127 | dd43edf4 | ths | |
128 | dd43edf4 | ths | cris_tst_cc_init(); |
129 | dd43edf4 | ths | r = cris_bound_w(0x78134452, 0); |
130 | dd43edf4 | ths | cris_tst_cc(0, 1, 0, 0); |
131 | dd43edf4 | ths | if (r != 0) |
132 | dd43edf4 | ths | err(); |
133 | dd43edf4 | ths | |
134 | dd43edf4 | ths | cris_tst_cc_init(); |
135 | dd43edf4 | ths | r = cris_bound_b(0xffff, -1); |
136 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
137 | dd43edf4 | ths | if (r != 0xff) |
138 | dd43edf4 | ths | err(); |
139 | dd43edf4 | ths | |
140 | dd43edf4 | ths | pass(); |
141 | dd43edf4 | ths | return 0; |
142 | dd43edf4 | ths | } |