as-gcc-inline-assembly.m4 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. dnl as-gcc-inline-assembly.m4 0.1.0
  2. dnl autostars m4 macro for detection of gcc inline assembly
  3. dnl David Schleef <ds@schleef.org>
  4. dnl AS_COMPILER_FLAG(ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
  5. dnl Tries to compile with the given CFLAGS.
  6. dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
  7. dnl and ACTION-IF-NOT-ACCEPTED otherwise.
  8. AC_DEFUN([AS_GCC_INLINE_ASSEMBLY],
  9. [
  10. AC_MSG_CHECKING([if compiler supports gcc-style inline assembly])
  11. AC_TRY_COMPILE([], [
  12. #ifdef __GNUC_MINOR__
  13. #if (__GNUC__ * 1000 + __GNUC_MINOR__) < 3004
  14. #error GCC before 3.4 has critical bugs compiling inline assembly
  15. #endif
  16. #endif
  17. __asm__ (""::) ], [flag_ok=yes], [flag_ok=no])
  18. if test "X$flag_ok" = Xyes ; then
  19. $1
  20. true
  21. else
  22. $2
  23. true
  24. fi
  25. AC_MSG_RESULT([$flag_ok])
  26. ])
  27. AC_DEFUN([AS_ASM_ARM_NEON],
  28. [
  29. AC_MSG_CHECKING([if assembler supports NEON instructions on ARM])
  30. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__("vorr d0,d0,d0")])],
  31. [AC_MSG_RESULT([yes])
  32. $1],
  33. [AC_MSG_RESULT([no])
  34. $2])
  35. ])
  36. AC_DEFUN([AS_ASM_ARM_NEON_FORCE],
  37. [
  38. AC_MSG_CHECKING([if assembler supports NEON instructions on ARM])
  39. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__(".arch armv7-a\n.fpu neon\n.object_arch armv4t\nvorr d0,d0,d0")])],
  40. [AC_MSG_RESULT([yes])
  41. $1],
  42. [AC_MSG_RESULT([no])
  43. $2])
  44. ])
  45. AC_DEFUN([AS_ASM_ARM_MEDIA],
  46. [
  47. AC_MSG_CHECKING([if assembler supports ARMv6 media instructions on ARM])
  48. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__("shadd8 r3,r3,r3")])],
  49. [AC_MSG_RESULT([yes])
  50. $1],
  51. [AC_MSG_RESULT([no])
  52. $2])
  53. ])
  54. AC_DEFUN([AS_ASM_ARM_MEDIA_FORCE],
  55. [
  56. AC_MSG_CHECKING([if assembler supports ARMv6 media instructions on ARM])
  57. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__(".arch armv6\n.object_arch armv4t\nshadd8 r3,r3,r3")])],
  58. [AC_MSG_RESULT([yes])
  59. $1],
  60. [AC_MSG_RESULT([no])
  61. $2])
  62. ])
  63. AC_DEFUN([AS_ASM_ARM_EDSP],
  64. [
  65. AC_MSG_CHECKING([if assembler supports EDSP instructions on ARM])
  66. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__("qadd r3,r3,r3")])],
  67. [AC_MSG_RESULT([yes])
  68. $1],
  69. [AC_MSG_RESULT([no])
  70. $2])
  71. ])
  72. AC_DEFUN([AS_ASM_ARM_EDSP_FORCE],
  73. [
  74. AC_MSG_CHECKING([if assembler supports EDSP instructions on ARM])
  75. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__(".arch armv5te\n.object_arch armv4t\nqadd r3,r3,r3")])],
  76. [AC_MSG_RESULT([yes])
  77. $1],
  78. [AC_MSG_RESULT([no])
  79. $2])
  80. ])