annotate run/a/asm_pfrsqrt_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 61d7e32e70a8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
984
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
1 // $HeadURL$
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
2 // $Date$
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
3 // $Author$
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
4
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
5 module dstress.run.a.asm_pfrsqrt_01_A;
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
6
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
7 version(D_InlineAsm_X86){
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
8 version = runTest;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
9 }else version(D_InlineAsm_X86_64){
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
10 version = runTest;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
11 }
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
12
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
13 version(runTest){
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
14 import addon.cpuinfo;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
15
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
16 int main(){
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
17 have3DNow!()();
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
18
1288
61d7e32e70a8 partial inline asm review
thomask
parents: 1164
diff changeset
19 float* a = (new float[2]).ptr;
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
20 a[0] = 4.0f;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
21 a[1] = 3.3f;
984
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
22
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
23 static if(size_t.sizeof == 4){
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
24 asm{
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
25 mov EAX, a;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
26 pfrsqrt MM0, [EAX];
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
27 movq [EAX], MM0;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
28 emms;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
29 }
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
30 }else static if(size_t.sizeof == 8){
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
31 asm{
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
32 mov RAX, a;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
33 pfrsqrt MM0, [RAX];
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
34 movq [RAX], MM0;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
35 emms;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
36 }
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
37 }else{
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
38 static assert(0, "unhandled pointer size");
984
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
39 }
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
40
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
41 a[0] -= 0.5f;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
42 if(a[0] < 0.0f){
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
43 a[0] = -a[0];
984
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
44 }
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
45 if(a[0] > float.epsilon * (1 << 11)){
984
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
46 assert(0);
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
47 }
1044
03c97933de98 inline ASM review
thomask
parents: 1042
diff changeset
48
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
49 a[1] -= 0.5f;
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
50 if(a[1] < 0.0f){
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
51 a[1] = -a[1];
984
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
52 }
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
53 if(a[1] > float.epsilon * (1 << 11)){
984
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
54 assert(0);
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
55 }
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
56
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
57 return 0;
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
58 }
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
59 }else{
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
60 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
61 static assert(0);
984
9acd7becc753 added 3DNow! tests - all of them are broken, see http://d.puremagic.com/bugzilla/show_bug.cgi?id=115
thomask
parents:
diff changeset
62 }