annotate run/a/asm_pmullw_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 e3d0dea394ab
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
1 // $HeadURL$
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
2 // $Date$
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
3 // $Author$
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
4
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
5 module dstress.run.a.asm_pmullw_01_A;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
6
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
7 version(D_InlineAsm_X86){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
8 version = runTest;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
9 }else version(D_InlineAsm_X86_64){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
10 version = runTest;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
11 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
12
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
13 version(runTest){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
14 import addon.cpuinfo;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
15
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
16 int main(){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
17 haveSSE2!()();
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
18
1290
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
19 short[] A = [cast(short)-1, 2, 0x7FFF, 7, 0x7FF0, 0x7EDC, 3, -16];
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
20 short* a = A.ptr;
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
21
1290
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
22 short[] B = [cast(short)2, 0, 7, 0x7FFF, 0x00FF, 0x7EDC, 5, 0x7ABC];
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
23 short* b = B.ptr;
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
24
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
25 ushort* c = (new ushort[8]).ptr;
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
26
1182
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
27 static if(size_t.sizeof == 4){
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
28 asm{
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
29 mov EAX, a;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
30 movdqu XMM0, [EAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
31 mov EAX, b;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
32 movdqu XMM1, [EAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
33 pmullw XMM0, XMM1;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
34 mov EAX, c;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
35 movdqu [EAX], XMM0;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
36 }
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
37 }else static if(size_t.sizeof == 8){
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
38 asm{
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
39 mov RAX, a;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
40 movdqu XMM0, [RAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
41 mov RAX, b;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
42 movdqu XMM1, [RAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
43 pmullw XMM0, XMM1;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
44 mov RAX, c;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
45 movdqu [RAX], XMM0;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
46 }
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
47 }else{
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
48 static assert(0, "unhandled pointer size");
1019
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
49 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
50
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
51 if(c[0] != 0xFFFE){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
52 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
53 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
54 if(c[1] != 0x0000){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
55 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
56 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
57 if(c[2] != 0x7FF9){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
58 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
59 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
60 if(c[3] != 0x7FF9){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
61 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
62 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
63 if(c[4] != 0x7010){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
64 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
65 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
66 if(c[5] != 0x4D10){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
67 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
68 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
69 if(c[6] != 0x000F){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
70 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
71 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
72 if(c[7] != 0x5440){
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
73 assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
74 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
75
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
76 return 0;
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
77 }
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
78 }else{
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
79 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
80 static assert(0);
d9dbc4d0698f inline ASM review
thomask
parents:
diff changeset
81 }