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

Unified Diff: lib/Analysis/NaCl/SimplificationAnalyses.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/SimplificationAnalyses.cpp
diff --git a/lib/Analysis/NaCl/SimplificationAnalyses.cpp b/lib/Analysis/NaCl/SimplificationAnalyses.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1d2e59482ba4f87616865d3dea752afb2ba0b2a4
--- /dev/null
+++ b/lib/Analysis/NaCl/SimplificationAnalyses.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/SimplificationAnalyses.h"
+#include "llvm/IR/InstIterator.h"
+
+using namespace llvm;
+
+AtomicInfo::AtomicInfo(Function &F) {
+ for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
JF 2015/07/23 22:44:38 Use inst_range instead? Or just make this an InstV
Richard Diamond 2015/07/24 19:54:38 Done.
+ 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;
+ 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