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

Side by Side Diff: include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h

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/PNaClSimplificationAnalyses.h ---------*- 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 analysis passes used by the PNaCl IR simplification passes
11 // to remove extra passes over modules while they progressively simplify the IR,
12 // allowing them direct access to what each pass needs to expand.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/Instructions.h"
19 #include "llvm/Pass.h"
20
21 namespace llvm {
22
23 class AtomicInfo {
24 public:
25 const SmallVectorImpl<AtomicCmpXchgInst *> &getCmpXchgs() const {
26 return CmpXchgs;
27 }
28 const SmallVectorImpl<LoadInst *> &getLoads() const { return Loads; }
29 const SmallVectorImpl<StoreInst *> &getStores() const { return Stores; }
30 const SmallVectorImpl<AtomicRMWInst *> &getRMWs() const { return RMWs; }
31 const SmallVectorImpl<FenceInst *> &getFences() const { return Fences; }
32
33 bool needsAtomicExpand() const { return NeedsAtomicExpand; }
34
35 AtomicInfo() {}
36 AtomicInfo(Function &F);
37 AtomicInfo(AtomicInfo &&Rhs)
38 : CmpXchgs(std::move(Rhs.CmpXchgs)), Loads(std::move(Rhs.Loads)),
39 Stores(std::move(Rhs.Stores)), RMWs(std::move(Rhs.RMWs)),
40 Fences(std::move(Rhs.Fences)),
41 NeedsAtomicExpand(Rhs.needsAtomicExpand()) {}
42 AtomicInfo &operator=(AtomicInfo &&Rhs) {
43 CmpXchgs = std::move(Rhs.CmpXchgs);
44 Loads = std::move(Rhs.Loads);
45 Stores = std::move(Rhs.Stores);
46 RMWs = std::move(Rhs.RMWs);
47 Fences = std::move(Rhs.Fences);
48 NeedsAtomicExpand = Rhs.needsAtomicExpand();
49 return *this;
50 }
51
52 void releaseMemory() {
53 CmpXchgs.clear();
54 Loads.clear();
55 Stores.clear();
56 RMWs.clear();
57 Fences.clear();
58 }
59
60 private:
61 SmallVector<AtomicCmpXchgInst *, 8> CmpXchgs;
62 SmallVector<LoadInst *, 8> Loads;
63 SmallVector<StoreInst *, 8> Stores;
64 SmallVector<AtomicRMWInst *, 8> RMWs;
65 SmallVector<FenceInst *, 4> Fences;
66
67 bool NeedsAtomicExpand = false;
68 };
69
70 /// \brief This is a very simple analysis pass that just collects the
71 /// instructions which need to be expanded into NaCl's stable atomic
72 /// intrinsics.
73 class AtomicAnalysis {
74 static char PassID;
75
76 public:
77 typedef AtomicInfo Result;
78
79 static void *ID() { return (void *)&PassID; }
80 static StringRef name() { return "AtomicInstructionsAnalysis"; }
81
82 AtomicAnalysis() {}
83 AtomicAnalysis(const AtomicAnalysis &) {}
84 AtomicAnalysis(AtomicAnalysis &&) {}
85 AtomicAnalysis &operator=(const AtomicAnalysis &) { return *this; }
86 AtomicAnalysis &operator=(AtomicAnalysis &&) { return *this; }
JF 2015/07/27 19:49:28 Do you need these? The default should be enough.
Richard Diamond 2015/07/30 11:47:08 All the other analysis have them, citing MSVC as t
87
88 AtomicInfo run(Function &F) { return AtomicInfo(F); }
89 };
90
91 class AtomicAnalysisWrapperPass : public FunctionPass {
92 AtomicInfo Info;
93
94 public:
95 static char ID;
96
97 AtomicAnalysisWrapperPass() : FunctionPass(ID) {
98 initializeAtomicAnalysisWrapperPassPass(*PassRegistry::getPassRegistry());
99 }
100
101 AtomicInfo &getInfo() { return Info; }
102 const AtomicInfo &getInfo() const { return Info; }
103
104 bool runOnFunction(Function &F) override;
105 void releaseMemory() override;
106 void getAnalysisUsage(AnalysisUsage &AU) const;
107 };
108 }
OLDNEW
« no previous file with comments | « no previous file | include/llvm/InitializePasses.h » ('j') | lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698