OLD | NEW |
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 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } | 155 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } |
156 | 156 |
157 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded | 157 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded |
158 // translation. | 158 // translation. |
159 RandomNumberGenerator &getRNG() { return RNG; } | 159 RandomNumberGenerator &getRNG() { return RNG; } |
160 | 160 |
161 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); } | 161 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); } |
162 | 162 |
163 // Reset stats at the beginning of a function. | 163 // Reset stats at the beginning of a function. |
164 void resetStats() { StatsFunction.reset(); } | 164 void resetStats() { |
| 165 if (ALLOW_DUMP) |
| 166 StatsFunction.reset(); |
| 167 } |
165 void dumpStats(const IceString &Name, bool Final = false); | 168 void dumpStats(const IceString &Name, bool Final = false); |
166 void statsUpdateEmitted(uint32_t InstCount) { | 169 void statsUpdateEmitted(uint32_t InstCount) { |
| 170 if (!ALLOW_DUMP) |
| 171 return; |
167 StatsFunction.updateEmitted(InstCount); | 172 StatsFunction.updateEmitted(InstCount); |
168 StatsCumulative.updateEmitted(InstCount); | 173 StatsCumulative.updateEmitted(InstCount); |
169 } | 174 } |
170 void statsUpdateRegistersSaved(uint32_t Num) { | 175 void statsUpdateRegistersSaved(uint32_t Num) { |
| 176 if (!ALLOW_DUMP) |
| 177 return; |
171 StatsFunction.updateRegistersSaved(Num); | 178 StatsFunction.updateRegistersSaved(Num); |
172 StatsCumulative.updateRegistersSaved(Num); | 179 StatsCumulative.updateRegistersSaved(Num); |
173 } | 180 } |
174 void statsUpdateFrameBytes(uint32_t Bytes) { | 181 void statsUpdateFrameBytes(uint32_t Bytes) { |
| 182 if (!ALLOW_DUMP) |
| 183 return; |
175 StatsFunction.updateFrameBytes(Bytes); | 184 StatsFunction.updateFrameBytes(Bytes); |
176 StatsCumulative.updateFrameBytes(Bytes); | 185 StatsCumulative.updateFrameBytes(Bytes); |
177 } | 186 } |
178 void statsUpdateSpills() { | 187 void statsUpdateSpills() { |
| 188 if (!ALLOW_DUMP) |
| 189 return; |
179 StatsFunction.updateSpills(); | 190 StatsFunction.updateSpills(); |
180 StatsCumulative.updateSpills(); | 191 StatsCumulative.updateSpills(); |
181 } | 192 } |
182 void statsUpdateFills() { | 193 void statsUpdateFills() { |
| 194 if (!ALLOW_DUMP) |
| 195 return; |
183 StatsFunction.updateFills(); | 196 StatsFunction.updateFills(); |
184 StatsCumulative.updateFills(); | 197 StatsCumulative.updateFills(); |
185 } | 198 } |
186 | 199 |
187 // These are predefined TimerStackIdT values. | 200 // These are predefined TimerStackIdT values. |
188 enum TimerStackKind { | 201 enum TimerStackKind { |
189 TSK_Default = 0, | 202 TSK_Default = 0, |
190 TSK_Funcs, | 203 TSK_Funcs, |
191 TSK_Num | 204 TSK_Num |
192 }; | 205 }; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 240 |
228 // Helper class to push and pop a timer marker. The constructor | 241 // Helper class to push and pop a timer marker. The constructor |
229 // pushes a marker, and the destructor pops it. This is for | 242 // pushes a marker, and the destructor pops it. This is for |
230 // convenient timing of regions of code. | 243 // convenient timing of regions of code. |
231 class TimerMarker { | 244 class TimerMarker { |
232 TimerMarker(const TimerMarker &) = delete; | 245 TimerMarker(const TimerMarker &) = delete; |
233 TimerMarker &operator=(const TimerMarker &) = delete; | 246 TimerMarker &operator=(const TimerMarker &) = delete; |
234 | 247 |
235 public: | 248 public: |
236 TimerMarker(TimerIdT ID, GlobalContext *Ctx) | 249 TimerMarker(TimerIdT ID, GlobalContext *Ctx) |
237 : ID(ID), Ctx(Ctx), Active(Ctx->getFlags().SubzeroTimingEnabled) { | 250 : ID(ID), Ctx(Ctx), Active(false) { |
238 if (Active) | 251 if (ALLOW_DUMP) { |
239 Ctx->pushTimer(ID); | 252 Active = Ctx->getFlags().SubzeroTimingEnabled; |
| 253 if (Active) |
| 254 Ctx->pushTimer(ID); |
| 255 } |
240 } | 256 } |
241 TimerMarker(TimerIdT ID, const Cfg *Func); | 257 TimerMarker(TimerIdT ID, const Cfg *Func); |
242 | 258 |
243 ~TimerMarker() { | 259 ~TimerMarker() { |
244 if (Active) | 260 if (ALLOW_DUMP && Active) |
245 Ctx->popTimer(ID); | 261 Ctx->popTimer(ID); |
246 } | 262 } |
247 | 263 |
248 private: | 264 private: |
249 TimerIdT ID; | 265 TimerIdT ID; |
250 GlobalContext *const Ctx; | 266 GlobalContext *const Ctx; |
251 const bool Active; | 267 bool Active; |
252 }; | 268 }; |
253 | 269 |
254 } // end of namespace Ice | 270 } // end of namespace Ice |
255 | 271 |
256 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 272 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
OLD | NEW |