| 1 |
# ESL_VMX([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
| 2 |
# |
| 3 |
# Check whether compiler supports features we need in our Altivec/VMX |
| 4 |
# implementations. |
| 5 |
# |
| 6 |
# Tries to compile and link a test program using the current CC, |
| 7 |
# CFLAGS, and (optionally) any VMX_CFLAGS passed by the user. If no |
| 8 |
# VMX_CFLAGS are provided, then we try to determine them, by trying |
| 9 |
# nothing, then trying ... |
| 10 |
# |
| 11 |
# Sets $esl_have_vmx = yes | no |
| 12 |
# Sets $esl_vmx_cflags to any needed CFLAGS, such as ... |
| 13 |
# |
| 14 |
# A typical ACTION-IF-FOUND might be: |
| 15 |
# AC_DEFINE(HAVE_VMX) |
| 16 |
# VMX_CFLAGS=$esl_vmx_cflags |
| 17 |
# AC_SUBST(VMX_CFLAGS) |
| 18 |
# |
| 19 |
# Do not replace the AC_LINK with an AC_RUN test. This is a test for |
| 20 |
# whether the _compiler_ supports Altivec/VMX, not whether the current |
| 21 |
# processor does. Our code uses runtime dispatching to choose an |
| 22 |
# appropriate ISA for the processor being used. |
| 23 |
# |
| 24 |
AC_DEFUN([ESL_VMX], [ |
| 25 |
AC_MSG_CHECKING([whether $CC can compile our Altivec/VMX code]) |
| 26 |
esl_have_vmx=no |
| 27 |
|
| 28 |
if test "x$VMX_CFLAGS" != x; then |
| 29 |
esl_vmx_try_flags=$VMX_CFLAGS |
| 30 |
else |
| 31 |
esl_vmx_try_flags="none -maltivec -faltivec" |
| 32 |
fi |
| 33 |
|
| 34 |
save_CFLAGS=$CFLAGS |
| 35 |
for esl_vmx_cflags in $esl_vmx_try_flags; do |
| 36 |
case $esl_vmx_cflags in |
| 37 |
none) CFLAGS=$save_CFLAGS;; |
| 38 |
*) CFLAGS="$save_CFLAGS $esl_vmx_cflags";; |
| 39 |
esac |
| 40 |
|
| 41 |
AC_LINK_IFELSE( |
| 42 |
[AC_LANG_SOURCE([[ |
| 43 |
#include <altivec.h> |
| 44 |
#include <stdint.h> |
| 45 |
int stub_vmx(void) { |
| 46 |
vector signed int v1,v2; |
| 47 |
union { vector signed int v; int32_t x[4]; } v3; |
| 48 |
v1 = vec_splat_s32(6); |
| 49 |
v2 = vec_splat_s32(12); |
| 50 |
v3.v = vec_add(v1,v2); |
| 51 |
return (int) v3.x[0];} |
| 52 |
int main(void) { if (stub_vmx() != 18) return 1; else return 0; } |
| 53 |
]])], [ esl_have_vmx=yes; break; ], []) |
| 54 |
done |
| 55 |
CFLAGS=$save_CFLAGS |
| 56 |
|
| 57 |
if test "$esl_have_vmx" = "no"; then |
| 58 |
AC_MSG_RESULT([no]) |
| 59 |
esl_vmx_cflags= |
| 60 |
else |
| 61 |
if test "$esl_vmx_cflags" = "none"; then |
| 62 |
AC_MSG_RESULT([yes]) |
| 63 |
esl_vmx_cflags= |
| 64 |
else |
| 65 |
AC_MSG_RESULT([yes, with $esl_vmx_cflags]) |
| 66 |
fi |
| 67 |
fi |
| 68 |
|
| 69 |
AS_VAR_IF([esl_have_vmx],[yes],[$1],[$2]) |
| 70 |
]) |
| 71 |
|
| 72 |
|
| 73 |
|