-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standard cpusupport framework -- the .../Build/ bits detect whether the compiler supports this and what flags are needed, while the new cpusupport_x86_sse2.c code checks CPUID.
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <emmintrin.h> | ||
|
||
static char a[16]; | ||
|
||
int main(void) | ||
{ | ||
__m128i x; | ||
|
||
x = _mm_loadu_si128((__m128i *)a); | ||
_mm_storeu_si128((__m128i *)a, x); | ||
return (a[0]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "cpusupport.h" | ||
|
||
#ifdef CPUSUPPORT_X86_CPUID | ||
#include <cpuid.h> | ||
#endif | ||
|
||
#define CPUID_SSE2_BIT (1 << 26) | ||
|
||
CPUSUPPORT_FEATURE_DECL(x86, sse2) | ||
{ | ||
#ifdef CPUSUPPORT_X86_CPUID | ||
unsigned int eax, ebx, ecx, edx; | ||
|
||
/* Check if CPUID supports the level we need. */ | ||
if (!__get_cpuid(0, &eax, &ebx, &ecx, &edx)) | ||
goto unsupported; | ||
if (eax < 1) | ||
goto unsupported; | ||
|
||
/* Ask about CPU features. */ | ||
if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx)) | ||
goto unsupported; | ||
|
||
/* Return the relevant feature bit. */ | ||
return (edx & CPUID_SSE2_BIT); | ||
|
||
unsupported: | ||
#endif | ||
return (0); | ||
} |