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