aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/sh/pr54760-2.c
blob: 4a3561a56e99cac73c838f4c7775aed43feb2d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/* Check that thread pointer relative memory accesses are converted to
   gbr displacement address modes.  If we see a gbr register store
   instruction something is not working properly.  */
/* { dg-do compile }  */
/* { dg-options "-O1" } */
/* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } }  */
/* { dg-final { scan-assembler-times "stc\tgbr" 0 } } */

/* ---------------------------------------------------------------------------
  Simple GBR load.
*/
#define func(name, rettype, type, disp)\
  rettype \
  name ## _tp_load (void) \
  { \
    type* tp = (type*)__builtin_thread_pointer (); \
    return tp[disp]; \
  }

func (test00, int, int, 0)
func (test01, int, int, 5)
func (test02, int, int, 255)

func (test03, int, short, 0)
func (test04, int, short, 5)
func (test05, int, short, 255)

func (test06, int, char, 0)
func (test07, int, char, 5)
func (test08, int, char, 255)

func (test09, int, unsigned int, 0)
func (test10, int, unsigned int, 5)
func (test11, int, unsigned int, 255)

func (test12, int, unsigned short, 0)
func (test13, int, unsigned short, 5)
func (test14, int, unsigned short, 255)

func (test15, int, unsigned char, 0)
func (test16, int, unsigned char, 5)
func (test17, int, unsigned char, 255)

func (test18, long long, long long, 0)
func (test19, long long, long long, 5)
func (test20, long long, long long, 127)

func (test21, long long, unsigned long long, 0)
func (test22, long long, unsigned long long, 5)
func (test23, long long, unsigned long long, 127)

#undef func

/* ---------------------------------------------------------------------------
  Simple GBR store.
*/
#define func(name, argtype, type, disp)\
  void \
  name ## _tp_store (argtype a) \
  { \
    type* tp = (type*)__builtin_thread_pointer (); \
    tp[disp] = (type)a; \
  }

func (test00, int, int, 0)
func (test01, int, int, 5)
func (test02, int, int, 255)

func (test03, int, short, 0)
func (test04, int, short, 5)
func (test05, int, short, 255)

func (test06, int, char, 0)
func (test07, int, char, 5)
func (test08, int, char, 255)

func (test09, int, unsigned int, 0)
func (test10, int, unsigned int, 5)
func (test11, int, unsigned int, 255)

func (test12, int, unsigned short, 0)
func (test13, int, unsigned short, 5)
func (test14, int, unsigned short, 255)

func (test15, int, unsigned char, 0)
func (test16, int, unsigned char, 5)
func (test17, int, unsigned char, 255)

func (test18, long long, long long, 0)
func (test19, long long, long long, 5)
func (test20, long long, long long, 127)

func (test21, long long, unsigned long long, 0)
func (test22, long long, unsigned long long, 5)
func (test23, long long, unsigned long long, 127)

#undef func

/* ---------------------------------------------------------------------------
  Arithmetic on the result of a GBR load.
*/
#define func(name, retargtype, type, disp, op, opname)\
  retargtype \
  name ## _tp_load_arith_ ##opname (retargtype a) \
  { \
    type* tp = (type*)__builtin_thread_pointer (); \
    return tp[disp] op a; \
  }

#define funcs(op, opname) \
  func (test00, int, int, 0, op, opname) \
  func (test01, int, int, 5, op, opname) \
  func (test02, int, int, 255, op, opname) \
  func (test03, int, short, 0, op, opname) \
  func (test04, int, short, 5, op, opname) \
  func (test05, int, short, 255, op, opname) \
  func (test06, int, char, 0, op, opname) \
  func (test07, int, char, 5, op, opname) \
  func (test08, int, char, 255, op, opname) \
  func (test09, int, unsigned int, 0, op, opname) \
  func (test10, int, unsigned int, 5, op, opname) \
  func (test11, int, unsigned int, 255, op, opname) \
  func (test12, int, unsigned short, 0, op, opname) \
  func (test13, int, unsigned short, 5, op, opname) \
  func (test14, int, unsigned short, 255, op, opname) \
  func (test15, int, unsigned char, 0, op, opname) \
  func (test16, int, unsigned char, 5, op, opname) \
  func (test17, int, unsigned char, 255, op, opname) \
  func (test18, long long, long long, 0, op, opname) \
  func (test19, long long, long long, 5, op, opname) \
  func (test20, long long, long long, 127, op, opname) \
  func (test21, long long, unsigned long long, 0, op, opname) \
  func (test22, long long, unsigned long long, 5, op, opname) \
  func (test23, long long, unsigned long long, 127, op, opname) \

funcs (+, plus)
funcs (-, minus)
funcs (*, mul)
funcs (&, and)
funcs (|, or)
funcs (^, xor)

#undef funcs
#undef func

/* ---------------------------------------------------------------------------
  Arithmetic of the result of two GBR loads.
*/
#define func(name, rettype, type, disp0, disp1, op, opname)\
  rettype \
  name ## _tp_load_load_arith_ ##opname (void) \
  { \
    type* tp = (type*)__builtin_thread_pointer (); \
    return tp[disp0] op tp[disp1]; \
  }

#define funcs(op, opname) \
  func (test00, int, int, 0, 5, op, opname) \
  func (test02, int, int, 1, 255, op, opname) \
  func (test03, int, short, 0, 5, op, opname) \
  func (test05, int, short, 1, 255, op, opname) \
  func (test06, int, char, 0, 5, op, opname) \
  func (test08, int, char, 1, 255, op, opname) \
  func (test09, int, unsigned int, 0, 5, op, opname) \
  func (test11, int, unsigned int, 1, 255, op, opname) \
  func (test12, int, unsigned short, 0, 5, op, opname) \
  func (test14, int, unsigned short, 1, 255, op, opname) \
  func (test15, int, unsigned char, 0, 5, op, opname) \
  func (test17, int, unsigned char, 1, 255, op, opname) \
  func (test18, long long, long long, 0, 5, op, opname) \
  func (test19, long long, long long, 1, 127, op, opname) \
  func (test20, long long, unsigned long long, 0, 5, op, opname) \
  func (test21, long long, unsigned long long, 1, 127, op, opname) \

funcs (+, plus)
funcs (-, minus)
funcs (*, mul)
funcs (&, and)
funcs (|, or)
funcs (^, xor)

#undef funcs
#undef func

/* ---------------------------------------------------------------------------
  GBR load GBR store copy.
*/

#define func(name, type, disp0, disp1)\
  void \
  name ## _tp_copy (void) \
  { \
    type* tp = (type*)__builtin_thread_pointer (); \
    tp[disp0] = tp[disp1]; \
  }

func (test00, int, 0, 5)
func (test02, int, 1, 255)
func (test03, short, 0, 5)
func (test05, short, 1, 255)
func (test06, char, 0, 5)
func (test08, char, 1, 255)
func (test09, unsigned int, 0, 5)
func (test11, unsigned int, 1, 255)
func (test12, unsigned short, 0, 5)
func (test14, unsigned short, 1, 255)
func (test15, unsigned char, 0, 5)
func (test17, unsigned char, 1, 255)
func (test18, long long, 0, 5)
func (test19, long long, 1, 127)
func (test20, unsigned long long, 0, 5)
func (test21, unsigned long long, 1, 127)

#undef func

/* ---------------------------------------------------------------------------
  GBR load, arithmetic, GBR store
*/

#define func(name, argtype, type, disp, op, opname)\
  void \
  name ## _tp_load_arith_store_ ##opname (argtype a) \
  { \
    type* tp = (type*)__builtin_thread_pointer (); \
    tp[disp] op a; \
  }

#define funcs(op, opname) \
  func (test00, int, int, 0, op, opname) \
  func (test01, int, int, 5, op, opname) \
  func (test02, int, int, 255, op, opname) \
  func (test03, int, short, 0, op, opname) \
  func (test04, int, short, 5, op, opname) \
  func (test05, int, short, 255, op, opname) \
  func (test06, int, char, 0, op, opname) \
  func (test07, int, char, 5, op, opname) \
  func (test08, int, char, 255, op, opname) \
  func (test09, int, unsigned int, 0, op, opname) \
  func (test10, int, unsigned int, 5, op, opname) \
  func (test11, int, unsigned int, 255, op, opname) \
  func (test12, int, unsigned short, 0, op, opname) \
  func (test13, int, unsigned short, 5, op, opname) \
  func (test14, int, unsigned short, 255, op, opname) \
  func (test15, int, unsigned char, 0, op, opname) \
  func (test16, int, unsigned char, 5, op, opname) \
  func (test17, int, unsigned char, 255, op, opname) \
  func (test18, long long, long long, 0, op, opname) \
  func (test19, long long, long long, 5, op, opname) \
  func (test20, long long, long long, 127, op, opname) \
  func (test21, long long, unsigned long long, 0, op, opname) \
  func (test22, long long, unsigned long long, 5, op, opname) \
  func (test23, long long, unsigned long long, 127, op, opname) \

funcs (+=, plus)
funcs (-=, minus)
funcs (*=, mul)
funcs (&=, and)
funcs (|=, or)
funcs (^=, xor)