This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[power7-meissner] Generate lwsync if the assembler supports it


When I was fixing the powerpc problem with asm constraints in boehm-gc, I
noticed the compiler was generating the lwsync instruction as a decimal
constant (evidently one version of the AIX assembler did not support it).  I
decided to add a configure test to see if the assembler supports lwsync, and if
so generate the mnemonic instead of the bit pattern.

David, can you test this on AIX to make sure I got the test right on AIX?

2009-06-14  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* config.in (HAVE_AS_LWSYNC): Add for configure test.

	* configure.ac (gcc_cv_as_powerpc_lwsync): Prope to see if the
	assembler supports the lwsync instruction.
	* configure: Regenerate.

	* config/rs6000/sync.md (lwsync): If the assembler can support
	lwsync generate it instead of putting in the bit pattern as an
	integer constant.

	* config/rs6000/rs6000.h (TARGET_LWSYNC_INSTRUCTION): Define as
	1/0 depending on whether the assembler supports the lwsync
	instruction.

Index: gcc/config.in
===================================================================
--- gcc/config.in	(revision 148454)
+++ gcc/config.in	(working copy)
@@ -362,6 +362,11 @@
 #undef HAVE_AS_POPCNTD
 #endif
 
+/* Define if your assembler supports lwsync instruction. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_LWSYNC
+#endif
+
 
 /* Define if your assembler supports .register. */
 #ifndef USED_FOR_TARGET
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 148454)
+++ gcc/configure.ac	(working copy)
@@ -3209,6 +3209,19 @@ LCF0:
       [AC_DEFINE(HAVE_AS_POPCNTD, 1,
 	  [Define if your assembler supports POPCNTD instructions.])])
 
+    case $target in
+      *-*-aix*) conftest_s='	.csect .text[[PR]]
+	lwsync';;
+      *) conftest_s='	.text
+	lwsync';;
+    esac
+
+    gcc_GAS_CHECK_FEATURE([lwsync support],
+      gcc_cv_as_powerpc_lwsync, [2,19,2], -a32,
+      [$conftest_s],,
+      [AC_DEFINE(HAVE_AS_LWSYNC, 1,
+	  [Define if your assembler supports LWSYNC instructions.])])
+
     gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
       gcc_cv_as_powerpc_gnu_attribute, [2,18,0],,
       [.gnu_attribute 4,1],,
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 148454)
+++ gcc/configure	(working copy)
@@ -23498,6 +23498,50 @@ _ACEOF
 
 fi
 
+    case $target in
+      *-*-aix*) conftest_s='	.csect .text[PR]
+	lwsync';;
+      *) conftest_s='	.text
+	lwsync';;
+    esac
+
+    echo "$as_me:$LINENO: checking assembler for lwsync support" >&5
+echo $ECHO_N "checking assembler for lwsync support... $ECHO_C" >&6
+if test "${gcc_cv_as_powerpc_lwsync+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  gcc_cv_as_powerpc_lwsync=no
+    if test $in_tree_gas = yes; then
+    if test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 19 \) \* 1000 + 2`
+  then gcc_cv_as_powerpc_lwsync=yes
+fi
+  elif test x$gcc_cv_as != x; then
+    echo "$conftest_s" > conftest.s
+    if { ac_try='$gcc_cv_as -a32 -o conftest.o conftest.s >&5'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }
+    then
+	gcc_cv_as_powerpc_lwsync=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+echo "$as_me:$LINENO: result: $gcc_cv_as_powerpc_lwsync" >&5
+echo "${ECHO_T}$gcc_cv_as_powerpc_lwsync" >&6
+if test $gcc_cv_as_powerpc_lwsync = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_AS_LWSYNC 1
+_ACEOF
+
+fi
+
     echo "$as_me:$LINENO: checking assembler for .gnu_attribute support" >&5
 echo $ECHO_N "checking assembler for .gnu_attribute support... $ECHO_C" >&6
 if test "${gcc_cv_as_powerpc_gnu_attribute+set}" = set; then
Index: gcc/config/rs6000/sync.md
===================================================================
--- gcc/config/rs6000/sync.md	(revision 148454)
+++ gcc/config/rs6000/sync.md	(working copy)
@@ -616,7 +616,7 @@ (define_insn "lwsync"
   if (TARGET_NO_LWSYNC)
     return "sync";
   else
-    return ".long 0x7c2004ac";
+    return (TARGET_LWSYNC_INSTRUCTION) ? "lwsync" : ".long 0x7c2004ac";
 }
   [(set_attr "type" "sync")])
 
Index: gcc/config/rs6000/rs6000.h
===================================================================
--- gcc/config/rs6000/rs6000.h	(revision 148454)
+++ gcc/config/rs6000/rs6000.h	(working copy)
@@ -261,6 +261,14 @@ extern const char *host_detect_local_cpu
 #define TARGET_POPCNTD 0
 #endif
 
+/* Define TARGET_LWSYNC_INSTRUCTION if the assembler knows about lwsync.  If
+   not, generate the lwsync code as an integer constant.  */
+#ifdef HAVE_AS_LWSYNC
+#define TARGET_LWSYNC_INSTRUCTION 1
+#else
+#define TARGET_LWSYNC_INSTRUCTION 0
+#endif
+
 /* Define TARGET_TLS_MARKERS if the target assembler does not support
    arg markers for __tls_get_addr calls.  */
 #ifndef HAVE_AS_TLS_MARKERS


-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]