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

Side by Side Diff: src/IceGlobalContext.cpp

Issue 610813002: Subzero: Rewrite the pass timing infrastructure. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix the problem timing parse() Created 6 years, 2 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
OLDNEW
1 //===- subzero/src/IceGlobalContext.cpp - Global context defs ---*- C++ -*-===// 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
11 // multiple functions. 11 // multiple functions.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include <ctype.h> // isdigit(), isupper() 15 #include <ctype.h> // isdigit(), isupper()
16 #include <locale> // locale 16 #include <locale> // locale
17 17
18 #include "IceDefs.h" 18 #include "IceDefs.h"
19 #include "IceTypes.h" 19 #include "IceTypes.h"
20 #include "IceCfg.h" 20 #include "IceCfg.h"
21 #include "IceClFlags.h" 21 #include "IceClFlags.h"
22 #include "IceGlobalContext.h" 22 #include "IceGlobalContext.h"
23 #include "IceOperand.h" 23 #include "IceOperand.h"
24 #include "IceTargetLowering.h" 24 #include "IceTargetLowering.h"
25 #include "IceTimerTree.h"
25 26
26 namespace Ice { 27 namespace Ice {
27 28
28 // TypePool maps constants of type KeyType (e.g. float) to pointers to 29 // TypePool maps constants of type KeyType (e.g. float) to pointers to
29 // type ValueType (e.g. ConstantFloat). KeyType values are compared 30 // type ValueType (e.g. ConstantFloat). KeyType values are compared
30 // using memcmp() because of potential NaN values in KeyType values. 31 // using memcmp() because of potential NaN values in KeyType values.
31 // KeyTypeHasFP indicates whether KeyType is a floating-point type 32 // KeyTypeHasFP indicates whether KeyType is a floating-point type
32 // whose values need to be compared using memcmp() for NaN 33 // whose values need to be compared using memcmp() for NaN
33 // correctness. TODO: use std::is_floating_point<KeyType> instead of 34 // correctness. TODO: use std::is_floating_point<KeyType> instead of
34 // KeyTypeHasFP with C++11. 35 // KeyTypeHasFP with C++11.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 UndefPool Undefs; 116 UndefPool Undefs;
116 }; 117 };
117 118
118 GlobalContext::GlobalContext(llvm::raw_ostream *OsDump, 119 GlobalContext::GlobalContext(llvm::raw_ostream *OsDump,
119 llvm::raw_ostream *OsEmit, VerboseMask Mask, 120 llvm::raw_ostream *OsEmit, VerboseMask Mask,
120 TargetArch Arch, OptLevel Opt, 121 TargetArch Arch, OptLevel Opt,
121 IceString TestPrefix, const ClFlags &Flags) 122 IceString TestPrefix, const ClFlags &Flags)
122 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), 123 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask),
123 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), 124 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt),
124 TestPrefix(TestPrefix), Flags(Flags), HasEmittedFirstMethod(false), 125 TestPrefix(TestPrefix), Flags(Flags), HasEmittedFirstMethod(false),
125 RNG("") {} 126 RNG(""), Timers(new TimerStack("main")) {}
126 127
127 // 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
128 // 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
129 // legitimately contains that pattern, then the substitution will be 130 // legitimately contains that pattern, then the substitution will be
130 // 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,
131 // 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
132 // much simpler and more reliable than implementing a full demangling 133 // much simpler and more reliable than implementing a full demangling
133 // parser. Another substitution-in-error may occur if a type 134 // parser. Another substitution-in-error may occur if a type
134 // 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
135 // 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
377 BaseOS << "Unsupported constant type: " << Ty; 378 BaseOS << "Unsupported constant type: " << Ty;
378 llvm_unreachable(BaseOS.str().c_str()); 379 llvm_unreachable(BaseOS.str().c_str());
379 } break; 380 } break;
380 case IceType_void: 381 case IceType_void:
381 case IceType_NUM: 382 case IceType_NUM:
382 break; 383 break;
383 } 384 }
384 llvm_unreachable("Unknown type"); 385 llvm_unreachable("Unknown type");
385 } 386 }
386 387
388 TimerIdT GlobalContext::getTimerID(const IceString &Name) {
389 return TimerStack::getTimerID(Name);
390 }
391
392 void GlobalContext::pushTimer(TimerIdT ID) { Timers.get()->push(ID); }
jvoung (off chromium) 2014/09/30 20:19:04 Could use the operator-> instead of get()-> -- I d
Jim Stichnoth 2014/09/30 22:45:59 Done.
393
394 void GlobalContext::popTimer(TimerIdT ID) { Timers.get()->pop(ID); }
395
387 void GlobalContext::dumpStats(const IceString &Name, bool Final) { 396 void GlobalContext::dumpStats(const IceString &Name, bool Final) {
388 if (Flags.DumpStats) { 397 if (Flags.DumpStats) {
389 if (Final) { 398 if (Final) {
390 StatsCumulative.dump(Name, getStrDump()); 399 StatsCumulative.dump(Name, getStrDump());
391 } else { 400 } else {
392 StatsFunction.dump(Name, getStrDump()); 401 StatsFunction.dump(Name, getStrDump());
393 StatsCumulative.dump("_TOTAL_", getStrDump()); 402 StatsCumulative.dump("_TOTAL_", getStrDump());
394 } 403 }
395 } 404 }
396 } 405 }
397 406
398 void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const { 407 void GlobalContext::dumpTimers() { Timers.get()->dump(getStrDump()); }
399 if (Ctx->isVerbose(IceV_Timing)) {
400 // Prefixing with '#' allows timing strings to be included
401 // without error in textual assembly output.
402 Ctx->getStrDump() << "# " << getElapsedUs() << " usec " << Tag << "\n";
403 }
404 }
405 408
406 } // end of namespace Ice 409 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698