Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs ---*- C++ -*-===// | 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs ---*- C++ -*-===// |
| 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 "llvm/Support/CommandLine.h" | |
| 19 | |
| 18 #include "IceDefs.h" | 20 #include "IceDefs.h" |
| 19 #include "IceTypes.h" | 21 #include "IceTypes.h" |
| 20 #include "IceCfg.h" | 22 #include "IceCfg.h" |
| 21 #include "IceGlobalContext.h" | 23 #include "IceGlobalContext.h" |
| 22 #include "IceOperand.h" | 24 #include "IceOperand.h" |
| 23 #include "IceTargetLowering.h" | 25 #include "IceTargetLowering.h" |
| 24 | 26 |
| 25 namespace Ice { | 27 namespace Ice { |
| 26 | 28 |
| 29 namespace { | |
| 30 namespace cl = llvm::cl; | |
| 31 | |
| 32 cl::opt<uint64_t> RandomSeed("random-seed", | |
| 33 cl::desc("Seed the random number generator"), | |
| 34 cl::init(1)); | |
|
Jim Stichnoth
2014/08/08 05:05:38
Can you default initialize to time(0) or something
wala
2014/08/08 16:36:13
Done.
| |
| 35 } // end anonymous namespace | |
| 36 | |
| 27 // TypePool maps constants of type KeyType (e.g. float) to pointers to | 37 // TypePool maps constants of type KeyType (e.g. float) to pointers to |
| 28 // type ValueType (e.g. ConstantFloat). KeyType values are compared | 38 // type ValueType (e.g. ConstantFloat). KeyType values are compared |
| 29 // using memcmp() because of potential NaN values in KeyType values. | 39 // using memcmp() because of potential NaN values in KeyType values. |
| 30 // KeyTypeHasFP indicates whether KeyType is a floating-point type | 40 // KeyTypeHasFP indicates whether KeyType is a floating-point type |
| 31 // whose values need to be compared using memcmp() for NaN | 41 // whose values need to be compared using memcmp() for NaN |
| 32 // correctness. TODO: use std::is_floating_point<KeyType> instead of | 42 // correctness. TODO: use std::is_floating_point<KeyType> instead of |
| 33 // KeyTypeHasFP with C++11. | 43 // KeyTypeHasFP with C++11. |
| 34 template <typename KeyType, typename ValueType, bool KeyTypeHasFP = false> | 44 template <typename KeyType, typename ValueType, bool KeyTypeHasFP = false> |
| 35 class TypePool { | 45 class TypePool { |
| 36 TypePool(const TypePool &) LLVM_DELETED_FUNCTION; | 46 TypePool(const TypePool &) LLVM_DELETED_FUNCTION; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 TypePool<RelocatableTuple, ConstantRelocatable> Relocatables; | 122 TypePool<RelocatableTuple, ConstantRelocatable> Relocatables; |
| 113 UndefPool Undefs; | 123 UndefPool Undefs; |
| 114 }; | 124 }; |
| 115 | 125 |
| 116 GlobalContext::GlobalContext(llvm::raw_ostream *OsDump, | 126 GlobalContext::GlobalContext(llvm::raw_ostream *OsDump, |
| 117 llvm::raw_ostream *OsEmit, VerboseMask Mask, | 127 llvm::raw_ostream *OsEmit, VerboseMask Mask, |
| 118 TargetArch Arch, OptLevel Opt, | 128 TargetArch Arch, OptLevel Opt, |
| 119 IceString TestPrefix) | 129 IceString TestPrefix) |
| 120 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), | 130 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), |
| 121 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), | 131 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), |
| 122 TestPrefix(TestPrefix), HasEmittedFirstMethod(false) {} | 132 TestPrefix(TestPrefix), HasEmittedFirstMethod(false), |
| 133 RNG(RandomSeed) {} | |
| 123 | 134 |
| 124 // Scan a string for S[0-9A-Z]*_ patterns and replace them with | 135 // 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 | 136 // S<num>_ where <num> is the next base-36 value. If a type name |
| 126 // legitimately contains that pattern, then the substitution will be | 137 // legitimately contains that pattern, then the substitution will be |
| 127 // made in error and most likely the link will fail. In this case, | 138 // 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 | 139 // the test classes can be rewritten not to use that pattern, which is |
| 129 // much simpler and more reliable than implementing a full demangling | 140 // much simpler and more reliable than implementing a full demangling |
| 130 // parser. Another substitution-in-error may occur if a type | 141 // parser. Another substitution-in-error may occur if a type |
| 131 // identifier ends with the pattern S[0-9A-Z]*, because an immediately | 142 // identifier ends with the pattern S[0-9A-Z]*, because an immediately |
| 132 // following substitution string like "S1_" or "PS1_" may be combined | 143 // following substitution string like "S1_" or "PS1_" may be combined |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 | 385 |
| 375 void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const { | 386 void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const { |
| 376 if (Ctx->isVerbose(IceV_Timing)) { | 387 if (Ctx->isVerbose(IceV_Timing)) { |
| 377 // Prefixing with '#' allows timing strings to be included | 388 // Prefixing with '#' allows timing strings to be included |
| 378 // without error in textual assembly output. | 389 // without error in textual assembly output. |
| 379 Ctx->getStrDump() << "# " << getElapsedUs() << " usec " << Tag << "\n"; | 390 Ctx->getStrDump() << "# " << getElapsedUs() << " usec " << Tag << "\n"; |
| 380 } | 391 } |
| 381 } | 392 } |
| 382 | 393 |
| 383 } // end of namespace Ice | 394 } // end of namespace Ice |
| OLD | NEW |