annotate addon/cpuinfo.d @ 1002:a7310ceac844

inline ASM review
author thomask
date Thu, 18 May 2006 16:07:06 +0000
parents 861fe190f7ef
children aab96ff8d6cd
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
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
31
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
32 template haveCMOV(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
33 void haveCMOV(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
34 uint a = 0;
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
35
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
36 version(haveX86InlineAsm){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
37 asm{
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
38 mov EAX, 1;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
39 cpuid;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
40 mov a, EDX;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
41 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
42 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
43 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
44 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
45
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
46 if(!((a >> 15) & 1)){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
47 throw new Exception("DSTRESS{XFAIL}: no CMOV support present");
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
48 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
49 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
50 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
51
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
52 void haveCX8(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
53 uint a = 0;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
54
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
55 version(haveX86InlineAsm){
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
56 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
57 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
58 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
59 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
60 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
61 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
62
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
63 if(!((a >> 8) & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
64 throw new Exception("no X86 CX8 support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
65 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
66 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
67
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
68 template haveFPU(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
69 void haveFPU(){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
70 uint a = 0;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
71
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
72 version(haveX86InlineAsm){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
73 asm{
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
74 mov EAX, 1;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
75 cpuid;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
76 mov a, EDX;
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
77 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
78 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
79 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
80 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
81
990
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
82 if(!(a & 1)){
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
83 throw new Exception("DSTRESS{XFAIL}: no X86 FPU present");
15b0469145fb inline ASM review
thomask
parents: 856
diff changeset
84 }
709
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
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
88 template haveMMX(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
89 void haveMMX(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
90 uint a = 0;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
91
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
92 version(haveX86InlineAsm){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
93 asm{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
94 mov EAX, 1;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
95 cpuid;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
96 mov a, EDX;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
97 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
98 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
99 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
100 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
101
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
102 if(!((a >> 23) & 1)){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
103 throw new Exception("DSTRESS{XFAIL}: no MMX support present");
a7310ceac844 inline ASM review
thomask
parents: 993
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 }
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
107
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
108 template haveSSE(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
109 void haveSSE(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
110 uint a = 0;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
111
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
112 version(haveX86InlineAsm){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
113 asm{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
114 mov EAX, 1;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
115 cpuid;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
116 mov a, EDX;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
117 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
118 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
119 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
120 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
121
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
122 if(!((a >> 25) & 1)){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
123 throw new Exception("DSTRESS{XFAIL}: no SSE support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
124 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
125 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
126 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
127
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
128 template haveSSE2(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
129 void haveSSE2(){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
130 uint a = 0;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
131
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
132 version(haveX86InlineAsm){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
133 asm{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
134 mov EAX, 1;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
135 cpuid;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
136 mov a, EDX;
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
137 }
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
138 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
139 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
140 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
141
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
142 if(!((a >> 26) & 1)){
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
143 throw new Exception("DSTRESS{XFAIL}: no SSE2 support present");
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
144 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
145 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
146 }
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
147
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
148 template haveSSE3(){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
149 void haveSSE3(){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
150 uint a = 1;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
151 uint b = 0;
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
152
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
153 version(haveX86InlineAsm){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
154 asm{
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
155 mov EAX, a;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
156 cpuid;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
157 mov b, ECX;
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
158 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
159 }else{
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
160 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
161 }
1002
a7310ceac844 inline ASM review
thomask
parents: 993
diff changeset
162
993
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
163 if(!(a & 1)){
861fe190f7ef inline ASM review
thomask
parents: 990
diff changeset
164 throw new Exception("DSTRESS{XFAIL}: no SSE3 support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
165 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
166 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
167 }