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
237
238
239
240
241
242
243
244
245
246
247
|
#include "macros.inc"
test_suite mac16
#if XCHAL_HAVE_MAC16
#define ext16(v) (((v) & 0xffff) | (((v) & 0x8000) * 0x1ffffffe))
#define mul16(a, b) ((ext16(a) * ext16(b)))
.macro assert_acc_value v
rsr a4, ACCLO
movi a5, (\v) & 0xffffffff
assert eq, a4, a5
rsr a4, ACCHI
movi a5, (\v) >> 32
sext a5, a5, 7
assert eq, a4, a5
.endm
.macro init_reg sr, reg, val
.if (\sr)
movi a4, \val
wsr a4, \reg
.else
movi \reg, \val
.endif
.endm
.macro test_mulxx mulop, comb, s, t, a, b
init_reg \comb & 2, \s, \a
init_reg \comb & 1, \t, \b
\mulop\().ll \s, \t
assert_acc_value mul16(\a, \b)
\mulop\().lh \s, \t
assert_acc_value mul16(\a, (\b >> 16))
\mulop\().hl \s, \t
assert_acc_value mul16((\a >> 16), \b)
\mulop\().hh \s, \t
assert_acc_value mul16((\a >> 16), (\b >> 16))
.endm
test mul_aa
test_mulxx mul.aa, 0, a2, a3, 0xf7315a5a, 0xa5a5137f
test_end
test mul_ad
test_mulxx mul.ad, 1, a2, m2, 0xf7315a5a, 0xa5a5137f
test_end
test mul_da
test_mulxx mul.da, 2, m1, a3, 0xf7315a5a, 0xa5a5137f
test_end
test mul_dd
test_mulxx mul.dd, 3, m0, m3, 0xf7315a5a, 0xa5a5137f
test_end
.macro init_acc iv
movi a4, (\iv) & 0xffffffff
wsr a4, ACCLO
movi a4, (\iv) >> 32
wsr a4, ACCHI
.endm
.macro test_mulxxx mulop, comb, s, t, a, b, iv, op
init_reg \comb & 2, \s, \a
init_reg \comb & 1, \t, \b
init_acc \iv
\mulop\().ll \s, \t
assert_acc_value (\iv \op mul16(\a, \b))
init_acc \iv
\mulop\().lh \s, \t
assert_acc_value (\iv \op mul16(\a, (\b >> 16)))
init_acc \iv
\mulop\().hl \s, \t
assert_acc_value (\iv \op mul16((\a >> 16), \b))
init_acc \iv
\mulop\().hh \s, \t
assert_acc_value (\iv \op mul16((\a >> 16), (\b >> 16)))
.endm
test mula_aa
test_mulxxx mula.aa, 0, a2, a3, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, +
test_end
test mula_ad
test_mulxxx mula.ad, 1, a2, m2, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, +
test_end
test mula_da
test_mulxxx mula.da, 2, m1, a3, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
test_end
test mula_dd
test_mulxxx mula.dd, 3, m0, m3, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
test_end
test muls_aa
test_mulxxx muls.aa, 0, a2, a3, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, -
test_end
test muls_ad
test_mulxxx muls.ad, 1, a2, m2, 0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, -
test_end
test muls_da
test_mulxxx muls.da, 2, m1, a3, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, -
test_end
test muls_dd
test_mulxxx muls.dd, 3, m0, m3, 0xf7315a5a, 0xa5a5137f, 0xfff73155aa, -
test_end
test ldinc
movi a2, 1f - 4
ldinc m0, a2
movi a3, 1f
assert eq, a2, a3
rsr a3, m0
movi a4, 0x55aa137f
assert eq, a3, a4
ldinc m1, a2
movi a3, 1f + 4
assert eq, a2, a3
rsr a3, m1
movi a4, 0x12345678
assert eq, a3, a4
.data
1: .word 0x55aa137f, 0x12345678, 0x137fa5a5
.text
test_end
test lddec
movi a2, 1f
lddec m2, a2
movi a3, 1f - 4
assert eq, a2, a3
rsr a3, m2
movi a4, 0x12345678
assert eq, a3, a4
lddec m3, a2
movi a3, 1f - 8
assert eq, a2, a3
rsr a3, m3
movi a4, 0x55aa137f
assert eq, a3, a4
.data
.word 0x55aa137f, 0x12345678
1:
.text
test_end
.macro test_mulxxx_ld mulop, ldop, comb, w, x, s, t, a, b, iv, op
init_reg \comb & 2, \s, \a
init_reg \comb & 1, \t, \b
init_acc \iv
\mulop\().ll.\ldop \w, \x, \s, \t
assert_acc_value (\iv \op mul16(\a, \b))
init_acc \iv
\mulop\().lh.\ldop \w, \x, \s, \t
assert_acc_value (\iv \op mul16(\a, (\b >> 16)))
init_acc \iv
\mulop\().hl.\ldop \w, \x, \s, \t
assert_acc_value (\iv \op mul16((\a >> 16), \b))
init_acc \iv
\mulop\().hh.\ldop \w, \x, \s, \t
assert_acc_value (\iv \op mul16((\a >> 16), (\b >> 16)))
.endm
test mula_da_ldinc
movi a2, 1f - 4
test_mulxxx_ld mula.da, ldinc, 2, m1, a2, m1, a3, \
0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
movi a3, 1f + 12
assert eq, a2, a3
rsr a2, m1
movi a3, 0x12345678
assert eq, a2, a3
.data
1: .word 0xf7315a5a, 0xf7315a5a, 0xf7315a5a, 0x12345678
.text
test_end
test mula_dd_ldinc
movi a2, 1f - 4
test_mulxxx_ld mula.dd, ldinc, 3, m2, a2, m1, m2, \
0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
movi a3, 1f + 12
assert eq, a2, a3
rsr a2, m2
movi a3, 0x12345678
assert eq, a2, a3
.data
1: .word 0xa5a5137f, 0xa5a5137f, 0xa5a5137f, 0x12345678
.text
test_end
test mula_da_lddec
movi a2, 1f
test_mulxxx_ld mula.da, lddec, 2, m1, a2, m1, a3, \
0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
movi a3, 1f - 16
assert eq, a2, a3
rsr a2, m1
movi a3, 0x12345678
assert eq, a2, a3
.data
.word 0x12345678, 0xf7315a5a, 0xf7315a5a, 0xf7315a5a
1:
.text
test_end
test mula_dd_lddec
movi a2, 1f
test_mulxxx_ld mula.dd, lddec, 3, m2, a2, m1, m2, \
0xf7315a5a, 0xa5a5137f, 0x0ff73155aa, +
movi a3, 1f - 16
assert eq, a2, a3
rsr a2, m2
movi a3, 0x12345678
assert eq, a2, a3
.data
.word 0x12345678, 0xa5a5137f, 0xa5a5137f, 0xa5a5137f
1:
.text
test_end
#endif
test_suite_end
|