Patchwork CRIS atomics revisited 1/4: use need_atomic_barrier_p.

login
register
mail settings
Submitter Hans-Peter Nilsson
Date July 16, 2012, 3:42 a.m.
Message ID <201207160342.q6G3gBS3019567@ignucius.se.axis.com>
Download mbox | patch
Permalink /patch/171121/
State New
Headers show

Comments

Hans-Peter Nilsson - July 16, 2012, 3:42 a.m.
Use the new need_atomic_barrier_p.

gcc:
	* config/cris/sync.md ("atomic_fetch_<atomic_op_name><mode>")
	("atomic_compare_and_swap<mode>"): Gate expand_mem_thread_fence
	calls on result of call to need_atomic_barrier_p.

brgds, H-P

Patch

Index: config/cris/sync.md
===================================================================
--- config/cris/sync.md	(revision 189499)
+++ config/cris/sync.md	(working copy)
@@ -93,11 +93,15 @@  (define_expand "atomic_fetch_<atomic_op_
   if (<MODE>mode != QImode && TARGET_TRAP_UNALIGNED_ATOMIC)
     cris_emit_trap_for_misalignment (operands[1]);
 
-  expand_mem_thread_fence (mmodel);
+  if (need_atomic_barrier_p (mmodel, true))
+    expand_mem_thread_fence (mmodel);
+
   emit_insn (gen_cris_atomic_fetch_<atomic_op_name><mode>_1 (operands[0],
 							     operands[1],
 							     operands[2]));
-  expand_mem_thread_fence (mmodel);
+  if (need_atomic_barrier_p (mmodel, false))
+    expand_mem_thread_fence (mmodel);
+
   DONE;
 })
 
@@ -196,13 +200,17 @@  (define_expand "atomic_compare_and_swap<
   if (<MODE>mode != QImode && TARGET_TRAP_UNALIGNED_ATOMIC)
     cris_emit_trap_for_misalignment (operands[2]);
 
-  expand_mem_thread_fence (mmodel);
+  if (need_atomic_barrier_p (mmodel, true))
+    expand_mem_thread_fence (mmodel);
+
   emit_insn (gen_cris_atomic_compare_and_swap<mode>_1 (operands[0],
 						       operands[1],
 						       operands[2],
 						       operands[3],
 						       operands[4]));
-  expand_mem_thread_fence (mmodel);
+  if (need_atomic_barrier_p (mmodel, false))
+    expand_mem_thread_fence (mmodel);
+
   DONE;
 })