annotate run/a/asm_pshufd_01_A.d @ 1329:1c8652b3795a

inline asm review
author thomask
date Fri, 12 Jan 2007 23:07:17 +0000
parents 6e5d377573e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
1 // $HeadURL$
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
2 // $Date$
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
3 // $Author$
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
4
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
5 module dstress.run.a.asm_pshufd_01_A;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
6
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
7 version(D_InlineAsm_X86){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
8 version = runTest;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
9 }else version(D_InlineAsm_X86_64){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
10 version = runTest;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
11 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
12
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
13 version(runTest){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
14 import addon.cpuinfo;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
15
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
16 int main(){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
17 haveSSE2!()();
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
18
1329
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
19 float[] A = [1.0f, 2.0f, 3.0f, 4.0f];
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
20 float* a = A.ptr;
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
21
1329
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
22 float[] B = [5.0f, 6.0f, 7.0f, 8.0f];
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
23 float* b = B.ptr;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
24
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
25 float* c = (new float[4]).ptr;
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
26
1329
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
27 static if(size_t.sizeof == 4){
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
28 asm{
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
29 mov EAX, a;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
30 movups XMM0, [EAX];
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
31 mov EAX, b;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
32 movups XMM1, [EAX];
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
33 pshufd XMM0, XMM1, 0b01_01_00_10;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
34 mov EAX, c;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
35 movups [EAX], XMM0;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
36 }
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
37 }else static if(size_t.sizeof == 8){
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
38 asm{
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
39 mov RAX, a;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
40 movups XMM0, [RAX];
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
41 mov RAX, b;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
42 movups XMM1, [RAX];
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
43 pshufd XMM0, XMM1, 0b01_01_00_10;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
44 mov RAX, c;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
45 movups [RAX], XMM0;
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
46 }
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
47 }else{
1c8652b3795a inline asm review
thomask
parents: 1182
diff changeset
48 static assert(0, "unhandled pointer size");
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
49 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
50
1182
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1044
diff changeset
51 if(c[0] != 7.0f){
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
52 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
53 }
1182
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1044
diff changeset
54 if(c[1] != 5.0f){
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
55 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
56 }
1182
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1044
diff changeset
57 if(c[2] != 6.0f){
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
58 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
59 }
1182
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1044
diff changeset
60 if(c[3] != 6.0f){
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
61 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
62 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
63
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
64 return 0;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
65 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
66 }else{
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
67 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
68 static assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
69 }