OLD | NEW |
(Empty) | |
| 1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===// |
| 2 // |
| 3 // The Subzero Code Generator |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 // |
| 10 // This file declares aspects of the compilation that persist across |
| 11 // multiple functions. |
| 12 // |
| 13 //===----------------------------------------------------------------------===// |
| 14 |
| 15 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| 16 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| 17 |
| 18 #include "llvm/ADT/OwningPtr.h" |
| 19 #include "llvm/Support/Allocator.h" |
| 20 #include "llvm/Support/raw_ostream.h" |
| 21 |
| 22 #include "IceDefs.h" |
| 23 #include "IceTypes.h" |
| 24 |
| 25 namespace Ice { |
| 26 |
| 27 // TODO: Accesses to all non-const fields of GlobalContext need to |
| 28 // be synchronized, especially the constant pool, the allocator, and |
| 29 // the output streams. |
| 30 class GlobalContext { |
| 31 public: |
| 32 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit, |
| 33 IceVerboseMask VerboseMask, IceString TestPrefix); |
| 34 ~GlobalContext(); |
| 35 |
| 36 // 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 // options at all are set. IceV_Timing is treated specially, so |
| 39 // that running with just IceV_Timing verbosity doesn't trigger an |
| 40 // avalanche of extra output. |
| 41 bool isVerbose(IceVerboseMask Mask = (IceV_All & ~IceV_Timing)) const { |
| 42 return VerboseMask & Mask; |
| 43 } |
| 44 void setVerbose(IceVerboseMask Mask) { VerboseMask = Mask; } |
| 45 void addVerbose(IceVerboseMask Mask) { VerboseMask |= Mask; } |
| 46 void subVerbose(IceVerboseMask Mask) { VerboseMask &= ~Mask; } |
| 47 |
| 48 IceOstream &getStrDump() { return StrDump; } |
| 49 IceOstream &getStrEmit() { return StrEmit; } |
| 50 |
| 51 // When emitting assembly, we allow a string to be prepended to |
| 52 // names of translated functions. This makes it easier to create an |
| 53 // execution test against a reference translator like llc, with both |
| 54 // translators using the same bitcode as input. |
| 55 IceString getTestPrefix() const { return TestPrefix; } |
| 56 IceString mangleName(const IceString &Name) const; |
| 57 |
| 58 // Manage Constants. |
| 59 // getConstant*() functions are not const because they might add |
| 60 // something to the constant pool. |
| 61 Constant *getConstantInt(IceType Type, uint64_t ConstantInt64); |
| 62 Constant *getConstantFloat(float Value); |
| 63 Constant *getConstantDouble(double Value); |
| 64 // Returns a symbolic constant. |
| 65 Constant *getConstantSym(IceType Type, int64_t Offset, |
| 66 const IceString &Name = "", |
| 67 bool SuppressMangling = false); |
| 68 |
| 69 // Allocate data of type T using the global allocator. |
| 70 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } |
| 71 |
| 72 private: |
| 73 IceOstream StrDump; // Stream for dumping / diagnostics |
| 74 IceOstream StrEmit; // Stream for code emission |
| 75 |
| 76 llvm::BumpPtrAllocator Allocator; |
| 77 IceVerboseMask VerboseMask; |
| 78 llvm::OwningPtr<class ConstantPool> ConstPool; |
| 79 const IceString TestPrefix; |
| 80 GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION; |
| 81 GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION; |
| 82 }; |
| 83 |
| 84 } // end of namespace Ice |
| 85 |
| 86 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
OLD | NEW |