mc.s
4.74 KB
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#include "rsp.h"
#include "mc.h"
.base MSPBOOTBASE
mc_start:
nop
addi store_flag , r0, 1 /* Always store results */
addi dum2, r0, SWITCH_TABLE
addi dum, r0, LOWER( X0Y0 )
lui dum, UPPER( X0Y0 )
sw dum, 0(dum2)
addi dum, r0, LOWER( X1Y0 )
lui dum, UPPER( X1Y0 )
sw dum, 4(dum2)
addi dum, r0, LOWER( X0Y1 )
lui dum, UPPER( X0Y1 )
sw dum, 8(dum2)
addi dum, r0, LOWER( X1Y1 )
lui dum, UPPER( X1Y1 )
sw dum, 12(dum2)
next_block:
nop
nop /* Break here to get input */
nop
lw mvx, MVX(r0)
lw mvy, MVY(r0)
#define xyh dum2
andi xh, mvx, 1
andi yh, mvy, 1
sll xyh, yh, 1
or xyh, xyh, xh /* XYH = (2*yh)+xh */
sll dum, xyh, 2
lw mc4, SWITCH_TABLE(dum)
sra dum, mvx, 1 /* toss the fraction */
andi dum, dum, 0xf /* remaining offset within MB */
addi xLbase, dum, LBASE
addi xRbase, dum, RBASE
addi xObase, r0, OBASE
jal mcFixYAddrs
nop
jalr mc4
nop
jalr mc4
nop
jalr mc4
nop
jalr mc4
nop
/* Chroma */
sra dum2, mvx, 31
and dum2, dum2, xh
add mvx, dum2, mvx
sra mvx, mvx, 1
sra dum, mvy, 31
and dum, dum, yh
add mvy, dum, mvy
sra mvy, mvy, 1
lw dum, MVCX(r0)
lw dum2, MVCY(r0)
bne dum, mvx, error
nop
bne dum2, mvy, error
nop
andi xh, mvx, 1
andi yh, mvy, 1
sll xyh, yh, 1
or xyh, xyh, xh /* XYH = (2*yh)+xh */
sll dum, xyh, 2
lw mc4, SWITCH_TABLE(dum)
sra dum, mvx, 1 /* toss the fraction */
andi dum, dum, 0x7 /* remaining offset within MB */
sll dum, dum, 1 /* Fix for UV interleave */
addi xLbase, dum, LCrBASE
addi xRbase, dum, RCrBASE
addi xObase, r0, OCrBASE
jal mcFixCrAddrs
nop
jalr mc4
nop
jalr mc4
nop
nop
nop /* Break here to write output */
nop
j next_block
nop
mcFixYAddrs:
andi dum, mvx, 1
blez dum, no_fix
addi Lbasep1, xLbase, 1
addi Rbasep1, xRbase, 1
andi dum, mvx, 0x1f /* What about 15.5 case? */
addi dum, dum, -30
blez dum, no_fix
nop /* Could be useful */
addi Lbasep1, Rbasep1, -16
no_fix: ret
nop
mcFixCrAddrs:
andi dum, mvx, 1
blez dum, no_fix2
addi Lbasep1, xLbase, 2
addi Rbasep1, xRbase, 2
andi dum, mvx, 0x1f /* What about 15.5 case? */
addi dum, dum, -30
blez dum, no_fix2
nop /* Could be useful */
addi Lbasep1, Rbasep1, -16
/* We don't need to fix Rbasep1 since
it is page QW aligned already, so
LRQ has no effect! */
no_fix2: ret
nop
error:
nop
nop /* OOPS! */
nop
x0y0:
lqv v0[0], 0(xLbase)
lrv v0[0], 0(xRbase)
lqv v1[0], 16(xLbase)
lrv v1[0], 16(xRbase)
lqv v2[0], 32(xLbase)
lrv v2[0], 32(xRbase)
lqv v3[0], 48(xLbase)
lrv v3[0], 48(xRbase)
finish:
addi xLbase, xLbase, 64
addi xRbase, xRbase, 64
blez store_flag, skip_stores
nop
sqv v0[0], 0(xObase)
sqv v1[0], 16(xObase)
sqv v2[0], 32(xObase)
sqv v3[0], 48(xObase)
addi xObase, xObase, 64
skip_stores:
ret
nop
x1y0:
lqv v0[0], 0(xLbase)
lrv v0[0], 0(xRbase)
lqv t1[0], 0(Lbasep1)
lrv t1[0], 0(Rbasep1)
nop
vaddb v0, v0, t1[1] /* Avg */
lqv v1[0], 16(xLbase)
lrv v1[0], 16(xRbase)
lqv t1[0], 16(Lbasep1)
lrv t1[0], 16(Rbasep1)
nop
vaddb v1, v1, t1[1] /* Avg */
lqv v2[0], 32(xLbase)
lrv v2[0], 32(xRbase)
lqv t1[0], 32(Lbasep1)
lrv t1[0], 32(Rbasep1)
nop
vaddb v2, v2, t1[1] /* Avg */
lqv v3[0], 48(xLbase)
lrv v3[0], 48(xRbase)
lqv t1[0], 48(Lbasep1)
lrv t1[0], 48(Rbasep1)
nop
vaddb v3, v3, t1[1] /* Avg */
addi Lbasep1, Lbasep1, 64
addi Rbasep1, Rbasep1, 64
j finish
nop
#define t3 t1p1
x0y1:
lqv t1[0], 0(xLbase)
lrv t1[0], 0(xRbase)
lqv t2[0], 16(xLbase)
lrv t2[0], 16(xRbase)
nop
vaddb v0, t1, t2[1] /* Avg */
lqv t3[0], 32(xLbase)
lrv t3[0], 32(xRbase)
nop
vaddb v1, t2, t3[1] /* Avg */
lqv t1[0], 48(xLbase)
lrv t1[0], 48(xRbase)
nop
vaddb v2, t3, t1[1] /* Avg */
lqv t2[0], 64(xLbase)
lrv t2[0], 64(xRbase)
nop
vaddb v3, t1, t2[1] /* Avg */
j finish
nop
x1y1:
lqv t1[0], 0(xLbase) /* Prefetch */
lrv t1[0], 0(xRbase)
lqv t1p1[0], 0(Lbasep1)
lrv t1p1[0], 0(Rbasep1)
lqv t2[0], 16(xLbase)
lrv t2[0], 16(xRbase)
lqv t2p1[0], 16(Lbasep1)
lrv t2p1[0], 16(Rbasep1)
vaddb v0, t1, t1p1[2] /* Avg of 4 */
vaccb v0, t2, t2p1[2] /* Avg of 4 */
lqv t1[0], 32(xLbase)
lrv t1[0], 32(xRbase)
lqv t1p1[0], 32(Lbasep1)
lrv t1p1[0], 32(Rbasep1)
nop
vaddb v1, t1, t1p1[2] /* Avg of 4 */
vaccb v1, t2, t2p1[2] /* Avg of 4 */
lqv t2[0], 48(xLbase)
lrv t2[0], 48(xRbase)
lqv t2p1[0], 48(Lbasep1)
lrv t2p1[0], 48(Rbasep1)
nop
vaddb v2, t1, t1p1[2] /* Avg of 4 */
vaccb v2, t2, t2p1[2] /* Avg of 4 */
lqv t1[0], 64(xLbase)
lrv t1[0], 64(xRbase)
lqv t1p1[0], 64(Lbasep1)
lrv t1p1[0], 64(Rbasep1)
nop
vaddb v3, t1, t1p1[2] /* Avg of 4 */
vaccb v3, t2, t2p1[2] /* Avg of 4 */
addi Lbasep1, Lbasep1, 64
addi Rbasep1, Rbasep1, 64
j finish
nop