VirtualBox

source: vbox/trunk/src/recompiler/tests/test-i386-ssse3.c@ 42119

Last change on this file since 42119 was 36140, checked in by vboxsync, 14 years ago

rem: Re-synced to svn://svn.savannah.nongnu.org/qemu/trunk@5495 (repo UUID c046a42c-6fe2-441c-8c8c-71466251a162).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1/* See if various MMX/SSE SSSE3 instructions give expected results */
2#include <stdio.h>
3#include <string.h>
4#include <stdint.h>
5
6int main(int argc, char *argv[]) {
7 char hello[16];
8 const char ehlo[8] = "EHLO ";
9 uint64_t mask = 0x8080800302020001;
10
11 uint64_t a = 0x0000000000090007;
12 uint64_t b = 0x0000000000000000;
13 uint32_t c;
14 uint16_t d;
15
16 const char e[16] = "LLOaaaaaaaaaaaaa";
17 const char f[16] = "aaaaaaaaaaaaaaHE";
18
19 /* pshufb mm1/xmm1, mm2/xmm2 */
20 asm volatile ("movq (%0), %%mm0" : : "r" (ehlo) : "mm0", "mm1");
21 asm volatile ("movq %0, %%mm1" : : "m" (mask));
22 asm volatile ("pshufb %mm1, %mm0");
23 asm volatile ("movq %%mm0, %0" : "=m" (hello));
24 printf("%s\n", hello);
25
26 /* pshufb mm1/xmm1, m64/m128 */
27 asm volatile ("movq (%0), %%mm0" : : "r" (ehlo) : "mm0");
28 asm volatile ("pshufb %0, %%mm0" : : "m" (mask));
29 asm volatile ("movq %%mm0, %0" : "=m" (hello));
30 printf("%s\n", hello);
31
32 /* psubsw mm1/xmm1, m64/m128 */
33 asm volatile ("movq %0, %%mm0" : : "r" (a) : "mm0");
34 asm volatile ("phsubsw %0, %%mm0" : : "m" (b));
35 asm volatile ("movq %%mm0, %0" : "=m" (a));
36 printf("%i - %i = %i\n", 9, 7, -(int16_t) a);
37
38 /* palignr mm1/xmm1, m64/m128, imm8 */
39 asm volatile ("movdqa (%0), %%xmm0" : : "r" (e) : "xmm0");
40 asm volatile ("palignr $14, (%0), %%xmm0" : : "r" (f));
41 asm volatile ("movdqa %%xmm0, (%0)" : : "r" (hello));
42 printf("%5.5s\n", hello);
43
44#if 1 /* SSE4 */
45 /* popcnt r64, r/m64 */
46 asm volatile ("movq $0x8421000010009c63, %%rax" : : : "rax");
47 asm volatile ("popcnt %%ax, %%dx" : : : "dx");
48 asm volatile ("popcnt %%eax, %%ecx" : : : "ecx");
49 asm volatile ("popcnt %rax, %rax");
50 asm volatile ("movq %%rax, %0" : "=m" (a));
51 asm volatile ("movl %%ecx, %0" : "=m" (c));
52 asm volatile ("movw %%dx, %0" : "=m" (d));
53 printf("%i = %i\n%i = %i = %i\n", 13, (int) a, 9, c, d + 1);
54#endif
55
56 return 0;
57}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette