diff options
author | Oded Gabbay <[email protected]> | 2015-12-03 09:11:04 +0200 |
---|---|---|
committer | Oded Gabbay <[email protected]> | 2016-01-06 14:54:16 +0200 |
commit | afe88f66a8a9cf3c6bf6ea5d3e00589c22219c30 (patch) | |
tree | 243d50cd20e5f2caf29ed19a3436d34d0a618de2 /configure.ac | |
parent | 7295f4fcc2b2dd1bc6a8d1d834774b8152a029cf (diff) |
configure.ac: Detect if running on POWER8 arch
To determine if we could use special POWER8 assembly directives, we first
need to detect whether we are running on POWER8 architecture. This patch
adds this detection to configure.ac and adds the necessary compilation
flags accordingly.
v2:
- Add option to disable POWER8 instructions generation
- Detect whether building on BE or LE machine and build with
-mpower8-vector only on LE machine
- Make the printed messages more standard
Signed-off-by: Oded Gabbay <[email protected]>
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index f8a70bef0e2..b1c1d7df4d8 100644 --- a/configure.ac +++ b/configure.ac @@ -396,6 +396,61 @@ fi AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1]) AC_SUBST([SSE41_CFLAGS], $SSE41_CFLAGS) +dnl Check for Endianness +AC_C_BIGENDIAN( + little_endian=no, + little_endian=yes, + little_endian=no, + little_endian=no +) + +dnl Check for POWER8 Architecture +PWR8_CFLAGS="-mpower8-vector" +have_pwr8_intrinsics=no +AC_MSG_CHECKING(whether gcc supports -mpower8-vector) +save_CFLAGS=$CFLAGS +CFLAGS="$PWR8_CFLAGS $CFLAGS" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ +#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)) +#error "Need GCC >= 4.8 for sane POWER8 support" +#endif +#include <altivec.h> +int main () { + vector unsigned char r; + vector unsigned int v = vec_splat_u32 (1); + r = __builtin_vec_vgbbd ((vector unsigned char) v); + return 0; +}]])], have_pwr8_intrinsics=yes) +CFLAGS=$save_CFLAGS + +AC_ARG_ENABLE(pwr8, + [AC_HELP_STRING([--disable-pwr8-inst], + [disable POWER8-specific instructions])], + [enable_pwr8=$enableval], [enable_pwr8=auto]) + +if test "x$enable_pwr8" = xno ; then + have_pwr8_intrinsics=disabled +fi + +if test $have_pwr8_intrinsics = yes && test $little_endian = yes ; then + DEFINES="$DEFINES -D_ARCH_PWR8" + CXXFLAGS="$CXXFLAGS $PWR8_CFLAGS" + CFLAGS="$CFLAGS $PWR8_CFLAGS" +else + PWR8_CFLAGS= +fi + +AC_MSG_RESULT($have_pwr8_intrinsics) +if test "x$enable_pwr8" = xyes && test $have_pwr8_intrinsics = no ; then + AC_MSG_ERROR([POWER8 compiler support not detected]) +fi + +if test $have_pwr8_intrinsics = yes && test $little_endian = no ; then + AC_MSG_WARN([POWER8 optimization is enabled only on POWER8 Little-Endian]) +fi + +AC_SUBST([PWR8_CFLAGS], $PWR8_CFLAGS) + dnl Can't have static and shared libraries, default to static if user dnl explicitly requested. If both disabled, set to static since shared dnl was explicitly requested. |