summaryrefslogtreecommitdiff
path: root/sim/testsuite/sim/or1k/ext.S
blob: e7e68f0c474c13e2ff6ffe8be865f64388dd1576 (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
/* Tests the l.ext{b,h}{s,z} instructions.

   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(0x0000007f);\n
# output: report(0x0000007f);\n
# output: report(0x00000053);\n
# output: report(0x00000053);\n
# output: report(0x0000ff53);\n
# output: report(0x00000053);\n
# output: report(0x00001234);\n
# output: report(0x00000034);\n
# output: report(0x000000ff);\n
# output: report(0xffffffff);\n
# output: report(0x00000080);\n
# output: report(0xffffff80);\n
# output: report(0x0000ff80);\n
# output: report(0xffffff80);\n
# output: report(0x00007f80);\n
# output: report(0xffffff80);\n
# output: report(0x00007fff);\n
# output: report(0xffffffff);\n
# output: report(0x0000007f);\n
# output: report(0x0000007f);\n
# output: report(0x00000053);\n
# output: report(0x00000053);\n
# output: report(0x0000ff53);\n
# output: report(0x00000053);\n
# output: report(0x00001234);\n
# output: report(0x00000034);\n
# output: report(0x000000ff);\n
# output: report(0x000000ff);\n
# output: report(0x00000080);\n
# output: report(0x00000080);\n
# output: report(0x0000ff80);\n
# output: report(0x00000080);\n
# output: report(0x00007f80);\n
# output: report(0x00000080);\n
# output: report(0x00007fff);\n
# output: report(0x000000ff);\n
# output: report(0x00007fff);\n
# output: report(0x00007fff);\n
# output: report(0x00005233);\n
# output: report(0x00005233);\n
# output: report(0xffff2f53);\n
# output: report(0x00002f53);\n
# output: report(0x12345678);\n
# output: report(0x00005678);\n
# output: report(0x0000ffff);\n
# output: report(0xffffffff);\n
# output: report(0x00008000);\n
# output: report(0xffff8000);\n
# output: report(0x0000ff80);\n
# output: report(0xffffff80);\n
# output: report(0x80008000);\n
# output: report(0xffff8000);\n
# output: report(0x7fffffff);\n
# output: report(0xffffffff);\n
# output: report(0x00007fff);\n
# output: report(0x00007fff);\n
# output: report(0x00005233);\n
# output: report(0x00005233);\n
# output: report(0xffff2f53);\n
# output: report(0x00002f53);\n
# output: report(0x12345678);\n
# output: report(0x00005678);\n
# output: report(0x0000ffff);\n
# output: report(0x0000ffff);\n
# output: report(0x00008000);\n
# output: report(0x00008000);\n
# output: report(0x0000ff80);\n
# output: report(0x0000ff80);\n
# output: report(0x80008000);\n
# output: report(0x00008000);\n
# output: report(0x7fffffff);\n
# output: report(0x0000ffff);\n
# output: report(0xffffffff);\n
# output: report(0xffffffff);\n
# output: report(0x7fffffff);\n
# output: report(0x7fffffff);\n
# output: report(0x7fff7fff);\n
# output: report(0x7fff7fff);\n
# output: report(0xffff7f7f);\n
# output: report(0xffff7f7f);\n
# output: report(0xffffff7f);\n
# output: report(0xffffff7f);\n
# output: report(0xffff7fff);\n
# output: report(0xffff7fff);\n
# output: report(0x7fff7f7f);\n
# output: report(0x7fff7f7f);\n
# output: report(0x12345678);\n
# output: report(0x12345678);\n
# output: report(0xffffffff);\n
# output: report(0xffffffff);\n
# output: report(0x7fffffff);\n
# output: report(0x7fffffff);\n
# output: report(0x7fff7fff);\n
# output: report(0x7fff7fff);\n
# output: report(0xffff7f7f);\n
# output: report(0xffff7f7f);\n
# output: report(0xffffff7f);\n
# output: report(0xffffff7f);\n
# output: report(0xffff7fff);\n
# output: report(0xffff7fff);\n
# output: report(0x7fff7f7f);\n
# output: report(0x7fff7f7f);\n
# output: report(0x12345678);\n
# output: report(0x12345678);\n
# output: exit(0)\n

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

	.macro CHECK_EXT insn, val, mask, high_mask
	LOAD_IMMEDIATE r4, \val
	REPORT_REG_TO_CONSOLE r4
	\insn   r5, r4
	REPORT_REG_TO_CONSOLE r5
	LOAD_IMMEDIATE r6, \mask
	l.xori  r7, r6, -1
	l.and   r8, r4, r6
	l.and   r9, r5, r6
	l.sfne  r8, r9
	OR1K_DELAYED_NOP (l.bf    ext_fail)
	l.and   r8, r5, r7
	LOAD_IMMEDIATE r7, \high_mask
	l.sfne  r8, r7
	OR1K_DELAYED_NOP (l.bf    ext_fail)
	.endm

#define CHECK_HIGH3_CLEAR(insn, val) CHECK_EXT insn, val, 0x000000ff, 0
#define CHECK_HIGH3_SET(val) CHECK_EXT l.extbs, val, 0x000000ff, 0xffffff00
#define CHECK_HIGH2_CLEAR(insn, val) CHECK_EXT insn, val, 0x0000ffff, 0
#define CHECK_HIGH2_SET(val) CHECK_EXT l.exths, val, 0x0000ffff, 0xffff0000

	.macro CHECK_MOVE insn, val
	LOAD_IMMEDIATE r4, \val
	REPORT_REG_TO_CONSOLE r4
	\insn   r5, r4
	REPORT_REG_TO_CONSOLE r5
	l.sfne  r5, r4
	OR1K_DELAYED_NOP (l.bf    ext_fail)
	.endm

	STANDARD_TEST_ENVIRONMENT

	.section .text
start_tests:
	PUSH LINK_REGISTER_R9

	/* Test l.extbs  */
	CHECK_HIGH3_CLEAR ( l.extbs, 0x7f   )
	CHECK_HIGH3_CLEAR ( l.extbs, 0x53   )
	CHECK_HIGH3_CLEAR ( l.extbs, 0xff53 )
	CHECK_HIGH3_CLEAR ( l.extbs, 0x1234 )

	CHECK_HIGH3_SET (0xff)
	CHECK_HIGH3_SET (0x80)
	CHECK_HIGH3_SET (0xff80)
	CHECK_HIGH3_SET (0x7f80)
	CHECK_HIGH3_SET (0x7fff)

	/* Test l.extbz  */
	CHECK_HIGH3_CLEAR (l.extbz, 0x7f)
	CHECK_HIGH3_CLEAR (l.extbz, 0x53)
	CHECK_HIGH3_CLEAR (l.extbz, 0xff53)
	CHECK_HIGH3_CLEAR (l.extbz, 0x1234)

	CHECK_HIGH3_CLEAR (l.extbz, 0xff)
	CHECK_HIGH3_CLEAR (l.extbz, 0x80)
	CHECK_HIGH3_CLEAR (l.extbz, 0xff80)
	CHECK_HIGH3_CLEAR (l.extbz, 0x7f80)
	CHECK_HIGH3_CLEAR (l.extbz, 0x7fff)

	/* Test l.exths  */
	CHECK_HIGH2_CLEAR (l.exths, 0x7fff)
	CHECK_HIGH2_CLEAR (l.exths, 0x5233)
	CHECK_HIGH2_CLEAR (l.exths, 0xffff2f53)
	CHECK_HIGH2_CLEAR (l.exths, 0x12345678)

	CHECK_HIGH2_SET (0xffff)
	CHECK_HIGH2_SET (0x8000)
	CHECK_HIGH2_SET (0xff80)
	CHECK_HIGH2_SET (0x80008000)
	CHECK_HIGH2_SET (0x7fffffff)

	/* Test l.exthz  */
	CHECK_HIGH2_CLEAR (l.exthz, 0x7fff)
	CHECK_HIGH2_CLEAR (l.exthz, 0x5233)
	CHECK_HIGH2_CLEAR (l.exthz, 0xffff2f53)
	CHECK_HIGH2_CLEAR (l.exthz, 0x12345678)

	CHECK_HIGH2_CLEAR (l.exthz, 0xffff)
	CHECK_HIGH2_CLEAR (l.exthz, 0x8000)
	CHECK_HIGH2_CLEAR (l.exthz, 0xff80)
	CHECK_HIGH2_CLEAR (l.exthz, 0x80008000)
	CHECK_HIGH2_CLEAR (l.exthz, 0x7fffffff)

	/* Test l.extws  */
	CHECK_MOVE l.extws, 0xffffffff
	CHECK_MOVE l.extws, 0x7fffffff
	CHECK_MOVE l.extws, 0x7fff7fff
	CHECK_MOVE l.extws, 0xffff7f7f
	CHECK_MOVE l.extws, 0xffffff7f
	CHECK_MOVE l.extws, 0xffff7fff
	CHECK_MOVE l.extws, 0x7fff7f7f
	CHECK_MOVE l.extws, 0x12345678

	/* Test l.extwz  */
	CHECK_MOVE l.extwz, 0xffffffff
	CHECK_MOVE l.extwz, 0x7fffffff
	CHECK_MOVE l.extwz, 0x7fff7fff
	CHECK_MOVE l.extwz, 0xffff7f7f
	CHECK_MOVE l.extwz, 0xffffff7f
	CHECK_MOVE l.extwz, 0xffff7fff
	CHECK_MOVE l.extwz, 0x7fff7f7f
	CHECK_MOVE l.extwz, 0x12345678

	POP LINK_REGISTER_R9
	RETURN_TO_LINK_REGISTER_R9

ext_fail:
	EXIT_SIMULATION_WITH_IMMEDIATE_EXIT_CODE SEC_GENERIC_ERROR