[PATCH] Add two helper functions: isAtLeastAcquire, isAtLeastRelease

Robin Morisset morisset at google.com
Tue Aug 12 17:06:02 PDT 2014


I moved the two helpers from being methods of LoadInst/StoreInst to being
free-standing functions operating on AtomicOrdering, on the suggestion of Philip Reames,
it is indeed much clearer.
Also added a doxygen comment (although it does not tell much more than the code..)
I did not change the name of the function, I hope it is more self-explanatory now that
they have an AtomicOrdering in their signature.
Using them elsewhere in the codebase will come in another patch if this one lands.

http://reviews.llvm.org/D4844

Files:
  include/llvm/IR/Instructions.h

Index: include/llvm/IR/Instructions.h
===================================================================
--- include/llvm/IR/Instructions.h
+++ include/llvm/IR/Instructions.h
@@ -50,6 +50,24 @@
   CrossThread = 1
 };
 
+namespace {
+/// Returns true if the ordering is at least as strong as acquire
+/// (i.e. acquire, acq_rel or seq_cst)
+inline bool isAtLeastAcquire(AtomicOrdering Ord) {
+   return (Ord == Acquire
+    || Ord == AcquireRelease
+    || Ord == SequentiallyConsistent);
+}
+
+/// Returns true if the ordering is at least as strong as release
+/// (i.e. release, acq_rel or seq_cst)
+inline bool isAtLeastRelease(AtomicOrdering Ord) {
+return (Ord == Release
+    || Ord == AcquireRelease
+    || Ord == SequentiallyConsistent);
+}
+} // end anonymous namespace
+
 //===----------------------------------------------------------------------===//
 //                                AllocaInst Class
 //===----------------------------------------------------------------------===//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4844.12424.patch
Type: text/x-patch
Size: 998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140813/feeebeb1/attachment.bin>


More information about the llvm-commits mailing list