annotate run/a/asm_addss_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_addss_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 haveSSE!()();
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 float* a = (new float[4]).ptr;
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
20 a[0] = 1.0f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
21 a[1] = 20.0f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
22 a[2] = 0.4f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
23 a[3] = 2.0f;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
24
1264
b3d4452d48ac added DMD-0.177's results
thomask
parents: 1151
diff changeset
25 float* b = (new float[4]).ptr;
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
26 b[0] = 4.0f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
27 b[1] = 10.0f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
28 b[2] = -4.0f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
29 b[3] = -0.4f;
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
30
1151
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
31 static if(size_t.sizeof == 4){
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
32 asm{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
33 mov EAX, a;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
34 movups XMM0, [EAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
35 mov EAX, b;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
36 movups XMM1, [EAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
37 addss XMM0, XMM1;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
38 movups [EAX], XMM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
39 }
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
40 }else static if(size_t.sizeof == 8){
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
41 asm{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
42 mov RAX, a;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
43 movups XMM0, [RAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
44 mov RAX, b;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
45 movups XMM1, [RAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
46 addss XMM0, XMM1;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
47 movups [RAX], XMM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
48 }
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
49 }else{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
50 static assert(0, "unhandled pointer size");
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
51 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
52
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
53 b[0] -= 5.0f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
54 if(b[0] < 0.0){
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
55 b[0] = -b[0];
976
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 if(b[0] > float.epsilon * 16){
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
59 assert(0);
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
60 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
61
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
62 b[1] -= 20.0f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
63 if(b[1] < 0.0){
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
64 b[1] = -b[1];
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
65 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
66
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
67 if(b[1] > float.epsilon * 16){
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
68 assert(0);
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
69 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
70
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
71 b[2] -= 0.4f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
72 if(b[2] < 0.0){
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
73 b[2] = -b[2];
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
74 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
75
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
76 if(b[2] > float.epsilon * 16){
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
77 assert(0);
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
78 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
79
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
80 b[3] -= 2.0f;
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
81 if(b[3] < 0.0){
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
82 b[3] = -b[3];
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
83 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
84
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
85 if(b[3] > float.epsilon * 16){
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
86 assert(0);
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
87 }
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
88 return 0;
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
89 }
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
90 }else{
1386
7a397590d6e0 64-bit fixes
thomask
parents: 1264
diff changeset
91 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
1063
4c41b782a14e pre 0.162 review
thomask
parents: 989
diff changeset
92 static assert(0);
976
4bc1d14d6851 extended SSE asm tests
thomask
parents:
diff changeset
93 }