annotate addon/cpuinfo.d @ 1630:d0efa3ae5522 default tip

run/mini/naked_asm5: New x86_64 ABI passes the arguments in reverse order.
author David Nadlinger <code@klickverbot.at>
date Sat, 23 Apr 2011 22:57:32 +0200
parents 23fe17e22a63
children
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;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
38 db 0x53;
1042
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
39 cpuid;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
40 db 0x5B;
1042
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
41 mov a, EDX;
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
42 }
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
43 }else{
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
44 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
45 }
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
46
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
47 if(!((a >> 30) & 1)){
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
48 throw new Exception("DSTRESS{XFAIL}: no 3DNow! support present");
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
49 }
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
50 }
f34b7d4a2db7 added DMD-0.160 results
thomask
parents: 1029
diff changeset
51 }
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
52
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
53 template haveCMOV(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
54 void haveCMOV(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
55 uint a = 0;
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
56
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
57 version(haveX86InlineAsm){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
58 asm{
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
59 mov EAX, 1;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
60 db 0x53;
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
61 cpuid;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
62 db 0x5B;
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
63 mov a, EDX;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
64 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
65 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
66 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
67 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
68
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
69 if(!((a >> 15) & 1)){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
70 throw new Exception("DSTRESS{XFAIL}: no CMOV support present");
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
71 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
72 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
73 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
74
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
75 void haveCX8(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
76 uint a = 0;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
77
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
78 version(haveX86InlineAsm){
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
79 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
80 mov EAX, 1;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
81 db 0x53;
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
82 cpuid;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
83 db 0x5B;
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
84 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
85 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
86 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
87
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
88 if(!((a >> 8) & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
89 throw new Exception("no X86 CX8 support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
90 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
91 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
92
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
93 template haveFPU(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
94 void haveFPU(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
95 uint a = 0;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
96
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
97 version(haveX86InlineAsm){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
98 asm{
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
99 mov EAX, 1;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
100 db 0x53;
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
101 cpuid;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
102 db 0x5B;
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
103 mov a, EDX;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
104 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
105 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
106 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
107 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
108
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
109 if(!(a & 1)){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
110 throw new Exception("DSTRESS{XFAIL}: no X86 FPU present");
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
111 }
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
112 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
113 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
114
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
115 template haveMMX(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
116 void haveMMX(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
117 uint a = 0;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
118
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
119 version(haveX86InlineAsm){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
120 asm{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
121 mov EAX, 1;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
122 db 0x53;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
123 cpuid;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
124 db 0x5B;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
125 mov a, EDX;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
126 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
127 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
128 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
129 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
130
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
131 if(!((a >> 23) & 1)){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
132 throw new Exception("DSTRESS{XFAIL}: no MMX support present");
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
133 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
134 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
135 }
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
136
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
137 template haveSSE(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
138 void haveSSE(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
139 uint a = 0;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
140
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
141 version(haveX86InlineAsm){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
142 asm{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
143 mov EAX, 1;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
144 db 0x53;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
145 cpuid;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
146 db 0x5B;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
147 mov a, EDX;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
148 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
149 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
150 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
151 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
152
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
153 if(!((a >> 25) & 1)){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
154 throw new Exception("DSTRESS{XFAIL}: no SSE support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
155 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
156 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
157 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
158
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
159 template haveSSE2(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
160 void haveSSE2(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
161 uint a = 0;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
162
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
163 version(haveX86InlineAsm){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
164 asm{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
165 mov EAX, 1;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
166 db 0x53;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
167 cpuid;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
168 db 0x5B;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
169 mov a, EDX;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
170 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
171 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
172 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
173 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
174
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
175 if(!((a >> 26) & 1)){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
176 throw new Exception("DSTRESS{XFAIL}: no SSE2 support present");
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
177 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
178 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
179 }
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
180
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
181 template haveSSE3(){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
182 void haveSSE3(){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
183 uint a = 1;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
184 uint b = 0;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
185
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
186 version(haveX86InlineAsm){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
187 asm{
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
188 mov EAX, a;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
189 db 0x53;
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
190 cpuid;
1279
23fe17e22a63 partial review
thomask
parents: 1266
diff changeset
191 db 0x5B;
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
192 mov b, ECX;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
193 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
194 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
195 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
196 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
197
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
198 if(!(a & 1)){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
199 throw new Exception("DSTRESS{XFAIL}: no SSE3 support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
200 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
201 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
202 }
1029
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
203
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
204 template aligned_new(T){
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
205 T[] aligned_new(size_t len, size_t alignment){
1266
516e1eeceb04 array -> pointer isn't implicit anymore
thomask
parents: 1042
diff changeset
206 ubyte* ptr = (new ubyte[len * T.sizeof + alignment]).ptr;
1029
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
207
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
208 alignment *= 8;
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
209
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
210 while((cast(size_t)ptr) % alignment){
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
211 ptr++;
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
212 }
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
213
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
214 T[]data = (cast(T*) ptr)[0 .. len];
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
215 data[] = T.init;
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
216
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
217 return data;
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
218 }
aab96ff8d6cd partial dmd-0.158 review
thomask
parents: 1002
diff changeset
219 }