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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 //===- llvm/Analysis/NaCl/SimplificationAnalyses.cpp ------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file houses implementations of the analysis passes used by the PNaCl IR
11 // simplification passes to remove extra passes over modules while progressive
12 // simplifying the IR, allowing them direct access to what each pass needs to
13 // expand.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #include "llvm/Analysis/NaCl/SimplificationAnalyses.h"
18 #include "llvm/IR/InstIterator.h"
19
20 using namespace llvm;
21
22 AtomicInfo::AtomicInfo(Function &F) {
23 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.
24 if (AtomicCmpXchgInst *AI = dyn_cast<AtomicCmpXchgInst>(&*I)) {
25 CmpXchgs.push_back(AI);
26 } else if (LoadInst *LI = dyn_cast<LoadInst>(&*I)) {
27 if (!LI->isSimple()) {
28 Loads.push_back(LI);
29 }
30 } else if (StoreInst *SI = dyn_cast<StoreInst>(&*I)) {
31 if (!SI->isSimple()) {
32 Stores.push_back(SI);
33 }
34 } else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(&*I)) {
35 RMWs.push_back(RMWI);
36 switch (RMWI->getOperation()) {
37 default:
38 NeedsAtomicExpand = true;
39 case AtomicRMWInst::Add:
40 case AtomicRMWInst::Sub:
41 case AtomicRMWInst::And:
42 case AtomicRMWInst::Or:
43 case AtomicRMWInst::Xor:
44 case AtomicRMWInst::Xchg:
45 continue;
46 }
47 } else if (FenceInst *FI = dyn_cast<FenceInst>(&*I)) {
48 Fences.push_back(FI);
49 }
50 }
51 }
52
53 char AtomicAnalysis::PassID;
54
55 INITIALIZE_PASS(AtomicAnalysisWrapperPass, "pnacl-atomic-analysis",
56 "Find atomic instruction to expand", true, true)
57 char AtomicAnalysisWrapperPass::ID = 0;
58
59 bool AtomicAnalysisWrapperPass::runOnFunction(Function &F) {
60 releaseMemory();
61 Info = std::move(AtomicInfo(F));
62 return false;
63 }
64 void AtomicAnalysisWrapperPass::releaseMemory() { Info.releaseMemory(); }
65 void AtomicAnalysisWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
66 AU.setPreservesAll();
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698