[Speex-dev] [PATCH 4/5] configure.ac: Add ARM NEON support

Jyri Sarha
Thu, 01 Sep 2011 12:30:30 -0000

Use --enable-neon to force NEON optimization on. The auto detection
should also work if your CFLAGS supports NEON.
---
 configure.ac |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 255c0b4..08d3d5f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,6 +89,23 @@ has_sse=no
 )
 AC_MSG_RESULT($has_sse)

+AC_MSG_CHECKING(for NEON in current arch/CFLAGS)
+AC_LINK_IFELSE([
+AC_LANG_PROGRAM([[
+#include <arm_neon.h>
+int32x4_t testfunc(int16_t *a, int16_t *b) {
+      return vmull_s16(vld1_s16(a), vld1_s16(b));
+}
+]])],
+[
+has_neon=yes
+],
+[
+has_neon=no
+]
+)
+AC_MSG_RESULT($has_neon)
+
 SAVE_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -fvisibility=hidden"
 AC_MSG_CHECKING(for ELF visibility)
@@ -148,6 +165,15 @@ has_sse=no
 fi
 ])

+AC_ARG_ENABLE(neon, [  --enable-neon           Enable NEON support], [
+if test "x$enableval" != xno; then
+has_neon=yes
+CFLAGS="$CFLAGS -O3 -march=armv7-a -mfpu=neon"
+else
+has_neon=no
+fi
+])
+

 FFT=smallft

@@ -165,6 +191,10 @@ if test "$has_sse" = yes; then
   AC_DEFINE([_USE_SSE], , [Enable SSE support])
 fi

+if test "$has_neon" = yes; then
+  AC_DEFINE([_USE_NEON], , [Enable NEON support])
+fi
+
 AC_ARG_ENABLE(float-api, [  --disable-float-api     Disable the floating-point
API],
 [if test "$enableval" = no; then
   AC_DEFINE([DISABLE_FLOAT_API], , [Disable all parts of the API that are using
floats])
@@ -198,7 +228,7 @@ AC_ARG_ENABLE(fixed-point-debug, [
--enable-fixed-point-debug  Debug fixed-poin
   AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
 fi])

-AC_ARG_ENABLE(resample-full-sinc-table, [  --enable-resample-full-sinc-table
Resample full SINC table],
+AC_ARG_ENABLE(resample-full-sinc-table, [  --enable-resample-full-sinc-table
Resample full SINC table (no interpolation)],
 [if test "$enableval" = yes; then
   AC_DEFINE([RESAMPLE_FULL_SINC_TABLE], , [Resample with full SINC table (no
interpolation)])
 fi])
--
1.7.4.1