Browse Source

x86/cpu: implement support for xgetbv through intrinsics

Signed-off-by: Martin Storsjö <martin@martin.st>
tags/n1.0
Ronald S. Bultje Martin Storsjö 13 years ago
parent
commit
3f150ffba3
2 changed files with 13 additions and 0 deletions
  1. +2
    -0
      configure
  2. +11
    -0
      libavutil/x86/cpu.c

+ 2
- 0
configure View File

@@ -1169,6 +1169,7 @@ HAVE_LIST="
windows_h windows_h
winsock2_h winsock2_h
xform_asm xform_asm
xgetbv
xmm_clobbers xmm_clobbers
yasm yasm
" "
@@ -2742,6 +2743,7 @@ elif enabled sparc; then


elif enabled x86; then elif enabled x86; then


check_code ld immintrin.h "__xgetbv(0)" && enable xgetbv
check_code ld intrin.h "__rdtsc()" && enable rdtsc check_code ld intrin.h "__rdtsc()" && enable rdtsc


check_code ld mmintrin.h "_mm_empty()" && enable mm_empty check_code ld mmintrin.h "_mm_empty()" && enable mm_empty


+ 11
- 0
libavutil/x86/cpu.c View File

@@ -34,8 +34,19 @@
: "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx) \ : "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx) \
: "0" (index)) : "0" (index))


#if HAVE_INLINE_ASM
#define xgetbv(index, eax, edx) \ #define xgetbv(index, eax, edx) \
__asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index)) __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
#elif HAVE_XGETBV
#include <immintrin.h>

#define xgetbv(index, eax, edx) \
do { \
uint64_t res = __xgetbv(index); \
eax = res; \
edx = res >> 32; \
} while (0)
#endif /* HAVE_XGETBV */


#define get_eflags(x) \ #define get_eflags(x) \
__asm__ volatile ("pushfl \n" \ __asm__ volatile ("pushfl \n" \


Loading…
Cancel
Save