2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr54760-2.c
blobbad478c97b5afb8e3559798fc45bb4a5220a1ef8
1 /* Check that thread pointer relative memory accesses are converted to
2 gbr displacement address modes. If we see a gbr register store
3 instruction something is not working properly. */
4 /* { dg-do compile } */
5 /* { dg-options "-O1" } */
6 /* { dg-final { scan-assembler-times "stc\tgbr" 0 } } */
8 /* ---------------------------------------------------------------------------
9 Simple GBR load.
11 #define func(name, rettype, type, disp)\
12 rettype \
13 name ## _tp_load (void) \
14 { \
15 type* tp = (type*)__builtin_thread_pointer (); \
16 return tp[disp]; \
19 func (test00, int, int, 0)
20 func (test01, int, int, 5)
21 func (test02, int, int, 255)
23 func (test03, int, short, 0)
24 func (test04, int, short, 5)
25 func (test05, int, short, 255)
27 func (test06, int, char, 0)
28 func (test07, int, char, 5)
29 func (test08, int, char, 255)
31 func (test09, int, unsigned int, 0)
32 func (test10, int, unsigned int, 5)
33 func (test11, int, unsigned int, 255)
35 func (test12, int, unsigned short, 0)
36 func (test13, int, unsigned short, 5)
37 func (test14, int, unsigned short, 255)
39 func (test15, int, unsigned char, 0)
40 func (test16, int, unsigned char, 5)
41 func (test17, int, unsigned char, 255)
43 func (test18, long long, long long, 0)
44 func (test19, long long, long long, 5)
45 func (test20, long long, long long, 127)
47 func (test21, long long, unsigned long long, 0)
48 func (test22, long long, unsigned long long, 5)
49 func (test23, long long, unsigned long long, 127)
51 #undef func
53 /* ---------------------------------------------------------------------------
54 Simple GBR store.
56 #define func(name, argtype, type, disp)\
57 void \
58 name ## _tp_store (argtype a) \
59 { \
60 type* tp = (type*)__builtin_thread_pointer (); \
61 tp[disp] = (type)a; \
64 func (test00, int, int, 0)
65 func (test01, int, int, 5)
66 func (test02, int, int, 255)
68 func (test03, int, short, 0)
69 func (test04, int, short, 5)
70 func (test05, int, short, 255)
72 func (test06, int, char, 0)
73 func (test07, int, char, 5)
74 func (test08, int, char, 255)
76 func (test09, int, unsigned int, 0)
77 func (test10, int, unsigned int, 5)
78 func (test11, int, unsigned int, 255)
80 func (test12, int, unsigned short, 0)
81 func (test13, int, unsigned short, 5)
82 func (test14, int, unsigned short, 255)
84 func (test15, int, unsigned char, 0)
85 func (test16, int, unsigned char, 5)
86 func (test17, int, unsigned char, 255)
88 func (test18, long long, long long, 0)
89 func (test19, long long, long long, 5)
90 func (test20, long long, long long, 127)
92 func (test21, long long, unsigned long long, 0)
93 func (test22, long long, unsigned long long, 5)
94 func (test23, long long, unsigned long long, 127)
96 #undef func
98 /* ---------------------------------------------------------------------------
99 Arithmetic on the result of a GBR load.
101 #define func(name, retargtype, type, disp, op, opname)\
102 retargtype \
103 name ## _tp_load_arith_ ##opname (retargtype a) \
105 type* tp = (type*)__builtin_thread_pointer (); \
106 return tp[disp] op a; \
109 #define funcs(op, opname) \
110 func (test00, int, int, 0, op, opname) \
111 func (test01, int, int, 5, op, opname) \
112 func (test02, int, int, 255, op, opname) \
113 func (test03, int, short, 0, op, opname) \
114 func (test04, int, short, 5, op, opname) \
115 func (test05, int, short, 255, op, opname) \
116 func (test06, int, char, 0, op, opname) \
117 func (test07, int, char, 5, op, opname) \
118 func (test08, int, char, 255, op, opname) \
119 func (test09, int, unsigned int, 0, op, opname) \
120 func (test10, int, unsigned int, 5, op, opname) \
121 func (test11, int, unsigned int, 255, op, opname) \
122 func (test12, int, unsigned short, 0, op, opname) \
123 func (test13, int, unsigned short, 5, op, opname) \
124 func (test14, int, unsigned short, 255, op, opname) \
125 func (test15, int, unsigned char, 0, op, opname) \
126 func (test16, int, unsigned char, 5, op, opname) \
127 func (test17, int, unsigned char, 255, op, opname) \
128 func (test18, long long, long long, 0, op, opname) \
129 func (test19, long long, long long, 5, op, opname) \
130 func (test20, long long, long long, 127, op, opname) \
131 func (test21, long long, unsigned long long, 0, op, opname) \
132 func (test22, long long, unsigned long long, 5, op, opname) \
133 func (test23, long long, unsigned long long, 127, op, opname) \
135 funcs (+, plus)
136 funcs (-, minus)
137 funcs (*, mul)
138 funcs (&, and)
139 funcs (|, or)
140 funcs (^, xor)
142 #undef funcs
143 #undef func
145 /* ---------------------------------------------------------------------------
146 Arithmetic of the result of two GBR loads.
148 #define func(name, rettype, type, disp0, disp1, op, opname)\
149 rettype \
150 name ## _tp_load_load_arith_ ##opname (void) \
152 type* tp = (type*)__builtin_thread_pointer (); \
153 return tp[disp0] op tp[disp1]; \
156 #define funcs(op, opname) \
157 func (test00, int, int, 0, 5, op, opname) \
158 func (test02, int, int, 1, 255, op, opname) \
159 func (test03, int, short, 0, 5, op, opname) \
160 func (test05, int, short, 1, 255, op, opname) \
161 func (test06, int, char, 0, 5, op, opname) \
162 func (test08, int, char, 1, 255, op, opname) \
163 func (test09, int, unsigned int, 0, 5, op, opname) \
164 func (test11, int, unsigned int, 1, 255, op, opname) \
165 func (test12, int, unsigned short, 0, 5, op, opname) \
166 func (test14, int, unsigned short, 1, 255, op, opname) \
167 func (test15, int, unsigned char, 0, 5, op, opname) \
168 func (test17, int, unsigned char, 1, 255, op, opname) \
169 func (test18, long long, long long, 0, 5, op, opname) \
170 func (test19, long long, long long, 1, 127, op, opname) \
171 func (test20, long long, unsigned long long, 0, 5, op, opname) \
172 func (test21, long long, unsigned long long, 1, 127, op, opname) \
174 funcs (+, plus)
175 funcs (-, minus)
176 funcs (*, mul)
177 funcs (&, and)
178 funcs (|, or)
179 funcs (^, xor)
181 #undef funcs
182 #undef func
184 /* ---------------------------------------------------------------------------
185 GBR load GBR store copy.
188 #define func(name, type, disp0, disp1)\
189 void \
190 name ## _tp_copy (void) \
192 type* tp = (type*)__builtin_thread_pointer (); \
193 tp[disp0] = tp[disp1]; \
196 func (test00, int, 0, 5)
197 func (test02, int, 1, 255)
198 func (test03, short, 0, 5)
199 func (test05, short, 1, 255)
200 func (test06, char, 0, 5)
201 func (test08, char, 1, 255)
202 func (test09, unsigned int, 0, 5)
203 func (test11, unsigned int, 1, 255)
204 func (test12, unsigned short, 0, 5)
205 func (test14, unsigned short, 1, 255)
206 func (test15, unsigned char, 0, 5)
207 func (test17, unsigned char, 1, 255)
208 func (test18, long long, 0, 5)
209 func (test19, long long, 1, 127)
210 func (test20, unsigned long long, 0, 5)
211 func (test21, unsigned long long, 1, 127)
213 #undef func
215 /* ---------------------------------------------------------------------------
216 GBR load, arithmetic, GBR store
219 #define func(name, argtype, type, disp, op, opname)\
220 void \
221 name ## _tp_load_arith_store_ ##opname (argtype a) \
223 type* tp = (type*)__builtin_thread_pointer (); \
224 tp[disp] op a; \
227 #define funcs(op, opname) \
228 func (test00, int, int, 0, op, opname) \
229 func (test01, int, int, 5, op, opname) \
230 func (test02, int, int, 255, op, opname) \
231 func (test03, int, short, 0, op, opname) \
232 func (test04, int, short, 5, op, opname) \
233 func (test05, int, short, 255, op, opname) \
234 func (test06, int, char, 0, op, opname) \
235 func (test07, int, char, 5, op, opname) \
236 func (test08, int, char, 255, op, opname) \
237 func (test09, int, unsigned int, 0, op, opname) \
238 func (test10, int, unsigned int, 5, op, opname) \
239 func (test11, int, unsigned int, 255, op, opname) \
240 func (test12, int, unsigned short, 0, op, opname) \
241 func (test13, int, unsigned short, 5, op, opname) \
242 func (test14, int, unsigned short, 255, op, opname) \
243 func (test15, int, unsigned char, 0, op, opname) \
244 func (test16, int, unsigned char, 5, op, opname) \
245 func (test17, int, unsigned char, 255, op, opname) \
246 func (test18, long long, long long, 0, op, opname) \
247 func (test19, long long, long long, 5, op, opname) \
248 func (test20, long long, long long, 127, op, opname) \
249 func (test21, long long, unsigned long long, 0, op, opname) \
250 func (test22, long long, unsigned long long, 5, op, opname) \
251 func (test23, long long, unsigned long long, 127, op, opname) \
253 funcs (+=, plus)
254 funcs (-=, minus)
255 funcs (*=, mul)
256 funcs (&=, and)
257 funcs (|=, or)
258 funcs (^=, xor)