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

partuial inline asm review
author thomask
date Tue, 26 Dec 2006 14:21:37 +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 dstress.run.a.asm_pand_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: 1017
diff changeset
15
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
16 int main(){
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
17 haveSSE2!()();
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
18
1285
229e630d4b1a partuial inline asm review
thomask
parents: 1182
diff changeset
19 ushort[] A = [
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
20 0b01101100_01101110, 0b01101001_01101101, 0b01100011_01101011, 0b11100111_01100111,
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
21 0b11000110_11100110, 0b10001101_10011011, 0b00011011_10011011, 0b01100110_00000000
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
22 ];
1285
229e630d4b1a partuial inline asm review
thomask
parents: 1182
diff changeset
23 ushort* a = A.ptr;
229e630d4b1a partuial inline asm review
thomask
parents: 1182
diff changeset
24
229e630d4b1a partuial inline asm review
thomask
parents: 1182
diff changeset
25 ushort[] B = [
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
26 0b10000000_11000000, 0b01000000_01100000, 0b00100000_00110000, 0b00010000_00011000,
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
27 0b00001000_00001100, 0b00000100_00000110, 0b00000010_00000011, 0b11111111_10101010
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
28 ];
1285
229e630d4b1a partuial inline asm review
thomask
parents: 1182
diff changeset
29 ushort* b = B.ptr;
229e630d4b1a partuial inline asm review
thomask
parents: 1182
diff changeset
30
229e630d4b1a partuial inline asm review
thomask
parents: 1182
diff changeset
31 ushort* c = (new ushort[8]).ptr;
1044
03c97933de98 inline ASM review
thomask
parents: 1017
diff changeset
32
1182
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
33 static if(size_t.sizeof == 4){
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
34 asm{
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
35 mov EAX, a;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
36 movdqu XMM0, [EAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
37 mov EAX, b;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
38 movdqu XMM1, [EAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
39 pand XMM0, XMM1;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
40 mov EAX, c;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
41 movdqu [EAX], XMM0;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
42 }
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
43 }else static if(size_t.sizeof == 8){
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
44 asm{
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
45 mov RAX, a;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
46 movdqu XMM0, [RAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
47 mov RAX, b;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
48 movdqu XMM1, [RAX];
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
49 pand XMM0, XMM1;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
50 mov RAX, c;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
51 movdqu [RAX], XMM0;
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
52 }
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
53 }else{
6e5d377573e1 fixed 64bit inline asm issues
thomask
parents: 1164
diff changeset
54 static assert(0, "unhandled pointer size");
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
55 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
56
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
57 if(c[0] != (a[0] & b[0])){
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
58 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
59 }
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
60 if(c[1] != (a[1] & b[1])){
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
61 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
62 }
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
63 if(c[2] != (a[2] & b[2])){
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
64 assert(0);
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
65 }
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
66 if(c[3] != (a[3] & b[3])){
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
67 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
68 }
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
69 if(c[4] != (a[4] & b[4])){
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
70 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
71 }
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
72 if(c[5] != (a[5] & b[5])){
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
73 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
74 }
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
75 if(c[6] != (a[6] & b[6])){
1017
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
76 assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
77 }
1164
7fbe1218b3b5 fPIC fixes(32bit only)
thomask
parents: 1044
diff changeset
78 if(c[7] != (a[7] & b[7])){
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 return 0;
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
82 }
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
83 }else{
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
84 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
85 static assert(0);
26f680ab52cd inline ASM review
thomask
parents:
diff changeset
86 }