annotate run/a/asm_addpd_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 7a397590d6e0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
1 // $HeadURL$
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
2 // $Date$
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
3 // $Author$
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
4
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
5 module dstress.run.a.asm_addpd_01_A;
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
6
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
7 version(D_InlineAsm_X86){
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
8 version = runTest;
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
9 }else version(D_InlineAsm_X86_64){
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
10 version = runTest;
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
11 }
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
12
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
13 version(runTest){
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
14 import addon.cpuinfo;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
15
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
16 int main(){
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
17 haveSSE2!()();
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
18
1264
b3d4452d48ac added DMD-0.177's results
thomask
parents: 1151
diff changeset
19 double* a = (new double[2]).ptr;
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
20 a[0] = 1.123;
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
21 a[1] = 1234.5;
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
22
1264
b3d4452d48ac added DMD-0.177's results
thomask
parents: 1151
diff changeset
23 double* b = (new double[2]).ptr;
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
24 b[0] = 0.0012;
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
25 b[1] = -2.4;
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
26
1151
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
27 static if(size_t.sizeof == 4){
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
28 asm{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
29 mov EAX, a;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
30 movupd XMM0, [EAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
31 mov EAX, b;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
32 movupd XMM1, [EAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
33 addpd XMM0, XMM1;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
34 movupd [EAX], XMM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
35 }
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
36 }else static if(size_t.sizeof == 8){
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
37 asm{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
38 mov RAX, a;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
39 movupd XMM0, [RAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
40 mov RAX, b;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
41 movupd XMM1, [RAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
42 addpd XMM0, XMM1;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
43 movupd [RAX], XMM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
44 }
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
45 }else{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
46 static assert(0, "unhandled pointer size");
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
47 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
48
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
49 b[0] -= 1.1242;
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
50 if(b[0] < 0.0){
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
51 b[0] = -b[0];
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
52 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
53
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
54 if(b[0] > double.epsilon * 16){
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
55 assert(0);
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
56 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
57
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
58 b[1] -= 1232.1;
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
59 if(b[1] < 0.0){
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
60 b[1] = -b[1];
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
61 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
62
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
63 if(b[1] > double.epsilon * 16){
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
64 assert(0);
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
65 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
66
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
67 return 0;
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
68 }
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
69 }else{
1386
7a397590d6e0 64-bit fixes
thomask
parents: 1264
diff changeset
70 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
1062
7360e428ad73 pre 0.162 review
thomask
parents: 976
diff changeset
71 static assert(0);
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
72 }