diff --git a/Shared/All.h b/Shared/All.h index f428e8c..0073475 100644 --- a/Shared/All.h +++ b/Shared/All.h @@ -112,6 +112,15 @@ Global compiler settings (useful for porting) #define ENABLE_SSE_ASSEMBLY #define ENABLE_AVX_ASSEMBLY #endif +#elif (defined(__GNUC__) || defined(__clang__)) + #if defined(__i386__) + #define ENABLE_MMX_ASSEMBLY + #endif + + #if defined(__i386__) || defined(__x86_64__) + #define ENABLE_SSE_ASSEMBLY + #define ENABLE_AVX_ASSEMBLY + #endif #endif // APE_BACKWARDS_COMPATIBILITY is only needed for decoding APE 3.92 or earlier files. It diff --git a/Source/Shared/GlobalFunctions.cpp b/Source/Shared/GlobalFunctions.cpp index 5491cc6..d1777e4 100644 --- a/Source/Shared/GlobalFunctions.cpp +++ b/Source/Shared/GlobalFunctions.cpp @@ -8,6 +8,9 @@ #ifdef PLATFORM_ANDROID #include #endif +#if (defined(__GNUC__) || defined(__clang__)) + #include +#endif namespace APE { @@ -118,6 +121,14 @@ bool GetMMXAvailable() if (cpuInfo[3] & CPU_MMX) bMMX = true; } +#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) + unsigned int eax, ebx, ecx, edx; + + if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + { + if (edx & bit_MMX) + bMMX = true; + } #endif return bMMX; #endif @@ -153,6 +164,22 @@ bool GetSSEAvailable(bool bTestForSSE41) bSSE = true; } } +#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) + unsigned int eax, ebx, ecx, edx; + + if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + { + if (bTestForSSE41) + { + if (edx & bit_SSE41) + bSSE = true; + } + else + { + if (edx & bit_SSE2) + bSSE = true; + } + } #endif return bSSE; #endif @@ -166,7 +193,6 @@ bool GetAVX2Available() bool bAVX = false; #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) #define CPU_AVX2 (1 << 5) - int cpuInfo[4] = { 0 }; __cpuid(cpuInfo, 0); @@ -177,6 +203,14 @@ bool GetAVX2Available() if (cpuInfo[1] & CPU_AVX2) bAVX = true; } +#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) + unsigned int eax, ebx, ecx, edx; + + if (__get_cpuid (7, &eax, &ebx, &ecx, &edx)) + { + if (ebx & bit_AVX2) + bAVX = true; + } #endif return bAVX; #endif