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

Side by Side Diff: src/IceGlobalContext.h

Issue 620373004: Subzero: Add a few performance measurement tools. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Minor fixes Created 6 years, 2 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
1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===// 1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file declares aspects of the compilation that persist across 10 // This file declares aspects of the compilation that persist across
11 // multiple functions. 11 // multiple functions.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H 15 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H
16 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H 16 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H
17 17
18 #include <memory> 18 #include <memory>
19 19
20 #include "llvm/Support/Allocator.h" 20 #include "llvm/Support/Allocator.h"
21 #include "llvm/Support/raw_ostream.h" 21 #include "llvm/Support/raw_ostream.h"
22 22
23 #include "IceDefs.h" 23 #include "IceDefs.h"
24 #include "IceIntrinsics.h" 24 #include "IceIntrinsics.h"
25 #include "IceRNG.h" 25 #include "IceRNG.h"
26 #include "IceTimerTree.h"
26 #include "IceTypes.h" 27 #include "IceTypes.h"
27 28
28 namespace Ice { 29 namespace Ice {
29 30
30 class ClFlags; 31 class ClFlags;
31 32
32 // This class collects rudimentary statistics during translation. 33 // This class collects rudimentary statistics during translation.
33 class CodeStats { 34 class CodeStats {
34 public: 35 public:
35 CodeStats() 36 CodeStats()
(...skipping 28 matching lines...) Expand all
64 class GlobalContext { 65 class GlobalContext {
65 public: 66 public:
66 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit, 67 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit,
67 VerboseMask Mask, TargetArch Arch, OptLevel Opt, 68 VerboseMask Mask, TargetArch Arch, OptLevel Opt,
68 IceString TestPrefix, const ClFlags &Flags); 69 IceString TestPrefix, const ClFlags &Flags);
69 ~GlobalContext(); 70 ~GlobalContext();
70 71
71 // Returns true if any of the specified options in the verbose mask 72 // Returns true if any of the specified options in the verbose mask
72 // are set. If the argument is omitted, it checks if any verbose 73 // are set. If the argument is omitted, it checks if any verbose
73 // options at all are set. 74 // options at all are set.
75 VerboseMask getVerbose() const { return VMask; }
74 bool isVerbose(VerboseMask Mask = IceV_All) const { return VMask & Mask; } 76 bool isVerbose(VerboseMask Mask = IceV_All) const { return VMask & Mask; }
75 void setVerbose(VerboseMask Mask) { VMask = Mask; } 77 void setVerbose(VerboseMask Mask) { VMask = Mask; }
76 void addVerbose(VerboseMask Mask) { VMask |= Mask; } 78 void addVerbose(VerboseMask Mask) { VMask |= Mask; }
77 void subVerbose(VerboseMask Mask) { VMask &= ~Mask; } 79 void subVerbose(VerboseMask Mask) { VMask &= ~Mask; }
78 80
79 Ostream &getStrDump() { return *StrDump; } 81 Ostream &getStrDump() { return *StrDump; }
80 Ostream &getStrEmit() { return *StrEmit; } 82 Ostream &getStrEmit() { return *StrEmit; }
81 83
82 TargetArch getTargetArch() const { return Arch; } 84 TargetArch getTargetArch() const { return Arch; }
83 OptLevel getOptLevel() const { return Opt; } 85 OptLevel getOptLevel() const { return Opt; }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 146 }
145 void statsUpdateSpills() { 147 void statsUpdateSpills() {
146 StatsFunction.updateSpills(); 148 StatsFunction.updateSpills();
147 StatsCumulative.updateSpills(); 149 StatsCumulative.updateSpills();
148 } 150 }
149 void statsUpdateFills() { 151 void statsUpdateFills() {
150 StatsFunction.updateFills(); 152 StatsFunction.updateFills();
151 StatsCumulative.updateFills(); 153 StatsCumulative.updateFills();
152 } 154 }
153 155
156 // These are predefined TimerStackIdT values.
157 enum TimerStackKind {
158 TSK_Default = 0,
159 TSK_Funcs,
160 TSK_Num
161 };
162
154 static TimerIdT getTimerID(const IceString &Name); 163 static TimerIdT getTimerID(const IceString &Name);
155 void pushTimer(TimerIdT ID); 164 static TimerStackIdT getTimerStackID();
jvoung (off chromium) 2014/10/06 16:30:56 How is getTimerStackID() planned to be used? (I do
Jim Stichnoth 2014/10/06 21:29:57 The thought is that some component, e.g. the bitco
156 void popTimer(TimerIdT ID); 165 void pushTimer(TimerIdT ID, TimerStackIdT StackID = TSK_Default);
157 void dumpTimers(); 166 void popTimer(TimerIdT ID, TimerStackIdT StackID = TSK_Default);
167 void dumpTimers(TimerStackIdT StackID = TSK_Default,
168 bool DumpCumulative = true);
158 169
159 private: 170 private:
160 Ostream *StrDump; // Stream for dumping / diagnostics 171 Ostream *StrDump; // Stream for dumping / diagnostics
161 Ostream *StrEmit; // Stream for code emission 172 Ostream *StrEmit; // Stream for code emission
162 173
163 llvm::BumpPtrAllocator Allocator; 174 llvm::BumpPtrAllocator Allocator;
164 VerboseMask VMask; 175 VerboseMask VMask;
165 std::unique_ptr<class ConstantPool> ConstPool; 176 std::unique_ptr<class ConstantPool> ConstPool;
166 Intrinsics IntrinsicsInfo; 177 Intrinsics IntrinsicsInfo;
167 const TargetArch Arch; 178 const TargetArch Arch;
168 const OptLevel Opt; 179 const OptLevel Opt;
169 const IceString TestPrefix; 180 const IceString TestPrefix;
170 const ClFlags &Flags; 181 const ClFlags &Flags;
171 bool HasEmittedFirstMethod; 182 bool HasEmittedFirstMethod;
172 RandomNumberGenerator RNG; 183 RandomNumberGenerator RNG;
173 CodeStats StatsFunction; 184 CodeStats StatsFunction;
174 CodeStats StatsCumulative; 185 CodeStats StatsCumulative;
175 std::unique_ptr<class TimerStack> Timers; 186 std::vector<TimerStack> Timers;
187 static TimerStackIdT NumTimerStackIds;
176 GlobalContext(const GlobalContext &) = delete; 188 GlobalContext(const GlobalContext &) = delete;
177 GlobalContext &operator=(const GlobalContext &) = delete; 189 GlobalContext &operator=(const GlobalContext &) = delete;
178 190
179 // Private helpers for mangleName() 191 // Private helpers for mangleName()
180 typedef llvm::SmallVector<char, 32> ManglerVector; 192 typedef llvm::SmallVector<char, 32> ManglerVector;
181 void incrementSubstitutions(ManglerVector &OldName) const; 193 void incrementSubstitutions(ManglerVector &OldName) const;
182 }; 194 };
183 195
184 // Helper class to push and pop a timer marker. The constructor 196 // Helper class to push and pop a timer marker. The constructor
185 // pushes a marker, and the destructor pops it. This is for 197 // pushes a marker, and the destructor pops it. This is for
186 // convenient timing of regions of code. 198 // convenient timing of regions of code.
187 class TimerMarker { 199 class TimerMarker {
188 TimerMarker(const TimerMarker &) = delete; 200 TimerMarker(const TimerMarker &) = delete;
189 TimerMarker &operator=(const TimerMarker &) = delete; 201 TimerMarker &operator=(const TimerMarker &) = delete;
190 202
191 public: 203 public:
192 TimerMarker(TimerIdT ID, GlobalContext *Ctx) 204 TimerMarker(TimerIdT ID, GlobalContext *Ctx)
193 : ID(ID), Ctx(Ctx), Active(Ctx->getFlags().SubzeroTimingEnabled) { 205 : ID(ID), Ctx(Ctx), Active(Ctx->getFlags().SubzeroTimingEnabled) {
194 if (Active) 206 if (Active)
195 Ctx->pushTimer(ID); 207 Ctx->pushTimer(ID);
196 } 208 }
209 TimerMarker(TimerIdT ID, const Cfg *Func);
210
197 ~TimerMarker() { 211 ~TimerMarker() {
198 if (Active) 212 if (Active)
199 Ctx->popTimer(ID); 213 Ctx->popTimer(ID);
200 } 214 }
201 215
202 private: 216 private:
203 TimerIdT ID; 217 TimerIdT ID;
204 GlobalContext *const Ctx; 218 GlobalContext *const Ctx;
205 const bool Active; 219 const bool Active;
206 }; 220 };
207 221
208 } // end of namespace Ice 222 } // end of namespace Ice
209 223
210 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H 224 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698