Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===// | 1 //===- subzero/src/IceGlobalContext.h - 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 declares aspects of the compilation that persist across | 10 // This file declares aspects of the compilation that persist across |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 #include "IceDefs.h" | 22 #include "IceDefs.h" |
| 23 #include "IceIntrinsics.h" | 23 #include "IceIntrinsics.h" |
| 24 #include "IceRNG.h" | 24 #include "IceRNG.h" |
| 25 #include "IceTypes.h" | 25 #include "IceTypes.h" |
| 26 | 26 |
| 27 namespace Ice { | 27 namespace Ice { |
| 28 | 28 |
| 29 class ClFlags; | 29 class ClFlags; |
| 30 | 30 |
| 31 // This class collects rudimentary statistics during translation. | |
| 32 class CodeStats { | |
| 33 public: | |
| 34 CodeStats() | |
| 35 : InstructionsEmitted(0), RegistersSaved(0), FrameBytes(0), Spills(0), | |
| 36 Fills(0), SpillsPlusFills(0) {} | |
| 37 void reset() { *this = CodeStats(); } | |
| 38 void updateEmitted(uint32_t InstCount) { InstructionsEmitted += InstCount; } | |
| 39 void updateRegistersSaved(uint32_t Num) { RegistersSaved += Num; } | |
| 40 void updateFrameBytes(uint32_t Bytes) { FrameBytes += Bytes; } | |
| 41 void updateSpills() { | |
| 42 ++Spills; | |
| 43 ++SpillsPlusFills; | |
| 44 } | |
| 45 void updateFills() { | |
| 46 ++Fills; | |
| 47 ++SpillsPlusFills; | |
| 48 } | |
| 49 void dump(const IceString &Name, Ostream &Str) { | |
| 50 Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n"; | |
| 51 Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n"; | |
| 52 Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n"; | |
| 53 Str << "|" << Name << "|Spills |" << Spills << "\n"; | |
| 54 Str << "|" << Name << "|Fills |" << Fills << "\n"; | |
| 55 Str << "|" << Name << "|Spills+Fills|" << SpillsPlusFills << "\n"; | |
|
jvoung (off chromium)
2014/09/17 01:21:12
nit: Seems like this could have been Spills + Fill
Jim Stichnoth
2014/09/17 02:57:06
True! Done.
| |
| 56 } | |
| 57 | |
| 58 private: | |
| 59 uint32_t InstructionsEmitted; | |
| 60 uint32_t RegistersSaved; | |
| 61 uint32_t FrameBytes; | |
| 62 uint32_t Spills; | |
| 63 uint32_t Fills; | |
| 64 uint32_t SpillsPlusFills; | |
| 65 }; | |
| 66 | |
| 31 // TODO: Accesses to all non-const fields of GlobalContext need to | 67 // TODO: Accesses to all non-const fields of GlobalContext need to |
| 32 // be synchronized, especially the constant pool, the allocator, and | 68 // be synchronized, especially the constant pool, the allocator, and |
| 33 // the output streams. | 69 // the output streams. |
| 34 class GlobalContext { | 70 class GlobalContext { |
| 35 public: | 71 public: |
| 36 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit, | 72 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit, |
| 37 VerboseMask Mask, TargetArch Arch, OptLevel Opt, | 73 VerboseMask Mask, TargetArch Arch, OptLevel Opt, |
| 38 IceString TestPrefix, const ClFlags &Flags); | 74 IceString TestPrefix, const ClFlags &Flags); |
| 39 ~GlobalContext(); | 75 ~GlobalContext(); |
| 40 | 76 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 | 129 |
| 94 // Allocate data of type T using the global allocator. | 130 // Allocate data of type T using the global allocator. |
| 95 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } | 131 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } |
| 96 | 132 |
| 97 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } | 133 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } |
| 98 | 134 |
| 99 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded | 135 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded |
| 100 // translation. | 136 // translation. |
| 101 RandomNumberGenerator &getRNG() { return RNG; } | 137 RandomNumberGenerator &getRNG() { return RNG; } |
| 102 | 138 |
| 139 // Reset stats at the beginning of a function. | |
| 140 void resetStats() { StatsFunction.reset(); } | |
| 141 void dumpStats(const IceString &Name); | |
| 142 void statsUpdateEmitted(uint32_t InstCount) { | |
| 143 StatsFunction.updateEmitted(InstCount); | |
| 144 StatsCumulative.updateEmitted(InstCount); | |
| 145 } | |
| 146 void statsUpdateRegistersSaved(uint32_t Num) { | |
| 147 StatsFunction.updateRegistersSaved(Num); | |
| 148 StatsCumulative.updateRegistersSaved(Num); | |
| 149 } | |
| 150 void statsUpdateFrameBytes(uint32_t Bytes) { | |
| 151 StatsFunction.updateFrameBytes(Bytes); | |
| 152 StatsCumulative.updateFrameBytes(Bytes); | |
| 153 } | |
| 154 void statsUpdateSpills() { | |
| 155 StatsFunction.updateSpills(); | |
| 156 StatsCumulative.updateSpills(); | |
| 157 } | |
| 158 void statsUpdateFills() { | |
| 159 StatsFunction.updateFills(); | |
| 160 StatsCumulative.updateFills(); | |
| 161 } | |
| 162 | |
| 103 private: | 163 private: |
| 104 Ostream *StrDump; // Stream for dumping / diagnostics | 164 Ostream *StrDump; // Stream for dumping / diagnostics |
| 105 Ostream *StrEmit; // Stream for code emission | 165 Ostream *StrEmit; // Stream for code emission |
| 106 | 166 |
| 107 llvm::BumpPtrAllocator Allocator; | 167 llvm::BumpPtrAllocator Allocator; |
| 108 VerboseMask VMask; | 168 VerboseMask VMask; |
| 109 llvm::OwningPtr<class ConstantPool> ConstPool; | 169 llvm::OwningPtr<class ConstantPool> ConstPool; |
| 110 Intrinsics IntrinsicsInfo; | 170 Intrinsics IntrinsicsInfo; |
| 111 const TargetArch Arch; | 171 const TargetArch Arch; |
| 112 const OptLevel Opt; | 172 const OptLevel Opt; |
| 113 const IceString TestPrefix; | 173 const IceString TestPrefix; |
| 114 const ClFlags &Flags; | 174 const ClFlags &Flags; |
| 115 bool HasEmittedFirstMethod; | 175 bool HasEmittedFirstMethod; |
| 116 RandomNumberGenerator RNG; | 176 RandomNumberGenerator RNG; |
| 177 CodeStats StatsFunction; | |
| 178 CodeStats StatsCumulative; | |
| 117 GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION; | 179 GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION; |
| 118 GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION; | 180 GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION; |
| 119 | 181 |
| 120 // Private helpers for mangleName() | 182 // Private helpers for mangleName() |
| 121 typedef llvm::SmallVector<char, 32> ManglerVector; | 183 typedef llvm::SmallVector<char, 32> ManglerVector; |
| 122 void incrementSubstitutions(ManglerVector &OldName) const; | 184 void incrementSubstitutions(ManglerVector &OldName) const; |
| 123 }; | 185 }; |
| 124 | 186 |
| 125 } // end of namespace Ice | 187 } // end of namespace Ice |
| 126 | 188 |
| 127 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 189 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| OLD | NEW |