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