1
|
1 /*
|
|
2 * sse.h
|
|
3 * Copyright (C) 1999 R. Fisher
|
|
4 *
|
|
5 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
|
|
6 *
|
|
7 * mpeg2dec is free software; you can redistribute it and/or modify
|
|
8 * it under the terms of the GNU General Public License as published by
|
|
9 * the Free Software Foundation; either version 2 of the License, or
|
|
10 * (at your option) any later version.
|
|
11 *
|
|
12 * mpeg2dec is distributed in the hope that it will be useful,
|
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 * GNU General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU General Public License
|
|
18 * along with this program; if not, write to the Free Software
|
|
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20 */
|
|
21
|
|
22
|
|
23 typedef union {
|
|
24 float sf[4]; /* Single-precision (32-bit) value */
|
|
25 } ATTR_ALIGN(16) sse_t; /* On a 16 byte (128-bit) boundary */
|
|
26
|
|
27
|
|
28 #define sse_i2r(op, imm, reg) \
|
|
29 __asm__ __volatile__ (#op " %0, %%" #reg \
|
|
30 : /* nothing */ \
|
|
31 : "X" (imm) )
|
|
32
|
|
33 #define sse_m2r(op, mem, reg) \
|
|
34 __asm__ __volatile__ (#op " %0, %%" #reg \
|
|
35 : /* nothing */ \
|
|
36 : "X" (mem))
|
|
37
|
|
38 #define sse_r2m(op, reg, mem) \
|
|
39 __asm__ __volatile__ (#op " %%" #reg ", %0" \
|
|
40 : "=X" (mem) \
|
|
41 : /* nothing */ )
|
|
42
|
|
43 #define sse_r2r(op, regs, regd) \
|
|
44 __asm__ __volatile__ (#op " %" #regs ", %" #regd)
|
|
45
|
|
46 #define sse_r2ri(op, regs, regd, imm) \
|
|
47 __asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \
|
|
48 : /* nothing */ \
|
|
49 : "X" (imm) )
|
|
50
|
|
51 #define sse_m2ri(op, mem, reg, subop) \
|
|
52 __asm__ __volatile__ (#op " %0, %%" #reg ", " #subop \
|
|
53 : /* nothing */ \
|
|
54 : "X" (mem))
|
|
55
|
|
56
|
|
57 #define movaps_m2r(var, reg) sse_m2r(movaps, var, reg)
|
|
58 #define movaps_r2m(reg, var) sse_r2m(movaps, reg, var)
|
|
59 #define movaps_r2r(regs, regd) sse_r2r(movaps, regs, regd)
|
|
60
|
|
61 #define movntps_r2m(xmmreg, var) sse_r2m(movntps, xmmreg, var)
|
|
62
|
|
63 #define movups_m2r(var, reg) sse_m2r(movups, var, reg)
|
|
64 #define movups_r2m(reg, var) sse_r2m(movups, reg, var)
|
|
65 #define movups_r2r(regs, regd) sse_r2r(movups, regs, regd)
|
|
66
|
|
67 #define movhlps_r2r(regs, regd) sse_r2r(movhlps, regs, regd)
|
|
68
|
|
69 #define movlhps_r2r(regs, regd) sse_r2r(movlhps, regs, regd)
|
|
70
|
|
71 #define movhps_m2r(var, reg) sse_m2r(movhps, var, reg)
|
|
72 #define movhps_r2m(reg, var) sse_r2m(movhps, reg, var)
|
|
73
|
|
74 #define movlps_m2r(var, reg) sse_m2r(movlps, var, reg)
|
|
75 #define movlps_r2m(reg, var) sse_r2m(movlps, reg, var)
|
|
76
|
|
77 #define movss_m2r(var, reg) sse_m2r(movss, var, reg)
|
|
78 #define movss_r2m(reg, var) sse_r2m(movss, reg, var)
|
|
79 #define movss_r2r(regs, regd) sse_r2r(movss, regs, regd)
|
|
80
|
|
81 #define shufps_m2r(var, reg, index) sse_m2ri(shufps, var, reg, index)
|
|
82 #define shufps_r2r(regs, regd, index) sse_r2ri(shufps, regs, regd, index)
|
|
83
|
|
84 #define cvtpi2ps_m2r(var, xmmreg) sse_m2r(cvtpi2ps, var, xmmreg)
|
|
85 #define cvtpi2ps_r2r(mmreg, xmmreg) sse_r2r(cvtpi2ps, mmreg, xmmreg)
|
|
86
|
|
87 #define cvtps2pi_m2r(var, mmreg) sse_m2r(cvtps2pi, var, mmreg)
|
|
88 #define cvtps2pi_r2r(xmmreg, mmreg) sse_r2r(cvtps2pi, mmreg, xmmreg)
|
|
89
|
|
90 #define cvttps2pi_m2r(var, mmreg) sse_m2r(cvttps2pi, var, mmreg)
|
|
91 #define cvttps2pi_r2r(xmmreg, mmreg) sse_r2r(cvttps2pi, mmreg, xmmreg)
|
|
92
|
|
93 #define cvtsi2ss_m2r(var, xmmreg) sse_m2r(cvtsi2ss, var, xmmreg)
|
|
94 #define cvtsi2ss_r2r(reg, xmmreg) sse_r2r(cvtsi2ss, reg, xmmreg)
|
|
95
|
|
96 #define cvtss2si_m2r(var, reg) sse_m2r(cvtss2si, var, reg)
|
|
97 #define cvtss2si_r2r(xmmreg, reg) sse_r2r(cvtss2si, xmmreg, reg)
|
|
98
|
|
99 #define cvttss2si_m2r(var, reg) sse_m2r(cvtss2si, var, reg)
|
|
100 #define cvttss2si_r2r(xmmreg, reg) sse_r2r(cvtss2si, xmmreg, reg)
|
|
101
|
|
102 #define movmskps(xmmreg, reg) \
|
|
103 __asm__ __volatile__ ("movmskps %" #xmmreg ", %" #reg)
|
|
104
|
|
105 #define addps_m2r(var, reg) sse_m2r(addps, var, reg)
|
|
106 #define addps_r2r(regs, regd) sse_r2r(addps, regs, regd)
|
|
107
|
|
108 #define addss_m2r(var, reg) sse_m2r(addss, var, reg)
|
|
109 #define addss_r2r(regs, regd) sse_r2r(addss, regs, regd)
|
|
110
|
|
111 #define subps_m2r(var, reg) sse_m2r(subps, var, reg)
|
|
112 #define subps_r2r(regs, regd) sse_r2r(subps, regs, regd)
|
|
113
|
|
114 #define subss_m2r(var, reg) sse_m2r(subss, var, reg)
|
|
115 #define subss_r2r(regs, regd) sse_r2r(subss, regs, regd)
|
|
116
|
|
117 #define mulps_m2r(var, reg) sse_m2r(mulps, var, reg)
|
|
118 #define mulps_r2r(regs, regd) sse_r2r(mulps, regs, regd)
|
|
119
|
|
120 #define mulss_m2r(var, reg) sse_m2r(mulss, var, reg)
|
|
121 #define mulss_r2r(regs, regd) sse_r2r(mulss, regs, regd)
|
|
122
|
|
123 #define divps_m2r(var, reg) sse_m2r(divps, var, reg)
|
|
124 #define divps_r2r(regs, regd) sse_r2r(divps, regs, regd)
|
|
125
|
|
126 #define divss_m2r(var, reg) sse_m2r(divss, var, reg)
|
|
127 #define divss_r2r(regs, regd) sse_r2r(divss, regs, regd)
|
|
128
|
|
129 #define rcpps_m2r(var, reg) sse_m2r(rcpps, var, reg)
|
|
130 #define rcpps_r2r(regs, regd) sse_r2r(rcpps, regs, regd)
|
|
131
|
|
132 #define rcpss_m2r(var, reg) sse_m2r(rcpss, var, reg)
|
|
133 #define rcpss_r2r(regs, regd) sse_r2r(rcpss, regs, regd)
|
|
134
|
|
135 #define rsqrtps_m2r(var, reg) sse_m2r(rsqrtps, var, reg)
|
|
136 #define rsqrtps_r2r(regs, regd) sse_r2r(rsqrtps, regs, regd)
|
|
137
|
|
138 #define rsqrtss_m2r(var, reg) sse_m2r(rsqrtss, var, reg)
|
|
139 #define rsqrtss_r2r(regs, regd) sse_r2r(rsqrtss, regs, regd)
|
|
140
|
|
141 #define sqrtps_m2r(var, reg) sse_m2r(sqrtps, var, reg)
|
|
142 #define sqrtps_r2r(regs, regd) sse_r2r(sqrtps, regs, regd)
|
|
143
|
|
144 #define sqrtss_m2r(var, reg) sse_m2r(sqrtss, var, reg)
|
|
145 #define sqrtss_r2r(regs, regd) sse_r2r(sqrtss, regs, regd)
|
|
146
|
|
147 #define andps_m2r(var, reg) sse_m2r(andps, var, reg)
|
|
148 #define andps_r2r(regs, regd) sse_r2r(andps, regs, regd)
|
|
149
|
|
150 #define andnps_m2r(var, reg) sse_m2r(andnps, var, reg)
|
|
151 #define andnps_r2r(regs, regd) sse_r2r(andnps, regs, regd)
|
|
152
|
|
153 #define orps_m2r(var, reg) sse_m2r(orps, var, reg)
|
|
154 #define orps_r2r(regs, regd) sse_r2r(orps, regs, regd)
|
|
155
|
|
156 #define xorps_m2r(var, reg) sse_m2r(xorps, var, reg)
|
|
157 #define xorps_r2r(regs, regd) sse_r2r(xorps, regs, regd)
|
|
158
|
|
159 #define maxps_m2r(var, reg) sse_m2r(maxps, var, reg)
|
|
160 #define maxps_r2r(regs, regd) sse_r2r(maxps, regs, regd)
|
|
161
|
|
162 #define maxss_m2r(var, reg) sse_m2r(maxss, var, reg)
|
|
163 #define maxss_r2r(regs, regd) sse_r2r(maxss, regs, regd)
|
|
164
|
|
165 #define minps_m2r(var, reg) sse_m2r(minps, var, reg)
|
|
166 #define minps_r2r(regs, regd) sse_r2r(minps, regs, regd)
|
|
167
|
|
168 #define minss_m2r(var, reg) sse_m2r(minss, var, reg)
|
|
169 #define minss_r2r(regs, regd) sse_r2r(minss, regs, regd)
|
|
170
|
|
171 #define cmpps_m2r(var, reg, op) sse_m2ri(cmpps, var, reg, op)
|
|
172 #define cmpps_r2r(regs, regd, op) sse_r2ri(cmpps, regs, regd, op)
|
|
173
|
|
174 #define cmpeqps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 0)
|
|
175 #define cmpeqps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 0)
|
|
176
|
|
177 #define cmpltps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 1)
|
|
178 #define cmpltps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 1)
|
|
179
|
|
180 #define cmpleps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 2)
|
|
181 #define cmpleps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 2)
|
|
182
|
|
183 #define cmpunordps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 3)
|
|
184 #define cmpunordps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 3)
|
|
185
|
|
186 #define cmpneqps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 4)
|
|
187 #define cmpneqps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 4)
|
|
188
|
|
189 #define cmpnltps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 5)
|
|
190 #define cmpnltps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 5)
|
|
191
|
|
192 #define cmpnleps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 6)
|
|
193 #define cmpnleps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 6)
|
|
194
|
|
195 #define cmpordps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 7)
|
|
196 #define cmpordps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 7)
|
|
197
|
|
198 #define cmpss_m2r(var, reg, op) sse_m2ri(cmpss, var, reg, op)
|
|
199 #define cmpss_r2r(regs, regd, op) sse_r2ri(cmpss, regs, regd, op)
|
|
200
|
|
201 #define cmpeqss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 0)
|
|
202 #define cmpeqss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 0)
|
|
203
|
|
204 #define cmpltss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 1)
|
|
205 #define cmpltss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 1)
|
|
206
|
|
207 #define cmpless_m2r(var, reg) sse_m2ri(cmpss, var, reg, 2)
|
|
208 #define cmpless_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 2)
|
|
209
|
|
210 #define cmpunordss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 3)
|
|
211 #define cmpunordss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 3)
|
|
212
|
|
213 #define cmpneqss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 4)
|
|
214 #define cmpneqss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 4)
|
|
215
|
|
216 #define cmpnltss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 5)
|
|
217 #define cmpnltss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 5)
|
|
218
|
|
219 #define cmpnless_m2r(var, reg) sse_m2ri(cmpss, var, reg, 6)
|
|
220 #define cmpnless_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 6)
|
|
221
|
|
222 #define cmpordss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 7)
|
|
223 #define cmpordss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 7)
|
|
224
|
|
225 #define comiss_m2r(var, reg) sse_m2r(comiss, var, reg)
|
|
226 #define comiss_r2r(regs, regd) sse_r2r(comiss, regs, regd)
|
|
227
|
|
228 #define ucomiss_m2r(var, reg) sse_m2r(ucomiss, var, reg)
|
|
229 #define ucomiss_r2r(regs, regd) sse_r2r(ucomiss, regs, regd)
|
|
230
|
|
231 #define unpcklps_m2r(var, reg) sse_m2r(unpcklps, var, reg)
|
|
232 #define unpcklps_r2r(regs, regd) sse_r2r(unpcklps, regs, regd)
|
|
233
|
|
234 #define unpckhps_m2r(var, reg) sse_m2r(unpckhps, var, reg)
|
|
235 #define unpckhps_r2r(regs, regd) sse_r2r(unpckhps, regs, regd)
|
|
236
|
|
237 #define fxrstor(mem) \
|
|
238 __asm__ __volatile__ ("fxrstor %0" \
|
|
239 : /* nothing */ \
|
|
240 : "X" (mem))
|
|
241
|
|
242 #define fxsave(mem) \
|
|
243 __asm__ __volatile__ ("fxsave %0" \
|
|
244 : /* nothing */ \
|
|
245 : "X" (mem))
|
|
246
|
|
247 #define stmxcsr(mem) \
|
|
248 __asm__ __volatile__ ("stmxcsr %0" \
|
|
249 : /* nothing */ \
|
|
250 : "X" (mem))
|
|
251
|
|
252 #define ldmxcsr(mem) \
|
|
253 __asm__ __volatile__ ("ldmxcsr %0" \
|
|
254 : /* nothing */ \
|
|
255 : "X" (mem))
|
|
256
|