summaryrefslogtreecommitdiff
path: root/m4/as-intrinsics.m4
blob: 9fb5829d43d43b9ddc9fa534e9c6cfbad2f242c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
dnl as-intrinsics.m4 0.1.0

dnl autostars m4 macro for detection of gcc inline assembly

dnl David Schleef <ds@schleef.org>

dnl $Id: as-intrinsics.m4,v 1.5 2006-05-19 06:58:29 ds Exp $

dnl AS_MMX_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.

AC_DEFUN([AS_MMX_INTRINSICS],
[
  AC_MSG_CHECKING([if compiler supports MMX intrinsics])

  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -mmmx"
  AC_TRY_COMPILE([#include <mmintrin.h>], [_mm_empty()], [flag_ok=yes], [flag_ok=no])
  CFLAGS="$save_CFLAGS"

  $1="-mmmx"
  if test "X$flag_ok" = Xyes ; then
    $2
    true
  else
    $3
    true
  fi
  AC_MSG_RESULT([$flag_ok])
])


dnl AS_SSE_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.

AC_DEFUN([AS_SSE_INTRINSICS],
[
  AC_MSG_CHECKING([if compiler supports SSE intrinsics])

  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -msse"
  AC_TRY_COMPILE([#include <xmmintrin.h>], [__m128 a; a = _mm_or_ps(a,a)], [flag_ok=yes], [flag_ok=no])
  CFLAGS="$save_CFLAGS"

  $1="-msse"
  if test "X$flag_ok" = Xyes ; then
    $2
    true
  else
    $3
    true
  fi
  AC_MSG_RESULT([$flag_ok])
])


dnl AS_SSE2_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.

AC_DEFUN([AS_SSE2_INTRINSICS],
[
  AC_MSG_CHECKING([if compiler supports SSE2 intrinsics])

  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -msse2"
  AC_TRY_COMPILE([#include <emmintrin.h>], [__m128i a; a = _mm_setzero_si128(); a = _mm_srli_epi16(a,8)], [flag_ok=yes], [flag_ok=no])
  CFLAGS="$save_CFLAGS"

  $1="-msse2"
  if test "X$flag_ok" = Xyes ; then
    $2
    true
  else
    $3
    true
  fi
  AC_MSG_RESULT([$flag_ok])
])


dnl AS_SSE3_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.

AC_DEFUN([AS_SSE3_INTRINSICS],
[
  AC_MSG_CHECKING([if compiler supports SSE3 intrinsics])

  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -msse3"
  AC_TRY_COMPILE([#include <pmmintrin.h>], [__m128 a; a = _mm_addsub_ps(a,a)], [flag_ok=yes], [flag_ok=no])
  CFLAGS="$save_CFLAGS"

  $1="-msse3"
  if test "X$flag_ok" = Xyes ; then
    $2
    true
  else
    $3
    true
  fi
  AC_MSG_RESULT([$flag_ok])
])


dnl AS_3DNOW_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.

AC_DEFUN([AS_3DNOW_INTRINSICS],
[
  AC_MSG_CHECKING([if compiler supports 3DNOW intrinsics])

  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -m3dnow"
  AC_TRY_COMPILE([#include <mm3dnow.h>], [_m_femms()], [flag_ok=yes], [flag_ok=no])
  CFLAGS="$save_CFLAGS"

  $1="-m3dnow"
  if test "X$flag_ok" = Xyes ; then
    $2
    true
  else
    $3
    true
  fi
  AC_MSG_RESULT([$flag_ok])
])


dnl AS_3DNOWEXT_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.

AC_DEFUN([AS_3DNOWEXT_INTRINSICS],
[
  AC_MSG_CHECKING([if compiler supports 3DNOWEXT intrinsics])

  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -m3dnow -march=athlon"
  AC_TRY_COMPILE([#include <mm3dnow.h>], [__m64 a;a=_m_pf2iw(a)], [flag_ok=yes], [flag_ok=no])
  CFLAGS="$save_CFLAGS"

  $1="-m3dnow -march=athlon"
  if test "X$flag_ok" = Xyes ; then
    $2
    true
  else
    $3
    true
  fi
  AC_MSG_RESULT([$flag_ok])
])


dnl AS_ALTIVEC_INTRINSICS(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.

AC_DEFUN([AS_ALTIVEC_INTRINSICS],
[
  AC_MSG_CHECKING([if compiler supports ALTIVEC intrinsics])

  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -maltivec"
  AC_TRY_COMPILE([#include <altivec.h>], [__vector a; a = vec_or(a,a)], [flag_ok=yes], [flag_ok=no])
  CFLAGS="$save_CFLAGS"

  $1="-maltivec"
  if test "X$flag_ok" = Xyes ; then
    $2
    true
  else
    $3
    true
  fi
  AC_MSG_RESULT([$flag_ok])
])