3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
* Copyright (C) 2005 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
36 |
|
|
37 |
void Features::detect() { |
void Features::detect() { |
38 |
// we store and restore all registers modified by 'cpuid' the old fashioned way |
// we store and restore all registers modified by 'cpuid' the old fashioned way |
39 |
__asm__ __volatile__ ("mov %eax,eax_temp\n\t" |
__asm__ __volatile__ ( |
40 |
"mov %ebx,ebx_temp\n\t" |
"mov %eax,eax_temp\n\t" |
41 |
"mov %ecx,ecx_temp\n\t" |
"mov %ebx,ebx_temp\n\t" |
42 |
"mov %edx,edx_temp\n\t" |
"mov %ecx,ecx_temp\n\t" |
43 |
"mov $1,%eax\n\t" |
"mov %edx,edx_temp\n\t" |
44 |
"cpuid\n\t" |
"mov $1,%eax\n\t" |
45 |
"mov %edx,edx\n\t" |
"cpuid\n\t" |
46 |
"mov eax_temp,%eax\n\t" |
"mov %edx,edx\n\t" |
47 |
"mov ebx_temp,%ebx\n\t" |
"mov eax_temp,%eax\n\t" |
48 |
"mov ecx_temp,%ecx\n\t" |
"mov ebx_temp,%ebx\n\t" |
49 |
"mov edx_temp,%edx\n\t" |
"mov ecx_temp,%ecx\n\t" |
50 |
); |
"mov edx_temp,%edx\n\t" |
51 |
|
); |
52 |
bMMX = (edx & 0x00800000); |
bMMX = (edx & 0x00800000); |
53 |
bSSE = (edx & 0x02000000); |
bSSE = (edx & 0x02000000); |
54 |
bSSE2 = (edx & 0x04000000); |
bSSE2 = (edx & 0x04000000); |
56 |
#else |
#else |
57 |
void Features::detect() {} |
void Features::detect() {} |
58 |
#endif // ARCH_X86 |
#endif // ARCH_X86 |
59 |
|
|
60 |
|
void Features::enableDenormalsAreZeroMode() { |
61 |
|
#if ARCH_X86 |
62 |
|
if (supportsSSE2()) { |
63 |
|
int x; |
64 |
|
__asm__ __volatile__ ( |
65 |
|
"stmxcsr %0\n\t" |
66 |
|
"movl %0, %%eax\n\t" |
67 |
|
"orl $0x40, %%eax\n\t" |
68 |
|
"movl %%eax, %0\n\t" |
69 |
|
"ldmxcsr %0\n\t" |
70 |
|
:: "m" (x) |
71 |
|
: "%eax" |
72 |
|
); |
73 |
|
} |
74 |
|
#endif // ARCH_X86 |
75 |
|
} |
76 |
|
|
77 |
|
String Features::featuresAsString() { |
78 |
|
String sFeatures = "none"; |
79 |
|
#if ARCH_X86 |
80 |
|
if (supportsMMX()) sFeatures = "MMX"; |
81 |
|
if (supportsSSE()) sFeatures += " SSE"; |
82 |
|
if (supportsSSE2()) sFeatures += " SSE2"; |
83 |
|
#endif // ARCH_X86 |
84 |
|
return sFeatures; |
85 |
|
} |