|
|
|
@ -21,6 +21,7 @@ |
|
|
|
|
|
|
|
#include "zend.h" |
|
|
|
|
|
|
|
#define ZEND_CPU_EBX_MASK (1<<30) |
|
|
|
#define ZEND_CPU_EDX_MASK (1<<31) |
|
|
|
|
|
|
|
typedef enum _zend_cpu_feature { |
|
|
|
@ -55,9 +56,12 @@ typedef enum _zend_cpu_feature { |
|
|
|
ZEND_CPU_FEATURE_OSXSAVE = (1<<27) , |
|
|
|
ZEND_CPU_FEATURE_AVX = (1<<28), |
|
|
|
ZEND_CPU_FEATURE_F16C = (1<<29), |
|
|
|
ZEND_CPU_FEATURE_RDRAND = (1<<30), |
|
|
|
/* intentionally don't support = (1<<30) */ |
|
|
|
/* intentionally don't support = (1<<31) */ |
|
|
|
|
|
|
|
/* EBX */ |
|
|
|
ZEND_CPU_FEATURE_AVX2 = (1<<5 | ZEND_CPU_EBX_MASK), |
|
|
|
|
|
|
|
/* EDX */ |
|
|
|
ZEND_CPU_FEATURE_FPU = (1<<0 | ZEND_CPU_EDX_MASK), |
|
|
|
ZEND_CPU_FEATURE_VME = (1<<1 | ZEND_CPU_EDX_MASK), |
|
|
|
@ -88,47 +92,59 @@ typedef enum _zend_cpu_feature { |
|
|
|
ZEND_CPU_FEATURE_SSE2 = (1<<26 | ZEND_CPU_EDX_MASK), |
|
|
|
ZEND_CPU_FEATURE_SS = (1<<27 | ZEND_CPU_EDX_MASK), |
|
|
|
ZEND_CPU_FEATURE_HT = (1<<28 | ZEND_CPU_EDX_MASK), |
|
|
|
ZEND_CPU_FEATURE_TM = (1<<29 | ZEND_CPU_EDX_MASK), |
|
|
|
ZEND_CPU_FEATURE_IA64 = (1<<30 | ZEND_CPU_EDX_MASK) |
|
|
|
ZEND_CPU_FEATURE_TM = (1<<29 | ZEND_CPU_EDX_MASK) |
|
|
|
/*intentionally don't support = (1<<30 | ZEND_CPU_EDX_MASK)*/ |
|
|
|
/*intentionally don't support = (1<<31 | ZEND_CPU_EDX_MASK)*/ |
|
|
|
} zend_cpu_feature; |
|
|
|
|
|
|
|
void zend_cpu_startup(); |
|
|
|
ZEND_API int zend_cpu_supports(zend_cpu_feature feature); |
|
|
|
|
|
|
|
#ifdef PHP_HAVE_BUILTIN_CPU_SUPPORTS |
|
|
|
#if PHP_HAVE_BUILTIN_CPU_SUPPORTS |
|
|
|
/* NOTE: you should use following inline function in |
|
|
|
* resolver functions (ifunc), as it could be called |
|
|
|
* before all PLT symbols are resloved. in other words, |
|
|
|
* resolver functions should not depends any external |
|
|
|
* functions */ |
|
|
|
static zend_always_inline int zend_cpu_support_sse2() { |
|
|
|
#if PHP_HAVE_BUILTIN_CPU_INIT |
|
|
|
__builtin_cpu_init(); |
|
|
|
#endif |
|
|
|
return __builtin_cpu_supports("sse2"); |
|
|
|
} |
|
|
|
|
|
|
|
static zend_always_inline int zend_cpu_support_sse3() { |
|
|
|
#if PHP_HAVE_BUILTIN_CPU_INIT |
|
|
|
__builtin_cpu_init(); |
|
|
|
#endif |
|
|
|
return __builtin_cpu_supports("sse3"); |
|
|
|
} |
|
|
|
|
|
|
|
static zend_always_inline int zend_cpu_support_sse41() { |
|
|
|
#if PHP_HAVE_BUILTIN_CPU_INIT |
|
|
|
__builtin_cpu_init(); |
|
|
|
#endif |
|
|
|
return __builtin_cpu_supports("sse4.1"); |
|
|
|
} |
|
|
|
|
|
|
|
static zend_always_inline int zend_cpu_support_sse42() { |
|
|
|
#if PHP_HAVE_BUILTIN_CPU_INIT |
|
|
|
__builtin_cpu_init(); |
|
|
|
#endif |
|
|
|
return __builtin_cpu_supports("sse4.2"); |
|
|
|
} |
|
|
|
|
|
|
|
static zend_always_inline int zend_cpu_support_avx() { |
|
|
|
#if PHP_HAVE_BUILTIN_CPU_INIT |
|
|
|
__builtin_cpu_init(); |
|
|
|
#endif |
|
|
|
return __builtin_cpu_supports("avx"); |
|
|
|
} |
|
|
|
|
|
|
|
static zend_always_inline int zend_cpu_support_avx2() { |
|
|
|
#if PHP_HAVE_BUILTIN_CPU_INIT |
|
|
|
__builtin_cpu_init(); |
|
|
|
#endif |
|
|
|
return __builtin_cpu_supports("avx2"); |
|
|
|
} |
|
|
|
#else |
|
|
|
|