annotate addon/cpuinfo.d @ 769:ce5513bd43f0

minor dmd-0.141 review
author thomask
date Fri, 09 Dec 2005 22:40:57 +0000
parents b0e6b3803e95
children 7b2c5a101190
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
1 // $HeadURL: svn://dstress.kuehne.cn/run/a/asm_sub_01_C.d $
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
2 // $Date: 2005-08-20 20:24:41 +0200 (Sat, 20 Aug 2005) $
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
3 // $Author: thomask $
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;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
23 }else{
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
24 pragma(msg, "no Inline ASM support");
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
25 const bool haveX86InlineAsm = false;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
26 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
27
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
28 void haveCMOV(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
29 uint a = 0;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
30
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
31 version(haveX86InlineAsm){
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
32 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
33 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
34 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
35 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
36 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
37 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
38
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
39 if(!((a >> 15) & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
40 throw new Exception("no X86 CMOV support present");
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
41 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
42 }
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
43
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
44 void haveCX8(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
45 uint a = 0;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
46
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
47 version(haveX86InlineAsm){
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
48 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
49 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
50 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
51 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
52 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
53 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
54
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
55 if(!((a >> 8) & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
56 throw new Exception("no X86 CX8 support present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
57 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
58 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
59
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
60 void haveFPU(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
61 uint a = 0;
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
62
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
63 version(haveX86InlineAsm){
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
64 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
65 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
66 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
67 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
68 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
69 }
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
70
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
71 if(!(a & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
72 throw new Exception("no X86 FPU present");
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
73 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
74 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
75
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
76 void haveMMX(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
77 uint a = 0;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
78
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
79 version(haveX86InlineAsm){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
80 asm{
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
81 mov EAX, 1;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
82 cpuid;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
83 mov a, EDX;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
84 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
85 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
86
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
87 if(!((a >> 23) & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
88 throw new Exception("no X86 MMX support present");
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
89 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
90 }
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
91
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
92
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
93 void haveSSE(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
94 uint a = 0;
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
95
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
96 version(haveX86InlineAsm){
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
97 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
98 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
99 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
100 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
101 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
102 }
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
103
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
104 if(!((a >> 25) & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
105 throw new Exception("no X86 SSE support present");
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
106 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
107 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
108
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
109 void haveSSE2(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
110 uint a = 0;
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 version(haveX86InlineAsm){
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
113 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
114 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
115 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
116 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
117 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
118 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
119
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
120 if(!((a >> 26) & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
121 throw new Exception("no X86 SSE2 support present");
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
122 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
123 }
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 void haveSSE3(){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
126 uint a = 0;
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
127
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
128 version(haveX86InlineAsm){
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
129 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
130 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
131 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
132 mov a, ECX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
133 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
134 }
769
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
135
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
136 if(!(a & 1)){
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
137 throw new Exception("no X86 SSE3 support present");
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
138 }
ce5513bd43f0 minor dmd-0.141 review
thomask
parents: 709
diff changeset
139 }