annotate run/a/asm_cvtpi2ps_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
1062
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
1 // $HeadURL$
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
2 // $Date$
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
3 // $Author$
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
4
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
5 module dstress.run.a.asm_cvtpi2ps_01_A;
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
6
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
7 version(D_InlineAsm_X86){
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
8 version = runTest;
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
9 }else version(D_InlineAsm_X86_64){
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
10 version = runTest;
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
11 }
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
12
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
13 version(runTest){
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
14 import addon.cpuinfo;
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
15
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
16 int main(){
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
17 haveSSE2!();
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
18 haveMMX!();
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
19
1268
93511f726375 partial review
thomask
parents: 1151
diff changeset
20 int* a = (new int[2]).ptr;
1083
8d76f113a70c fPIC fixes
thomask
parents: 1062
diff changeset
21 a[0] = -3;
8d76f113a70c fPIC fixes
thomask
parents: 1062
diff changeset
22 a[1] = 2;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1083
diff changeset
23
1268
93511f726375 partial review
thomask
parents: 1151
diff changeset
24 float* b = (new float[4]).ptr;
1083
8d76f113a70c fPIC fixes
thomask
parents: 1062
diff changeset
25 b[0] = 10.1f;
8d76f113a70c fPIC fixes
thomask
parents: 1062
diff changeset
26 b[1] = 20.2f;
8d76f113a70c fPIC fixes
thomask
parents: 1062
diff changeset
27 b[2] = 30.3f;
8d76f113a70c fPIC fixes
thomask
parents: 1062
diff changeset
28 b[3] = 40.4f;
1091
9dcac8d4e97f post DMD-0.163 review
thomask
parents: 1083
diff changeset
29
1268
93511f726375 partial review
thomask
parents: 1151
diff changeset
30 float* c = (new float[4]).ptr;
1062
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
31
1151
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
32 static if(size_t.sizeof == 4){
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
33 asm{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
34 mov EAX, a;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
35 movq MM0, [EAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
36 mov EAX, b;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
37 movups XMM0, [EAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
38 cvtpi2ps XMM0, MM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
39 mov EAX, c;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
40 movups [EAX], XMM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
41 emms;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
42 }
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
43 }else static if(size_t.sizeof == 8){
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
44 asm{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
45 mov RAX, a;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
46 movq MM0, [RAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
47 mov RAX, b;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
48 movups XMM0, [RAX];
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
49 cvtpi2ps XMM0, MM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
50 mov RAX, c;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
51 movups [RAX], XMM0;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
52 emms;
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
53 }
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
54 }else{
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1116
diff changeset
55 static assert(0, "unhandled pointer size");
1062
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
56 }
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
57
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
58 c[0] += 3.0f;
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
59 if(c[0] < 0.0f){
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
60 c[0] = -c[0];
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
61 }
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
62 if(c[0] > c[0].epsilon * 8){
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
63 assert(0);
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
64 }
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
65
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
66 c[1] -= 2.0f;
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
67 if(c[1] < 0.0f){
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
68 c[1] = -c[1];
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
69 }
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
70 if(c[1] > c[1].epsilon * 8){
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
71 assert(0);
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
72 }
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
73
1083
8d76f113a70c fPIC fixes
thomask
parents: 1062
diff changeset
74 if(c[2] != b[2]){
1062
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
75 assert(0);
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
76 }
1083
8d76f113a70c fPIC fixes
thomask
parents: 1062
diff changeset
77 if(c[3] != b[3]){
1062
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
78 assert(0);
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
79 }
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
80 return 0;
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
81 }
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
82 }else{
1386
7a397590d6e0 64-bit fixes
thomask
parents: 1268
diff changeset
83 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
1062
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
84 static assert(0);
7360e428ad73 pre 0.162 review
thomask
parents:
diff changeset
85 }