OLD | NEW |
---|---|
1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// | 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// |
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 defines aspects of the compilation that persist across | 10 // This file defines aspects of the compilation that persist across |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 UndefPool Undefs; | 112 UndefPool Undefs; |
113 }; | 113 }; |
114 | 114 |
115 GlobalContext::GlobalContext(llvm::raw_ostream *OsDump, | 115 GlobalContext::GlobalContext(llvm::raw_ostream *OsDump, |
116 llvm::raw_ostream *OsEmit, VerboseMask Mask, | 116 llvm::raw_ostream *OsEmit, VerboseMask Mask, |
117 TargetArch Arch, OptLevel Opt, | 117 TargetArch Arch, OptLevel Opt, |
118 IceString TestPrefix, const ClFlags &Flags) | 118 IceString TestPrefix, const ClFlags &Flags) |
119 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), | 119 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), |
120 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), | 120 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), |
121 TestPrefix(TestPrefix), Flags(Flags), HasEmittedFirstMethod(false), | 121 TestPrefix(TestPrefix), Flags(Flags), HasEmittedFirstMethod(false), |
122 RNG(""), Timers(new TimerStack("main")) {} | 122 RNG("") {} |
123 | 123 |
124 // Scan a string for S[0-9A-Z]*_ patterns and replace them with | 124 // Scan a string for S[0-9A-Z]*_ patterns and replace them with |
125 // S<num>_ where <num> is the next base-36 value. If a type name | 125 // S<num>_ where <num> is the next base-36 value. If a type name |
126 // legitimately contains that pattern, then the substitution will be | 126 // legitimately contains that pattern, then the substitution will be |
127 // made in error and most likely the link will fail. In this case, | 127 // made in error and most likely the link will fail. In this case, |
128 // the test classes can be rewritten not to use that pattern, which is | 128 // the test classes can be rewritten not to use that pattern, which is |
129 // much simpler and more reliable than implementing a full demangling | 129 // much simpler and more reliable than implementing a full demangling |
130 // parser. Another substitution-in-error may occur if a type | 130 // parser. Another substitution-in-error may occur if a type |
131 // identifier ends with the pattern S[0-9A-Z]*, because an immediately | 131 // identifier ends with the pattern S[0-9A-Z]*, because an immediately |
132 // following substitution string like "S1_" or "PS1_" may be combined | 132 // following substitution string like "S1_" or "PS1_" may be combined |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 case IceType_NUM: | 378 case IceType_NUM: |
379 break; | 379 break; |
380 } | 380 } |
381 llvm_unreachable("Unknown type"); | 381 llvm_unreachable("Unknown type"); |
382 } | 382 } |
383 | 383 |
384 TimerIdT GlobalContext::getTimerID(const IceString &Name) { | 384 TimerIdT GlobalContext::getTimerID(const IceString &Name) { |
385 return TimerStack::getTimerID(Name); | 385 return TimerStack::getTimerID(Name); |
386 } | 386 } |
387 | 387 |
388 void GlobalContext::pushTimer(TimerIdT ID) { Timers->push(ID); } | 388 TimerStackIdT GlobalContext::NumTimerStackIds = GlobalContext::TSK_Num; |
389 | 389 |
390 void GlobalContext::popTimer(TimerIdT ID) { Timers->pop(ID); } | 390 TimerStackIdT GlobalContext::getTimerStackID() { return NumTimerStackIds++; } |
391 | |
392 void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { | |
393 if (Timers.size() <= StackID) | |
394 Timers.resize(StackID + 1); | |
395 Timers[StackID].push(ID); | |
396 } | |
397 | |
398 void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { | |
399 assert(Timers.size() > StackID); | |
400 Timers[StackID].pop(ID); | |
401 } | |
391 | 402 |
392 void GlobalContext::dumpStats(const IceString &Name, bool Final) { | 403 void GlobalContext::dumpStats(const IceString &Name, bool Final) { |
393 if (Flags.DumpStats) { | 404 if (Flags.DumpStats) { |
394 if (Final) { | 405 if (Final) { |
395 StatsCumulative.dump(Name, getStrDump()); | 406 StatsCumulative.dump(Name, getStrDump()); |
396 } else { | 407 } else { |
397 StatsFunction.dump(Name, getStrDump()); | 408 StatsFunction.dump(Name, getStrDump()); |
398 StatsCumulative.dump("_TOTAL_", getStrDump()); | 409 StatsCumulative.dump("_TOTAL_", getStrDump()); |
399 } | 410 } |
400 } | 411 } |
401 } | 412 } |
402 | 413 |
403 void GlobalContext::dumpTimers() { Timers->dump(getStrDump()); } | 414 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { |
415 assert(Timers.size() > StackID); | |
416 Timers[StackID].dump(getStrDump(), DumpCumulative); | |
jvoung (off chromium)
2014/10/06 16:30:56
Maybe the dump() can indicate which StackID the du
Jim Stichnoth
2014/10/06 21:29:57
Done.
| |
417 } | |
418 | |
419 TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) | |
420 : ID(ID), Ctx(Func->getContext()), | |
421 Active(Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled) { | |
422 if (Active) | |
423 Ctx->pushTimer(ID); | |
424 } | |
404 | 425 |
405 } // end of namespace Ice | 426 } // end of namespace Ice |
OLD | NEW |