# Check that NASM exists and determine flags
AC_DEFUN([AC_PROG_NASM],[
-AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
-test -z "$NASM" && AC_MSG_ERROR([no nasm (Netwide Assembler) found])
+AC_ARG_VAR(NASM, [NASM command (used to build the x86/x86-64 SIMD code)])
+if test "x$NASM" = "x"; then
+ AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
+ test -z "$NASM" && AC_MSG_ERROR([no nasm (Netwide Assembler) found])
+fi
AC_MSG_CHECKING([for object file format of host system])
case "$host_os" in
;;
esac
;;
- freebsd* | netbsd* | openbsd*)
+ kfreebsd* | freebsd* | netbsd* | openbsd*)
if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
objfmt='BSD-a.out'
else
ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CCASFLAGS -x assembler-with-cpp"
CC="$CCAS"
- AC_COMPILE_IFELSE([[
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
.text
.fpu neon
.arch armv7a
.object_arch armv4
.arm
pld [r0]
- vmovn.u16 d0, q0]], ac_good_gnu_arm_assembler=yes)
+ vmovn.u16 d0, q0]])], ac_good_gnu_arm_assembler=yes)
ac_use_gas_preprocessor=no
if test "x$ac_good_gnu_arm_assembler" = "xno" ; then
CC="gas-preprocessor.pl $CCAS"
- AC_COMPILE_IFELSE([[
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
.text
.fpu neon
.arch armv7a
.object_arch armv4
.arm
pld [r0]
- vmovn.u16 d0, q0]], ac_use_gas_preprocessor=yes)
+ vmovn.u16 d0, q0]])], ac_use_gas_preprocessor=yes)
+ fi
+ CFLAGS="$ac_save_CFLAGS"
+ CC="$ac_save_CC"
+
+ if test "x$ac_use_gas_preprocessor" = "xyes" ; then
+ CCAS="gas-preprocessor.pl $CCAS"
+ AC_SUBST([CCAS])
+ ac_good_gnu_arm_assembler=yes
+ fi
+
+ if test "x$ac_good_gnu_arm_assembler" = "xyes" ; then
+ $1
+ else
+ $2
+ fi
+])
+
+# AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE
+# --------------------------
+# Test whether the assembler is suitable and supports MIPS instructions
+AC_DEFUN([AC_CHECK_COMPATIBLE_MIPS_ASSEMBLER_IFELSE],[
+ have_mips_dspr2=no
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CCASFLAGS -mdspr2"
+
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+
+ int main ()
+ {
+ int c = 0, a = 0, b = 0;
+ __asm__ __volatile__ (
+ "precr.qb.ph %[c], %[a], %[b] \n\t"
+ : [c] "=r" (c)
+ : [a] "r" (a), [b] "r" (b)
+ );
+ return c;
+ }
+ ]])], have_mips_dspr2=yes)
+ CFLAGS=$ac_save_CFLAGS
+
+ if test "x$have_mips_dspr2" = "xyes" ; then
+ $1
+ else
+ $2
+ fi
+])
+
+AC_DEFUN([AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE],[
+ ac_good_gnu_arm_assembler=no
+ ac_save_CC="$CC"
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CCASFLAGS -x assembler-with-cpp"
+ CC="$CCAS"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ .text
+ MYVAR .req x0
+ movi v0.16b, #100
+ mov MYVAR, #100
+ .unreq MYVAR]])], ac_good_gnu_arm_assembler=yes)
+
+ ac_use_gas_preprocessor=no
+ if test "x$ac_good_gnu_arm_assembler" = "xno" ; then
+ CC="gas-preprocessor.pl $CCAS"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ .text
+ MYVAR .req x0
+ movi v0.16b, #100
+ mov MYVAR, #100
+ .unreq MYVAR]])], ac_use_gas_preprocessor=yes)
fi
CFLAGS="$ac_save_CFLAGS"
CC="$ac_save_CC"
$2
fi
])
+
+# AC_CHECK_ALTIVEC
+# ----------------
+# Test whether AltiVec intrinsics are supported
+AC_DEFUN([AC_CHECK_ALTIVEC],[
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -maltivec"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ #include <altivec.h>
+ int main(void) {
+ __vector int vi = { 0, 0, 0, 0 };
+ int i[4];
+ vec_st(vi, 0, i);
+ return i[0];
+ }]])], ac_has_altivec=yes)
+ CFLAGS="$ac_save_CFLAGS"
+ if test "x$ac_has_altivec" = "xyes" ; then
+ $1
+ else
+ $2
+ fi
+])
+
+AC_DEFUN([AC_NO_SIMD],[
+ AC_MSG_RESULT([no ("$1")])
+ with_simd=no;
+ if test "x${require_simd}" = "xyes"; then
+ AC_MSG_ERROR([SIMD support not available for this CPU.])
+ else
+ AC_MSG_WARN([SIMD support not available for this CPU. Performance will\
+ suffer.])
+ fi
+])