From a93b115cd6e536587b5c5e78a4b79601206f26a0 Mon Sep 17 00:00:00 2001
From: Jim Bankoski <jimbankoski@google.com>
Date: Mon, 5 Aug 2013 17:28:52 -0700
Subject: [PATCH] reworked config for use_x86_inc

Support enabling it or disabling it.  Moved read out to configure.sh
so that its done once instead of in make and in config.

Change-Id: I73a9190cf31de9f03e8a577f478fa522f8c01c8b
---
 build/make/configure.sh     | 6 ++++++
 configure                   | 2 +-
 libs.mk                     | 8 +-------
 test/vp9_subtract_test.cc   | 2 +-
 vp9/common/vp9_rtcd_defs.sh | 2 +-
 vp9/vp9cx.mk                | 6 +++++-
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/build/make/configure.sh b/build/make/configure.sh
index 30a61067fc..e2566b0a7a 100755
--- a/build/make/configure.sh
+++ b/build/make/configure.sh
@@ -1189,6 +1189,12 @@ EOF
         fi
     fi
 
+    # default use_x86inc to yes if pic is no or 64bit or we are not on darwin
+    echo "  checking here for x86inc \"${tgt_isa}\" \"$pic\" "
+    if [ ${tgt_isa} = x86_64 -o ! "$pic" == "yes" -o ! ${tgt_os:0:6} = darwin ]; then
+      soft_enable use_x86inc
+    fi
+
     # Position Independent Code (PIC) support, for building relocatable
     # shared objects
     enabled gcc && enabled pic && check_add_cflags -fPIC
diff --git a/configure b/configure
index c45f908d9b..24be893f7a 100755
--- a/configure
+++ b/configure
@@ -257,7 +257,7 @@ CONFIG_LIST="
     install_bins
     install_libs
     install_srcs
-    force_x86inc
+    use_x86inc
     debug
     gprof
     gcov
diff --git a/libs.mk b/libs.mk
index ac2e73a43a..2338631085 100644
--- a/libs.mk
+++ b/libs.mk
@@ -60,13 +60,7 @@ endef
 # x86inc.asm is not compatible with pic 32bit builds. Restrict
 # files which use it to 64bit builds or 32bit without pic
 USE_X86INC = no
-ifneq ($(CONFIG_PIC),yes)
-  USE_X86INC = yes
-endif
-ifeq ($(ARCH_X86_64),yes)
-  USE_X86INC = yes
-endif
-ifeq ($(CONFIG_FORCE_X86INC),yes)
+ifeq ($(CONFIG_USE_X86INC),yes)
   USE_X86INC = yes
 endif
 
diff --git a/test/vp9_subtract_test.cc b/test/vp9_subtract_test.cc
index 4e53e77342..dbe37563cc 100644
--- a/test/vp9_subtract_test.cc
+++ b/test/vp9_subtract_test.cc
@@ -93,7 +93,7 @@ TEST_P(VP9SubtractBlockTest, SimpleSubtract) {
 INSTANTIATE_TEST_CASE_P(C, VP9SubtractBlockTest,
                         ::testing::Values(vp9_subtract_block_c));
 
-#if HAVE_SSE2
+#if HAVE_SSE2 && CONFIG_USE_X86INC
 INSTANTIATE_TEST_CASE_P(SSE2, VP9SubtractBlockTest,
                         ::testing::Values(vp9_subtract_block_sse2));
 #endif
diff --git a/vp9/common/vp9_rtcd_defs.sh b/vp9/common/vp9_rtcd_defs.sh
index 2b16cfaff0..5ada2260d5 100644
--- a/vp9/common/vp9_rtcd_defs.sh
+++ b/vp9/common/vp9_rtcd_defs.sh
@@ -21,7 +21,7 @@ EOF
 forward_decls vp9_common_forward_decls
 
 # x86inc.asm doesn't work if pic is enabled on 32 bit platforms so no assembly.
-[ $arch = "x86_64" -o ! "$CONFIG_PIC" = "yes" -o "$CONFIG_FORCE_X86INC" == "yes" ] && mmx_x86inc=mmx && sse2_x86inc=sse2  && ssse3_x86inc=ssse3
+[ "$CONFIG_USE_X86INC" = "yes" ] && mmx_x86inc=mmx && sse2_x86inc=sse2  && ssse3_x86inc=ssse3
 
 # this variable is for functions that are 64 bit only.
 [ $arch = "x86_64" ] && mmx_x86_64=mmx && sse2_x86_64=sse2  && ssse3_x86_64=ssse3
diff --git a/vp9/vp9cx.mk b/vp9/vp9cx.mk
index dee83c9e41..bd0792d67d 100644
--- a/vp9/vp9cx.mk
+++ b/vp9/vp9cx.mk
@@ -83,11 +83,15 @@ VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_variance_impl_sse2.asm
 VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_sad_sse2.asm
 VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_sad4d_sse2.asm
 VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_subpel_variance.asm
-VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_subtract_sse2.asm
 VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_error_sse2.asm
 VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_subpel_variance_impl_sse2.asm
 VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_temporal_filter_apply_sse2.asm
 VP9_CX_SRCS-$(HAVE_SSE3) += encoder/x86/vp9_sad_sse3.asm
+
+ifeq ($(USE_X86INC),yes)
+VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_subtract_sse2.asm
+endif
+
 ifeq ($(ARCH_X86_64),yes)
 VP9_CX_SRCS-$(HAVE_SSSE3) += encoder/x86/vp9_quantize_ssse3.asm
 endif
-- 
GitLab