Bug 972945 - Add autoconf test to enable AltiVec on supported targets only. r=glandium
authorJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Tue, 16 Aug 2016 05:17:00 -0400
changeset 310048 18992fa737043c54445bc6849ff20ff99966a282
parent 310047 075e2a3ab45c6c7ac32fc87081cb42ce0b9fa431
child 310049 e6ac44ef858aa664e83a35df136caee0f8f261a9
push id20348
push userryanvm@gmail.com
push dateFri, 19 Aug 2016 13:56:01 +0000
treeherderfx-team@8dfc2fdb7ae3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs972945
milestone51.0a1
Bug 972945 - Add autoconf test to enable AltiVec on supported targets only. r=glandium Currently, the build scripts enable AltiVec unconditionally on all ppc* targets. However, there some ppc* targets which do not support AltiVec instruction set extensions, these are often embedded systems like the PowerPC e500 or similar which have their own type of instruction set extensions like SPE. Trying to enable Altivec support on these targets results in a compiler error, hence we need to add an autoconf test for AltiVec support before trying to enable it on ppc* targets. Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
gfx/qcms/moz.build
gfx/qcms/transform.c
old-configure.in
--- a/gfx/qcms/moz.build
+++ b/gfx/qcms/moz.build
@@ -27,19 +27,18 @@ use_sse2 = False
 use_altivec = False
 if '86' in CONFIG['OS_TEST']:
     use_sse2 = True
     if CONFIG['_MSC_VER']:
         if CONFIG['OS_ARCH'] != 'WINNT' or CONFIG['OS_TEST'] != 'x86_64':
             use_sse1 = True
     else:
         use_sse1 = True
-elif 'ppc' in CONFIG['CPU_ARCH']:
-    if CONFIG['GNU_CC']:
-        use_altivec = True
+elif CONFIG['HAVE_ALTIVEC']:
+    use_altivec = True
 
 if use_sse1:
     SOURCES += ['transform-sse1.c']
     SOURCES['transform-sse1.c'].flags += CONFIG['SSE_FLAGS']
 
 if use_sse2:
     SOURCES += ['transform-sse2.c']
     SOURCES['transform-sse2.c'].flags += CONFIG['SSE2_FLAGS']
--- a/gfx/qcms/transform.c
+++ b/gfx/qcms/transform.c
@@ -1291,17 +1291,17 @@ qcms_transform* qcms_transform_create(
 		    if (sse_version_available() >= 1) {
 			    if (in_type == QCMS_DATA_RGB_8)
 				    transform->transform_fn = qcms_transform_data_rgb_out_lut_sse1;
 			    else
 				    transform->transform_fn = qcms_transform_data_rgba_out_lut_sse1;
 #endif
 		    } else
 #endif
-#if (defined(__POWERPC__) || defined(__powerpc__))
+#if (defined(__POWERPC__) || defined(__powerpc__) && !defined(__NO_FPRS__))
 		    if (have_altivec()) {
 			    if (in_type == QCMS_DATA_RGB_8)
 				    transform->transform_fn = qcms_transform_data_rgb_out_lut_altivec;
 			    else
 				    transform->transform_fn = qcms_transform_data_rgba_out_lut_altivec;
 		    } else
 #endif
 			{
--- a/old-configure.in
+++ b/old-configure.in
@@ -710,16 +710,28 @@ if test "$GNU_CC"; then
       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
       AC_TRY_COMPILE([],
                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
                      result="yes", result="no")
       AC_MSG_RESULT("$result")
       if test "$result" = "yes"; then
           HAVE_X86_AVX2=1
       fi
+      ;;
+
+    ppc*)
+      AC_MSG_CHECKING([whether we can enable AltiVec support])
+      HAVE_ALTIVEC=
+      _SAVE_CFLAGS=$CFLAGS
+      CFLAGS="$CFLAGS -maltivec"
+      AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
+                       [HAVE_ALTIVEC=1],
+                       AC_MSG_RESULT([no]))
+      CFLAGS=$_SAVE_CFLAGS
+      ;;
     esac
 
     DSO_LDOPTS='-shared'
     if test "$GCC_USE_GNU_LD"; then
         # Some tools like ASan use a runtime library that is only
         # linked against executables, so we must allow undefined
         # symbols for shared objects in some cases.
         if test -z "$MOZ_NO_WLZDEFS"; then
@@ -5961,16 +5973,17 @@ AC_SUBST(HOST_AR_FLAGS)
 AC_SUBST(HOST_LD)
 AC_SUBST(HOST_RANLIB)
 AC_SUBST(HOST_BIN_SUFFIX)
 
 AC_SUBST(TARGET_XPCOM_ABI)
 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
 AC_SUBST(HAVE_X86_AVX2)
+AC_SUBST(HAVE_ALTIVEC)
 AC_SUBST(GCC_USE_GNU_LD)
 
 AC_SUBST(WRAP_LDFLAGS)
 AC_SUBST(MKSHLIB)
 AC_SUBST(MKCSHLIB)
 AC_SUBST(DSO_CFLAGS)
 AC_SUBST(DSO_PIC_CFLAGS)
 AC_SUBST(DSO_LDOPTS)