annotate run/a/asm_pmaxsw_01_A.d @ 1290:e3d0dea394ab

partial inline asm review
author thomask
date Wed, 27 Dec 2006 11:59:48 +0000
parents 6e5d377573e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
1 // $HeadURL$
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
2 // $Date$
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
3 // $Author$
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
4
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
5 module dsterss.run.a.asm_pmaxsw_01_A;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
6
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
7
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
8 version(D_InlineAsm_X86){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
9 version = runTest;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
10 }else version(D_InlineAsm_X86_64){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
11 version = runTest;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
12 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
13
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
14 version(runTest){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
15 import addon.cpuinfo;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
16
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
17 int main(){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
18 haveSSE!()();
1044
03c97933de98 inline ASM review
thomask
parents: 1017
diff changeset
19
1290
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
20 short[] A = [cast(short)1, 2, 3, 4, 5, 6, 16, 2];
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
21 short* a = A.ptr;
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
22
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
23 short[] B = [cast(short)-9, 10, -11, -12, 13, 14, 0xFFF, 1];
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
24 short* b = B.ptr;
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
25
e3d0dea394ab partial inline asm review
thomask
parents: 1182
diff changeset
26 short* c = (new short[8]).ptr;
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
27
1182
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
28 static if(size_t.sizeof == 4){
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
29 asm{
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
30 mov EAX, a;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
31 movdqu XMM0, [EAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
32 mov EAX, b;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
33 movdqu XMM1, [EAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
34 pmaxsw XMM0, XMM1;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
35 mov EAX, c;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
36 movdqu [EAX], XMM0;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
37 }
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
38 }else static if(size_t.sizeof == 8){
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
39 asm{
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
40 mov RAX, a;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
41 movdqu XMM0, [RAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
42 mov RAX, b;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
43 movdqu XMM1, [RAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
44 pmaxsw XMM0, XMM1;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
45 mov RAX, c;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
46 movdqu [RAX], XMM0;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
47 }
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
48 }else{
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
49 static assert(0, "unhandled pointer size");
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
50 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
51
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
52 if(c[0] != 1){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
53 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
54 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
55 if(c[1] != 10){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
56 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
57 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
58 if(c[2] != 3){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
59 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
60 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
61 if(c[3] != 4){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
62 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
63 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
64 if(c[4] != 13){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
65 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
66 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
67 if(c[5] != 14){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
68 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
69 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
70 if(c[6] != 0xFFF){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
71 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
72 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
73 if(c[7] != 2){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
74 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
75 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
76
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
77 return 0;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
78 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
79 }else{
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
80 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
81 static assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
82 }