annotate addon/cpuinfo.d @ 1266:516e1eeceb04

array -> pointer isn't implicit anymore
author thomask
date Thu, 21 Dec 2006 15:11:45 +0000
parents f34b7d4a2db7
children 23fe17e22a63
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
856
7b2c5a101190 meta data maintenance
thomask
parents: 769
diff changeset
1 // $HeadURL$
7b2c5a101190 meta data maintenance
thomask
parents: 769
diff changeset
2 // $Date$
7b2c5a101190 meta data maintenance
thomask
parents: 769
diff changeset
3 // $Author$
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
4
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
5 // @author@ Thomas Kuehne <thomas-dloop@kuehne.cn>
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
6
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
7 module /*dstress.*/addon.cpuinfo;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
8
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
9 version(D_InlineAsm){
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
10 version(X86){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
11 const bool haveX86InlineAsm = true;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
12 version = haveX86InlineAsm;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
13 }else version(X86_64){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
14 const bool haveX86InlineAsm = true;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
15 version = haveX86InlineAsm;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
16 }else{
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
17 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
18 const bool haveX86InlineAsm = false;
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
19 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
20 }else version(D_InlineAsm_X86){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
21 const bool haveX86InlineAsm = true;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
22 version = haveX86InlineAsm;
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
23 }else version(D_InlineAsm_X86_X64){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
24 const bool haveX86InlineAsm = true;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
25 version = haveX86InlineAsm;
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
26 }else{
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
27 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
28 const bool haveX86InlineAsm = false;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
29 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
30
1042
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
31 template have3DNow(){
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
32 void have3DNow(){
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
33 uint a = 0;
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
34
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
35 version(haveX86InlineAsm){
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
36 asm{
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
37 mov EAX, 0x8000_0001;
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
38 cpuid;
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
39 mov a, EDX;
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
40 }
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
41 }else{
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
42 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
43 }
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
44
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
45 if(!((a >> 30) & 1)){
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
46 throw new Exception("DSTRESS{XFAIL}: no 3DNow! support present");
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
47 }
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
48 }
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
49 }
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
50
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
51 template haveCMOV(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
52 void haveCMOV(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
53 uint a = 0;
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
54
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
55 version(haveX86InlineAsm){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
56 asm{
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
57 mov EAX, 1;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
58 cpuid;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
59 mov a, EDX;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
60 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
61 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
62 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
63 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
64
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
65 if(!((a >> 15) & 1)){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
66 throw new Exception("DSTRESS{XFAIL}: no CMOV support present");
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
67 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
68 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
69 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
70
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
71 void haveCX8(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
72 uint a = 0;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
73
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
74 version(haveX86InlineAsm){
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
75 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
76 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
77 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
78 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
79 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
80 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
81
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
82 if(!((a >> 8) & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
83 throw new Exception("no X86 CX8 support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
84 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
85 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
86
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
87 template haveFPU(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
88 void haveFPU(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
89 uint a = 0;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
90
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
91 version(haveX86InlineAsm){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
92 asm{
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
93 mov EAX, 1;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
94 cpuid;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
95 mov a, EDX;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
96 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
97 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
98 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
99 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
100
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
101 if(!(a & 1)){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
102 throw new Exception("DSTRESS{XFAIL}: no X86 FPU present");
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
103 }
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
104 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
105 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
106
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
107 template haveMMX(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
108 void haveMMX(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
109 uint a = 0;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
110
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
111 version(haveX86InlineAsm){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
112 asm{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
113 mov EAX, 1;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
114 cpuid;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
115 mov a, EDX;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
116 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
117 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
118 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
119 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
120
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
121 if(!((a >> 23) & 1)){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
122 throw new Exception("DSTRESS{XFAIL}: no MMX support present");
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
123 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
124 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
125 }
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
126
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
127 template haveSSE(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
128 void haveSSE(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
129 uint a = 0;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
130
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
131 version(haveX86InlineAsm){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
132 asm{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
133 mov EAX, 1;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
134 cpuid;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
135 mov a, EDX;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
136 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
137 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
138 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
139 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
140
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
141 if(!((a >> 25) & 1)){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
142 throw new Exception("DSTRESS{XFAIL}: no SSE support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
143 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
144 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
145 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
146
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
147 template haveSSE2(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
148 void haveSSE2(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
149 uint a = 0;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
150
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
151 version(haveX86InlineAsm){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
152 asm{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
153 mov EAX, 1;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
154 cpuid;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
155 mov a, EDX;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
156 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
157 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
158 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
159 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
160
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
161 if(!((a >> 26) & 1)){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
162 throw new Exception("DSTRESS{XFAIL}: no SSE2 support present");
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
163 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
164 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
165 }
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
166
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
167 template haveSSE3(){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
168 void haveSSE3(){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
169 uint a = 1;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
170 uint b = 0;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
171
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
172 version(haveX86InlineAsm){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
173 asm{
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
174 mov EAX, a;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
175 cpuid;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
176 mov b, ECX;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
177 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
178 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
179 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
180 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
181
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
182 if(!(a & 1)){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
183 throw new Exception("DSTRESS{XFAIL}: no SSE3 support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
184 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
185 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
186 }
1029
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
187
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
188 template aligned_new(T){
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
189 T[] aligned_new(size_t len, size_t alignment){
1266
516e1eeceb04 array -> pointer isn't implicit anymore
thomask
parents: 1042
diff changeset
190 ubyte* ptr = (new ubyte[len * T.sizeof + alignment]).ptr;
1029
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
191
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
192 alignment *= 8;
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
193
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
194 while((cast(size_t)ptr) % alignment){
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
195 ptr++;
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
196 }
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
197
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
198 T[]data = (cast(T*) ptr)[0 .. len];
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
199 data[] = T.init;
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
200
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
201 return data;
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
202 }
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
203 }