Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / sim / testsuite / or1k / shift.S
CommitLineData
702d582e
PG
1/* Tests the shift instructions.
2
88b9d363 3 Copyright (C) 2017-2022 Free Software Foundation, Inc.
702d582e
PG
4
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.
9
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.
14
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/>. */
17
18# mach: or1k
19# output: report(0xb38f0f83);\n
20# output: report(0x00000000);\n
21# output: report(0xb38f0f83);\n
22# output: \n
23# output: report(0xb38f0f83);\n
24# output: report(0x00000001);\n
25# output: report(0x671e1f06);\n
26# output: \n
27# output: report(0xb38f0f83);\n
28# output: report(0x00000004);\n
29# output: report(0x38f0f830);\n
30# output: \n
31# output: report(0xb38f0f83);\n
32# output: report(0x00000010);\n
33# output: report(0x0f830000);\n
34# output: \n
35# output: report(0xb38f0f83);\n
36# output: report(0x0000001f);\n
37# output: report(0x80000000);\n
38# output: \n
39# output: report(0xb38f0f83);\n
40# output: report(0x00000021);\n
41# output: report(0x671e1f06);\n
42# output: \n
43# output: report(0xb38f0f83);\n
44# output: report(0x00002224);\n
45# output: report(0x38f0f830);\n
46# output: \n
47# output: report(0xb38f0f83);\n
48# output: report(0x00f789f0);\n
49# output: report(0x0f830000);\n
50# output: \n
51# output: report(0xb38f0f83);\n
52# output: report(0xffffffff);\n
53# output: report(0x80000000);\n
54# output: \n
55# output: report(0xb38f0f83);\n
56# output: report(0x00000000);\n
57# output: report(0xb38f0f83);\n
58# output: \n
59# output: report(0xb38f0f83);\n
60# output: report(0x00000001);\n
61# output: report(0x671e1f06);\n
62# output: \n
63# output: report(0xb38f0f83);\n
64# output: report(0x00000004);\n
65# output: report(0x38f0f830);\n
66# output: \n
67# output: report(0xb38f0f83);\n
68# output: report(0x00000010);\n
69# output: report(0x0f830000);\n
70# output: \n
71# output: report(0xb38f0f83);\n
72# output: report(0x0000001f);\n
73# output: report(0x80000000);\n
74# output: \n
75# output: report(0xb38f0f83);\n
76# output: report(0x00000021);\n
77# output: report(0x671e1f06);\n
78# output: \n
79# output: report(0xb38f0f83);\n
80# output: report(0x00000024);\n
81# output: report(0x38f0f830);\n
82# output: \n
83# output: report(0xb38f0f83);\n
84# output: report(0x00000030);\n
85# output: report(0x0f830000);\n
86# output: \n
87# output: report(0xb38f0f83);\n
88# output: report(0x0000003f);\n
89# output: report(0x80000000);\n
90# output: \n
91# output: report(0xb38f0f83);\n
92# output: report(0x00000000);\n
93# output: report(0xb38f0f83);\n
94# output: \n
95# output: report(0xb38f0f83);\n
96# output: report(0x00000001);\n
97# output: report(0xd9c787c1);\n
98# output: \n
99# output: report(0xb38f0f83);\n
100# output: report(0x00000004);\n
101# output: report(0xfb38f0f8);\n
102# output: \n
103# output: report(0xb38f0f83);\n
104# output: report(0x00000010);\n
105# output: report(0xffffb38f);\n
106# output: \n
107# output: report(0xb38f0f83);\n
108# output: report(0x0000001f);\n
109# output: report(0xffffffff);\n
110# output: \n
111# output: report(0x4c70f07c);\n
112# output: report(0x00000001);\n
113# output: report(0x2638783e);\n
114# output: \n
115# output: report(0x4c70f07c);\n
116# output: report(0x00000004);\n
117# output: report(0x04c70f07);\n
118# output: \n
119# output: report(0x4c70f07c);\n
120# output: report(0x00000010);\n
121# output: report(0x00004c70);\n
122# output: \n
123# output: report(0x4c70f07c);\n
124# output: report(0x0000001f);\n
125# output: report(0x00000000);\n
126# output: \n
127# output: report(0xb38f0f83);\n
128# output: report(0x00000021);\n
129# output: report(0xd9c787c1);\n
130# output: \n
131# output: report(0xb38f0f83);\n
132# output: report(0x00002224);\n
133# output: report(0xfb38f0f8);\n
134# output: \n
135# output: report(0xb38f0f83);\n
136# output: report(0x00f789f0);\n
137# output: report(0xffffb38f);\n
138# output: \n
139# output: report(0xb38f0f83);\n
140# output: report(0xffffffff);\n
141# output: report(0xffffffff);\n
142# output: \n
143# output: report(0x4c70f07c);\n
144# output: report(0x00000021);\n
145# output: report(0x2638783e);\n
146# output: \n
147# output: report(0x4c70f07c);\n
148# output: report(0x00002224);\n
149# output: report(0x04c70f07);\n
150# output: \n
151# output: report(0x4c70f07c);\n
152# output: report(0x00f789f0);\n
153# output: report(0x00004c70);\n
154# output: \n
155# output: report(0x4c70f07c);\n
156# output: report(0xffffffff);\n
157# output: report(0x00000000);\n
158# output: \n
159# output: report(0xb38f0f83);\n
160# output: report(0x00000000);\n
161# output: report(0xb38f0f83);\n
162# output: \n
163# output: report(0xb38f0f83);\n
164# output: report(0x00000001);\n
165# output: report(0xd9c787c1);\n
166# output: \n
167# output: report(0xb38f0f83);\n
168# output: report(0x00000004);\n
169# output: report(0xfb38f0f8);\n
170# output: \n
171# output: report(0xb38f0f83);\n
172# output: report(0x00000010);\n
173# output: report(0xffffb38f);\n
174# output: \n
175# output: report(0xb38f0f83);\n
176# output: report(0x0000001f);\n
177# output: report(0xffffffff);\n
178# output: \n
179# output: report(0x4c70f07c);\n
180# output: report(0x00000001);\n
181# output: report(0x2638783e);\n
182# output: \n
183# output: report(0x4c70f07c);\n
184# output: report(0x00000004);\n
185# output: report(0x04c70f07);\n
186# output: \n
187# output: report(0x4c70f07c);\n
188# output: report(0x00000010);\n
189# output: report(0x00004c70);\n
190# output: \n
191# output: report(0x4c70f07c);\n
192# output: report(0x0000001f);\n
193# output: report(0x00000000);\n
194# output: \n
195# output: report(0xb38f0f83);\n
196# output: report(0x00000021);\n
197# output: report(0xd9c787c1);\n
198# output: \n
199# output: report(0xb38f0f83);\n
200# output: report(0x00000024);\n
201# output: report(0xfb38f0f8);\n
202# output: \n
203# output: report(0xb38f0f83);\n
204# output: report(0x00000030);\n
205# output: report(0xffffb38f);\n
206# output: \n
207# output: report(0xb38f0f83);\n
208# output: report(0x0000003f);\n
209# output: report(0xffffffff);\n
210# output: \n
211# output: report(0x4c70f07c);\n
212# output: report(0x00000021);\n
213# output: report(0x2638783e);\n
214# output: \n
215# output: report(0x4c70f07c);\n
216# output: report(0x00000024);\n
217# output: report(0x04c70f07);\n
218# output: \n
219# output: report(0x4c70f07c);\n
220# output: report(0x00000030);\n
221# output: report(0x00004c70);\n
222# output: \n
223# output: report(0x4c70f07c);\n
224# output: report(0x0000003f);\n
225# output: report(0x00000000);\n
226# output: \n
227# output: report(0xb38f0f83);\n
228# output: report(0x00000000);\n
229# output: report(0xb38f0f83);\n
230# output: \n
231# output: report(0xb38f0f83);\n
232# output: report(0x00000001);\n
233# output: report(0x59c787c1);\n
234# output: \n
235# output: report(0xb38f0f83);\n
236# output: report(0x00000004);\n
237# output: report(0x0b38f0f8);\n
238# output: \n
239# output: report(0xb38f0f83);\n
240# output: report(0x00000010);\n
241# output: report(0x0000b38f);\n
242# output: \n
243# output: report(0xb38f0f83);\n
244# output: report(0x0000001f);\n
245# output: report(0x00000001);\n
246# output: \n
247# output: report(0x4c70f07c);\n
248# output: report(0x00000001);\n
249# output: report(0x2638783e);\n
250# output: \n
251# output: report(0x4c70f07c);\n
252# output: report(0x00000004);\n
253# output: report(0x04c70f07);\n
254# output: \n
255# output: report(0x4c70f07c);\n
256# output: report(0x00000010);\n
257# output: report(0x00004c70);\n
258# output: \n
259# output: report(0x4c70f07c);\n
260# output: report(0x0000001f);\n
261# output: report(0x00000000);\n
262# output: \n
263# output: report(0xb38f0f83);\n
264# output: report(0x00000021);\n
265# output: report(0x59c787c1);\n
266# output: \n
267# output: report(0xb38f0f83);\n
268# output: report(0x00002224);\n
269# output: report(0x0b38f0f8);\n
270# output: \n
271# output: report(0xb38f0f83);\n
272# output: report(0x00f789f0);\n
273# output: report(0x0000b38f);\n
274# output: \n
275# output: report(0xb38f0f83);\n
276# output: report(0xffffffff);\n
277# output: report(0x00000001);\n
278# output: \n
279# output: report(0x4c70f07c);\n
280# output: report(0x00000021);\n
281# output: report(0x2638783e);\n
282# output: \n
283# output: report(0x4c70f07c);\n
284# output: report(0x00002224);\n
285# output: report(0x04c70f07);\n
286# output: \n
287# output: report(0x4c70f07c);\n
288# output: report(0x00f789f0);\n
289# output: report(0x00004c70);\n
290# output: \n
291# output: report(0x4c70f07c);\n
292# output: report(0xffffffff);\n
293# output: report(0x00000000);\n
294# output: \n
295# output: report(0xb38f0f83);\n
296# output: report(0x00000000);\n
297# output: report(0xb38f0f83);\n
298# output: \n
299# output: report(0xb38f0f83);\n
300# output: report(0x00000001);\n
301# output: report(0x59c787c1);\n
302# output: \n
303# output: report(0xb38f0f83);\n
304# output: report(0x00000004);\n
305# output: report(0x0b38f0f8);\n
306# output: \n
307# output: report(0xb38f0f83);\n
308# output: report(0x00000010);\n
309# output: report(0x0000b38f);\n
310# output: \n
311# output: report(0xb38f0f83);\n
312# output: report(0x0000001f);\n
313# output: report(0x00000001);\n
314# output: \n
315# output: report(0x4c70f07c);\n
316# output: report(0x00000001);\n
317# output: report(0x2638783e);\n
318# output: \n
319# output: report(0x4c70f07c);\n
320# output: report(0x00000004);\n
321# output: report(0x04c70f07);\n
322# output: \n
323# output: report(0x4c70f07c);\n
324# output: report(0x00000010);\n
325# output: report(0x00004c70);\n
326# output: \n
327# output: report(0x4c70f07c);\n
328# output: report(0x0000001f);\n
329# output: report(0x00000000);\n
330# output: \n
331# output: report(0xb38f0f83);\n
332# output: report(0x00000021);\n
333# output: report(0x59c787c1);\n
334# output: \n
335# output: report(0xb38f0f83);\n
336# output: report(0x00000024);\n
337# output: report(0x0b38f0f8);\n
338# output: \n
339# output: report(0xb38f0f83);\n
340# output: report(0x00000030);\n
341# output: report(0x0000b38f);\n
342# output: \n
343# output: report(0xb38f0f83);\n
344# output: report(0x0000003f);\n
345# output: report(0x00000001);\n
346# output: \n
347# output: report(0x4c70f07c);\n
348# output: report(0x00000021);\n
349# output: report(0x2638783e);\n
350# output: \n
351# output: report(0x4c70f07c);\n
352# output: report(0x00000024);\n
353# output: report(0x04c70f07);\n
354# output: \n
355# output: report(0x4c70f07c);\n
356# output: report(0x00000030);\n
357# output: report(0x00004c70);\n
358# output: \n
359# output: report(0x4c70f07c);\n
360# output: report(0x0000003f);\n
361# output: report(0x00000000);\n
362# output: \n
363# output: exit(0)\n
364
365#include "or1k-asm-test-helpers.h"
366
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
372 \opcode r4, r5, r6
373 CHECK_CARRY_AND_OVERFLOW_NOT_SET r2, r3
374 REPORT_REG_TO_CONSOLE r4
375 PRINT_NEWLINE_TO_CONSOLE
376 .endm
377
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
382 \opcode r4, r5, \op2
383 CHECK_CARRY_AND_OVERFLOW_NOT_SET r2, r3
384 REPORT_REG_TO_CONSOLE r4
385 PRINT_NEWLINE_TO_CONSOLE
386 .endm
387
388 STANDARD_TEST_ENVIRONMENT
389
390 .section .text
391start_tests:
392 PUSH LINK_REGISTER_R9
393
394 /* Always set OVE. We should never trigger an exception, even if
395 this bit is set. */
396 SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3
397
398 /* Test l.sll */
399
400 /* Shift left by zero. */
401 TEST_SHIFT l.sll, 0xb38f0f83, 0x00000000
402
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
408
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
414
415 /* Test l.slli */
416
417 /* Shift left by zero. */
418 TEST_SHIFT_I l.slli, 0xb38f0f83, 0x0000
419
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
425
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
431
432 /* Test l.sra */
433
434 /* Shift right by zero. */
435 TEST_SHIFT l.sra, 0xb38f0f83, 0x00000000
436
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
442
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
447
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
453
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
458
459 /* Test l.srai */
460
461 /* Shift right by zero. */
462 TEST_SHIFT_I l.srai, 0xb38f0f83, 0x0000
463
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
469
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
474
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
480
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
485
486 /* Test l.srl */
487
488 /* Shift right by zero. */
489 TEST_SHIFT l.srl, 0xb38f0f83, 0x00000000
490
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
496
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
501
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
507
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
512
513 /* Test l.srli */
514
515 /* Shift right by zero. */
516 TEST_SHIFT_I l.srli, 0xb38f0f83, 0x0000
517
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
523
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
528
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
534
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
539
540 POP LINK_REGISTER_R9
541 RETURN_TO_LINK_REGISTER_R9
This page took 0.224341 seconds and 4 git commands to generate.