Work around lameness in older ppc assemblers.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5757
This commit is contained in:
Julian Seward 2006-03-12 16:47:10 +00:00
parent 3323731af8
commit 090c5bd0e4
2 changed files with 29 additions and 3 deletions

View File

@ -545,6 +545,7 @@ if test x$declaration_after_statement = xyes; then
CFLAGS="$CFLAGS -Wdeclaration-after-statement"
fi
# does this compiler support __builtin_expect?
AC_MSG_CHECKING([if gcc supports __builtin_expect])
@ -563,6 +564,25 @@ if test x$ac_have_builtin_expect = xyes ; then
fi
# does the ppc assembler support "mtocrf" et al?
AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
AC_TRY_COMPILE(, [
__asm__ __volatile__("mtocrf 0,0");
__asm__ __volatile__("mfocrf 0,0");
],
[
ac_have_as_ppc_mftocrf=yes
AC_MSG_RESULT([yes])
], [
ac_have_as_ppc_mftocrf=no
AC_MSG_RESULT([no])
])
if test x$ac_have_as_ppc_mftocrf = xyes ; then
AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
fi
# Check for TLS support in the compiler and linker
AC_CACHE_CHECK([for TLS support], vg_cv_tls,
[AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],

View File

@ -1,12 +1,13 @@
#include <stdio.h>
#include <config.h>
static
int try_mtocrf ( int x )
{
int base = 0x31415927;
int res;
#ifdef HAVE_AS_PPC_MFTOCRF
/* pre-set CR */
__asm__ __volatile__(
"mtcr %0"
@ -21,7 +22,9 @@ int try_mtocrf ( int x )
__asm__ __volatile__(
"mfcr %0"
: /*w*/"=b"(res) : /*r*/ );
#else
res = 42;
#endif
return res;
}
@ -29,6 +32,7 @@ static
int try_mfocrf ( int x )
{
int res;
#ifdef HAVE_AS_PPC_MFTOCRF
/* CR = x */
__asm__ __volatile__(
"mtcr %0"
@ -39,7 +43,9 @@ int try_mfocrf ( int x )
"li %0,0\n\t"
"mfocrf %0,64"
: /*w*/"=b"(res) : /*r*/ );
#else
res = 42;
#endif
return res;
}