annotate addon/cpuinfo.d @ 993:861fe190f7ef

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