diff options
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 051d7933f..938c106a7 100644 --- a/configure.ac +++ b/configure.ac @@ -334,6 +334,9 @@ AC_ARG_ENABLE([hardware-optimizations], enable_intel_sse=no AC_DEFINE([PNG_INTEL_SSE_OPT], [0], [Disable INTEL_SSE optimizations]) + enable_loongarch_lsx=no + AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0], + [Disable LOONGARCH_LSX optimizations]) ;; *) # allow enabling hardware optimization on any system: @@ -358,6 +361,11 @@ AC_ARG_ENABLE([hardware-optimizations], AC_DEFINE([PNG_POWERPC_VSX_OPT], [2], [Enable POWERPC VSX optimizations]) ;; + loongarch*) + enable_loongarch_lsx=yes + AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], + [Enable LOONGARCH_LSX optimizations]) + ;; esac ;; esac]) @@ -535,6 +543,69 @@ AM_CONDITIONAL([PNG_POWERPC_VSX], powerpc*|ppc64*) : ;; esac]) +# LOONGARCH +# === +# +# LOONGARCH LSX (SIMD) support + +if test "$LSX_CFLAGS" = ''; then + LSX_CFLAGS="-mlsx" +fi + +compiler_support_loongarch_lsx=no +AC_MSG_CHECKING(whether to use loongarch LSX intrinsics) +save_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS $LSX_CFLAGS" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ +#include<lsxintrin.h> +int main(){ + __m128i a, b, c; + a = __lsx_vadd_w(b, c); + return 0; +}]])],compiler_support_loongarch_lsx=yes) +CFLAGS=$save_CFLAGS +AC_MSG_RESULT($compiler_support_loongarch_lsx) + +AC_ARG_ENABLE([loongarch-lsx], + AS_HELP_STRING([[[--enable-loongarch-lsx]]], + [Enable LOONGARCH LSX optimizations: =no/off, yes/on:] + [no/off: disable the optimizations;] + [yes/on: turn on unconditionally.] + [If not specified: determined by the compiler.]), + [case "$enableval" in + no|off) + # disable the default enabling on __loongarch_simd systems: + AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0], + [Disable LOONGARCH LSX optimizations]) + # Prevent inclusion of the assembler files below: + enable_loongarch_lsx=no;; + yes|on) + AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], + [Enable LOONGARCH LSX optimizations]) + ;; + *) + AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}: invalid value]) + esac]) + +if test "$enable_loongarch_lsx" != 'no'; then + if test $compiler_support_loongarch_lsx = yes; then + AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], [Enable LOONGARCH LSX optimizations]) + else + AC_MSG_WARN([Compiler does not support loongarch LSX.]) + fi +fi + +# Add LOONGARCH specific files to all builds where the host_cpu is loongarch ('loongarch*') or +# where LOONGARCH optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'loongarch*') + +AM_CONDITIONAL([PNG_LOONGARCH_LSX], + [test "$enable_loongarch_lsx" != 'no' && test $compiler_support_loongarch_lsx = yes && + case "$host_cpu" in + loongarch*) :;; + *) test "$enable_loongarch_lsx" != '';; + esac]) + AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) # Config files, substituting as above |