]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/testsuite/sim/or1k/mfspr.S
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / sim / testsuite / sim / or1k / mfspr.S
CommitLineData
702d582e
PG
1/* Tests instructions l.mfspr and l.mtspr.
2
b811d2c2 3 Copyright (C) 2017-2020 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(0x00000000);\n
20# output: report(0x00002801);\n
21# output: report(0xdeadbeef);\n
22# output: \n
23# output: report(0x00002801);\n
24# output: report(0x00000000);\n
25# output: report(0xdeadbeef);\n
26# output: \n
27# output: report(0x00002801);\n
28# output: report(0x00002801);\n
29# output: report(0xdeadbeef);\n
30# output: \n
31# output: report(0x00000801);\n
32# output: report(0x00002000);\n
33# output: report(0xdeadbeef);\n
34# output: \n
35# output: report(0x00002000);\n
36# output: report(0x00000801);\n
37# output: report(0xdeadbeef);\n
38# output: \n
39# output: report(0x00002801);\n
40# output: report(0x00000001);\n
41# output: report(0xdeadbeef);\n
42# output: \n
43# output: report(0x00000800);\n
44# output: report(0x00002801);\n
45# output: report(0xdeadbeef);\n
46# output: \n
47# output: report(0x00000000);\n
48# output: report(0x00002801);\n
49# output: report(0xdeadbeef);\n
50# output: \n
51# output: report(0x00002801);\n
52# output: report(0x00000000);\n
53# output: report(0xdeadbeef);\n
54# output: \n
55# output: report(0x00002801);\n
56# output: report(0x00002801);\n
57# output: report(0xdeadbeef);\n
58# output: \n
59# output: report(0x00000801);\n
60# output: report(0x00002000);\n
61# output: report(0xdeadbeef);\n
62# output: \n
63# output: report(0x00002000);\n
64# output: report(0x00000801);\n
65# output: report(0xdeadbeef);\n
66# output: \n
67# output: report(0x00002801);\n
68# output: report(0x00000001);\n
69# output: report(0xdeadbeef);\n
70# output: \n
71# output: report(0x00000800);\n
72# output: report(0x00002801);\n
73# output: report(0xdeadbeef);\n
74# output: \n
75# output: exit(0)\n
76
77#include "or1k-asm-test-env.h"
78
79#define MACLO_VAL 0xdeadbeef
80
81 /* A macro to carry out a test of l.mfspr.
82
83 MACLO (0x2801) is used as the SPR, since it can be read and
84 cleared using l.macrc and can be set using l.maci. spr_number
85 and immediate_val_to_or should be chosen to address this
86 register.
87
88 The value placed in the register is entirely arbitrary - we use
89 0xdeadbeef. */
90
91 .macro TEST_MFSPR spr_number, immediate_val_to_or
92 REPORT_IMMEDIATE_TO_CONSOLE \spr_number
93 REPORT_IMMEDIATE_TO_CONSOLE \immediate_val_to_or
94 /* Write MACLO_VAL to MACLO. */
95 l.macrc r2
96 LOAD_IMMEDIATE r2, MACLO_VAL
97 l.maci r2, 1
98 LOAD_IMMEDIATE r5, \spr_number
99 l.mfspr r4, r5, \immediate_val_to_or
100 REPORT_REG_TO_CONSOLE r4
101 PRINT_NEWLINE_TO_CONSOLE
102 .endm
103
104 /* A macro to carry out a test of l.mtspr
105
106 MACLO (0x2801) is used as the SPR, since it can be read and
107 cleared using l.macrc and can be set using l.maci. The
108 arguments spr_number and immediate_val_to_or should be chosen
109 to address this register.
110
111 The value placed in the register is entirely arbitrary - we use
112 0xdeadbeef. */
113
114 .macro TEST_MTSPR spr_number, immediate_val_to_or
115 REPORT_IMMEDIATE_TO_CONSOLE \spr_number
116 REPORT_IMMEDIATE_TO_CONSOLE \immediate_val_to_or
117 /* Clear MACLO */
118 l.macrc r2
119 LOAD_IMMEDIATE r4, MACLO_VAL
120 LOAD_IMMEDIATE r5, \spr_number
121 l.mtspr r5, r4, \immediate_val_to_or
122 /* Retrieve MACLO. */
123 l.macrc r4
124 REPORT_REG_TO_CONSOLE r4
125 PRINT_NEWLINE_TO_CONSOLE
126 .endm
127
128 STANDARD_TEST_ENVIRONMENT
129
130 .section .text
131start_tests:
132 PUSH LINK_REGISTER_R9
133
134 /* Test the l.mfspr instruction with a range of operands. */
135
136 /* Move a test value using zero in the register. */
137 TEST_MFSPR SPR_VR, SPR_MACLO /* 0x0000, 0x2801 */
138
139 /* Move a test value using zero as the constant. */
140 TEST_MFSPR SPR_MACLO, SPR_VR /* 0x2801, 0x0000 */
141
142 /* Move a test value using non-zero in both register and constant. */
143
144 /* Some of these values will not give the correct result if OR
145 rather than ADD is used to determine the SPR address. */
146 TEST_MFSPR SPR_MACLO, SPR_MACLO /* 0x2801, 0x2801 */
147 TEST_MFSPR SPR_DMMUPR, SPR_ICCR /* 0x0801, 0x2000 */
148 TEST_MFSPR SPR_ICCR, SPR_DMMUPR /* 0x2000, 0x0801 */
149 TEST_MFSPR SPR_MACLO, SPR_UPR /* 0x2801, 0x0001 */
150 TEST_MFSPR SPR_DMMUCR, SPR_MACLO /* 0x0800, 0x2801 */
151
152 /* Test the l.mtspr instruction with a range of operands. */
153
154 /* Move a test value using zero in the register. */
155 TEST_MTSPR SPR_VR, SPR_MACLO /* 0x0000, 0x2801 */
156
157 /* Move a test value using zero as the constant. */
158 TEST_MTSPR SPR_MACLO, SPR_VR /* 0x2801, 0x0000 */
159
160 /* Move a test value using non-zero in both register and constant. */
161
162 /* Some of these values will not give the correct result if or
163 rather than add is used to determine the SPR address. */
164 TEST_MTSPR SPR_MACLO, SPR_MACLO /* 0x2801, 0x2801 */
165 TEST_MTSPR SPR_DMMUPR, SPR_ICCR /* 0x0801, 0x2000 */
166 TEST_MTSPR SPR_ICCR, SPR_DMMUPR /* 0x2000, 0x0801 */
167 TEST_MTSPR SPR_MACLO, SPR_UPR /* 0x2801, 0x0001 */
168 TEST_MTSPR SPR_DMMUCR, SPR_MACLO /* 0x0800, 0x2801 */
169
170 POP LINK_REGISTER_R9
171 RETURN_TO_LINK_REGISTER_R9