annotate run/a/asm_movhps_01_A.d @ 1630:d0efa3ae5522 default tip

run/mini/naked_asm5: New x86_64 ABI passes the arguments in reverse order.
author David Nadlinger <code@klickverbot.at>
date Sat, 23 Apr 2011 22:57:32 +0200
parents 409746d4e240
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
1 // $HeadURL$
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
2 // $Date$
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
3 // $Author$
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
4
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
5 module dstress.run.a.asm_movhps_01_A;
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
6
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
7 version(D_InlineAsm_X86){
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
8 version = runTest;
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
9 }else version(D_InlineAsm_X86_64){
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
10 version = runTest;
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
11 }
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
12
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
13 version(runTest){
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
14 import addon.cpuinfo;
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
15
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
16 int main(){
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
17 haveSSE!()();
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
18
1267
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
19 float* a = (new float[4]).ptr;
1084
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
20 a[0] = 1.0f;
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
21 a[1] = 2.0f;
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
22 a[2] = 3.0f;
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
23 a[3] = 4.0f;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
24
1267
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
25 float* b = (new float[2]).ptr;
1084
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
26 b[0] = 5.0f;
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
27 b[1] = 6.0f;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
28
1267
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
29 float* c = (new float[4]).ptr;
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
30
1267
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
31 static if(size_t.sizeof == 4){
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
32 asm{
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
33 mov EAX, a;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
34 movups XMM0, [EAX];
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
35 mov EAX, b;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
36 movhps XMM0, [EAX];
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
37 mov EAX, c;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
38 movups [EAX], XMM0;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
39 }
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
40 }else static if(size_t.sizeof == 8){
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
41 asm{
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
42 mov RAX, a;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
43 movups XMM0, [RAX];
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
44 mov RAX, b;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
45 movhps XMM0, [RAX];
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
46 mov RAX, c;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
47 movups [RAX], XMM0;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
48 }
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
49 }else{
409746d4e240 32<->64 iasm fixes
thomask
parents: 1091
diff changeset
50 static assert(0, "unhandled pointer size");
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
51 }
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
52
1084
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
53 if(c[0] != a[0]){
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
54 assert(0);
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
55 }
1084
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
56 if(c[1] != a[1]){
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
57 assert(0);
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
58 }
1084
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
59 if(c[2] != b[0]){
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
60 assert(0);
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
61 }
1084
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
62 if(c[3] != b[1]){
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
63 assert(0);
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
64 }
1044
03c97933de98 inline ASM review
thomask
parents: 1002
diff changeset
65
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
66 return 0;
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
67 }
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
68 }else{
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
69 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
70 static assert(0);
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
71 }