Chromium Code Reviews| 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(""), NumTimerStackIds(0) { |
| 123 // Pre-register built-in stack names. | |
| 124 newTimerStackID("Total across all functions"); | |
| 125 newTimerStackID("Per-function summary"); | |
| 126 } | |
| 123 | 127 |
| 124 // Scan a string for S[0-9A-Z]*_ patterns and replace them with | 128 // 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 | 129 // S<num>_ where <num> is the next base-36 value. If a type name |
| 126 // legitimately contains that pattern, then the substitution will be | 130 // legitimately contains that pattern, then the substitution will be |
| 127 // made in error and most likely the link will fail. In this case, | 131 // 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 | 132 // the test classes can be rewritten not to use that pattern, which is |
| 129 // much simpler and more reliable than implementing a full demangling | 133 // much simpler and more reliable than implementing a full demangling |
| 130 // parser. Another substitution-in-error may occur if a type | 134 // parser. Another substitution-in-error may occur if a type |
| 131 // identifier ends with the pattern S[0-9A-Z]*, because an immediately | 135 // identifier ends with the pattern S[0-9A-Z]*, because an immediately |
| 132 // following substitution string like "S1_" or "PS1_" may be combined | 136 // following substitution string like "S1_" or "PS1_" may be combined |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 BaseOS << "Unsupported constant type: " << Ty; | 378 BaseOS << "Unsupported constant type: " << Ty; |
| 375 llvm_unreachable(BaseOS.str().c_str()); | 379 llvm_unreachable(BaseOS.str().c_str()); |
| 376 } break; | 380 } break; |
| 377 case IceType_void: | 381 case IceType_void: |
| 378 case IceType_NUM: | 382 case IceType_NUM: |
| 379 break; | 383 break; |
| 380 } | 384 } |
| 381 llvm_unreachable("Unknown type"); | 385 llvm_unreachable("Unknown type"); |
| 382 } | 386 } |
| 383 | 387 |
| 384 TimerIdT GlobalContext::getTimerID(const IceString &Name) { | 388 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, |
| 385 return TimerStack::getTimerID(Name); | 389 const IceString &Name) { |
| 390 assert(StackID < Timers.size()); | |
| 391 return Timers[StackID].getTimerID(Name); | |
| 386 } | 392 } |
| 387 | 393 |
| 388 void GlobalContext::pushTimer(TimerIdT ID) { Timers->push(ID); } | 394 TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) { |
| 395 Timers.push_back(TimerStack(Name)); | |
| 396 return NumTimerStackIds++; | |
|
jvoung (off chromium)
2014/10/06 23:01:52
Could this just use Timers.size() (or return void)
Jim Stichnoth
2014/10/06 23:54:39
Done (and removed the NumTimerStackIds field entir
| |
| 397 } | |
| 389 | 398 |
| 390 void GlobalContext::popTimer(TimerIdT ID) { Timers->pop(ID); } | 399 void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { |
| 400 assert(StackID < Timers.size()); | |
| 401 Timers[StackID].push(ID); | |
| 402 } | |
| 403 | |
| 404 void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { | |
| 405 assert(StackID < Timers.size()); | |
| 406 Timers[StackID].pop(ID); | |
| 407 } | |
| 391 | 408 |
| 392 void GlobalContext::dumpStats(const IceString &Name, bool Final) { | 409 void GlobalContext::dumpStats(const IceString &Name, bool Final) { |
| 393 if (Flags.DumpStats) { | 410 if (Flags.DumpStats) { |
| 394 if (Final) { | 411 if (Final) { |
| 395 StatsCumulative.dump(Name, getStrDump()); | 412 StatsCumulative.dump(Name, getStrDump()); |
| 396 } else { | 413 } else { |
| 397 StatsFunction.dump(Name, getStrDump()); | 414 StatsFunction.dump(Name, getStrDump()); |
| 398 StatsCumulative.dump("_TOTAL_", getStrDump()); | 415 StatsCumulative.dump("_TOTAL_", getStrDump()); |
| 399 } | 416 } |
| 400 } | 417 } |
| 401 } | 418 } |
| 402 | 419 |
| 403 void GlobalContext::dumpTimers() { Timers->dump(getStrDump()); } | 420 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { |
| 421 assert(Timers.size() > StackID); | |
| 422 Timers[StackID].dump(getStrDump(), DumpCumulative); | |
| 423 } | |
| 424 | |
| 425 TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) | |
| 426 : ID(ID), Ctx(Func->getContext()), | |
| 427 Active(Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled) { | |
| 428 if (Active) | |
| 429 Ctx->pushTimer(ID); | |
| 430 } | |
| 404 | 431 |
| 405 } // end of namespace Ice | 432 } // end of namespace Ice |
| OLD | NEW |