annotate run/a/asm_addsubpd_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 b3d4452d48ac
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_addsubpd_01_A;
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
6
987
1c9d1337cb77 inline asm review
thomask
parents: 976
diff changeset
7 version(D_InlineAsm_X86){
989
a468938b0160 inline ASM review
thomask
parents: 987
diff changeset
8 version = runTest;
987
1c9d1337cb77 inline asm review
thomask
parents: 976
diff changeset
9 }else version(D_InlineAsm_X86_64){
989
a468938b0160 inline ASM review
thomask
parents: 987
diff changeset
10 version = runTest;
987
1c9d1337cb77 inline asm review
thomask
parents: 976
diff changeset
11 }
1c9d1337cb77 inline asm review
thomask
parents: 976
diff changeset
12
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
13 version(runTest){
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
14 import addon.cpuinfo;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
15
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
16 int main(){
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
17 haveSSE3!()();
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
18
1264
b3d4452d48ac added DMD-0.177's results
thomask
parents: 1151
diff changeset
19 double* a = (new double[2]).ptr;
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
20 a[0] = 1.0;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
21 a[1] = 30.0;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
22
1264
b3d4452d48ac added DMD-0.177's results
thomask
parents: 1151
diff changeset
23 double* b = (new double[2]).ptr;
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
24 b[0] = 4.0;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
25 b[1] = 10.0;
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 addsubpd 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 addsubpd 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
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
49 b[0] += 3.0;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
50 if(b[0] < 0.0){
4c41b782a14e pre 0.162 review
thomask
parents: 989
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
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
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
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
58 b[1] -= 40.0;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
59 if(b[1] < 0.0){
4c41b782a14e pre 0.162 review
thomask
parents: 989
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
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
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 }
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
66
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
67 return 0;
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
68 }
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
69 }else{
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
70 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
71 static assert(0);
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
72 }