ax_check_arm_neon.m4 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # @synopsis AX_CHECK_ARM_NEON
  2. #
  3. # Does the machine support the ARM NEON instruction set?
  4. # @version 1.01 Feb 11 2013
  5. # @author Steve Underwood
  6. #
  7. # Permission to use, copy, modify, distribute, and sell this file for any
  8. # purpose is hereby granted without fee, provided that the above copyright
  9. # and this permission notice appear in all copies. No representations are
  10. # made about the suitability of this software for any purpose. It is
  11. # provided "as is" without express or implied warranty.
  12. AC_DEFUN([AX_CHECK_ARM_NEON],
  13. [AC_CACHE_CHECK([if $1 supports the ARM NEON instruction set],
  14. ac_cv_symbol_arm_neon,
  15. [# Initialize to unknown
  16. ac_cv_symbol_arm_neon="no"
  17. case "${ax_cv_c_compiler_vendor}" in
  18. gnu)
  19. save_CFLAGS="${CFLAGS}"
  20. CFLAGS="${CFLAGS} -mfpu=neon -mfloat-abi=hard"
  21. AC_RUN_IFELSE(
  22. [AC_LANG_PROGRAM(
  23. [
  24. #include <inttypes.h>
  25. #include <arm_neon.h>
  26. int32x4_t testfunc(int16_t *a, int16_t *b)
  27. {
  28. return vmull_s16(vld1_s16(a), vld1_s16(b));
  29. }
  30. ],
  31. [
  32. volatile int32x4_t z;
  33. int16_t x[[8]];
  34. int16_t y[[8]];
  35. z = testfunc(x, y);
  36. ]
  37. )],
  38. [AC_MSG_RESULT([yes])
  39. COMP_VENDOR_CFLAGS="-mfpu=neon $COMP_VENDOR_CFLAGS"
  40. COMP_VENDOR_CXXFLAGS="-mfpu=neon $COMP_VENDOR_CXXFLAGS"
  41. ac_cv_symbol_arm_neon="yes"],
  42. [AC_MSG_RESULT([no])],
  43. dnl Assume "no" if cross-compiling
  44. [AC_MSG_RESULT([no])]
  45. )
  46. CFLAGS="${save_CFLAGS}"
  47. ;;
  48. esac])
  49. AS_IF([test AS_VAR_GET(ac_cv_symbol_arm_neon) = yes], [$2], [$3])[]dnl
  50. ]) # AX_CHECK_ARM_NEON