| 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 |
| 11 // multiple functions. | 11 // multiple functions. |
| 12 // | 12 // |
| 13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
| 14 | 14 |
| 15 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H | 15 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| 16 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H | 16 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| 17 | 17 |
| 18 #include <memory> | 18 #include <memory> |
| 19 | 19 |
| 20 #include "llvm/Support/Allocator.h" | 20 #include "llvm/Support/Allocator.h" |
| 21 #include "llvm/Support/raw_ostream.h" | |
| 22 | 21 |
| 23 #include "IceDefs.h" | 22 #include "IceDefs.h" |
| 24 #include "IceClFlags.h" | 23 #include "IceClFlags.h" |
| 24 #include "IceELFObjectWriter.h" |
| 25 #include "IceIntrinsics.h" | 25 #include "IceIntrinsics.h" |
| 26 #include "IceRNG.h" | 26 #include "IceRNG.h" |
| 27 #include "IceTimerTree.h" | 27 #include "IceTimerTree.h" |
| 28 #include "IceTypes.h" | 28 #include "IceTypes.h" |
| 29 | 29 |
| 30 namespace Ice { | 30 namespace Ice { |
| 31 | 31 |
| 32 class ClFlags; | 32 class ClFlags; |
| 33 class FuncSigType; | 33 class FuncSigType; |
| 34 | 34 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // TODO: Accesses to all non-const fields of GlobalContext need to | 69 // TODO: Accesses to all non-const fields of GlobalContext need to |
| 70 // be synchronized, especially the constant pool, the allocator, and | 70 // be synchronized, especially the constant pool, the allocator, and |
| 71 // the output streams. | 71 // the output streams. |
| 72 class GlobalContext { | 72 class GlobalContext { |
| 73 GlobalContext(const GlobalContext &) = delete; | 73 GlobalContext(const GlobalContext &) = delete; |
| 74 GlobalContext &operator=(const GlobalContext &) = delete; | 74 GlobalContext &operator=(const GlobalContext &) = delete; |
| 75 | 75 |
| 76 public: | 76 public: |
| 77 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit, | 77 GlobalContext(Ostream *OsDump, Ostream *OsEmit, ELFStreamer *ELFStreamer, |
| 78 VerboseMask Mask, TargetArch Arch, OptLevel Opt, | 78 VerboseMask Mask, TargetArch Arch, OptLevel Opt, |
| 79 IceString TestPrefix, const ClFlags &Flags); | 79 IceString TestPrefix, const ClFlags &Flags); |
| 80 ~GlobalContext(); | 80 ~GlobalContext(); |
| 81 | 81 |
| 82 // Returns true if any of the specified options in the verbose mask | 82 // Returns true if any of the specified options in the verbose mask |
| 83 // are set. If the argument is omitted, it checks if any verbose | 83 // are set. If the argument is omitted, it checks if any verbose |
| 84 // options at all are set. | 84 // options at all are set. |
| 85 VerboseMask getVerbose() const { return VMask; } | 85 VerboseMask getVerbose() const { return VMask; } |
| 86 bool isVerbose(VerboseMask Mask = IceV_All) const { return VMask & Mask; } | 86 bool isVerbose(VerboseMask Mask = IceV_All) const { return VMask & Mask; } |
| 87 void setVerbose(VerboseMask Mask) { VMask = Mask; } | 87 void setVerbose(VerboseMask Mask) { VMask = Mask; } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 // Allocate data of type T using the global allocator. | 152 // Allocate data of type T using the global allocator. |
| 153 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } | 153 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } |
| 154 | 154 |
| 155 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } | 155 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } |
| 156 | 156 |
| 157 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded | 157 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded |
| 158 // translation. | 158 // translation. |
| 159 RandomNumberGenerator &getRNG() { return RNG; } | 159 RandomNumberGenerator &getRNG() { return RNG; } |
| 160 | 160 |
| 161 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); } |
| 162 |
| 161 // Reset stats at the beginning of a function. | 163 // Reset stats at the beginning of a function. |
| 162 void resetStats() { StatsFunction.reset(); } | 164 void resetStats() { StatsFunction.reset(); } |
| 163 void dumpStats(const IceString &Name, bool Final = false); | 165 void dumpStats(const IceString &Name, bool Final = false); |
| 164 void statsUpdateEmitted(uint32_t InstCount) { | 166 void statsUpdateEmitted(uint32_t InstCount) { |
| 165 StatsFunction.updateEmitted(InstCount); | 167 StatsFunction.updateEmitted(InstCount); |
| 166 StatsCumulative.updateEmitted(InstCount); | 168 StatsCumulative.updateEmitted(InstCount); |
| 167 } | 169 } |
| 168 void statsUpdateRegistersSaved(uint32_t Num) { | 170 void statsUpdateRegistersSaved(uint32_t Num) { |
| 169 StatsFunction.updateRegistersSaved(Num); | 171 StatsFunction.updateRegistersSaved(Num); |
| 170 StatsCumulative.updateRegistersSaved(Num); | 172 StatsCumulative.updateRegistersSaved(Num); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 1024 * 1024> Allocator; | 207 llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 1024 * 1024> Allocator; |
| 206 VerboseMask VMask; | 208 VerboseMask VMask; |
| 207 std::unique_ptr<class ConstantPool> ConstPool; | 209 std::unique_ptr<class ConstantPool> ConstPool; |
| 208 Intrinsics IntrinsicsInfo; | 210 Intrinsics IntrinsicsInfo; |
| 209 const TargetArch Arch; | 211 const TargetArch Arch; |
| 210 const OptLevel Opt; | 212 const OptLevel Opt; |
| 211 const IceString TestPrefix; | 213 const IceString TestPrefix; |
| 212 const ClFlags &Flags; | 214 const ClFlags &Flags; |
| 213 bool HasEmittedFirstMethod; | 215 bool HasEmittedFirstMethod; |
| 214 RandomNumberGenerator RNG; | 216 RandomNumberGenerator RNG; |
| 217 std::unique_ptr<ELFObjectWriter> ObjectWriter; |
| 215 CodeStats StatsFunction; | 218 CodeStats StatsFunction; |
| 216 CodeStats StatsCumulative; | 219 CodeStats StatsCumulative; |
| 217 std::vector<TimerStack> Timers; | 220 std::vector<TimerStack> Timers; |
| 218 std::vector<GlobalDeclaration *> GlobalDeclarations; | 221 std::vector<GlobalDeclaration *> GlobalDeclarations; |
| 219 | 222 |
| 220 // Private helpers for mangleName() | 223 // Private helpers for mangleName() |
| 221 typedef llvm::SmallVector<char, 32> ManglerVector; | 224 typedef llvm::SmallVector<char, 32> ManglerVector; |
| 222 void incrementSubstitutions(ManglerVector &OldName) const; | 225 void incrementSubstitutions(ManglerVector &OldName) const; |
| 223 }; | 226 }; |
| 224 | 227 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 244 | 247 |
| 245 private: | 248 private: |
| 246 TimerIdT ID; | 249 TimerIdT ID; |
| 247 GlobalContext *const Ctx; | 250 GlobalContext *const Ctx; |
| 248 const bool Active; | 251 const bool Active; |
| 249 }; | 252 }; |
| 250 | 253 |
| 251 } // end of namespace Ice | 254 } // end of namespace Ice |
| 252 | 255 |
| 253 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 256 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| OLD | NEW |