| 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 12 matching lines...) Expand all Loading... |
| 23 #include "IceTypes.h" | 23 #include "IceTypes.h" |
| 24 | 24 |
| 25 namespace Ice { | 25 namespace Ice { |
| 26 | 26 |
| 27 // TODO: Accesses to all non-const fields of GlobalContext need to | 27 // TODO: Accesses to all non-const fields of GlobalContext need to |
| 28 // be synchronized, especially the constant pool, the allocator, and | 28 // be synchronized, especially the constant pool, the allocator, and |
| 29 // the output streams. | 29 // the output streams. |
| 30 class GlobalContext { | 30 class GlobalContext { |
| 31 public: | 31 public: |
| 32 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit, | 32 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit, |
| 33 VerboseMask Mask, IceString TestPrefix); | 33 VerboseMask Mask, TargetArch Arch, OptLevel Opt, |
| 34 IceString TestPrefix); |
| 34 ~GlobalContext(); | 35 ~GlobalContext(); |
| 35 | 36 |
| 36 // Returns true if any of the specified options in the verbose mask | 37 // Returns true if any of the specified options in the verbose mask |
| 37 // are set. If the argument is omitted, it checks if any verbose | 38 // are set. If the argument is omitted, it checks if any verbose |
| 38 // options at all are set. IceV_Timing is treated specially, so | 39 // options at all are set. IceV_Timing is treated specially, so |
| 39 // that running with just IceV_Timing verbosity doesn't trigger an | 40 // that running with just IceV_Timing verbosity doesn't trigger an |
| 40 // avalanche of extra output. | 41 // avalanche of extra output. |
| 41 bool isVerbose(VerboseMask Mask = (IceV_All & ~IceV_Timing)) const { | 42 bool isVerbose(VerboseMask Mask = (IceV_All & ~IceV_Timing)) const { |
| 42 return VMask & Mask; | 43 return VMask & Mask; |
| 43 } | 44 } |
| 44 void setVerbose(VerboseMask Mask) { VMask = Mask; } | 45 void setVerbose(VerboseMask Mask) { VMask = Mask; } |
| 45 void addVerbose(VerboseMask Mask) { VMask |= Mask; } | 46 void addVerbose(VerboseMask Mask) { VMask |= Mask; } |
| 46 void subVerbose(VerboseMask Mask) { VMask &= ~Mask; } | 47 void subVerbose(VerboseMask Mask) { VMask &= ~Mask; } |
| 47 | 48 |
| 48 Ostream &getStrDump() { return StrDump; } | 49 Ostream &getStrDump() { return StrDump; } |
| 49 Ostream &getStrEmit() { return StrEmit; } | 50 Ostream &getStrEmit() { return StrEmit; } |
| 50 | 51 |
| 52 TargetArch getTargetArch() const { return Arch; } |
| 53 OptLevel getOptLevel() const { return Opt; } |
| 54 |
| 51 // When emitting assembly, we allow a string to be prepended to | 55 // When emitting assembly, we allow a string to be prepended to |
| 52 // names of translated functions. This makes it easier to create an | 56 // names of translated functions. This makes it easier to create an |
| 53 // execution test against a reference translator like llc, with both | 57 // execution test against a reference translator like llc, with both |
| 54 // translators using the same bitcode as input. | 58 // translators using the same bitcode as input. |
| 55 IceString getTestPrefix() const { return TestPrefix; } | 59 IceString getTestPrefix() const { return TestPrefix; } |
| 56 IceString mangleName(const IceString &Name) const; | 60 IceString mangleName(const IceString &Name) const; |
| 57 | 61 |
| 62 // The purpose of HasEmitted is to add a header comment at the |
| 63 // beginning of assembly code emission, doing it once per file |
| 64 // rather than once per function. |
| 65 bool testAndSetHasEmittedFirstMethod() { |
| 66 bool HasEmitted = HasEmittedFirstMethod; |
| 67 HasEmittedFirstMethod = true; |
| 68 return HasEmitted; |
| 69 } |
| 70 |
| 58 // Manage Constants. | 71 // Manage Constants. |
| 59 // getConstant*() functions are not const because they might add | 72 // getConstant*() functions are not const because they might add |
| 60 // something to the constant pool. | 73 // something to the constant pool. |
| 61 Constant *getConstantInt(Type Ty, uint64_t ConstantInt64); | 74 Constant *getConstantInt(Type Ty, uint64_t ConstantInt64); |
| 62 Constant *getConstantFloat(float Value); | 75 Constant *getConstantFloat(float Value); |
| 63 Constant *getConstantDouble(double Value); | 76 Constant *getConstantDouble(double Value); |
| 64 // Returns a symbolic constant. | 77 // Returns a symbolic constant. |
| 65 Constant *getConstantSym(Type Ty, int64_t Offset, const IceString &Name = "", | 78 Constant *getConstantSym(Type Ty, int64_t Offset, const IceString &Name = "", |
| 66 bool SuppressMangling = false); | 79 bool SuppressMangling = false); |
| 67 | 80 |
| 68 // Allocate data of type T using the global allocator. | 81 // Allocate data of type T using the global allocator. |
| 69 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } | 82 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } |
| 70 | 83 |
| 71 private: | 84 private: |
| 72 Ostream StrDump; // Stream for dumping / diagnostics | 85 Ostream StrDump; // Stream for dumping / diagnostics |
| 73 Ostream StrEmit; // Stream for code emission | 86 Ostream StrEmit; // Stream for code emission |
| 74 | 87 |
| 75 llvm::BumpPtrAllocator Allocator; | 88 llvm::BumpPtrAllocator Allocator; |
| 76 VerboseMask VMask; | 89 VerboseMask VMask; |
| 77 llvm::OwningPtr<class ConstantPool> ConstPool; | 90 llvm::OwningPtr<class ConstantPool> ConstPool; |
| 91 const TargetArch Arch; |
| 92 const OptLevel Opt; |
| 78 const IceString TestPrefix; | 93 const IceString TestPrefix; |
| 94 bool HasEmittedFirstMethod; |
| 79 GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION; | 95 GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION; |
| 80 GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION; | 96 GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION; |
| 81 }; | 97 }; |
| 82 | 98 |
| 83 } // end of namespace Ice | 99 } // end of namespace Ice |
| 84 | 100 |
| 85 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 101 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| OLD | NEW |