From ac951330a98a3e01a50cc60d43b75576c5c04271 Mon Sep 17 00:00:00 2001
From: jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sat, 18 Nov 2006 00:22:45 +0000
Subject: [PATCH] gcc: 	* config/rs6000/rs6000.h (TARGET_NO_LWSYNC): Define. 
 * config/rs6000/rs6000-c.c (rs6000_cpu_cpp_builtins): Define 	__NO_LWSYNC__
 if TARGET_NO_LWSYNC. 	* config/rs6000/sync.md (lwsync): Emit plain sync if 
 TARGET_NO_LWSYNC.

libstdc++-v3:
	* config/cpu/powerpc/atomic_word.h (_GLIBCXX_WRITE_MEM_BARRIER):
	Use plain sync if __NO_LWSYNC__.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118961 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                                 | 8 ++++++++
 gcc/config/rs6000/rs6000-c.c                  | 3 +++
 gcc/config/rs6000/rs6000.h                    | 3 +++
 gcc/config/rs6000/sync.md                     | 7 ++++++-
 libstdc++-v3/ChangeLog                        | 5 +++++
 libstdc++-v3/config/cpu/powerpc/atomic_word.h | 4 ++++
 6 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f3c8b8786539..01ed1bfe1f49 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2006-11-18  Joseph Myers  <joseph@codesourcery.com>
+
+	* config/rs6000/rs6000.h (TARGET_NO_LWSYNC): Define.
+	* config/rs6000/rs6000-c.c (rs6000_cpu_cpp_builtins): Define
+	__NO_LWSYNC__ if TARGET_NO_LWSYNC.
+	* config/rs6000/sync.md (lwsync): Emit plain sync if
+	TARGET_NO_LWSYNC.
+
 2006-11-17  DJ Delorie  <dj@redhat.com>
 
 	* reload1.c (reloads_unique_chain): New.
diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c
index 94d4a6a8c3bf..d4988bd3ffd4 100644
--- a/gcc/config/rs6000/rs6000-c.c
+++ b/gcc/config/rs6000/rs6000-c.c
@@ -127,6 +127,9 @@ rs6000_cpu_cpp_builtins (cpp_reader *pfile)
   /* Used by lwarx/stwcx. errata work-around.  */
   if (rs6000_cpu == PROCESSOR_PPC405)
     builtin_define ("__PPC405__");
+  /* Used by libstdc++.  */
+  if (TARGET_NO_LWSYNC)
+    builtin_define ("__NO_LWSYNC__");
 
   /* May be overridden by target configuration.  */
   RS6000_CPU_CPP_ENDIAN_BUILTINS();
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 6ccc3c01ad4e..0795e6ee6376 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -342,6 +342,9 @@ extern enum rs6000_nop_insertion rs6000_sched_insert_nops;
 #define TARGET_E500_SINGLE 0
 #define TARGET_E500_DOUBLE 0
 
+/* E500 processors only support plain "sync", not lwsync.  */
+#define TARGET_NO_LWSYNC TARGET_E500
+
 /* Sometimes certain combinations of command options do not make sense
    on a particular target machine.  You can define a macro
    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
diff --git a/gcc/config/rs6000/sync.md b/gcc/config/rs6000/sync.md
index b244ef639863..b7166473efec 100644
--- a/gcc/config/rs6000/sync.md
+++ b/gcc/config/rs6000/sync.md
@@ -615,6 +615,11 @@
   [(set (mem:BLK (match_scratch 0 "X"))
 	(unspec_volatile:BLK [(mem:BLK (match_scratch 1 "X"))] UNSPEC_LWSYNC))]
   ""
-  ".long 0x7c2004ac"
+{
+  if (TARGET_NO_LWSYNC)
+    return "sync";
+  else
+    return ".long 0x7c2004ac";
+}
   [(set_attr "type" "sync")])
 
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 2118ba1bcc90..a41049a7ff11 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2006-11-18  Joseph Myers  <joseph@codesourcery.com>
+
+	* config/cpu/powerpc/atomic_word.h (_GLIBCXX_WRITE_MEM_BARRIER):
+	Use plain sync if __NO_LWSYNC__.
+
 2006-11-14  Joseph Myers  <joseph@codesourcery.com>
 
 	* testsuite/26_numerics/complex/13450.cc: Do not test long double
diff --git a/libstdc++-v3/config/cpu/powerpc/atomic_word.h b/libstdc++-v3/config/cpu/powerpc/atomic_word.h
index 2a5d192c54bb..4f8c670d2a23 100644
--- a/libstdc++-v3/config/cpu/powerpc/atomic_word.h
+++ b/libstdc++-v3/config/cpu/powerpc/atomic_word.h
@@ -33,6 +33,10 @@
 typedef int _Atomic_word;
 
 #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("isync":::"memory")
+#ifdef __NO_LWSYNC__
+#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("sync":::"memory")
+#else
 #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("lwsync":::"memory")
+#endif
 
 #endif 
-- 
GitLab