shithub: libvpx

Download patch

ref: 52da0428becb6b4dfcd67fd744fc8b89199a78a6
parent: 4038632fab26f3f1dbed423e9beb3739a520d69e
parent: 726b021a12c1bc0733565fc9c408a9873067db23
author: Johann Koenig <johannkoenig@google.com>
date: Tue Mar 20 13:05:17 EDT 2018

Merge "reland "use intrinsics for 'emms'""

--- a/test/clear_system_state.h
+++ b/test/clear_system_state.h
@@ -11,19 +11,13 @@
 #define TEST_CLEAR_SYSTEM_STATE_H_
 
 #include "./vpx_config.h"
-#if ARCH_X86 || ARCH_X86_64
-#include "vpx_ports/x86.h"
-#endif
+#include "vpx_ports/system_state.h"
 
 namespace libvpx_test {
 
 // Reset system to a known state. This function should be used for all non-API
 // test cases.
-inline void ClearSystemState() {
-#if ARCH_X86 || ARCH_X86_64
-  vpx_reset_mmx_state();
-#endif
-}
+inline void ClearSystemState() { vpx_clear_system_state(); }
 
 }  // namespace libvpx_test
 #endif  // TEST_CLEAR_SYSTEM_STATE_H_
--- a/test/register_state_check.h
+++ b/test/register_state_check.h
@@ -140,7 +140,7 @@
 
 #endif  // _WIN64
 
-#if ARCH_X86 || ARCH_X86_64
+#if ARCH_X86
 #if defined(__GNUC__)
 
 namespace libvpx_test {
@@ -178,7 +178,7 @@
 }  // namespace libvpx_test
 
 #endif  // __GNUC__
-#endif  // ARCH_X86 || ARCH_X86_64
+#endif  // ARCH_X86
 
 #ifndef API_REGISTER_STATE_CHECK
 #define API_REGISTER_STATE_CHECK ASM_REGISTER_STATE_CHECK
--- a/vpx_ports/emms.asm
+++ /dev/null
@@ -1,38 +1,0 @@
-;
-;  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
-;
-;  Use of this source code is governed by a BSD-style license
-;  that can be found in the LICENSE file in the root of the source
-;  tree. An additional intellectual property rights grant can be found
-;  in the file PATENTS.  All contributing project authors may
-;  be found in the AUTHORS file in the root of the source tree.
-;
-
-
-%include "vpx_ports/x86_abi_support.asm"
-
-section .text
-global sym(vpx_reset_mmx_state) PRIVATE
-sym(vpx_reset_mmx_state):
-    emms
-    ret
-
-
-%if LIBVPX_YASM_WIN64
-global sym(vpx_winx64_fldcw) PRIVATE
-sym(vpx_winx64_fldcw):
-    sub   rsp, 8
-    mov   [rsp], rcx ; win x64 specific
-    fldcw [rsp]
-    add   rsp, 8
-    ret
-
-
-global sym(vpx_winx64_fstcw) PRIVATE
-sym(vpx_winx64_fstcw):
-    sub   rsp, 8
-    fstcw [rsp]
-    mov   rax, [rsp]
-    add   rsp, 8
-    ret
-%endif
--- /dev/null
+++ b/vpx_ports/emms_mmx.c
@@ -1,0 +1,13 @@
+/*
+ *  Copyright (c) 2018 The WebM project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <mmintrin.h>
+
+void vpx_clear_system_state() { _mm_empty(); }
--- /dev/null
+++ b/vpx_ports/float_control_word.asm
@@ -1,0 +1,33 @@
+;
+;  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+;
+;  Use of this source code is governed by a BSD-style license
+;  that can be found in the LICENSE file in the root of the source
+;  tree. An additional intellectual property rights grant can be found
+;  in the file PATENTS.  All contributing project authors may
+;  be found in the AUTHORS file in the root of the source tree.
+;
+
+
+%include "vpx_ports/x86_abi_support.asm"
+
+section .text
+
+%if LIBVPX_YASM_WIN64
+global sym(vpx_winx64_fldcw) PRIVATE
+sym(vpx_winx64_fldcw):
+    sub   rsp, 8
+    mov   [rsp], rcx ; win x64 specific
+    fldcw [rsp]
+    add   rsp, 8
+    ret
+
+
+global sym(vpx_winx64_fstcw) PRIVATE
+sym(vpx_winx64_fstcw):
+    sub   rsp, 8
+    fstcw [rsp]
+    mov   rax, [rsp]
+    add   rsp, 8
+    ret
+%endif
--- a/vpx_ports/system_state.h
+++ b/vpx_ports/system_state.h
@@ -13,10 +13,18 @@
 
 #include "./vpx_config.h"
 
-#if ARCH_X86 || ARCH_X86_64
-void vpx_reset_mmx_state(void);
-#define vpx_clear_system_state() vpx_reset_mmx_state()
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if ARCH_X86 && HAVE_MMX
+extern void vpx_clear_system_state();
 #else
 #define vpx_clear_system_state()
-#endif  // ARCH_X86 || ARCH_X86_64
+#endif  // ARCH_X86 && HAVE_MMX
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VPX_PORTS_SYSTEM_STATE_H_
--- a/vpx_ports/vpx_ports.mk
+++ b/vpx_ports/vpx_ports.mk
@@ -17,8 +17,15 @@
 PORTS_SRCS-yes += system_state.h
 PORTS_SRCS-yes += vpx_timer.h
 
+ifeq ($(ARCH_X86),yes)
+PORTS_SRCS-$(HAVE_MMX) += emms_mmx.c
+endif
+
+ifeq ($(ARCH_X86_64),yes)
+PORTS_SRCS-$(CONFIG_MSVS) += float_control_word.asm
+endif
+
 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
-PORTS_SRCS-yes += emms.asm
 PORTS_SRCS-yes += x86.h
 PORTS_SRCS-yes += x86_abi_support.asm
 endif
--- a/vpx_ports/x86.h
+++ b/vpx_ports/x86.h
@@ -317,8 +317,6 @@
   return mode;
 }
 
-extern void vpx_reset_mmx_state(void);
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif