Chromium Code Reviews| Index: src/IceGlobalContext.cpp |
| diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp |
| index 74dfb9ecebd7c29797960fd13498721b6fa31dc7..d7fb59738b6a8bd65791344ba2e02e9db1084007 100644 |
| --- a/src/IceGlobalContext.cpp |
| +++ b/src/IceGlobalContext.cpp |
| @@ -131,7 +131,9 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, |
| IceString TestPrefix, const ClFlags &Flags) |
| : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), |
| ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), |
| - TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter() { |
| + TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter(), |
| + CfgQ(Flags.NumTranslationThreads, (Flags.NumTranslationThreads == 0)), |
|
JF
2015/01/23 17:22:43
Add /*MaxSize=*/ and /*Sequential=*/ here.
Jim Stichnoth
2015/01/23 21:54:02
Nice, done.
|
| + ErrorStatus() { |
| // Create a new ThreadContext for the current thread. No need to |
| // lock AllThreadContexts at this point since no other threads have |
| // access yet to this GlobalContext object. |
| @@ -149,6 +151,43 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, |
| } |
| } |
| +void GlobalContext::translateFunctions() { |
| + while (Cfg *Func = cfgQueueGet()) { |
| + // Reset per-function stats being accumulated in TLS. |
| + resetStats(); |
| + // Install Func in TLS for Cfg-specific container allocators. |
| + Func->updateTLS(); |
| + // Set verbose level to none if the current function does NOT |
| + // match the -verbose-focus command-line option. |
| + if (!matchSymbolName(Func->getFunctionName(), getFlags().VerboseFocusOn)) |
| + Func->setVerbose(IceV_None); |
| + // Disable translation if -notranslate is specified, or if the |
| + // current function matches the -translate-only option. If |
| + // translation is disabled, just dump the high-level IR and |
| + // continue. |
| + if (getFlags().DisableTranslation || |
| + !matchSymbolName(Func->getFunctionName(), getFlags().TranslateOnly)) { |
| + Func->dump(); |
| + } else { |
| + Func->translate(); |
| + if (Func->hasError()) { |
| + OstreamLocker L(this); |
| + getStrDump() << "ICE translation error: " << Func->getError() << "\n"; |
| + ErrorStatus.assign(1, std::generic_category()); |
| + } else { |
| + if (getFlags().UseIntegratedAssembler) |
| + Func->emitIAS(); |
| + else |
| + Func->emit(); |
| + // TODO(stichnot): actually add to emit queue |
| + } |
| + // TODO(stichnot): fix multithreaded stats dumping. |
| + dumpStats(Func->getFunctionName()); |
| + } |
| + delete Func; |
| + } |
| +} |
| + |
| // Scan a string for S[0-9A-Z]*_ patterns and replace them with |
| // S<num>_ where <num> is the next base-36 value. If a type name |
| // legitimately contains that pattern, then the substitution will be |
| @@ -464,12 +503,18 @@ TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, |
| } |
| void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { |
| + // TODO(stichnot): Timers are completely broken for multithreading; fix. |
| + if (getFlags().NumTranslationThreads) |
| + llvm::report_fatal_error("Timers and multithreading are currently broken"); |
| auto Timers = getTimers(); |
| assert(StackID < Timers->size()); |
| Timers->at(StackID).push(ID); |
| } |
| void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { |
| + // TODO(stichnot): Timers are completely broken for multithreading; fix. |
| + if (getFlags().NumTranslationThreads) |
| + llvm::report_fatal_error("Timers and multithreading are currently broken"); |
| auto Timers = getTimers(); |
| assert(StackID < Timers->size()); |
| Timers->at(StackID).pop(ID); |