| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // internal memory pool. Ownership of the function is maintained by | 140 // internal memory pool. Ownership of the function is maintained by |
| 140 // this class instance. | 141 // this class instance. |
| 141 VariableDeclaration *newVariableDeclaration(); | 142 VariableDeclaration *newVariableDeclaration(); |
| 142 | 143 |
| 143 const ClFlags &getFlags() const { return Flags; } | 144 const ClFlags &getFlags() const { return Flags; } |
| 144 | 145 |
| 145 bool isIRGenerationDisabled() const { | 146 bool isIRGenerationDisabled() const { |
| 146 return ALLOW_DISABLE_IR_GEN ? getFlags().DisableIRGeneration : false; | 147 return ALLOW_DISABLE_IR_GEN ? getFlags().DisableIRGeneration : false; |
| 147 } | 148 } |
| 148 | 149 |
| 149 // Allocate data of type T using the global allocator. | 150 // Allocate one instance of data of type T using the global allocator. |
| 150 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } | 151 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } |
| 151 | 152 |
| 153 // Allocate an N element array of data of bytes using the global allocator. |
| 154 template uint8_t *allocateBytes(size_t N, size_t Align) { |
| 155 return reinterpret_cast<uint8_t *>(Allocator.Allocate(N, Align)); |
| 156 } |
| 157 |
| 152 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } | 158 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } |
| 153 | 159 |
| 154 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded | 160 // TODO(wala,stichnot): Make the RNG play nicely with multithreaded |
| 155 // translation. | 161 // translation. |
| 156 RandomNumberGenerator &getRNG() { return RNG; } | 162 RandomNumberGenerator &getRNG() { return RNG; } |
| 157 | 163 |
| 164 ELFObjectWriter *getObjectWriter() const { return ObjectWriter.get(); } |
| 165 |
| 166 const GlobalDeclarationList &getGlobalDeclarations() const { |
| 167 return GlobalDeclarations; |
| 168 } |
| 169 |
| 158 // Reset stats at the beginning of a function. | 170 // Reset stats at the beginning of a function. |
| 159 void resetStats() { StatsFunction.reset(); } | 171 void resetStats() { StatsFunction.reset(); } |
| 160 void dumpStats(const IceString &Name, bool Final = false); | 172 void dumpStats(const IceString &Name, bool Final = false); |
| 161 void statsUpdateEmitted(uint32_t InstCount) { | 173 void statsUpdateEmitted(uint32_t InstCount) { |
| 162 StatsFunction.updateEmitted(InstCount); | 174 StatsFunction.updateEmitted(InstCount); |
| 163 StatsCumulative.updateEmitted(InstCount); | 175 StatsCumulative.updateEmitted(InstCount); |
| 164 } | 176 } |
| 165 void statsUpdateRegistersSaved(uint32_t Num) { | 177 void statsUpdateRegistersSaved(uint32_t Num) { |
| 166 StatsFunction.updateRegistersSaved(Num); | 178 StatsFunction.updateRegistersSaved(Num); |
| 167 StatsCumulative.updateRegistersSaved(Num); | 179 StatsCumulative.updateRegistersSaved(Num); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 llvm::BumpPtrAllocator Allocator; | 214 llvm::BumpPtrAllocator Allocator; |
| 203 VerboseMask VMask; | 215 VerboseMask VMask; |
| 204 std::unique_ptr<class ConstantPool> ConstPool; | 216 std::unique_ptr<class ConstantPool> ConstPool; |
| 205 Intrinsics IntrinsicsInfo; | 217 Intrinsics IntrinsicsInfo; |
| 206 const TargetArch Arch; | 218 const TargetArch Arch; |
| 207 const OptLevel Opt; | 219 const OptLevel Opt; |
| 208 const IceString TestPrefix; | 220 const IceString TestPrefix; |
| 209 const ClFlags &Flags; | 221 const ClFlags &Flags; |
| 210 bool HasEmittedFirstMethod; | 222 bool HasEmittedFirstMethod; |
| 211 RandomNumberGenerator RNG; | 223 RandomNumberGenerator RNG; |
| 224 std::unique_ptr<ELFObjectWriter> ObjectWriter; |
| 212 CodeStats StatsFunction; | 225 CodeStats StatsFunction; |
| 213 CodeStats StatsCumulative; | 226 CodeStats StatsCumulative; |
| 214 std::vector<TimerStack> Timers; | 227 std::vector<TimerStack> Timers; |
| 215 std::vector<GlobalDeclaration *> GlobalDeclarations; | 228 GlobalDeclarationList GlobalDeclarations; |
| 216 | 229 |
| 217 // Private helpers for mangleName() | 230 // Private helpers for mangleName() |
| 218 typedef llvm::SmallVector<char, 32> ManglerVector; | 231 typedef llvm::SmallVector<char, 32> ManglerVector; |
| 219 void incrementSubstitutions(ManglerVector &OldName) const; | 232 void incrementSubstitutions(ManglerVector &OldName) const; |
| 220 }; | 233 }; |
| 221 | 234 |
| 222 // Helper class to push and pop a timer marker. The constructor | 235 // Helper class to push and pop a timer marker. The constructor |
| 223 // pushes a marker, and the destructor pops it. This is for | 236 // pushes a marker, and the destructor pops it. This is for |
| 224 // convenient timing of regions of code. | 237 // convenient timing of regions of code. |
| 225 class TimerMarker { | 238 class TimerMarker { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 241 | 254 |
| 242 private: | 255 private: |
| 243 TimerIdT ID; | 256 TimerIdT ID; |
| 244 GlobalContext *const Ctx; | 257 GlobalContext *const Ctx; |
| 245 const bool Active; | 258 const bool Active; |
| 246 }; | 259 }; |
| 247 | 260 |
| 248 } // end of namespace Ice | 261 } // end of namespace Ice |
| 249 | 262 |
| 250 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 263 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| OLD | NEW |