Commit 59e0fbf8e916efa9b9e9fed00f5692e8a7d684d9
1 parent
0086de1c
Add a simple SSSE3 test.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5320 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
42 additions
and
0 deletions
tests/test-i386-ssse3.c
0 → 100644
1 | +/* See if various MMX/SSE SSSE3 instructions give expected results */ | |
2 | +#include <stdio.h> | |
3 | +#include <string.h> | |
4 | + | |
5 | +int main(int argc, char *argv[]) { | |
6 | + char hello[16]; | |
7 | + const char ehlo[8] = "EHLO "; | |
8 | + uint64_t mask = 0x8080800302020001; | |
9 | + | |
10 | + uint64_t a = 0x0000000000090007; | |
11 | + uint64_t b = 0x0000000000000000; | |
12 | + | |
13 | + const char c[16] = "LLOaaaaaaaaaaaaa"; | |
14 | + const char d[16] = "aaaaaaaaaaaaaaHE"; | |
15 | + | |
16 | + /* pshufb mm1/xmm1, mm2/xmm2 */ | |
17 | + asm volatile ("movq (%0), %%mm0" : : "r" (ehlo) : "mm0", "mm1"); | |
18 | + asm volatile ("movq %0, %%mm1" : : "m" (mask)); | |
19 | + asm volatile ("pshufb %mm1, %mm0"); | |
20 | + asm volatile ("movq %%mm0, %0" : "=m" (hello)); | |
21 | + printf("%s\n", hello); | |
22 | + | |
23 | + /* pshufb mm1/xmm1, m64/m128 */ | |
24 | + asm volatile ("movq (%0), %%mm0" : : "r" (ehlo) : "mm0"); | |
25 | + asm volatile ("pshufb %0, %%mm0" : : "m" (mask)); | |
26 | + asm volatile ("movq %%mm0, %0" : "=m" (hello)); | |
27 | + printf("%s\n", hello); | |
28 | + | |
29 | + /* psubsw mm1/xmm1, m64/m128 */ | |
30 | + asm volatile ("movq %0, %%mm0" : : "r" (a) : "mm0"); | |
31 | + asm volatile ("phsubsw %0, %%mm0" : : "m" (b)); | |
32 | + asm volatile ("movq %%mm0, %0" : "=m" (a)); | |
33 | + printf("%i - %i = %i\n", 9, 7, -(int16_t) a); | |
34 | + | |
35 | + /* palignr mm1/xmm1, m64/m128, imm8 */ | |
36 | + asm volatile ("movdqa (%0), %%xmm0" : : "r" (c) : "xmm0"); | |
37 | + asm volatile ("palignr $14, (%0), %%xmm0" : : "r" (d)); | |
38 | + asm volatile ("movdqa %%xmm0, (%0)" : : "r" (hello)); | |
39 | + printf("%5.5s\n", hello); | |
40 | + | |
41 | + return 0; | |
42 | +} | ... | ... |