summaryrefslogtreecommitdiffstats
path: root/qemu/tests/tcg/xtensa/test_shift.S
blob: 5df9ed4b1e1ebe329e93632ff62430e59d554d00 (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
#include "macros.inc"

test_suite shift

.macro test_shift prefix, dst, src, v, imm
    \prefix\()_set \dst, \src, \v, \imm
    \prefix\()_ver \dst, \v, \imm
.endm

.macro test_shift_sd prefix, v, imm
    test_shift \prefix, a3, a2, \v, \imm
    test_shift \prefix, a2, a2, \v, \imm
.endm

.macro tests_imm_shift prefix, v
    test_shift_sd \prefix, \v, 1
    test_shift_sd \prefix, \v, 2
    test_shift_sd \prefix, \v, 7
    test_shift_sd \prefix, \v, 8
    test_shift_sd \prefix, \v, 15
    test_shift_sd \prefix, \v, 16
    test_shift_sd \prefix, \v, 31
.endm

.macro tests_shift prefix, v
    test_shift_sd \prefix, \v, 0
    tests_imm_shift \prefix, \v
    test_shift_sd \prefix, \v, 32
.endm


.macro slli_set dst, src, v, imm
    movi    \src, \v
    slli    \dst, \src, \imm
.endm

.macro slli_ver dst, v, imm
    mov     a2, \dst
    movi    a3, ((\v) << (\imm)) & 0xffffffff
    assert  eq, a2, a3
.endm

test slli
    tests_imm_shift slli, 0xa3c51249
test_end


.macro srai_set dst, src, v, imm
    movi    \src, \v
    srai    \dst, \src, \imm
.endm

.macro srai_ver dst, v, imm
    mov     a2, \dst
    .if (\imm)
    movi    a3, (((\v) >> (\imm)) & 0xffffffff) | \
                ~((((\v) & 0x80000000) >> ((\imm) - 1)) - 1)
    .else
    movi    a3, \v
    .endif
    assert  eq, a2, a3
.endm

test srai
    tests_imm_shift srai, 0x49a3c512
    tests_imm_shift srai, 0xa3c51249
test_end


.macro srli_set dst, src, v, imm
    movi    \src, \v
    srli    \dst, \src, \imm
.endm

.macro srli_ver dst, v, imm
    mov     a2, \dst
    movi    a3, (((\v) >> (\imm)) & 0xffffffff)
    assert  eq, a2, a3
.endm

test srli
    tests_imm_shift srli, 0x49a3c512
    tests_imm_shift srli, 0xa3c51249
test_end


.macro sll_set dst, src, v, imm
    movi    a2, \imm
    ssl     a2
    movi    \src, \v
    sll     \dst, \src
.endm

.macro sll_sar_set dst, src, v, imm
    movi    a2, 32 - \imm
    wsr     a2, sar
    movi    \src, \v
    sll     \dst, \src
.endm

.macro sll_ver dst, v, imm
    slli_ver \dst, \v, (\imm) & 0x1f
.endm

.macro sll_sar_ver dst, v, imm
    slli_ver \dst, \v, \imm
.endm

test sll
    tests_shift sll, 0xa3c51249
    tests_shift sll_sar, 0xa3c51249
test_end


.macro srl_set dst, src, v, imm
    movi    a2, \imm
    ssr     a2
    movi    \src, \v
    srl     \dst, \src
.endm

.macro srl_sar_set dst, src, v, imm
    movi    a2, \imm
    wsr     a2, sar
    movi    \src, \v
    srl     \dst, \src
.endm

.macro srl_ver dst, v, imm
    srli_ver \dst, \v, (\imm) & 0x1f
.endm

.macro srl_sar_ver dst, v, imm
    srli_ver \dst, \v, \imm
.endm

test srl
    tests_shift srl, 0xa3c51249
    tests_shift srl_sar, 0xa3c51249
    tests_shift srl, 0x49a3c512
    tests_shift srl_sar, 0x49a3c512
test_end


.macro sra_set dst, src, v, imm
    movi    a2, \imm
    ssr     a2
    movi    \src, \v
    sra     \dst, \src
.endm

.macro sra_sar_set dst, src, v, imm
    movi    a2, \imm
    wsr     a2, sar
    movi    \src, \v
    sra     \dst, \src
.endm

.macro sra_ver dst, v, imm
    srai_ver \dst, \v, (\imm) & 0x1f
.endm

.macro sra_sar_ver dst, v, imm
    srai_ver \dst, \v, \imm
.endm

test sra
    tests_shift sra, 0xa3c51249
    tests_shift sra_sar, 0xa3c51249
    tests_shift sra, 0x49a3c512
    tests_shift sra_sar, 0x49a3c512
test_end


.macro src_set dst, src, v, imm
    movi    a2, \imm
    ssr     a2
    movi    \src, (\v) & 0xffffffff
    movi    a4, (\v) >> 32
    src     \dst, a4, \src
.endm

.macro src_sar_set dst, src, v, imm
    movi    a2, \imm
    wsr     a2, sar
    movi    \src, (\v) & 0xffffffff
    movi    a4, (\v) >> 32
    src     \dst, a4, \src
.endm

.macro src_ver dst, v, imm
    src_sar_ver \dst, \v, (\imm) & 0x1f
.endm

.macro src_sar_ver dst, v, imm
    mov     a2, \dst
    movi    a3, ((\v) >> (\imm)) & 0xffffffff
    assert  eq, a2, a3
.endm

test src
    tests_shift src, 0xa3c51249215c3a94
    tests_shift src_sar, 0xa3c51249215c3a94
test_end

test_suite_end