--- a/src/cpuinfo/SDL_cpuinfo.c 2020-12-25 17:10:02.000000000 +0300 +++ b/src/cpuinfo/SDL_cpuinfo.c 2020-12-25 14:23:22.807939400 +0300 @@ -115,6 +115,44 @@ #define CPU_HAS_AVX512F (1 << 12) #define CPU_HAS_ARM_SIMD (1 << 13) +#if defined(__e2k__) +#if !defined(__3dNOW__) +#define __3dNOW__ 0 +#endif + +#if !defined(__MMX__) +#define __MMX__ 0 +#endif + +#if !defined(__SSE__) +#define __SSE__ 0 +#endif + +#if !defined(__SSE2__) +#define __SSE2__ 0 +#endif + +#if !defined(__SSE3__) +#define __SSE3__ 0 +#endif + +#if !defined(__SSE4_1__) +#define __SSE4_1__ 0 +#endif + +#if !defined(__SSE4_2__) +#define __SSE4_2__ 0 +#endif + +#if !defined(__AVX__) +#define __AVX__ 0 +#endif + +#if !defined(__AVX2__) +#define __AVX2__ 0 +#endif +#endif + #if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__ /* This is the brute force way of detecting instruction sets... the idea is borrowed from the libmpeg2 library - thanks! @@ -509,6 +547,13 @@ #endif } +#if defined(__e2k__) +static int +CPU_have3DNow(void) +{ + return __3dNOW__; +} +#else static int CPU_have3DNow(void) { @@ -522,7 +567,18 @@ } return 0; } +#endif +#if defined(__e2k__) +#define CPU_haveRDTSC() (0) +#define CPU_haveMMX() (__MMX__) +#define CPU_haveSSE() (__SSE__) +#define CPU_haveSSE2() (__SSE2__) +#define CPU_haveSSE3() (__SSE3__) +#define CPU_haveSSE41() (__SSE4_1__) +#define CPU_haveSSE42() (__SSE4_2__) +#define CPU_haveAVX() (__AVX__) +#else #define CPU_haveRDTSC() (CPU_CPUIDFeatures[3] & 0x00000010) #define CPU_haveMMX() (CPU_CPUIDFeatures[3] & 0x00800000) #define CPU_haveSSE() (CPU_CPUIDFeatures[3] & 0x02000000) @@ -531,7 +587,15 @@ #define CPU_haveSSE41() (CPU_CPUIDFeatures[2] & 0x00080000) #define CPU_haveSSE42() (CPU_CPUIDFeatures[2] & 0x00100000) #define CPU_haveAVX() (CPU_OSSavesYMM && (CPU_CPUIDFeatures[2] & 0x10000000)) +#endif +#if defined(__e2k__) +static int +CPU_haveAVX2(void) +{ + return __AVX2__; +} +#else static int CPU_haveAVX2(void) { @@ -543,7 +607,15 @@ } return 0; } +#endif +#if defined(__e2k__) +static int +CPU_haveAVX512F(void) +{ + return 0; +} +#else static int CPU_haveAVX512F(void) { @@ -555,6 +627,7 @@ } return 0; } +#endif static int SDL_CPUCount = 0; @@ -596,6 +669,17 @@ return SDL_CPUCount; } +#if defined(__e2k__) +static const char * +SDL_GetCPUType(void) +{ + static char SDL_CPUType[13]; + + SDL_strlcpy(SDL_CPUType, "E2K MACHINE", sizeof(SDL_CPUType)); + + return SDL_CPUType; +} +#else /* Oh, such a sweet sweet trick, just not very useful. :) */ static const char * SDL_GetCPUType(void) @@ -631,9 +715,21 @@ } return SDL_CPUType; } +#endif #ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */ +#if defined(__e2k__) +static const char * +SDL_GetCPUName(void) +{ + static char SDL_CPUName[48]; + + SDL_strlcpy(SDL_CPUName, __builtin_cpu_name(), sizeof(SDL_CPUName)); + + return SDL_CPUName; +} +#else static const char * SDL_GetCPUName(void) { @@ -707,6 +803,7 @@ return SDL_CPUName; } #endif +#endif int SDL_GetCPUCacheLineSize(void)