summaryrefslogtreecommitdiffstats
path: root/media/libtheora/lib/x86/sse2trans.h
blob: e76da5140bc4563a30530b173ddf79d54144cca6 (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
237
238
239
240
241
242
/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009                *
 * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
 *                                                                  *
 ********************************************************************

  function:
    last mod: $Id: sse2trans.h 15675 2009-02-06 09:43:27Z tterribe $

 ********************************************************************/

#if !defined(_x86_sse2trans_H)
# define _x86_sse2trans_H (1)
# include "x86int.h"

# if defined(OC_X86_64_ASM)
/*On x86-64 we can transpose in-place without spilling registers.
  By clever choices of the order to apply the butterflies and the order of
   their outputs, we can take the rows in order and output the columns in order
   without any extra operations and using just one temporary register.*/
#  define OC_TRANSPOSE_8x8 \
 "#OC_TRANSPOSE_8x8\n\t" \
 "movdqa %%xmm4,%%xmm8\n\t" \
 /*xmm4 = f3 e3 f2 e2 f1 e1 f0 e0*/ \
 "punpcklwd %%xmm5,%%xmm4\n\t" \
 /*xmm8 = f7 e7 f6 e6 f5 e5 f4 e4*/ \
 "punpckhwd %%xmm5,%%xmm8\n\t" \
 /*xmm5 is free.*/ \
 "movdqa %%xmm0,%%xmm5\n\t" \
 /*xmm0 = b3 a3 b2 a2 b1 a1 b0 a0*/ \
 "punpcklwd %%xmm1,%%xmm0\n\t" \
 /*xmm5 = b7 a7 b6 a6 b5 a5 b4 a4*/ \
 "punpckhwd %%xmm1,%%xmm5\n\t" \
 /*xmm1 is free.*/ \
 "movdqa %%xmm6,%%xmm1\n\t" \
 /*xmm6 = h3 g3 h2 g2 h1 g1 h0 g0*/ \
 "punpcklwd %%xmm7,%%xmm6\n\t" \
 /*xmm1 = h7 g7 h6 g6 h5 g5 h4 g4*/ \
 "punpckhwd %%xmm7,%%xmm1\n\t" \
 /*xmm7 is free.*/ \
 "movdqa %%xmm2,%%xmm7\n\t" \
 /*xmm2 = d7 c7 d6 c6 d5 c5 d4 c4*/ \
 "punpckhwd %%xmm3,%%xmm2\n\t" \
 /*xmm7 = d3 c3 d2 c2 d1 c1 d0 c0*/ \
 "punpcklwd %%xmm3,%%xmm7\n\t" \
 /*xmm3 is free.*/ \
 "movdqa %%xmm0,%%xmm3\n\t" \
 /*xmm0 = d1 c1 b1 a1 d0 c0 b0 a0*/ \
 "punpckldq %%xmm7,%%xmm0\n\t" \
 /*xmm3 = d3 c3 b3 a3 d2 c2 b2 a2*/ \
 "punpckhdq %%xmm7,%%xmm3\n\t" \
 /*xmm7 is free.*/ \
 "movdqa %%xmm5,%%xmm7\n\t" \
 /*xmm5 = d5 c5 b5 a5 d4 c4 b4 a4*/ \
 "punpckldq %%xmm2,%%xmm5\n\t" \
 /*xmm7 = d7 c7 b7 a7 d6 c6 b6 a6*/ \
 "punpckhdq %%xmm2,%%xmm7\n\t" \
 /*xmm2 is free.*/ \
 "movdqa %%xmm4,%%xmm2\n\t" \
 /*xmm4 = h3 g3 f3 e3 h2 g2 f2 e2*/ \
 "punpckhdq %%xmm6,%%xmm4\n\t" \
 /*xmm2 = h1 g1 f1 e1 h0 g0 f0 e0*/ \
 "punpckldq %%xmm6,%%xmm2\n\t" \
 /*xmm6 is free.*/ \
 "movdqa %%xmm8,%%xmm6\n\t" \
 /*xmm6 = h5 g5 f5 e5 h4 g4 f4 e4*/ \
 "punpckldq %%xmm1,%%xmm6\n\t" \
 /*xmm8 = h7 g7 f7 e7 h6 g6 f6 e6*/ \
 "punpckhdq %%xmm1,%%xmm8\n\t" \
 /*xmm1 is free.*/ \
 "movdqa %%xmm0,%%xmm1\n\t" \
 /*xmm0 = h0 g0 f0 e0 d0 c0 b0 a0*/ \
 "punpcklqdq %%xmm2,%%xmm0\n\t" \
 /*xmm1 = h1 g1 f1 e1 d1 c1 b1 a1*/ \
 "punpckhqdq %%xmm2,%%xmm1\n\t" \
 /*xmm2 is free.*/ \
 "movdqa %%xmm3,%%xmm2\n\t" \
 /*xmm3 = h3 g3 f3 e3 d3 c3 b3 a3*/ \
 "punpckhqdq %%xmm4,%%xmm3\n\t" \
 /*xmm2 = h2 g2 f2 e2 d2 c2 b2 a2*/ \
 "punpcklqdq %%xmm4,%%xmm2\n\t" \
 /*xmm4 is free.*/ \
 "movdqa %%xmm5,%%xmm4\n\t" \
 /*xmm5 = h5 g5 f5 e5 d5 c5 b5 a5*/ \
 "punpckhqdq %%xmm6,%%xmm5\n\t" \
 /*xmm4 = h4 g4 f4 e4 d4 c4 b4 a4*/ \
 "punpcklqdq %%xmm6,%%xmm4\n\t" \
 /*xmm6 is free.*/ \
 "movdqa %%xmm7,%%xmm6\n\t" \
 /*xmm7 = h7 g7 f7 e7 d7 c7 b7 a7*/ \
 "punpckhqdq %%xmm8,%%xmm7\n\t" \
 /*xmm6 = h6 g6 f6 e6 d6 c6 b6 a6*/ \
 "punpcklqdq %%xmm8,%%xmm6\n\t" \
 /*xmm8 is free.*/ \

# else
/*Otherwise, we need to spill some values to %[buf] temporarily.
  Again, the butterflies are carefully arranged to get the columns to come out
   in order, minimizing register spills and maximizing the delay between a load
   and when the value loaded is actually used.*/
#  define OC_TRANSPOSE_8x8 \
 "#OC_TRANSPOSE_8x8\n\t" \
 /*buf[0] = a7 a6 a5 a4 a3 a2 a1 a0*/ \
 "movdqa %%xmm0,"OC_MEM_OFFS(0x00,buf)"\n\t" \
 /*xmm0 is free.*/ \
 "movdqa %%xmm2,%%xmm0\n\t" \
 /*xmm2 = d7 c7 d6 c6 d5 c5 d4 c4*/ \
 "punpckhwd %%xmm3,%%xmm2\n\t" \
 /*xmm0 = d3 c3 d2 c2 d1 c1 d0 c0*/ \
 "punpcklwd %%xmm3,%%xmm0\n\t" \
 /*xmm3 = a7 a6 a5 a4 a3 a2 a1 a0*/ \
 "movdqa "OC_MEM_OFFS(0x00,buf)",%%xmm3\n\t" \
 /*buf[1] = d7 c7 d6 c6 d5 c5 d4 c4*/ \
 "movdqa %%xmm2,"OC_MEM_OFFS(0x10,buf)"\n\t" \
 /*xmm2 is free.*/ \
 "movdqa %%xmm6,%%xmm2\n\t" \
 /*xmm6 = h3 g3 h2 g2 h1 g1 h0 g0*/ \
 "punpcklwd %%xmm7,%%xmm6\n\t" \
 /*xmm2 = h7 g7 h6 g6 h5 g5 h4 g4*/ \
 "punpckhwd %%xmm7,%%xmm2\n\t" \
 /*xmm7 is free.*/ \
 "movdqa %%xmm4,%%xmm7\n\t" \
 /*xmm4 = f3 e3 f2 e2 f1 e1 f0 e0*/ \
 "punpcklwd %%xmm5,%%xmm4\n\t" \
 /*xmm7 = f7 e7 f6 e6 f5 e5 f4 e4*/ \
 "punpckhwd %%xmm5,%%xmm7\n\t" \
 /*xmm5 is free.*/ \
 "movdqa %%xmm3,%%xmm5\n\t" \
 /*xmm3 = b3 a3 b2 a2 b1 a1 b0 a0*/ \
 "punpcklwd %%xmm1,%%xmm3\n\t" \
 /*xmm5 = b7 a7 b6 a6 b5 a5 b4 a4*/ \
 "punpckhwd %%xmm1,%%xmm5\n\t" \
 /*xmm1 is free.*/ \
 "movdqa %%xmm7,%%xmm1\n\t" \
 /*xmm7 = h5 g5 f5 e5 h4 g4 f4 e4*/ \
 "punpckldq %%xmm2,%%xmm7\n\t" \
 /*xmm1 = h7 g7 f7 e7 h6 g6 f6 e6*/ \
 "punpckhdq %%xmm2,%%xmm1\n\t" \
 /*xmm2 = d7 c7 d6 c6 d5 c5 d4 c4*/ \
 "movdqa "OC_MEM_OFFS(0x10,buf)",%%xmm2\n\t" \
 /*buf[0] = h7 g7 f7 e7 h6 g6 f6 e6*/ \
 "movdqa %%xmm1,"OC_MEM_OFFS(0x00,buf)"\n\t" \
 /*xmm1 is free.*/ \
 "movdqa %%xmm3,%%xmm1\n\t" \
 /*xmm3 = d3 c3 b3 a3 d2 c2 b2 a2*/ \
 "punpckhdq %%xmm0,%%xmm3\n\t" \
 /*xmm1 = d1 c1 b1 a1 d0 c0 b0 a0*/ \
 "punpckldq %%xmm0,%%xmm1\n\t" \
 /*xmm0 is free.*/ \
 "movdqa %%xmm4,%%xmm0\n\t" \
 /*xmm4 = h3 g3 f3 e3 h2 g2 f2 e2*/ \
 "punpckhdq %%xmm6,%%xmm4\n\t" \
 /*xmm0 = h1 g1 f1 e1 h0 g0 f0 e0*/ \
 "punpckldq %%xmm6,%%xmm0\n\t" \
 /*xmm6 is free.*/ \
 "movdqa %%xmm5,%%xmm6\n\t" \
 /*xmm5 = d5 c5 b5 a5 d4 c4 b4 a4*/ \
 "punpckldq %%xmm2,%%xmm5\n\t" \
 /*xmm6 = d7 c7 b7 a7 d6 c6 b6 a6*/ \
 "punpckhdq %%xmm2,%%xmm6\n\t" \
 /*xmm2 is free.*/ \
 "movdqa %%xmm1,%%xmm2\n\t" \
 /*xmm1 = h1 g1 f1 e1 d1 c1 b1 a1*/ \
 "punpckhqdq %%xmm0,%%xmm1\n\t" \
 /*xmm2 = h0 g0 f0 e0 d0 c0 b0 a0*/ \
 "punpcklqdq %%xmm0,%%xmm2\n\t" \
 /*xmm0 = h7 g7 f7 e7 h6 g6 f6 e6*/ \
 "movdqa "OC_MEM_OFFS(0x00,buf)",%%xmm0\n\t" \
 /*buf[1] = h0 g0 f0 e0 d0 c0 b0 a0*/ \
 "movdqa %%xmm2,"OC_MEM_OFFS(0x10,buf)"\n\t" \
 /*xmm2 is free.*/ \
 "movdqa %%xmm3,%%xmm2\n\t" \
 /*xmm3 = h3 g3 f3 e3 d3 c3 b3 a3*/ \
 "punpckhqdq %%xmm4,%%xmm3\n\t" \
 /*xmm2 = h2 g2 f2 e2 d2 c2 b2 a2*/ \
 "punpcklqdq %%xmm4,%%xmm2\n\t" \
 /*xmm4 is free.*/ \
 "movdqa %%xmm5,%%xmm4\n\t" \
 /*xmm5 = h5 g5 f5 e5 d5 c5 b5 a5*/ \
 "punpckhqdq %%xmm7,%%xmm5\n\t" \
 /*xmm4 = h4 g4 f4 e4 d4 c4 b4 a4*/ \
 "punpcklqdq %%xmm7,%%xmm4\n\t" \
 /*xmm7 is free.*/ \
 "movdqa %%xmm6,%%xmm7\n\t" \
 /*xmm6 = h6 g6 f6 e6 d6 c6 b6 a6*/ \
 "punpcklqdq %%xmm0,%%xmm6\n\t" \
 /*xmm7 = h7 g7 f7 e7 d7 c7 b7 a7*/ \
 "punpckhqdq %%xmm0,%%xmm7\n\t" \
 /*xmm0 = h0 g0 f0 e0 d0 c0 b0 a0*/ \
 "movdqa "OC_MEM_OFFS(0x10,buf)",%%xmm0\n\t" \

# endif

/*Transpose 4 values in each of 8 MMX registers into 8 values in the first
   four SSE registers.
  No need to be clever here; we have plenty of room.*/
#  define OC_TRANSPOSE_8x4_MMX2SSE \
 "#OC_TRANSPOSE_8x4_MMX2SSE\n\t" \
 "movq2dq %%mm0,%%xmm0\n\t" \
 "movq2dq %%mm1,%%xmm1\n\t" \
 /*xmmA = b3 a3 b2 a2 b1 a1 b0 a0*/ \
 "punpcklwd %%xmm1,%%xmm0\n\t" \
 "movq2dq %%mm2,%%xmm3\n\t" \
 "movq2dq %%mm3,%%xmm2\n\t" \
 /*xmmC = d3 c3 d2 c2 d1 c1 d0 c0*/ \
 "punpcklwd %%xmm2,%%xmm3\n\t" \
 "movq2dq %%mm4,%%xmm4\n\t" \
 "movq2dq %%mm5,%%xmm5\n\t" \
 /*xmmE = f3 e3 f2 e2 f1 e1 f0 e0*/ \
 "punpcklwd %%xmm5,%%xmm4\n\t" \
 "movq2dq %%mm6,%%xmm7\n\t" \
 "movq2dq %%mm7,%%xmm6\n\t" \
 /*xmmG = h3 g3 h2 g2 h1 g1 h0 g0*/ \
 "punpcklwd %%xmm6,%%xmm7\n\t" \
 "movdqa %%xmm0,%%xmm2\n\t" \
 /*xmm0 = d1 c1 b1 a1 d0 c0 b0 a0*/ \
 "punpckldq %%xmm3,%%xmm0\n\t" \
 /*xmm2 = d3 c3 b3 a3 d2 c2 b2 a2*/ \
 "punpckhdq %%xmm3,%%xmm2\n\t" \
 "movdqa %%xmm4,%%xmm5\n\t" \
 /*xmm4 = h1 g1 f1 e1 h0 g0 f0 e0*/ \
 "punpckldq %%xmm7,%%xmm4\n\t" \
 /*xmm3 = h3 g3 f3 e3 h2 g2 f2 e2*/ \
 "punpckhdq %%xmm7,%%xmm5\n\t" \
 "movdqa %%xmm0,%%xmm1\n\t" \
 /*xmm0 = h0 g0 f0 e0 d0 c0 b0 a0*/ \
 "punpcklqdq %%xmm4,%%xmm0\n\t" \
 /*xmm1 = h1 g1 f1 e1 d1 c1 b1 a1*/ \
 "punpckhqdq %%xmm4,%%xmm1\n\t" \
 "movdqa %%xmm2,%%xmm3\n\t" \
 /*xmm2 = h2 g2 f2 e2 d2 c2 b2 a2*/ \
 "punpcklqdq %%xmm5,%%xmm2\n\t" \
 /*xmm3 = h3 g3 f3 e3 d3 c3 b3 a3*/ \
 "punpckhqdq %%xmm5,%%xmm3\n\t" \

#endif