Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp

Issue 927493002: PNaCl: Impl the other atomicrmw operations: nand, max, min, umax, and umin. Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp
diff --git a/lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp b/lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7dda08fbba56f68c317b66867204bcdeb70c857e
--- /dev/null
+++ b/lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp
@@ -0,0 +1,67 @@
+//===- llvm/Analysis/NaCl/SimplificationAnalyses.cpp ------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file houses implementations of the analysis passes used by the PNaCl IR
+// simplification passes to remove extra passes over modules while progressive
+// simplifying the IR, allowing them direct access to what each pass needs to
+// expand.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h"
+#include "llvm/IR/InstIterator.h"
+
+using namespace llvm;
+
+AtomicInfo::AtomicInfo(Function &F) {
+ for (Instruction &I : inst_range(F)) {
+ if (AtomicCmpXchgInst *AI = dyn_cast<AtomicCmpXchgInst>(&I)) {
+ CmpXchgs.push_back(AI);
+ } else if (LoadInst *LI = dyn_cast<LoadInst>(&I)) {
+ if (!LI->isSimple()) {
+ Loads.push_back(LI);
+ }
+ } else if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
+ if (!SI->isSimple()) {
+ Stores.push_back(SI);
+ }
+ } else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(&I)) {
+ RMWs.push_back(RMWI);
+ switch (RMWI->getOperation()) {
+ default:
+ NeedsAtomicExpand = true;
JF 2015/07/27 19:49:28 Don't leave a fallthrough here, usual LLVM style t
Richard Diamond 2015/07/30 11:47:08 That wasn't intended. I think Rust's lack of fall
+ case AtomicRMWInst::Add:
+ case AtomicRMWInst::Sub:
+ case AtomicRMWInst::And:
+ case AtomicRMWInst::Or:
+ case AtomicRMWInst::Xor:
+ case AtomicRMWInst::Xchg:
+ continue;
+ }
+ } else if (FenceInst *FI = dyn_cast<FenceInst>(&I)) {
+ Fences.push_back(FI);
+ }
+ }
+}
+
+char AtomicAnalysis::PassID;
+
+INITIALIZE_PASS(AtomicAnalysisWrapperPass, "pnacl-atomic-analysis",
+ "Find atomic instruction to expand", true, true)
+char AtomicAnalysisWrapperPass::ID = 0;
+
+bool AtomicAnalysisWrapperPass::runOnFunction(Function &F) {
+ releaseMemory();
+ Info = std::move(AtomicInfo(F));
+ return false;
+}
+void AtomicAnalysisWrapperPass::releaseMemory() { Info.releaseMemory(); }
+void AtomicAnalysisWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+}

Powered by Google App Engine
This is Rietveld 408576698