3 MultiMedia eXtensions GCC interface library for IA32.
5 To use this library, simply include this header file
6 and compile with GCC. You MUST have inlining enabled
7 in order for mmx_ok() to work; this can be done by
8 simply using -O on the GCC command line.
10 Compiling with -DMMX_TRACE will cause detailed trace
11 output to be sent to stderr for each mmx operation.
12 This adds lots of code, and obviously slows execution to
13 a crawl, but can be very useful for debugging.
15 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
16 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
17 LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18 AND FITNESS FOR ANY PARTICULAR PURPOSE.
20 1997-99 by H. Dietz and R. Fisher
23 It appears that the latest gas has the pand problem fixed, therefore
24 I'll undefine BROKEN_PAND by default.
31 /* Warning: at this writing, the version of GAS packaged
32 with most Linux distributions does not handle the
33 parallel AND operation mnemonic correctly. If the
34 symbol BROKEN_PAND is defined, a slower alternative
35 coding will be used. If execution of mmxtest results
36 in an illegal instruction fault, define this symbol.
41 /* The type of an value that fits in an MMX register
42 (note that long long constant values MUST be suffixed
43 by LL and unsigned long long values by ULL, lest
44 they be truncated by the compiler)
47 long long q; /* Quadword (64-bit) value */
48 unsigned long long uq; /* Unsigned Quadword */
49 int d[2]; /* 2 Doubleword (32-bit) values */
50 unsigned int ud[2]; /* 2 Unsigned Doubleword */
51 short w[4]; /* 4 Word (16-bit) values */
52 unsigned short uw[4]; /* 4 Unsigned Word */
53 char b[8]; /* 8 Byte (8-bit) values */
54 unsigned char ub[8]; /* 8 Unsigned Byte */
55 float s[2]; /* Single-precision (32-bit) value */
56 } __attribute__ ((aligned (8))) mmx_t; /* On an 8-byte (64-bit) boundary */
60 /* Function to test if multimedia instructions are supported...
65 /* Returns 1 if MMX instructions are supported,
66 3 if Cyrix MMX and Extended MMX instructions are supported
67 5 if AMD MMX and 3DNow! instructions are supported
68 0 if hardware does not support any of these
72 __asm__ __volatile__ (
73 /* See if CPUID instruction is supported ... */
74 /* ... Get copies of EFLAGS into eax and ecx */
80 "movl %%eax, %%ecx\n\t"
82 /* ... Toggle the ID bit in one copy and store */
83 /* to the EFLAGS reg */
84 "xorl $0x200000, %%eax\n\t"
88 /* ... Get the (hopefully modified) EFLAGS */
92 /* ... Compare and test result */
93 "xorl %%eax, %%ecx\n\t"
94 "testl $0x200000, %%ecx\n\t"
95 "jz NotSupported1\n\t" /* CPUID not supported */
98 /* Get standard CPUID information, and
99 go to a specific vendor section */
103 /* Check for Intel */
104 "cmpl $0x756e6547, %%ebx\n\t"
106 "cmpl $0x49656e69, %%edx\n\t"
108 "cmpl $0x6c65746e, %%ecx\n"
114 "cmpl $0x68747541, %%ebx\n\t"
116 "cmpl $0x69746e65, %%edx\n\t"
118 "cmpl $0x444d4163, %%ecx\n"
122 /* Check for Cyrix */
124 "cmpl $0x69727943, %%ebx\n\t"
125 "jne TryNSCGeode\n\t"
126 "cmpl $0x736e4978, %%edx\n\t"
127 "jne TryNSCGeode\n\t"
128 "cmpl $0x64616574, %%ecx\n\t"
129 "jne TryNSCGeode\n\t"
132 /* See if extended CPUID level 80000001 is supported */
133 /* The value of CPUID/80000001 for the 6x86MX is undefined
134 according to the Cyrix CPU Detection Guide (Preliminary
135 Rev. 1.01 table 1), so we'll check the value of eax for
136 CPUID/0 to see if standard CPUID level 2 is supported.
137 According to the table, the only CPU which supports level
138 2 is also the only one which supports extended CPUID levels.
140 "cmpl $0x2, %%eax\n\t"
141 "jne MMXtest\n\t" /* Use standard CPUID instead */
143 /* Extended CPUID supported (in theory), so get extended
145 "movl $0x80000001, %%eax\n\t"
147 "testl $0x00800000, %%eax\n\t" /* Test for MMX */
148 "jz NotSupported5\n\t" /* MMX not supported */
149 "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */
150 "jnz EMMXSupported\n\t"
151 "movl $1, %0\n\n\t" /* MMX Supported */
154 "movl $3, %0\n\n\t" /* EMMX and MMX Supported */
158 /* Drop through to NSC Geode... */
159 "cmpl $0x646f6547, %%ebx\n\t"
160 "jne NotSupported2\n\t"
161 "cmpl $0x79622065, %%edx\n\t"
162 "jne NotSupported3\n\t"
163 "cmpl $0x43534e20, %%ecx\n\t"
164 "jne NotSupported4\n\t"
166 /* Extended CPUID supported (in theory), so get extended
168 "movl $0x80000001, %%eax\n\t"
170 "testl $0x00800000, %%edx\n\t" /* Test for MMX */
171 "jz NotSupported5\n\t" /* MMX not supported */
172 "testl $0x01000000, %%edx\n\t" /* Test for Ext'd MMX */
173 "jnz GEMMXSupported\n\t"
174 "movl $1, %0\n\n\t" /* MMX Supported */
176 "GEMMXSupported:\n\t"
177 "movl $3, %0\n\n\t" /* EMMX and MMX Supported */
183 /* See if extended CPUID is supported */
184 "movl $0x80000000, %%eax\n\t"
186 "cmpl $0x80000000, %%eax\n\t"
187 "jl MMXtest\n\t" /* Use standard CPUID instead */
189 /* Extended CPUID supported, so get extended features */
190 "movl $0x80000001, %%eax\n\t"
192 "testl $0x00800000, %%edx\n\t" /* Test for MMX */
193 "jz NotSupported6\n\t" /* MMX not supported */
194 "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */
195 "jnz ThreeDNowSupported\n\t"
196 "movl $1, %0\n\n\t" /* MMX Supported */
198 "ThreeDNowSupported:\n\t"
199 "movl $5, %0\n\n\t" /* 3DNow! and MMX Supported */
210 "testl $0x00800000, %%edx\n\t" /* Test for MMX */
211 "jz NotSupported7\n\t" /* MMX Not supported */
212 "movl $1, %0\n\n\t" /* MMX Supported */
215 /* Nothing supported */
216 "\nNotSupported1:\n\t"
217 "#movl $101, %0\n\n\t"
218 "\nNotSupported2:\n\t"
219 "#movl $102, %0\n\n\t"
220 "\nNotSupported3:\n\t"
221 "#movl $103, %0\n\n\t"
222 "\nNotSupported4:\n\t"
223 "#movl $104, %0\n\n\t"
224 "\nNotSupported5:\n\t"
225 "#movl $105, %0\n\n\t"
226 "\nNotSupported6:\n\t"
227 "#movl $106, %0\n\n\t"
228 "\nNotSupported7:\n\t"
229 "#movl $107, %0\n\n\t"
244 /* Function to test if mmx instructions are supported...
249 /* Returns 1 if MMX instructions are supported, 0 otherwise */
250 return ( mm_support() & 0x1 );
254 /* Helper functions for the instruction macros that follow...
255 (note that memory-to-register, m2r, instructions are nearly
256 as efficient as register-to-register, r2r, instructions;
257 however, memory-to-memory instructions are really simulated
258 as a convenience, and are only 1/3 as efficient)
262 /* Include the stuff for printing a trace to stderr...
267 #define mmx_i2r(op, imm, reg) \
270 mmx_trace.uq = (imm); \
271 fprintf(stderr, #op "_i2r(" #imm "=0x%08x%08x, ", \
272 mmx_trace.d[1], mmx_trace.d[0]); \
273 __asm__ __volatile__ ("movq %%" #reg ", %0" \
276 fprintf(stderr, #reg "=0x%08x%08x) => ", \
277 mmx_trace.d[1], mmx_trace.d[0]); \
278 __asm__ __volatile__ (#op " %0, %%" #reg \
281 __asm__ __volatile__ ("movq %%" #reg ", %0" \
284 fprintf(stderr, #reg "=0x%08x%08x\n", \
285 mmx_trace.d[1], mmx_trace.d[0]); \
288 #define mmx_m2r(op, mem, reg) \
292 fprintf(stderr, #op "_m2r(" #mem "=0x%08x%08x, ", \
293 mmx_trace.d[1], mmx_trace.d[0]); \
294 __asm__ __volatile__ ("movq %%" #reg ", %0" \
297 fprintf(stderr, #reg "=0x%08x%08x) => ", \
298 mmx_trace.d[1], mmx_trace.d[0]); \
299 __asm__ __volatile__ (#op " %0, %%" #reg \
302 __asm__ __volatile__ ("movq %%" #reg ", %0" \
305 fprintf(stderr, #reg "=0x%08x%08x\n", \
306 mmx_trace.d[1], mmx_trace.d[0]); \
309 #define mmx_r2m(op, reg, mem) \
312 __asm__ __volatile__ ("movq %%" #reg ", %0" \
315 fprintf(stderr, #op "_r2m(" #reg "=0x%08x%08x, ", \
316 mmx_trace.d[1], mmx_trace.d[0]); \
318 fprintf(stderr, #mem "=0x%08x%08x) => ", \
319 mmx_trace.d[1], mmx_trace.d[0]); \
320 __asm__ __volatile__ (#op " %%" #reg ", %0" \
324 fprintf(stderr, #mem "=0x%08x%08x\n", \
325 mmx_trace.d[1], mmx_trace.d[0]); \
328 #define mmx_r2r(op, regs, regd) \
331 __asm__ __volatile__ ("movq %%" #regs ", %0" \
334 fprintf(stderr, #op "_r2r(" #regs "=0x%08x%08x, ", \
335 mmx_trace.d[1], mmx_trace.d[0]); \
336 __asm__ __volatile__ ("movq %%" #regd ", %0" \
339 fprintf(stderr, #regd "=0x%08x%08x) => ", \
340 mmx_trace.d[1], mmx_trace.d[0]); \
341 __asm__ __volatile__ (#op " %" #regs ", %" #regd); \
342 __asm__ __volatile__ ("movq %%" #regd ", %0" \
345 fprintf(stderr, #regd "=0x%08x%08x\n", \
346 mmx_trace.d[1], mmx_trace.d[0]); \
349 #define mmx_m2m(op, mems, memd) \
352 mmx_trace = (mems); \
353 fprintf(stderr, #op "_m2m(" #mems "=0x%08x%08x, ", \
354 mmx_trace.d[1], mmx_trace.d[0]); \
355 mmx_trace = (memd); \
356 fprintf(stderr, #memd "=0x%08x%08x) => ", \
357 mmx_trace.d[1], mmx_trace.d[0]); \
358 __asm__ __volatile__ ("movq %0, %%mm0\n\t" \
359 #op " %1, %%mm0\n\t" \
363 mmx_trace = (memd); \
364 fprintf(stderr, #memd "=0x%08x%08x\n", \
365 mmx_trace.d[1], mmx_trace.d[0]); \
370 /* These macros are a lot simpler without the tracing...
373 #define mmx_i2r(op, imm, reg) \
374 __asm__ __volatile__ (#op " %0, %%" #reg \
378 #define mmx_m2r(op, mem, reg) \
379 __asm__ __volatile__ (#op " %0, %%" #reg \
383 #define mmx_r2m(op, reg, mem) \
384 __asm__ __volatile__ (#op " %%" #reg ", %0" \
388 #define mmx_r2r(op, regs, regd) \
389 __asm__ __volatile__ (#op " %" #regs ", %" #regd)
391 #define mmx_m2m(op, mems, memd) \
392 __asm__ __volatile__ ("movq %0, %%mm0\n\t" \
393 #op " %1, %%mm0\n\t" \
401 /* 1x64 MOVe Quadword
402 (this is both a load and a store...
403 in fact, it is the only way to store)
405 #define movq_m2r(var, reg) mmx_m2r(movq, var, reg)
406 #define movq_r2m(reg, var) mmx_r2m(movq, reg, var)
407 #define movq_r2r(regs, regd) mmx_r2r(movq, regs, regd)
408 #define movq(vars, vard) \
409 __asm__ __volatile__ ("movq %1, %%mm0\n\t" \
415 /* 1x32 MOVe Doubleword
416 (like movq, this is both load and store...
417 but is most useful for moving things between
418 mmx registers and ordinary registers)
420 #define movd_m2r(var, reg) mmx_m2r(movd, var, reg)
421 #define movd_r2m(reg, var) mmx_r2m(movd, reg, var)
422 #define movd_r2r(regs, regd) mmx_r2r(movd, regs, regd)
423 #define movd(vars, vard) \
424 __asm__ __volatile__ ("movd %1, %%mm0\n\t" \
430 /* 2x32, 4x16, and 8x8 Parallel ADDs
432 #define paddd_m2r(var, reg) mmx_m2r(paddd, var, reg)
433 #define paddd_r2r(regs, regd) mmx_r2r(paddd, regs, regd)
434 #define paddd(vars, vard) mmx_m2m(paddd, vars, vard)
436 #define paddw_m2r(var, reg) mmx_m2r(paddw, var, reg)
437 #define paddw_r2r(regs, regd) mmx_r2r(paddw, regs, regd)
438 #define paddw(vars, vard) mmx_m2m(paddw, vars, vard)
440 #define paddb_m2r(var, reg) mmx_m2r(paddb, var, reg)
441 #define paddb_r2r(regs, regd) mmx_r2r(paddb, regs, regd)
442 #define paddb(vars, vard) mmx_m2m(paddb, vars, vard)
445 /* 4x16 and 8x8 Parallel ADDs using Saturation arithmetic
447 #define paddsw_m2r(var, reg) mmx_m2r(paddsw, var, reg)
448 #define paddsw_r2r(regs, regd) mmx_r2r(paddsw, regs, regd)
449 #define paddsw(vars, vard) mmx_m2m(paddsw, vars, vard)
451 #define paddsb_m2r(var, reg) mmx_m2r(paddsb, var, reg)
452 #define paddsb_r2r(regs, regd) mmx_r2r(paddsb, regs, regd)
453 #define paddsb(vars, vard) mmx_m2m(paddsb, vars, vard)
456 /* 4x16 and 8x8 Parallel ADDs using Unsigned Saturation arithmetic
458 #define paddusw_m2r(var, reg) mmx_m2r(paddusw, var, reg)
459 #define paddusw_r2r(regs, regd) mmx_r2r(paddusw, regs, regd)
460 #define paddusw(vars, vard) mmx_m2m(paddusw, vars, vard)
462 #define paddusb_m2r(var, reg) mmx_m2r(paddusb, var, reg)
463 #define paddusb_r2r(regs, regd) mmx_r2r(paddusb, regs, regd)
464 #define paddusb(vars, vard) mmx_m2m(paddusb, vars, vard)
467 /* 2x32, 4x16, and 8x8 Parallel SUBs
469 #define psubd_m2r(var, reg) mmx_m2r(psubd, var, reg)
470 #define psubd_r2r(regs, regd) mmx_r2r(psubd, regs, regd)
471 #define psubd(vars, vard) mmx_m2m(psubd, vars, vard)
473 #define psubw_m2r(var, reg) mmx_m2r(psubw, var, reg)
474 #define psubw_r2r(regs, regd) mmx_r2r(psubw, regs, regd)
475 #define psubw(vars, vard) mmx_m2m(psubw, vars, vard)
477 #define psubb_m2r(var, reg) mmx_m2r(psubb, var, reg)
478 #define psubb_r2r(regs, regd) mmx_r2r(psubb, regs, regd)
479 #define psubb(vars, vard) mmx_m2m(psubb, vars, vard)
482 /* 4x16 and 8x8 Parallel SUBs using Saturation arithmetic
484 #define psubsw_m2r(var, reg) mmx_m2r(psubsw, var, reg)
485 #define psubsw_r2r(regs, regd) mmx_r2r(psubsw, regs, regd)
486 #define psubsw(vars, vard) mmx_m2m(psubsw, vars, vard)
488 #define psubsb_m2r(var, reg) mmx_m2r(psubsb, var, reg)
489 #define psubsb_r2r(regs, regd) mmx_r2r(psubsb, regs, regd)
490 #define psubsb(vars, vard) mmx_m2m(psubsb, vars, vard)
493 /* 4x16 and 8x8 Parallel SUBs using Unsigned Saturation arithmetic
495 #define psubusw_m2r(var, reg) mmx_m2r(psubusw, var, reg)
496 #define psubusw_r2r(regs, regd) mmx_r2r(psubusw, regs, regd)
497 #define psubusw(vars, vard) mmx_m2m(psubusw, vars, vard)
499 #define psubusb_m2r(var, reg) mmx_m2r(psubusb, var, reg)
500 #define psubusb_r2r(regs, regd) mmx_r2r(psubusb, regs, regd)
501 #define psubusb(vars, vard) mmx_m2m(psubusb, vars, vard)
504 /* 4x16 Parallel MULs giving Low 4x16 portions of results
506 #define pmullw_m2r(var, reg) mmx_m2r(pmullw, var, reg)
507 #define pmullw_r2r(regs, regd) mmx_r2r(pmullw, regs, regd)
508 #define pmullw(vars, vard) mmx_m2m(pmullw, vars, vard)
511 /* 4x16 Parallel MULs giving High 4x16 portions of results
513 #define pmulhw_m2r(var, reg) mmx_m2r(pmulhw, var, reg)
514 #define pmulhw_r2r(regs, regd) mmx_r2r(pmulhw, regs, regd)
515 #define pmulhw(vars, vard) mmx_m2m(pmulhw, vars, vard)
518 /* 4x16->2x32 Parallel Mul-ADD
519 (muls like pmullw, then adds adjacent 16-bit fields
520 in the multiply result to make the final 2x32 result)
522 #define pmaddwd_m2r(var, reg) mmx_m2r(pmaddwd, var, reg)
523 #define pmaddwd_r2r(regs, regd) mmx_r2r(pmaddwd, regs, regd)
524 #define pmaddwd(vars, vard) mmx_m2m(pmaddwd, vars, vard)
530 #define pand_m2r(var, reg) \
532 mmx_m2r(pandn, (mmx_t) -1LL, reg); \
533 mmx_m2r(pandn, var, reg); \
535 #define pand_r2r(regs, regd) \
537 mmx_m2r(pandn, (mmx_t) -1LL, regd); \
538 mmx_r2r(pandn, regs, regd) \
540 #define pand(vars, vard) \
542 movq_m2r(vard, mm0); \
543 mmx_m2r(pandn, (mmx_t) -1LL, mm0); \
544 mmx_m2r(pandn, vars, mm0); \
545 movq_r2m(mm0, vard); \
548 #define pand_m2r(var, reg) mmx_m2r(pand, var, reg)
549 #define pand_r2r(regs, regd) mmx_r2r(pand, regs, regd)
550 #define pand(vars, vard) mmx_m2m(pand, vars, vard)
554 /* 1x64 bitwise AND with Not the destination
556 #define pandn_m2r(var, reg) mmx_m2r(pandn, var, reg)
557 #define pandn_r2r(regs, regd) mmx_r2r(pandn, regs, regd)
558 #define pandn(vars, vard) mmx_m2m(pandn, vars, vard)
563 #define por_m2r(var, reg) mmx_m2r(por, var, reg)
564 #define por_r2r(regs, regd) mmx_r2r(por, regs, regd)
565 #define por(vars, vard) mmx_m2m(por, vars, vard)
568 /* 1x64 bitwise eXclusive OR
570 #define pxor_m2r(var, reg) mmx_m2r(pxor, var, reg)
571 #define pxor_r2r(regs, regd) mmx_r2r(pxor, regs, regd)
572 #define pxor(vars, vard) mmx_m2m(pxor, vars, vard)
575 /* 2x32, 4x16, and 8x8 Parallel CoMPare for EQuality
576 (resulting fields are either 0 or -1)
578 #define pcmpeqd_m2r(var, reg) mmx_m2r(pcmpeqd, var, reg)
579 #define pcmpeqd_r2r(regs, regd) mmx_r2r(pcmpeqd, regs, regd)
580 #define pcmpeqd(vars, vard) mmx_m2m(pcmpeqd, vars, vard)
582 #define pcmpeqw_m2r(var, reg) mmx_m2r(pcmpeqw, var, reg)
583 #define pcmpeqw_r2r(regs, regd) mmx_r2r(pcmpeqw, regs, regd)
584 #define pcmpeqw(vars, vard) mmx_m2m(pcmpeqw, vars, vard)
586 #define pcmpeqb_m2r(var, reg) mmx_m2r(pcmpeqb, var, reg)
587 #define pcmpeqb_r2r(regs, regd) mmx_r2r(pcmpeqb, regs, regd)
588 #define pcmpeqb(vars, vard) mmx_m2m(pcmpeqb, vars, vard)
591 /* 2x32, 4x16, and 8x8 Parallel CoMPare for Greater Than
592 (resulting fields are either 0 or -1)
594 #define pcmpgtd_m2r(var, reg) mmx_m2r(pcmpgtd, var, reg)
595 #define pcmpgtd_r2r(regs, regd) mmx_r2r(pcmpgtd, regs, regd)
596 #define pcmpgtd(vars, vard) mmx_m2m(pcmpgtd, vars, vard)
598 #define pcmpgtw_m2r(var, reg) mmx_m2r(pcmpgtw, var, reg)
599 #define pcmpgtw_r2r(regs, regd) mmx_r2r(pcmpgtw, regs, regd)
600 #define pcmpgtw(vars, vard) mmx_m2m(pcmpgtw, vars, vard)
602 #define pcmpgtb_m2r(var, reg) mmx_m2r(pcmpgtb, var, reg)
603 #define pcmpgtb_r2r(regs, regd) mmx_r2r(pcmpgtb, regs, regd)
604 #define pcmpgtb(vars, vard) mmx_m2m(pcmpgtb, vars, vard)
607 /* 1x64, 2x32, and 4x16 Parallel Shift Left Logical
609 #define psllq_i2r(imm, reg) mmx_i2r(psllq, imm, reg)
610 #define psllq_m2r(var, reg) mmx_m2r(psllq, var, reg)
611 #define psllq_r2r(regs, regd) mmx_r2r(psllq, regs, regd)
612 #define psllq(vars, vard) mmx_m2m(psllq, vars, vard)
614 #define pslld_i2r(imm, reg) mmx_i2r(pslld, imm, reg)
615 #define pslld_m2r(var, reg) mmx_m2r(pslld, var, reg)
616 #define pslld_r2r(regs, regd) mmx_r2r(pslld, regs, regd)
617 #define pslld(vars, vard) mmx_m2m(pslld, vars, vard)
619 #define psllw_i2r(imm, reg) mmx_i2r(psllw, imm, reg)
620 #define psllw_m2r(var, reg) mmx_m2r(psllw, var, reg)
621 #define psllw_r2r(regs, regd) mmx_r2r(psllw, regs, regd)
622 #define psllw(vars, vard) mmx_m2m(psllw, vars, vard)
625 /* 1x64, 2x32, and 4x16 Parallel Shift Right Logical
627 #define psrlq_i2r(imm, reg) mmx_i2r(psrlq, imm, reg)
628 #define psrlq_m2r(var, reg) mmx_m2r(psrlq, var, reg)
629 #define psrlq_r2r(regs, regd) mmx_r2r(psrlq, regs, regd)
630 #define psrlq(vars, vard) mmx_m2m(psrlq, vars, vard)
632 #define psrld_i2r(imm, reg) mmx_i2r(psrld, imm, reg)
633 #define psrld_m2r(var, reg) mmx_m2r(psrld, var, reg)
634 #define psrld_r2r(regs, regd) mmx_r2r(psrld, regs, regd)
635 #define psrld(vars, vard) mmx_m2m(psrld, vars, vard)
637 #define psrlw_i2r(imm, reg) mmx_i2r(psrlw, imm, reg)
638 #define psrlw_m2r(var, reg) mmx_m2r(psrlw, var, reg)
639 #define psrlw_r2r(regs, regd) mmx_r2r(psrlw, regs, regd)
640 #define psrlw(vars, vard) mmx_m2m(psrlw, vars, vard)
643 /* 2x32 and 4x16 Parallel Shift Right Arithmetic
645 #define psrad_i2r(imm, reg) mmx_i2r(psrad, imm, reg)
646 #define psrad_m2r(var, reg) mmx_m2r(psrad, var, reg)
647 #define psrad_r2r(regs, regd) mmx_r2r(psrad, regs, regd)
648 #define psrad(vars, vard) mmx_m2m(psrad, vars, vard)
650 #define psraw_i2r(imm, reg) mmx_i2r(psraw, imm, reg)
651 #define psraw_m2r(var, reg) mmx_m2r(psraw, var, reg)
652 #define psraw_r2r(regs, regd) mmx_r2r(psraw, regs, regd)
653 #define psraw(vars, vard) mmx_m2m(psraw, vars, vard)
656 /* 2x32->4x16 and 4x16->8x8 PACK and Signed Saturate
657 (packs source and dest fields into dest in that order)
659 #define packssdw_m2r(var, reg) mmx_m2r(packssdw, var, reg)
660 #define packssdw_r2r(regs, regd) mmx_r2r(packssdw, regs, regd)
661 #define packssdw(vars, vard) mmx_m2m(packssdw, vars, vard)
663 #define packsswb_m2r(var, reg) mmx_m2r(packsswb, var, reg)
664 #define packsswb_r2r(regs, regd) mmx_r2r(packsswb, regs, regd)
665 #define packsswb(vars, vard) mmx_m2m(packsswb, vars, vard)
668 /* 4x16->8x8 PACK and Unsigned Saturate
669 (packs source and dest fields into dest in that order)
671 #define packuswb_m2r(var, reg) mmx_m2r(packuswb, var, reg)
672 #define packuswb_r2r(regs, regd) mmx_r2r(packuswb, regs, regd)
673 #define packuswb(vars, vard) mmx_m2m(packuswb, vars, vard)
676 /* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK Low
677 (interleaves low half of dest with low half of source
678 as padding in each result field)
680 #define punpckldq_m2r(var, reg) mmx_m2r(punpckldq, var, reg)
681 #define punpckldq_r2r(regs, regd) mmx_r2r(punpckldq, regs, regd)
682 #define punpckldq(vars, vard) mmx_m2m(punpckldq, vars, vard)
684 #define punpcklwd_m2r(var, reg) mmx_m2r(punpcklwd, var, reg)
685 #define punpcklwd_r2r(regs, regd) mmx_r2r(punpcklwd, regs, regd)
686 #define punpcklwd(vars, vard) mmx_m2m(punpcklwd, vars, vard)
688 #define punpcklbw_m2r(var, reg) mmx_m2r(punpcklbw, var, reg)
689 #define punpcklbw_r2r(regs, regd) mmx_r2r(punpcklbw, regs, regd)
690 #define punpcklbw(vars, vard) mmx_m2m(punpcklbw, vars, vard)
693 /* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK High
694 (interleaves high half of dest with high half of source
695 as padding in each result field)
697 #define punpckhdq_m2r(var, reg) mmx_m2r(punpckhdq, var, reg)
698 #define punpckhdq_r2r(regs, regd) mmx_r2r(punpckhdq, regs, regd)
699 #define punpckhdq(vars, vard) mmx_m2m(punpckhdq, vars, vard)
701 #define punpckhwd_m2r(var, reg) mmx_m2r(punpckhwd, var, reg)
702 #define punpckhwd_r2r(regs, regd) mmx_r2r(punpckhwd, regs, regd)
703 #define punpckhwd(vars, vard) mmx_m2m(punpckhwd, vars, vard)
705 #define punpckhbw_m2r(var, reg) mmx_m2r(punpckhbw, var, reg)
706 #define punpckhbw_r2r(regs, regd) mmx_r2r(punpckhbw, regs, regd)
707 #define punpckhbw(vars, vard) mmx_m2m(punpckhbw, vars, vard)
711 (used to clean-up when going from mmx to float use
712 of the registers that are shared by both; note that
713 there is no float-to-mmx operation needed, because
714 only the float tag word info is corruptible)
720 fprintf(stderr, "emms()\n"); \
721 __asm__ __volatile__ ("emms"); \
726 #define emms() __asm__ __volatile__ ("emms")