summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Instruction.cpp
diff options
context:
space:
mode:
authorRobin Morisset <morisset@google.com>2014-09-03 21:29:59 +0000
committerRobin Morisset <morisset@google.com>2014-09-03 21:29:59 +0000
commited3d48f16128304821e884b4e4ff0ec6f95323bf (patch)
tree0ee18638d5d751545433c6dd3b42b7a9045b7290 /llvm/lib/IR/Instruction.cpp
parentc8d8ca0bd67c65e209a85d16fb4b4ec6dfaab65f (diff)
downloadbcm5719-llvm-ed3d48f16128304821e884b4e4ff0ec6f95323bf.tar.gz
bcm5719-llvm-ed3d48f16128304821e884b4e4ff0ec6f95323bf.zip
Refactor AtomicExpandPass and add a generic isAtomic() method to Instruction
Summary: Split shouldExpandAtomicInIR() into different versions for Stores/Loads/RMWs/CmpXchgs. Makes runOnFunction cleaner (no more redundant checking/casting), and will help moving the X86 backend to this pass. This requires a way of easily detecting which instructions are atomic. I followed the pattern of mayReadFromMemory, mayWriteOrReadMemory, etc.. in making isAtomic() a method of Instruction implemented by a switch on the opcodes. Test Plan: make check Reviewers: jfb Subscribers: mcrosier, llvm-commits Differential Revision: http://reviews.llvm.org/D5035 llvm-svn: 217080
Diffstat (limited to 'llvm/lib/IR/Instruction.cpp')
-rw-r--r--llvm/lib/IR/Instruction.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 50b1f04d41e..3e7b0314473 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -443,6 +443,21 @@ bool Instruction::mayWriteToMemory() const {
}
}
+bool Instruction::isAtomic() const {
+ switch (getOpcode()) {
+ default:
+ return false;
+ case Instruction::AtomicCmpXchg:
+ case Instruction::AtomicRMW:
+ case Instruction::Fence:
+ return true;
+ case Instruction::Load:
+ return cast<LoadInst>(this)->getOrdering() != NotAtomic;
+ case Instruction::Store:
+ return cast<StoreInst>(this)->getOrdering() != NotAtomic;
+ }
+}
+
bool Instruction::mayThrow() const {
if (const CallInst *CI = dyn_cast<CallInst>(this))
return !CI->doesNotThrow();
OpenPOWER on IntegriCloud