From 090c5bd0e436b878c8cc725a012a2eee934c80d9 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Sun, 12 Mar 2006 16:47:10 +0000 Subject: [PATCH] Work around lameness in older ppc assemblers. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5757 --- configure.in | 20 ++++++++++++++++++++ none/tests/ppc32/mftocrf.c | 12 +++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 318f9e4eae..e1dfab894e 100644 --- a/configure.in +++ b/configure.in @@ -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], diff --git a/none/tests/ppc32/mftocrf.c b/none/tests/ppc32/mftocrf.c index 099fbdfdbd..916b9ada73 100644 --- a/none/tests/ppc32/mftocrf.c +++ b/none/tests/ppc32/mftocrf.c @@ -1,12 +1,13 @@ #include +#include 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; } -- 2.47.2