annotate run/a/asm_minsd_01_B.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_minsd_01_B;
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 haveSSE2!()();
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
18
1267
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
19 double* a = (new double[2]).ptr;
1084
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
20 a[0] = 3.0;
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
21 a[1] = 4.0;
91ff3e405be5 -fPIC fixes
thomask
parents: 1044
diff changeset
22
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
23 double b = 2.0;
1267
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
24
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
25 double* c = (new double[2]).ptr;
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
26
1267
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
27 static if(size_t.sizeof == 4){
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
28 asm{
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
29 mov EAX, a;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
30 movupd XMM0, [EAX];
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
31 minsd XMM0, b;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
32 mov EAX, c;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
33 movupd [EAX], XMM0;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
34 }
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
35 }else static if(size_t.sizeof == 8){
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
36 asm{
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
37 mov RAX, a;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
38 movupd XMM0, [RAX];
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
39 minsd XMM0, b;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
40 mov RAX, c;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
41 movupd [RAX], XMM0;
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
42 }
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
43 }else{
409746d4e240 32<->64 iasm fixes
thomask
parents: 1085
diff changeset
44 static assert(0, "unhandled pointer size");
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
45 }
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
46
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
47 if(c[0] != 2.0){
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
48 assert(0);
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
49 }
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
50 if(c[1] != 4.0){
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
51 assert(0);
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
52 }
1044
03c97933de98 inline ASM review
thomask
parents: 1002
diff changeset
53
1002
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
54 return 0;
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
55 }
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
56 }else{
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
57 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
58 static assert(0);
a7310ceac844 inline ASM review
thomask
parents:
diff changeset
59 }