1 dnl as-intrinsics.m4 0.1.0
3 dnl autostars m4 macro for detection of gcc inline assembly
5 dnl David Schleef <ds@schleef.org>
7 dnl $Id: as-intrinsics.m4,v 1.5 2006-05-19 06:58:29 ds Exp $
9 dnl AS_MMX_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
10 dnl Tries to compile with the given CFLAGS.
11 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
12 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
14 AC_DEFUN([AS_MMX_INTRINSICS],
16 AC_MSG_CHECKING([if compiler supports MMX intrinsics])
19 CFLAGS="$CFLAGS -mmmx"
20 AC_TRY_COMPILE([#include <mmintrin.h>], [_mm_empty()], [flag_ok=yes], [flag_ok=no])
24 if test "X$flag_ok" = Xyes ; then
31 AC_MSG_RESULT([$flag_ok])
35 dnl AS_SSE_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
36 dnl Tries to compile with the given CFLAGS.
37 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
38 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
40 AC_DEFUN([AS_SSE_INTRINSICS],
42 AC_MSG_CHECKING([if compiler supports SSE intrinsics])
45 CFLAGS="$CFLAGS -msse"
46 AC_TRY_COMPILE([#include <xmmintrin.h>], [
48 #if (__GNUC__ * 1000 + __GNUC_MINOR__) < 4002
49 #error GCC before 4.2 has critical bugs compiling SSE intrinsics
52 __m128 a; a = _mm_or_ps(a,a)], [flag_ok=yes], [flag_ok=no])
56 if test "X$flag_ok" = Xyes ; then
63 AC_MSG_RESULT([$flag_ok])
67 dnl AS_SSE2_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
68 dnl Tries to compile with the given CFLAGS.
69 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
70 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
72 AC_DEFUN([AS_SSE2_INTRINSICS],
74 AC_MSG_CHECKING([if compiler supports SSE2 intrinsics])
77 CFLAGS="$CFLAGS -msse2"
78 AC_TRY_COMPILE([#include <emmintrin.h>], [
80 #if (__GNUC__ * 1000 + __GNUC_MINOR__) < 4002
81 #error GCC before 4.2 has critical bugs compiling SSE2 intrinsics
84 __m128i a; a = _mm_setzero_si128(); a = _mm_srli_epi16(a,8)], [flag_ok=yes], [flag_ok=no])
88 if test "X$flag_ok" = Xyes ; then
95 AC_MSG_RESULT([$flag_ok])
99 dnl AS_SSE3_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
100 dnl Tries to compile with the given CFLAGS.
101 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
102 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
104 AC_DEFUN([AS_SSE3_INTRINSICS],
106 AC_MSG_CHECKING([if compiler supports SSE3 intrinsics])
108 save_CFLAGS="$CFLAGS"
109 CFLAGS="$CFLAGS -msse3"
110 AC_TRY_COMPILE([#include <pmmintrin.h>], [
111 #ifdef __GNUC_MINOR__
112 #if (__GNUC__ * 1000 + __GNUC_MINOR__) < 4002
113 #error GCC before 4.2 has critical bugs compiling SSE2 intrinsics
116 __m128 a; a = _mm_addsub_ps(a,a)], [flag_ok=yes], [flag_ok=no])
117 CFLAGS="$save_CFLAGS"
120 if test "X$flag_ok" = Xyes ; then
127 AC_MSG_RESULT([$flag_ok])
131 dnl AS_3DNOW_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
132 dnl Tries to compile with the given CFLAGS.
133 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
134 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
136 AC_DEFUN([AS_3DNOW_INTRINSICS],
138 AC_MSG_CHECKING([if compiler supports 3DNOW intrinsics])
140 save_CFLAGS="$CFLAGS"
141 CFLAGS="$CFLAGS -m3dnow"
142 AC_TRY_COMPILE([#include <mm3dnow.h>], [_m_femms()], [flag_ok=yes], [flag_ok=no])
143 CFLAGS="$save_CFLAGS"
146 if test "X$flag_ok" = Xyes ; then
153 AC_MSG_RESULT([$flag_ok])
157 dnl AS_3DNOWEXT_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
158 dnl Tries to compile with the given CFLAGS.
159 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
160 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
162 AC_DEFUN([AS_3DNOWEXT_INTRINSICS],
164 AC_MSG_CHECKING([if compiler supports 3DNOWEXT intrinsics])
166 save_CFLAGS="$CFLAGS"
167 CFLAGS="$CFLAGS -m3dnow -march=athlon"
168 AC_TRY_COMPILE([#include <mm3dnow.h>], [__m64 a;a=_m_pf2iw(a)], [flag_ok=yes], [flag_ok=no])
169 CFLAGS="$save_CFLAGS"
171 $1="-m3dnow -march=athlon"
172 if test "X$flag_ok" = Xyes ; then
179 AC_MSG_RESULT([$flag_ok])
183 dnl AS_ALTIVEC_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
184 dnl Tries to compile with the given CFLAGS.
185 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
186 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
188 AC_DEFUN([AS_ALTIVEC_INTRINSICS],
190 AC_MSG_CHECKING([if compiler supports ALTIVEC intrinsics])
192 save_CFLAGS="$CFLAGS"
193 CFLAGS="$CFLAGS -maltivec"
194 AC_TRY_COMPILE([#include <altivec.h>], [__vector a; a = vec_or(a,a)], [flag_ok=yes], [flag_ok=no])
195 CFLAGS="$save_CFLAGS"
198 if test "X$flag_ok" = Xyes ; then
205 AC_MSG_RESULT([$flag_ok])