#ifndef VPX_VPX_PORTS_X86_H_
#define VPX_VPX_PORTS_X86_H_
#include <stdlib.h>
#if defined(_MSC_VER)
#include <intrin.h>
#endif
#include "vpx_config.h"
#include "vpx/vpx_integer.h"
#ifdef __cplusplus
extern "C" {
#endif
vpx_cpu_t;
#if defined(__GNUC__) || defined(__ANDROID__)
#if VPX_ARCH_X86_64
#define cpuid(func, func2, ax, bx, cx, dx) …
#else
#define cpuid …
#endif
#elif defined(__SUNPRO_C) || \
defined(__SUNPRO_CC)
#if VPX_ARCH_X86_64
#define cpuid …
#else
#define cpuid …
#endif
#else
#if VPX_ARCH_X86_64
#if defined(_MSC_VER) && _MSC_VER > 1500
#define cpuid …
#else
#define cpuid …
#endif
#else
#define cpuid …
#endif
#endif
#if !defined(__native_client__) && (defined(__i386__) || defined(__x86_64__))
static INLINE uint64_t xgetbv(void) { … }
#elif (defined(_M_X64) || defined(_M_IX86)) && defined(_MSC_FULL_VER) && \
_MSC_FULL_VER >= 160040219
#include <immintrin.h>
#define xgetbv …
#elif defined(_MSC_VER) && defined(_M_IX86)
static INLINE uint64_t xgetbv(void) {
uint32_t eax_, edx_;
__asm {
xor ecx, ecx
__asm _emit 0x0f __asm _emit 0x01 __asm _emit 0xd0
mov eax_, eax
mov edx_, edx
}
return ((uint64_t)edx_ << 32) | eax_;
}
#else
#define xgetbv …
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1700
#undef NOMINMAX
#define NOMINMAX
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#if WINAPI_FAMILY_PARTITION(WINAPI_FAMILY_APP)
#define getenv …
#endif
#endif
#define HAS_MMX …
#define HAS_SSE …
#define HAS_SSE2 …
#define HAS_SSE3 …
#define HAS_SSSE3 …
#define HAS_SSE4_1 …
#define HAS_AVX …
#define HAS_AVX2 …
#define HAS_AVX512 …
#ifndef BIT
#define BIT(n) …
#endif
static INLINE int x86_simd_caps(void) { … }
static INLINE unsigned int x86_readtsc(void) { … }
static INLINE uint64_t x86_readtsc64(void) { … }
static INLINE unsigned int x86_readtscp(void) { … }
static INLINE unsigned int x86_tsc_start(void) { … }
static INLINE unsigned int x86_tsc_end(void) { … }
#if defined(__GNUC__)
#define x86_pause_hint() …
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#define x86_pause_hint …
#else
#if VPX_ARCH_X86_64
#define x86_pause_hint …
#else
#define x86_pause_hint …
#endif
#endif
#if defined(__GNUC__)
static void x87_set_control_word(unsigned short mode) { … }
static unsigned short x87_get_control_word(void) { … }
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
static void x87_set_control_word(unsigned short mode) {
asm volatile("fldcw %0" : : "m"(*&mode));
}
static unsigned short x87_get_control_word(void) {
unsigned short mode;
asm volatile("fstcw %0\n\t" : "=m"(*&mode) :);
return mode;
}
#elif VPX_ARCH_X86_64
extern void vpx_winx64_fldcw(unsigned short mode);
extern unsigned short vpx_winx64_fstcw(void);
#define x87_set_control_word …
#define x87_get_control_word …
#else
static void x87_set_control_word(unsigned short mode) {
__asm { fldcw mode }
}
static unsigned short x87_get_control_word(void) {
unsigned short mode;
__asm { fstcw mode }
return mode;
}
#endif
static INLINE unsigned int x87_set_double_precision(void) { … }
#ifdef __cplusplus
}
#endif
#endif