annotate run/a/asm_pavgb_01_A.d @ 1285:229e630d4b1a

partuial inline asm review
author thomask
date Tue, 26 Dec 2006 14:21:37 +0000
parents f9084d3862e8
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 dstress.run.a.asm_pavgb_01_A;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
6
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
7 version(D_InlineAsm_X86){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
8 version = runTest;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
9 }else version(D_InlineAsm_X86_64){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
10 version = runTest;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
11 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
12
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
13 version(runTest){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
14 import addon.cpuinfo;
1044
03c97933de98 inline ASM review
thomask
parents: 1042
diff changeset
15
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
16 int main(){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
17 haveSSE!()();
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
18
1285
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
19 byte* a = (new byte[8]).ptr;
1071
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
20 a[0] = 1;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
21 a[1] = 2;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
22 a[2] = 3;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
23 a[3] = 4;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
24 a[4] = 5;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
25 a[5] = 6;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
26 a[6] = 7;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
27 a[7] = 8;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
28
1285
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
29 byte* b = (new byte[8]).ptr;
1071
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
30 b[0] = 5;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
31 b[1] = 2;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
32 b[2] = 1;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
33 b[3] = 8;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
34 b[4] = 15;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
35 b[5] = 4;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
36 b[6] = 1;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
37 b[7] = 4;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
38
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
39 byte[] c = new byte[8];
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
40 c[0] = 3;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
41 c[1] = 2;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
42 c[2] = 2;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
43 c[3] = 6;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
44 c[4] = 10;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
45 c[5] = 5;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
46 c[6] = 4;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
47 c[7] = 6;
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
48
1285
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
49 byte* d = (new byte[8]).ptr;
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
50
1285
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
51 static if(size_t.sizeof == 4){
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
52 asm{
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
53 mov EAX, a;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
54 movq MM0, [EAX];
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
55 mov EAX, b;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
56 movq MM1, [EAX];
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
57 pavgb MM0, MM1;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
58 mov EAX, d;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
59 movq [EAX], MM0;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
60 emms;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
61 }
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
62 }else static if(size_t.sizeof == 8){
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
63 asm{
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
64 mov RAX, a;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
65 movq MM0, [RAX];
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
66 mov RAX, b;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
67 movq MM1, [RAX];
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
68 pavgb MM0, MM1;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
69 mov RAX, d;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
70 movq [RAX], MM0;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
71 emms;
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
72 }
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
73 }else{
229e630d4b1a partuial inline asm review
thomask
parents: 1071
diff changeset
74 static assert(0, "unhandled pointer size");
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
75 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
76
1071
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
77 for(size_t i = 0; i < c.length; i++){
f9084d3862e8 pre 0.162 review
thomask
parents: 1044
diff changeset
78 if(d[i] != c[i]){
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
79 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
80 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
81 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
82
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
83 return 0;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
84 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
85 }else{
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
86 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
87 static assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
88 }