annotate run/a/asm_divsd_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 93511f726375
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
978
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
1 // $HeadURL$
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
2 // $Date$
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
3 // $Author$
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
4
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
5 module dstress.run.a.asm_divsd_01_A;
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
6
989
a468938b0160 inline ASM review
thomask
parents: 978
diff changeset
7 version(D_InlineAsm_X86){
a468938b0160 inline ASM review
thomask
parents: 978
diff changeset
8 version = runTest;
a468938b0160 inline ASM review
thomask
parents: 978
diff changeset
9 }else version(D_InlineAsm_X86_64){
a468938b0160 inline ASM review
thomask
parents: 978
diff changeset
10 version = runTest;
a468938b0160 inline ASM review
thomask
parents: 978
diff changeset
11 }
a468938b0160 inline ASM review
thomask
parents: 978
diff changeset
12
1083
8d76f113a70c fPIC fixes
thomask
parents: 1044
diff changeset
13 version(runTest){
8d76f113a70c fPIC fixes
thomask
parents: 1044
diff changeset
14 import addon.cpuinfo;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
15
1083
8d76f113a70c fPIC fixes
thomask
parents: 1044
diff changeset
16 int main(){
1268
93511f726375 partial review
thomask
parents: 1151
diff changeset
17 double* a = (new double[2]).ptr;
1083
8d76f113a70c fPIC fixes
thomask
parents: 1044
diff changeset
18 a[0] = -16.0f;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
19 a[1] = 12.0;
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
20
1268
93511f726375 partial review
thomask
parents: 1151
diff changeset
21 double* b = (new double[2]).ptr;
1083
8d76f113a70c fPIC fixes
thomask
parents: 1044
diff changeset
22 b[0] = 2.0f;
8d76f113a70c fPIC fixes
thomask
parents: 1044
diff changeset
23 b[1] = 3.0f;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1085
diff changeset
24
1268
93511f726375 partial review
thomask
parents: 1151
diff changeset
25 double* c = (new double[2]).ptr;
978
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
26
1151
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
27 static if(size_t.sizeof == 4){
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
28 asm{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
29 mov EAX, a;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
30 movupd XMM0, [EAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
31 mov EAX, b;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
32 movupd XMM1, [EAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
33 divsd XMM0, XMM1;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
34 mov EAX, c;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
35 movupd [EAX], XMM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
36 }
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
37 }else static if(size_t.sizeof == 8){
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
38 asm{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
39 mov RAX, a;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
40 movupd XMM0, [RAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
41 mov RAX, b;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
42 movupd XMM1, [RAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
43 divsd XMM0, XMM1;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
44 mov RAX, c;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
45 movupd [RAX], XMM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
46 }
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
47 }else{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1125
diff changeset
48 static assert(0, "unhandled pointer size");
978
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
49 }
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
50
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
51 c[0] += 8.0f;
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
52 if(c[0] < 0){
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
53 c[0] = -c[0];
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
54 }
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
55 if(c[0] > double.epsilon * 16){
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
56 assert(0);
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
57 }
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
58
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
59 c[1] -= 12.0f;
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
60 if(c[1] < 0){
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
61 c[1] = -c[1];
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
62 }
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
63 if(c[1] > double.epsilon * 16){
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
64 assert(0);
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
65 }
1044
03c97933de98 inline ASM review
thomask
parents: 989
diff changeset
66
978
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
67 return 0;
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
68 }
1083
8d76f113a70c fPIC fixes
thomask
parents: 1044
diff changeset
69 }else{
8d76f113a70c fPIC fixes
thomask
parents: 1044
diff changeset
70 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
8d76f113a70c fPIC fixes
thomask
parents: 1044
diff changeset
71 static assert(0);
978
4c5ccd0d4947 extended SSE asm tests
thomask
parents:
diff changeset
72 }