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

partial inline asm review
author thomask
date Wed, 27 Dec 2006 11:59:48 +0000
parents 03c97933de98
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_pmaddwd_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 haveSSE2!()();
1044
03c97933de98 inline ASM review
thomask
parents: 1017
diff changeset
19
1290
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
20 short[] A = [1, 2, 3, 4, 5, 6, 16, 1];
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
21 short* a = A.ptr;
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
22
1290
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
23 short[] B = [-9, 10, -11, -12, 13, 14, 0xFFF, 2];
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
24 short* b = B.ptr;
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
25
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
26 int* c = (new int[4]).ptr;
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
27
1290
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
28 asm{
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
29 mov EAX, a;
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
30 movdqu XMM0, [EAX];
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
31 mov EAX, b;
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
32 movdqu XMM1, [EAX];
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
33 pmaddwd XMM0, XMM1;
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
34 mov EAX, c;
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
35 movdqu [EAX], XMM0;
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
36 }
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
37
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
38 if(c[0] != (1 * -9) + (2 * 10)){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
39 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
40 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
41 if(c[1] != (3 * -11) + (4 * -12)){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
42 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
43 }
1290
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
44 if(c[2] != (5 * 13) + (6 * 14)){
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
45 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
46 }
1290
e3d0dea394ab partial inline asm review
thomask
parents: 1044
diff changeset
47 if(c[3] != 0xFFF2){
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
48 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
49 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
50
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
51 return 0;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
52 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
53 }else{
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
54 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
55 static assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
56 }