1 /* Tests the shift instructions.
3 Copyright (C) 2017-2019 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 # output: report(0xb38f0f83);\n
20 # output: report(0x00000000);\n
21 # output: report(0xb38f0f83);\n
23 # output: report(0xb38f0f83);\n
24 # output: report(0x00000001);\n
25 # output: report(0x671e1f06);\n
27 # output: report(0xb38f0f83);\n
28 # output: report(0x00000004);\n
29 # output: report(0x38f0f830);\n
31 # output: report(0xb38f0f83);\n
32 # output: report(0x00000010);\n
33 # output: report(0x0f830000);\n
35 # output: report(0xb38f0f83);\n
36 # output: report(0x0000001f);\n
37 # output: report(0x80000000);\n
39 # output: report(0xb38f0f83);\n
40 # output: report(0x00000021);\n
41 # output: report(0x671e1f06);\n
43 # output: report(0xb38f0f83);\n
44 # output: report(0x00002224);\n
45 # output: report(0x38f0f830);\n
47 # output: report(0xb38f0f83);\n
48 # output: report(0x00f789f0);\n
49 # output: report(0x0f830000);\n
51 # output: report(0xb38f0f83);\n
52 # output: report(0xffffffff);\n
53 # output: report(0x80000000);\n
55 # output: report(0xb38f0f83);\n
56 # output: report(0x00000000);\n
57 # output: report(0xb38f0f83);\n
59 # output: report(0xb38f0f83);\n
60 # output: report(0x00000001);\n
61 # output: report(0x671e1f06);\n
63 # output: report(0xb38f0f83);\n
64 # output: report(0x00000004);\n
65 # output: report(0x38f0f830);\n
67 # output: report(0xb38f0f83);\n
68 # output: report(0x00000010);\n
69 # output: report(0x0f830000);\n
71 # output: report(0xb38f0f83);\n
72 # output: report(0x0000001f);\n
73 # output: report(0x80000000);\n
75 # output: report(0xb38f0f83);\n
76 # output: report(0x00000021);\n
77 # output: report(0x671e1f06);\n
79 # output: report(0xb38f0f83);\n
80 # output: report(0x00000024);\n
81 # output: report(0x38f0f830);\n
83 # output: report(0xb38f0f83);\n
84 # output: report(0x00000030);\n
85 # output: report(0x0f830000);\n
87 # output: report(0xb38f0f83);\n
88 # output: report(0x0000003f);\n
89 # output: report(0x80000000);\n
91 # output: report(0xb38f0f83);\n
92 # output: report(0x00000000);\n
93 # output: report(0xb38f0f83);\n
95 # output: report(0xb38f0f83);\n
96 # output: report(0x00000001);\n
97 # output: report(0xd9c787c1);\n
99 # output: report(0xb38f0f83);\n
100 # output: report(0x00000004);\n
101 # output: report(0xfb38f0f8);\n
103 # output: report(0xb38f0f83);\n
104 # output: report(0x00000010);\n
105 # output: report(0xffffb38f);\n
107 # output: report(0xb38f0f83);\n
108 # output: report(0x0000001f);\n
109 # output: report(0xffffffff);\n
111 # output: report(0x4c70f07c);\n
112 # output: report(0x00000001);\n
113 # output: report(0x2638783e);\n
115 # output: report(0x4c70f07c);\n
116 # output: report(0x00000004);\n
117 # output: report(0x04c70f07);\n
119 # output: report(0x4c70f07c);\n
120 # output: report(0x00000010);\n
121 # output: report(0x00004c70);\n
123 # output: report(0x4c70f07c);\n
124 # output: report(0x0000001f);\n
125 # output: report(0x00000000);\n
127 # output: report(0xb38f0f83);\n
128 # output: report(0x00000021);\n
129 # output: report(0xd9c787c1);\n
131 # output: report(0xb38f0f83);\n
132 # output: report(0x00002224);\n
133 # output: report(0xfb38f0f8);\n
135 # output: report(0xb38f0f83);\n
136 # output: report(0x00f789f0);\n
137 # output: report(0xffffb38f);\n
139 # output: report(0xb38f0f83);\n
140 # output: report(0xffffffff);\n
141 # output: report(0xffffffff);\n
143 # output: report(0x4c70f07c);\n
144 # output: report(0x00000021);\n
145 # output: report(0x2638783e);\n
147 # output: report(0x4c70f07c);\n
148 # output: report(0x00002224);\n
149 # output: report(0x04c70f07);\n
151 # output: report(0x4c70f07c);\n
152 # output: report(0x00f789f0);\n
153 # output: report(0x00004c70);\n
155 # output: report(0x4c70f07c);\n
156 # output: report(0xffffffff);\n
157 # output: report(0x00000000);\n
159 # output: report(0xb38f0f83);\n
160 # output: report(0x00000000);\n
161 # output: report(0xb38f0f83);\n
163 # output: report(0xb38f0f83);\n
164 # output: report(0x00000001);\n
165 # output: report(0xd9c787c1);\n
167 # output: report(0xb38f0f83);\n
168 # output: report(0x00000004);\n
169 # output: report(0xfb38f0f8);\n
171 # output: report(0xb38f0f83);\n
172 # output: report(0x00000010);\n
173 # output: report(0xffffb38f);\n
175 # output: report(0xb38f0f83);\n
176 # output: report(0x0000001f);\n
177 # output: report(0xffffffff);\n
179 # output: report(0x4c70f07c);\n
180 # output: report(0x00000001);\n
181 # output: report(0x2638783e);\n
183 # output: report(0x4c70f07c);\n
184 # output: report(0x00000004);\n
185 # output: report(0x04c70f07);\n
187 # output: report(0x4c70f07c);\n
188 # output: report(0x00000010);\n
189 # output: report(0x00004c70);\n
191 # output: report(0x4c70f07c);\n
192 # output: report(0x0000001f);\n
193 # output: report(0x00000000);\n
195 # output: report(0xb38f0f83);\n
196 # output: report(0x00000021);\n
197 # output: report(0xd9c787c1);\n
199 # output: report(0xb38f0f83);\n
200 # output: report(0x00000024);\n
201 # output: report(0xfb38f0f8);\n
203 # output: report(0xb38f0f83);\n
204 # output: report(0x00000030);\n
205 # output: report(0xffffb38f);\n
207 # output: report(0xb38f0f83);\n
208 # output: report(0x0000003f);\n
209 # output: report(0xffffffff);\n
211 # output: report(0x4c70f07c);\n
212 # output: report(0x00000021);\n
213 # output: report(0x2638783e);\n
215 # output: report(0x4c70f07c);\n
216 # output: report(0x00000024);\n
217 # output: report(0x04c70f07);\n
219 # output: report(0x4c70f07c);\n
220 # output: report(0x00000030);\n
221 # output: report(0x00004c70);\n
223 # output: report(0x4c70f07c);\n
224 # output: report(0x0000003f);\n
225 # output: report(0x00000000);\n
227 # output: report(0xb38f0f83);\n
228 # output: report(0x00000000);\n
229 # output: report(0xb38f0f83);\n
231 # output: report(0xb38f0f83);\n
232 # output: report(0x00000001);\n
233 # output: report(0x59c787c1);\n
235 # output: report(0xb38f0f83);\n
236 # output: report(0x00000004);\n
237 # output: report(0x0b38f0f8);\n
239 # output: report(0xb38f0f83);\n
240 # output: report(0x00000010);\n
241 # output: report(0x0000b38f);\n
243 # output: report(0xb38f0f83);\n
244 # output: report(0x0000001f);\n
245 # output: report(0x00000001);\n
247 # output: report(0x4c70f07c);\n
248 # output: report(0x00000001);\n
249 # output: report(0x2638783e);\n
251 # output: report(0x4c70f07c);\n
252 # output: report(0x00000004);\n
253 # output: report(0x04c70f07);\n
255 # output: report(0x4c70f07c);\n
256 # output: report(0x00000010);\n
257 # output: report(0x00004c70);\n
259 # output: report(0x4c70f07c);\n
260 # output: report(0x0000001f);\n
261 # output: report(0x00000000);\n
263 # output: report(0xb38f0f83);\n
264 # output: report(0x00000021);\n
265 # output: report(0x59c787c1);\n
267 # output: report(0xb38f0f83);\n
268 # output: report(0x00002224);\n
269 # output: report(0x0b38f0f8);\n
271 # output: report(0xb38f0f83);\n
272 # output: report(0x00f789f0);\n
273 # output: report(0x0000b38f);\n
275 # output: report(0xb38f0f83);\n
276 # output: report(0xffffffff);\n
277 # output: report(0x00000001);\n
279 # output: report(0x4c70f07c);\n
280 # output: report(0x00000021);\n
281 # output: report(0x2638783e);\n
283 # output: report(0x4c70f07c);\n
284 # output: report(0x00002224);\n
285 # output: report(0x04c70f07);\n
287 # output: report(0x4c70f07c);\n
288 # output: report(0x00f789f0);\n
289 # output: report(0x00004c70);\n
291 # output: report(0x4c70f07c);\n
292 # output: report(0xffffffff);\n
293 # output: report(0x00000000);\n
295 # output: report(0xb38f0f83);\n
296 # output: report(0x00000000);\n
297 # output: report(0xb38f0f83);\n
299 # output: report(0xb38f0f83);\n
300 # output: report(0x00000001);\n
301 # output: report(0x59c787c1);\n
303 # output: report(0xb38f0f83);\n
304 # output: report(0x00000004);\n
305 # output: report(0x0b38f0f8);\n
307 # output: report(0xb38f0f83);\n
308 # output: report(0x00000010);\n
309 # output: report(0x0000b38f);\n
311 # output: report(0xb38f0f83);\n
312 # output: report(0x0000001f);\n
313 # output: report(0x00000001);\n
315 # output: report(0x4c70f07c);\n
316 # output: report(0x00000001);\n
317 # output: report(0x2638783e);\n
319 # output: report(0x4c70f07c);\n
320 # output: report(0x00000004);\n
321 # output: report(0x04c70f07);\n
323 # output: report(0x4c70f07c);\n
324 # output: report(0x00000010);\n
325 # output: report(0x00004c70);\n
327 # output: report(0x4c70f07c);\n
328 # output: report(0x0000001f);\n
329 # output: report(0x00000000);\n
331 # output: report(0xb38f0f83);\n
332 # output: report(0x00000021);\n
333 # output: report(0x59c787c1);\n
335 # output: report(0xb38f0f83);\n
336 # output: report(0x00000024);\n
337 # output: report(0x0b38f0f8);\n
339 # output: report(0xb38f0f83);\n
340 # output: report(0x00000030);\n
341 # output: report(0x0000b38f);\n
343 # output: report(0xb38f0f83);\n
344 # output: report(0x0000003f);\n
345 # output: report(0x00000001);\n
347 # output: report(0x4c70f07c);\n
348 # output: report(0x00000021);\n
349 # output: report(0x2638783e);\n
351 # output: report(0x4c70f07c);\n
352 # output: report(0x00000024);\n
353 # output: report(0x04c70f07);\n
355 # output: report(0x4c70f07c);\n
356 # output: report(0x00000030);\n
357 # output: report(0x00004c70);\n
359 # output: report(0x4c70f07c);\n
360 # output: report(0x0000003f);\n
361 # output: report(0x00000000);\n
365 #include "or1k-asm-test-helpers.h"
367 .macro TEST_SHIFT opcode, op1, op2
368 LOAD_IMMEDIATE r5, \op1
369 LOAD_IMMEDIATE r6, \op2
370 REPORT_REG_TO_CONSOLE r5
371 REPORT_REG_TO_CONSOLE r6
373 CHECK_CARRY_AND_OVERFLOW_NOT_SET r2, r3
374 REPORT_REG_TO_CONSOLE r4
375 PRINT_NEWLINE_TO_CONSOLE
378 .macro TEST_SHIFT_I opcode, op1, op2
379 LOAD_IMMEDIATE r5, \op1
380 REPORT_REG_TO_CONSOLE r5
381 REPORT_IMMEDIATE_TO_CONSOLE \op2
383 CHECK_CARRY_AND_OVERFLOW_NOT_SET r2, r3
384 REPORT_REG_TO_CONSOLE r4
385 PRINT_NEWLINE_TO_CONSOLE
388 STANDARD_TEST_ENVIRONMENT
392 PUSH LINK_REGISTER_R9
394 /* Always set OVE. We should never trigger an exception, even if
396 SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3
400 /* Shift left by zero. */
401 TEST_SHIFT l.sll, 0xb38f0f83, 0x00000000
403 /* Shift left by amounts in the 1-31 range. */
404 TEST_SHIFT l.sll, 0xb38f0f83, 0x00000001
405 TEST_SHIFT l.sll, 0xb38f0f83, 0x00000004
406 TEST_SHIFT l.sll, 0xb38f0f83, 0x00000010
407 TEST_SHIFT l.sll, 0xb38f0f83, 0x0000001f
409 /* Shift left by larger amounts - should be masked. */
410 TEST_SHIFT l.sll, 0xb38f0f83, 0x00000021
411 TEST_SHIFT l.sll, 0xb38f0f83, 0x00002224
412 TEST_SHIFT l.sll, 0xb38f0f83, 0x00f789f0
413 TEST_SHIFT l.sll, 0xb38f0f83, 0xffffffff
417 /* Shift left by zero. */
418 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x0000
420 /* Shift left by amounts in the 1-31 range. */
421 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x0001
422 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x0004
423 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x0010
424 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x001f
426 /* Shift left by larger amounts - should be masked. */
427 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x0021
428 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x0024
429 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x0030
430 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x003f
434 /* Shift right by zero. */
435 TEST_SHIFT l.sra, 0xb38f0f83, 0x00000000
437 /* Shift right by amounts in the 1-31 range. */
438 TEST_SHIFT l.sra, 0xb38f0f83, 0x00000001
439 TEST_SHIFT l.sra, 0xb38f0f83, 0x00000004
440 TEST_SHIFT l.sra, 0xb38f0f83, 0x00000010
441 TEST_SHIFT l.sra, 0xb38f0f83, 0x0000001f
443 TEST_SHIFT l.sra, 0x4c70f07c, 0x00000001
444 TEST_SHIFT l.sra, 0x4c70f07c, 0x00000004
445 TEST_SHIFT l.sra, 0x4c70f07c, 0x00000010
446 TEST_SHIFT l.sra, 0x4c70f07c, 0x0000001f
448 /* Shift right by larger amounts - should be masked. */
449 TEST_SHIFT l.sra, 0xb38f0f83, 0x00000021
450 TEST_SHIFT l.sra, 0xb38f0f83, 0x00002224
451 TEST_SHIFT l.sra, 0xb38f0f83, 0x00f789f0
452 TEST_SHIFT l.sra, 0xb38f0f83, 0xffffffff
454 TEST_SHIFT l.sra, 0x4c70f07c, 0x00000021
455 TEST_SHIFT l.sra, 0x4c70f07c, 0x00002224
456 TEST_SHIFT l.sra, 0x4c70f07c, 0x00f789f0
457 TEST_SHIFT l.sra, 0x4c70f07c, 0xffffffff
461 /* Shift right by zero. */
462 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x0000
464 /* Shift right by amounts in the 1-31 range. */
465 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x0001
466 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x0004
467 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x0010
468 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x001f
470 TEST_SHIFT_I l.srai, 0x4c70f07c, 0x0001
471 TEST_SHIFT_I l.srai, 0x4c70f07c, 0x0004
472 TEST_SHIFT_I l.srai, 0x4c70f07c, 0x0010
473 TEST_SHIFT_I l.srai, 0x4c70f07c, 0x001f
475 /* Shift right by larger amounts - should be masked. */
476 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x0021
477 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x0024
478 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x0030
479 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x003f
481 TEST_SHIFT_I l.srai, 0x4c70f07c, 0x0021
482 TEST_SHIFT_I l.srai, 0x4c70f07c, 0x0024
483 TEST_SHIFT_I l.srai, 0x4c70f07c, 0x0030
484 TEST_SHIFT_I l.srai, 0x4c70f07c, 0x003f
488 /* Shift right by zero. */
489 TEST_SHIFT l.srl, 0xb38f0f83, 0x00000000
491 /* Shift right by amounts in the 1-31 range. */
492 TEST_SHIFT l.srl, 0xb38f0f83, 0x00000001
493 TEST_SHIFT l.srl, 0xb38f0f83, 0x00000004
494 TEST_SHIFT l.srl, 0xb38f0f83, 0x00000010
495 TEST_SHIFT l.srl, 0xb38f0f83, 0x0000001f
497 TEST_SHIFT l.srl, 0x4c70f07c, 0x00000001
498 TEST_SHIFT l.srl, 0x4c70f07c, 0x00000004
499 TEST_SHIFT l.srl, 0x4c70f07c, 0x00000010
500 TEST_SHIFT l.srl, 0x4c70f07c, 0x0000001f
502 /* Shift right by larger amounts - should be masked. */
503 TEST_SHIFT l.srl, 0xb38f0f83, 0x00000021
504 TEST_SHIFT l.srl, 0xb38f0f83, 0x00002224
505 TEST_SHIFT l.srl, 0xb38f0f83, 0x00f789f0
506 TEST_SHIFT l.srl, 0xb38f0f83, 0xffffffff
508 TEST_SHIFT l.srl, 0x4c70f07c, 0x00000021
509 TEST_SHIFT l.srl, 0x4c70f07c, 0x00002224
510 TEST_SHIFT l.srl, 0x4c70f07c, 0x00f789f0
511 TEST_SHIFT l.srl, 0x4c70f07c, 0xffffffff
515 /* Shift right by zero. */
516 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x0000
518 /* Shift right by amounts in the 1-31 range. */
519 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x0001
520 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x0004
521 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x0010
522 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x001f
524 TEST_SHIFT_I l.srli, 0x4c70f07c, 0x0001
525 TEST_SHIFT_I l.srli, 0x4c70f07c, 0x0004
526 TEST_SHIFT_I l.srli, 0x4c70f07c, 0x0010
527 TEST_SHIFT_I l.srli, 0x4c70f07c, 0x001f
529 /* Shift right by larger amounts - should be masked. */
530 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x0021
531 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x0024
532 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x0030
533 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x003f
535 TEST_SHIFT_I l.srli, 0x4c70f07c, 0x0021
536 TEST_SHIFT_I l.srli, 0x4c70f07c, 0x0024
537 TEST_SHIFT_I l.srli, 0x4c70f07c, 0x0030
538 TEST_SHIFT_I l.srli, 0x4c70f07c, 0x003f
541 RETURN_TO_LINK_REGISTER_R9