summaryrefslogtreecommitdiff
path: root/sim/testsuite/or1k/mfspr.S
blob: 1aa74e195b67cf141b416106317dd5e8e5d2056d (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
/* Tests instructions l.mfspr and l.mtspr.

   Copyright (C) 2017-2021 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

# mach: or1k
# output: report(0x00000000);\n
# output: report(0x00002801);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00002801);\n
# output: report(0x00000000);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00002801);\n
# output: report(0x00002801);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00000801);\n
# output: report(0x00002000);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00002000);\n
# output: report(0x00000801);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00002801);\n
# output: report(0x00000001);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00000800);\n
# output: report(0x00002801);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00000000);\n
# output: report(0x00002801);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00002801);\n
# output: report(0x00000000);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00002801);\n
# output: report(0x00002801);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00000801);\n
# output: report(0x00002000);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00002000);\n
# output: report(0x00000801);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00002801);\n
# output: report(0x00000001);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: report(0x00000800);\n
# output: report(0x00002801);\n
# output: report(0xdeadbeef);\n
# output: \n
# output: exit(0)\n

#include "or1k-asm-test-env.h"

#define MACLO_VAL 0xdeadbeef

	/* A macro to carry out a test of l.mfspr.

	   MACLO (0x2801) is used as the SPR, since it can be read and
	   cleared using l.macrc and can be set using l.maci.  spr_number
	   and immediate_val_to_or should be chosen to address this
	   register.

	   The value placed in the register is entirely arbitrary - we use
	   0xdeadbeef.  */

	.macro TEST_MFSPR  spr_number, immediate_val_to_or
	REPORT_IMMEDIATE_TO_CONSOLE \spr_number
	REPORT_IMMEDIATE_TO_CONSOLE \immediate_val_to_or
	/* Write MACLO_VAL to MACLO.  */
	l.macrc r2
	LOAD_IMMEDIATE r2, MACLO_VAL
	l.maci  r2, 1
	LOAD_IMMEDIATE r5, \spr_number
	l.mfspr r4, r5, \immediate_val_to_or
	REPORT_REG_TO_CONSOLE r4
	PRINT_NEWLINE_TO_CONSOLE
	.endm

	/* A macro to carry out a test of l.mtspr

	   MACLO (0x2801) is used as the SPR, since it can be read and
	   cleared using l.macrc and can be set using l.maci.  The
	   arguments spr_number and immediate_val_to_or should be chosen
	   to address this register.

	   The value placed in the register is entirely arbitrary - we use
	   0xdeadbeef.  */

	.macro TEST_MTSPR  spr_number, immediate_val_to_or
	REPORT_IMMEDIATE_TO_CONSOLE \spr_number
	REPORT_IMMEDIATE_TO_CONSOLE \immediate_val_to_or
	/* Clear MACLO  */
	l.macrc r2
	LOAD_IMMEDIATE r4, MACLO_VAL
	LOAD_IMMEDIATE r5, \spr_number
	l.mtspr r5, r4, \immediate_val_to_or
	/* Retrieve MACLO.  */
	l.macrc r4
	REPORT_REG_TO_CONSOLE r4
	PRINT_NEWLINE_TO_CONSOLE
	.endm

	STANDARD_TEST_ENVIRONMENT

	.section .text
start_tests:
	PUSH LINK_REGISTER_R9

	/* Test the l.mfspr instruction with a range of operands.  */

	/* Move a test value using zero in the register.  */
	TEST_MFSPR SPR_VR, SPR_MACLO /* 0x0000, 0x2801  */

	/* Move a test value using zero as the constant.  */
	TEST_MFSPR SPR_MACLO, SPR_VR /* 0x2801, 0x0000  */

	/* Move a test value using non-zero in both register and constant.  */

	/* Some of these values will not give the correct result if OR
	   rather than ADD is used to determine the SPR address.  */
	TEST_MFSPR SPR_MACLO,  SPR_MACLO /* 0x2801, 0x2801  */
	TEST_MFSPR SPR_DMMUPR, SPR_ICCR /* 0x0801, 0x2000  */
	TEST_MFSPR SPR_ICCR,   SPR_DMMUPR /* 0x2000, 0x0801  */
	TEST_MFSPR SPR_MACLO,  SPR_UPR /* 0x2801, 0x0001  */
	TEST_MFSPR SPR_DMMUCR, SPR_MACLO /* 0x0800, 0x2801  */

	/* Test the l.mtspr instruction with a range of operands.  */

	/* Move a test value using zero in the register.  */
	TEST_MTSPR SPR_VR, SPR_MACLO /* 0x0000, 0x2801  */

	/* Move a test value using zero as the constant.  */
	TEST_MTSPR SPR_MACLO, SPR_VR /* 0x2801, 0x0000  */

	/* Move a test value using non-zero in both register and constant.  */

	/* Some of these values will not give the correct result if or
	   rather than add is used to determine the SPR address.  */
	TEST_MTSPR SPR_MACLO,  SPR_MACLO /* 0x2801, 0x2801  */
	TEST_MTSPR SPR_DMMUPR, SPR_ICCR /* 0x0801, 0x2000  */
	TEST_MTSPR SPR_ICCR,   SPR_DMMUPR /* 0x2000, 0x0801  */
	TEST_MTSPR SPR_MACLO,  SPR_UPR /* 0x2801, 0x0001  */
	TEST_MTSPR SPR_DMMUCR, SPR_MACLO /* 0x0800, 0x2801  */

	POP LINK_REGISTER_R9
	RETURN_TO_LINK_REGISTER_R9