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 // 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 TimerStackIdT NewID = Timers.size(); |
| 396 Timers.push_back(TimerStack(Name)); |
| 397 return NewID; |
| 398 } |
389 | 399 |
390 void GlobalContext::popTimer(TimerIdT ID) { Timers->pop(ID); } | 400 void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { |
| 401 assert(StackID < Timers.size()); |
| 402 Timers[StackID].push(ID); |
| 403 } |
| 404 |
| 405 void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { |
| 406 assert(StackID < Timers.size()); |
| 407 Timers[StackID].pop(ID); |
| 408 } |
391 | 409 |
392 void GlobalContext::dumpStats(const IceString &Name, bool Final) { | 410 void GlobalContext::dumpStats(const IceString &Name, bool Final) { |
393 if (Flags.DumpStats) { | 411 if (Flags.DumpStats) { |
394 if (Final) { | 412 if (Final) { |
395 StatsCumulative.dump(Name, getStrDump()); | 413 StatsCumulative.dump(Name, getStrDump()); |
396 } else { | 414 } else { |
397 StatsFunction.dump(Name, getStrDump()); | 415 StatsFunction.dump(Name, getStrDump()); |
398 StatsCumulative.dump("_TOTAL_", getStrDump()); | 416 StatsCumulative.dump("_TOTAL_", getStrDump()); |
399 } | 417 } |
400 } | 418 } |
401 } | 419 } |
402 | 420 |
403 void GlobalContext::dumpTimers() { Timers->dump(getStrDump()); } | 421 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { |
| 422 assert(Timers.size() > StackID); |
| 423 Timers[StackID].dump(getStrDump(), DumpCumulative); |
| 424 } |
| 425 |
| 426 TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) |
| 427 : ID(ID), Ctx(Func->getContext()), |
| 428 Active(Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled) { |
| 429 if (Active) |
| 430 Ctx->pushTimer(ID); |
| 431 } |
404 | 432 |
405 } // end of namespace Ice | 433 } // end of namespace Ice |
OLD | NEW |