root / tests / tcg / cris / check_addo.c @ c09015dd
History | View | Annotate | Download (3 kB)
1 |
#include <stdio.h> |
---|---|
2 |
#include <stdlib.h> |
3 |
#include <stdint.h> |
4 |
#include "sys.h" |
5 |
#include "crisutils.h" |
6 |
|
7 |
/* this would be better to do in asm, it's an orgy in GCC inline asm now. */
|
8 |
|
9 |
#define cris_addo_b(o, v) \
|
10 |
asm volatile ("addo.b\t[%0], %1, $acr\n" : : "r" (o), "r" (v) : "acr"); |
11 |
#define cris_addo_w(o, v) \
|
12 |
asm volatile ("addo.w\t[%0], %1, $acr\n" : : "r" (o), "r" (v) : "acr"); |
13 |
#define cris_addo_d(o, v) \
|
14 |
asm volatile ("addo.d\t[%0], %1, $acr\n" : : "r" (o), "r" (v) : "acr"); |
15 |
#define cris_addo_pi_b(o, v) \
|
16 |
asm volatile ("addo.b\t[%0+], %1, $acr\n" \ |
17 |
: "+b" (o): "r" (v) : "acr"); |
18 |
#define cris_addo_pi_w(o, v) \
|
19 |
asm volatile ("addo.w\t[%0+], %1, $acr\n" \ |
20 |
: "+b" (o): "r" (v) : "acr"); |
21 |
#define cris_addo_pi_d(o, v) \
|
22 |
asm volatile ("addo.d\t[%0+], %1, $acr\n" \ |
23 |
: "+b" (o): "r" (v) : "acr"); |
24 |
|
25 |
struct {
|
26 |
uint32_t v1; |
27 |
uint16_t v2; |
28 |
uint32_t v3; |
29 |
uint8_t v4; |
30 |
uint8_t v5; |
31 |
uint16_t v6; |
32 |
uint32_t v7; |
33 |
} y = { |
34 |
32769,
|
35 |
-1,
|
36 |
5,
|
37 |
3, -4, |
38 |
2,
|
39 |
-76789887
|
40 |
}; |
41 |
|
42 |
static int x[3] = {0x55aa77ff, 0xccff2244, 0x88ccee19}; |
43 |
|
44 |
int main(void) |
45 |
{ |
46 |
int *r;
|
47 |
unsigned char *t, *p; |
48 |
|
49 |
/* Note, this test-case will trig an unaligned access, partly
|
50 |
to x[0] and to [x1]. */
|
51 |
t = (unsigned char *)x; |
52 |
t -= 32768;
|
53 |
p = (unsigned char *) &y.v1; |
54 |
mb(); /* dont reorder anything beyond here. */
|
55 |
cris_tst_cc_init(); |
56 |
asm volatile ("setf\tzvnc\n"); |
57 |
cris_addo_pi_d(p, t); |
58 |
cris_tst_cc(1, 1, 1, 1); |
59 |
asm volatile ("move.d\t$acr, %0\n" : "=r" (r)); |
60 |
if (*r != 0x4455aa77) |
61 |
err(); |
62 |
|
63 |
|
64 |
t += 32770;
|
65 |
mb(); /* dont reorder anything beyond here. */
|
66 |
cris_tst_cc_init(); |
67 |
asm volatile ("setf\tzvnc\n"); |
68 |
cris_addo_pi_w(p, t); |
69 |
cris_tst_cc(1, 1, 1, 1); |
70 |
asm volatile ("move.d\t$acr, %0\n" : "=r" (r)); |
71 |
if (*r != 0x4455aa77) |
72 |
err(); |
73 |
|
74 |
mb(); /* dont reorder anything beyond here. */
|
75 |
cris_tst_cc_init(); |
76 |
asm volatile ("setf\tzvnc\n"); |
77 |
cris_addo_d(p, r); |
78 |
cris_tst_cc(1, 1, 1, 1); |
79 |
p += 4;
|
80 |
asm volatile ("move.d\t$acr, %0\n" : "=r" (r)); |
81 |
if (*r != 0xee19ccff) |
82 |
err(); |
83 |
|
84 |
mb(); /* dont reorder anything beyond here. */
|
85 |
cris_tst_cc_init(); |
86 |
asm volatile ("setf\tzvnc\n"); |
87 |
cris_addo_pi_b(p, t); |
88 |
cris_tst_cc(0, 0, 0, 0); |
89 |
asm volatile ("move.d\t$acr, %0\n" : "=r" (r)); |
90 |
if (*(uint16_t*)r != 0xff22) |
91 |
err(); |
92 |
|
93 |
mb(); /* dont reorder anything beyond here. */
|
94 |
cris_tst_cc_init(); |
95 |
asm volatile ("setf\tzvnc\n"); |
96 |
cris_addo_b(p, r); |
97 |
cris_tst_cc(1, 1, 1, 1); |
98 |
p += 1;
|
99 |
asm volatile ("move.d\t$acr, %0\n" : "=r" (r)); |
100 |
if (*r != 0x4455aa77) |
101 |
err(); |
102 |
|
103 |
mb(); /* dont reorder anything beyond here. */
|
104 |
cris_tst_cc_init(); |
105 |
asm volatile ("setf\tzvnc\n"); |
106 |
cris_addo_w(p, r); |
107 |
cris_tst_cc(1, 1, 1, 1); |
108 |
p += 2;
|
109 |
asm volatile ("move.d\t$acr, %0\n" : "=r" (r)); |
110 |
if (*r != 0xff224455) |
111 |
err(); |
112 |
|
113 |
mb(); /* dont reorder anything beyond here. */
|
114 |
cris_tst_cc_init(); |
115 |
asm volatile ("setf\tzvnc\n"); |
116 |
cris_addo_pi_d(p, t); |
117 |
cris_tst_cc(0, 0, 0, 0); |
118 |
asm volatile ("move.d\t$acr, %0\n" : "=r" (r)); |
119 |
r = (void*)(((char *)r) + 76789885); |
120 |
if (*r != 0x55aa77ff) |
121 |
err(); |
122 |
|
123 |
pass(); |
124 |
return 0; |
125 |
} |