Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: src/IceGlobalContext.cpp

Issue 1848303003: Simplify references to command line flags. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceGlobalInits.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /// \file 10 /// \file
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 << " MB\n"; 286 << " MB\n";
287 Str << "|" << Name << "|Liveness Memory |" << Func->getLivenessMemoryMB() 287 Str << "|" << Name << "|Liveness Memory |" << Func->getLivenessMemoryMB()
288 << " MB\n"; 288 << " MB\n";
289 } 289 }
290 } 290 }
291 291
292 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError, 292 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError,
293 ELFStreamer *ELFStr) 293 ELFStreamer *ELFStr)
294 : Strings(new StringPool()), ConstPool(new ConstantPool()), ErrorStatus(), 294 : Strings(new StringPool()), ConstPool(new ConstantPool()), ErrorStatus(),
295 StrDump(OsDump), StrEmit(OsEmit), StrError(OsError), IntrinsicsInfo(this), 295 StrDump(OsDump), StrEmit(OsEmit), StrError(OsError), IntrinsicsInfo(this),
296 ObjectWriter(), 296 ObjectWriter(), OptQ(/*Sequential=*/getFlags().isSequential(),
297 OptQ(/*Sequential=*/Flags.isSequential(), 297 /*MaxSize=*/
298 /*MaxSize=*/ 298 getFlags().isParseParallel()
299 Flags.isParseParallel() ? MaxOptQSize 299 ? MaxOptQSize
300 : Flags.getNumTranslationThreads()), 300 : getFlags().getNumTranslationThreads()),
301 // EmitQ is allowed unlimited size. 301 // EmitQ is allowed unlimited size.
302 EmitQ(/*Sequential=*/Flags.isSequential()), 302 EmitQ(/*Sequential=*/getFlags().isSequential()),
303 DataLowering(TargetDataLowering::createLowering(this)) { 303 DataLowering(TargetDataLowering::createLowering(this)) {
304 assert(OsDump && "OsDump is not defined for GlobalContext"); 304 assert(OsDump && "OsDump is not defined for GlobalContext");
305 assert(OsEmit && "OsEmit is not defined for GlobalContext"); 305 assert(OsEmit && "OsEmit is not defined for GlobalContext");
306 assert(OsError && "OsError is not defined for GlobalContext"); 306 assert(OsError && "OsError is not defined for GlobalContext");
307 // Make sure thread_local fields are properly initialized before any 307 // Make sure thread_local fields are properly initialized before any
308 // accesses are made. Do this here instead of at the start of 308 // accesses are made. Do this here instead of at the start of
309 // main() so that all clients (e.g. unit tests) can benefit for 309 // main() so that all clients (e.g. unit tests) can benefit for
310 // free. 310 // free.
311 GlobalContext::TlsInit(); 311 GlobalContext::TlsInit();
312 Cfg::TlsInit(); 312 Cfg::TlsInit();
313 Liveness::TlsInit(); 313 Liveness::TlsInit();
314 // Create a new ThreadContext for the current thread. No need to 314 // Create a new ThreadContext for the current thread. No need to
315 // lock AllThreadContexts at this point since no other threads have 315 // lock AllThreadContexts at this point since no other threads have
316 // access yet to this GlobalContext object. 316 // access yet to this GlobalContext object.
317 ThreadContext *MyTLS = new ThreadContext(); 317 ThreadContext *MyTLS = new ThreadContext();
318 AllThreadContexts.push_back(MyTLS); 318 AllThreadContexts.push_back(MyTLS);
319 ICE_TLS_SET_FIELD(TLS, MyTLS); 319 ICE_TLS_SET_FIELD(TLS, MyTLS);
320 // Pre-register built-in stack names. 320 // Pre-register built-in stack names.
321 if (BuildDefs::timers()) { 321 if (BuildDefs::timers()) {
322 // TODO(stichnot): There needs to be a strong relationship between 322 // TODO(stichnot): There needs to be a strong relationship between
323 // the newTimerStackID() return values and TSK_Default/TSK_Funcs. 323 // the newTimerStackID() return values and TSK_Default/TSK_Funcs.
324 newTimerStackID("Total across all functions"); 324 newTimerStackID("Total across all functions");
325 newTimerStackID("Per-function summary"); 325 newTimerStackID("Per-function summary");
326 } 326 }
327 Timers.initInto(MyTLS->Timers); 327 Timers.initInto(MyTLS->Timers);
328 switch (Flags.getOutFileType()) { 328 switch (getFlags().getOutFileType()) {
329 case FT_Elf: 329 case FT_Elf:
330 ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr)); 330 ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr));
331 break; 331 break;
332 case FT_Asm: 332 case FT_Asm:
333 case FT_Iasm: 333 case FT_Iasm:
334 break; 334 break;
335 } 335 }
336 // Cache up front common constants. 336 // Cache up front common constants.
337 #define X(tag, sizeLog2, align, elts, elty, str, rcstr) \ 337 #define X(tag, sizeLog2, align, elts, elty, str, rcstr) \
338 ConstZeroForType[IceType_##tag] = getConstantZeroInternal(IceType_##tag); 338 ConstZeroForType[IceType_##tag] = getConstantZeroInternal(IceType_##tag);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 void GlobalContext::saveBlockInfoPtrs() { 448 void GlobalContext::saveBlockInfoPtrs() {
449 for (VariableDeclaration *Global : Globals) { 449 for (VariableDeclaration *Global : Globals) {
450 if (Cfg::isProfileGlobal(*Global)) { 450 if (Cfg::isProfileGlobal(*Global)) {
451 ProfileBlockInfos.push_back(Global); 451 ProfileBlockInfos.push_back(Global);
452 } 452 }
453 } 453 }
454 } 454 }
455 455
456 void GlobalContext::lowerGlobals(const std::string &SectionSuffix) { 456 void GlobalContext::lowerGlobals(const std::string &SectionSuffix) {
457 TimerMarker T(TimerStack::TT_emitGlobalInitializers, this); 457 TimerMarker T(TimerStack::TT_emitGlobalInitializers, this);
458 const bool DumpGlobalVariables = BuildDefs::dump() && 458 const bool DumpGlobalVariables =
459 (Flags.getVerbose() & IceV_GlobalInit) && 459 BuildDefs::dump() && (getFlags().getVerbose() & IceV_GlobalInit) &&
460 Flags.getVerboseFocusOn().empty(); 460 getFlags().getVerboseFocusOn().empty();
461 if (DumpGlobalVariables) { 461 if (DumpGlobalVariables) {
462 OstreamLocker L(this); 462 OstreamLocker L(this);
463 Ostream &Stream = getStrDump(); 463 Ostream &Stream = getStrDump();
464 for (const Ice::VariableDeclaration *Global : Globals) { 464 for (const Ice::VariableDeclaration *Global : Globals) {
465 Global->dump(Stream); 465 Global->dump(Stream);
466 } 466 }
467 } 467 }
468 if (Flags.getDisableTranslation()) 468 if (getFlags().getDisableTranslation())
469 return; 469 return;
470 470
471 saveBlockInfoPtrs(); 471 saveBlockInfoPtrs();
472 // If we need to shuffle the layout of global variables, shuffle them now. 472 // If we need to shuffle the layout of global variables, shuffle them now.
473 if (getFlags().getReorderGlobalVariables()) { 473 if (getFlags().getReorderGlobalVariables()) {
474 // Create a random number generator for global variable reordering. 474 // Create a random number generator for global variable reordering.
475 RandomNumberGenerator RNG(getFlags().getRandomSeed(), 475 RandomNumberGenerator RNG(getFlags().getRandomSeed(),
476 RPE_GlobalVariableReordering); 476 RPE_GlobalVariableReordering);
477 RandomShuffle(Globals.begin(), Globals.end(), 477 RandomShuffle(Globals.begin(), Globals.end(),
478 [&RNG](int N) { return (uint32_t)RNG.next(N); }); 478 [&RNG](int N) { return (uint32_t)RNG.next(N); });
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 return; 672 return;
673 OstreamLocker _(this); 673 OstreamLocker _(this);
674 Ostream &Str = getStrDump(); 674 Ostream &Str = getStrDump();
675 Str << "GlobalContext strings:\n"; 675 Str << "GlobalContext strings:\n";
676 getStrings()->dump(Str); 676 getStrings()->dump(Str);
677 } 677 }
678 678
679 void GlobalContext::dumpConstantLookupCounts() { 679 void GlobalContext::dumpConstantLookupCounts() {
680 if (!BuildDefs::dump()) 680 if (!BuildDefs::dump())
681 return; 681 return;
682 const bool DumpCounts = (Flags.getVerbose() & IceV_ConstPoolStats) && 682 const bool DumpCounts = (getFlags().getVerbose() & IceV_ConstPoolStats) &&
683 Flags.getVerboseFocusOn().empty(); 683 getFlags().getVerboseFocusOn().empty();
684 if (!DumpCounts) 684 if (!DumpCounts)
685 return; 685 return;
686 686
687 OstreamLocker _(this); 687 OstreamLocker _(this);
688 Ostream &Str = getStrDump(); 688 Ostream &Str = getStrDump();
689 Str << "Constant pool use stats: count+value+type\n"; 689 Str << "Constant pool use stats: count+value+type\n";
690 #define X(WhichPool) \ 690 #define X(WhichPool) \
691 for (auto *C : getConstPool()->WhichPool.getConstantPool()) { \ 691 for (auto *C : getConstPool()->WhichPool.getConstantPool()) { \
692 Str << C->getLookupCount() << " "; \ 692 Str << C->getLookupCount() << " "; \
693 C->dump(Str); \ 693 C->dump(Str); \
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 assert(Timers->size() > StackID); 973 assert(Timers->size() > StackID);
974 OstreamLocker L(this); 974 OstreamLocker L(this);
975 Timers->at(StackID).dump(getStrDump(), DumpCumulative); 975 Timers->at(StackID).dump(getStrDump(), DumpCumulative);
976 } 976 }
977 977
978 LockedPtr<StringPool> 978 LockedPtr<StringPool>
979 GlobalStringPoolTraits::getStrings(const GlobalContext *PoolOwner) { 979 GlobalStringPoolTraits::getStrings(const GlobalContext *PoolOwner) {
980 return PoolOwner->getStrings(); 980 return PoolOwner->getStrings();
981 } 981 }
982 982
983 ClFlags GlobalContext::Flags;
984
985 TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx, 983 TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx,
986 const std::string &FuncName) { 984 const std::string &FuncName) {
987 if (!BuildDefs::timers()) 985 if (!BuildDefs::timers())
988 return 0; 986 return 0;
989 if (!Ctx->getFlags().getTimeEachFunction()) 987 if (!getFlags().getTimeEachFunction())
990 return 0; 988 return 0;
991 return Ctx->getTimerID(GlobalContext::TSK_Funcs, FuncName); 989 return Ctx->getTimerID(GlobalContext::TSK_Funcs, FuncName);
992 } 990 }
993 991
994 void TimerMarker::push() { 992 void TimerMarker::push() {
995 switch (StackID) { 993 switch (StackID) {
996 case GlobalContext::TSK_Default: 994 case GlobalContext::TSK_Default:
997 Active = Ctx->getFlags().getSubzeroTimingEnabled(); 995 Active = getFlags().getSubzeroTimingEnabled();
998 break; 996 break;
999 case GlobalContext::TSK_Funcs: 997 case GlobalContext::TSK_Funcs:
1000 Active = Ctx->getFlags().getTimeEachFunction(); 998 Active = getFlags().getTimeEachFunction();
1001 break; 999 break;
1002 default: 1000 default:
1003 break; 1001 break;
1004 } 1002 }
1005 if (Active) 1003 if (Active)
1006 Ctx->pushTimer(ID, StackID); 1004 Ctx->pushTimer(ID, StackID);
1007 } 1005 }
1008 1006
1009 void TimerMarker::pushCfg(const Cfg *Func) { 1007 void TimerMarker::pushCfg(const Cfg *Func) {
1010 Ctx = Func->getContext(); 1008 Ctx = Func->getContext();
1011 Active = 1009 Active = Func->getFocusedTiming() || getFlags().getSubzeroTimingEnabled();
1012 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled();
1013 if (Active) 1010 if (Active)
1014 Ctx->pushTimer(ID, StackID); 1011 Ctx->pushTimer(ID, StackID);
1015 } 1012 }
1016 1013
1017 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); 1014 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS);
1018 1015
1019 } // end of namespace Ice 1016 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceGlobalInits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698