From 30c3c4427521f96fb58b6e1debb86da4f113f06f Mon Sep 17 00:00:00 2001 From: mkuvyrkov Date: Wed, 20 Jun 2012 01:05:25 +0000 Subject: * emit-rtl.c (need_atomic_barrier_p): New function. * emit-rtl.h (need_atomic_barrier_p): Declare it. * config/alpha/alpha.c (alpha_{pre,post}_atomic_barrier): Use it. * config/arm/arm.c (arm_{pre,post}_atomic_barrier): Use it. * config/tilegx/tilegx.c (tile_{pre,post}_atomic_barrier): Use it. * config/mips/mips.c (mips_{pre,post}_atomic_barrier_p): Remove. (mips_process_sync_loop): Use generic version instead. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188806 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/emit-rtl.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'gcc/emit-rtl.c') diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index c82bd61c7e1..9565c618b81 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -6161,4 +6161,29 @@ locator_eq (int loc1, int loc2) return locator_scope (loc1) == locator_scope (loc2); } + +/* Return true if memory model MODEL requires a pre-operation (release-style) + barrier or a post-operation (acquire-style) barrier. While not universal, + this function matches behavior of several targets. */ + +bool +need_atomic_barrier_p (enum memmodel model, bool pre) +{ + switch (model) + { + case MEMMODEL_RELAXED: + case MEMMODEL_CONSUME: + return false; + case MEMMODEL_RELEASE: + return pre; + case MEMMODEL_ACQUIRE: + return !pre; + case MEMMODEL_ACQ_REL: + case MEMMODEL_SEQ_CST: + return true; + default: + gcc_unreachable (); + } +} + #include "gt-emit-rtl.h" -- cgit v1.2.1