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 "llvm/ADT/OwningPtr.h" | 18 #include "llvm/ADT/OwningPtr.h" |
19 #include "llvm/Support/Allocator.h" | 19 #include "llvm/Support/Allocator.h" |
20 #include "llvm/Support/raw_ostream.h" | 20 #include "llvm/Support/raw_ostream.h" |
21 | 21 |
22 #include "IceDefs.h" | 22 #include "IceDefs.h" |
23 #include "IceIntrinsics.h" | 23 #include "IceIntrinsics.h" |
24 #include "IceTypes.h" | 24 #include "IceTypes.h" |
25 | 25 |
26 namespace Ice { | 26 namespace Ice { |
27 | 27 |
| 28 class ClFlags; |
| 29 |
28 // TODO: Accesses to all non-const fields of GlobalContext need to | 30 // TODO: Accesses to all non-const fields of GlobalContext need to |
29 // be synchronized, especially the constant pool, the allocator, and | 31 // be synchronized, especially the constant pool, the allocator, and |
30 // the output streams. | 32 // the output streams. |
31 class GlobalContext { | 33 class GlobalContext { |
32 public: | 34 public: |
33 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit, | 35 GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit, |
34 VerboseMask Mask, TargetArch Arch, OptLevel Opt, | 36 VerboseMask Mask, TargetArch Arch, OptLevel Opt, |
35 IceString TestPrefix); | 37 IceString TestPrefix, const ClFlags &Flags); |
36 ~GlobalContext(); | 38 ~GlobalContext(); |
37 | 39 |
38 // Returns true if any of the specified options in the verbose mask | 40 // Returns true if any of the specified options in the verbose mask |
39 // are set. If the argument is omitted, it checks if any verbose | 41 // are set. If the argument is omitted, it checks if any verbose |
40 // options at all are set. IceV_Timing is treated specially, so | 42 // options at all are set. IceV_Timing is treated specially, so |
41 // that running with just IceV_Timing verbosity doesn't trigger an | 43 // that running with just IceV_Timing verbosity doesn't trigger an |
42 // avalanche of extra output. | 44 // avalanche of extra output. |
43 bool isVerbose(VerboseMask Mask = (IceV_All & ~IceV_Timing)) const { | 45 bool isVerbose(VerboseMask Mask = (IceV_All & ~IceV_Timing)) const { |
44 return VMask & Mask; | 46 return VMask & Mask; |
45 } | 47 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 Constant *getConstantSym(Type Ty, int64_t Offset, const IceString &Name = "", | 81 Constant *getConstantSym(Type Ty, int64_t Offset, const IceString &Name = "", |
80 bool SuppressMangling = false); | 82 bool SuppressMangling = false); |
81 // Returns an undef. | 83 // Returns an undef. |
82 Constant *getConstantUndef(Type Ty); | 84 Constant *getConstantUndef(Type Ty); |
83 // Returns a zero value. | 85 // Returns a zero value. |
84 Constant *getConstantZero(Type Ty); | 86 Constant *getConstantZero(Type Ty); |
85 // getConstantPool() returns a copy of the constant pool for | 87 // getConstantPool() returns a copy of the constant pool for |
86 // constants of a given type. | 88 // constants of a given type. |
87 ConstantList getConstantPool(Type Ty) const; | 89 ConstantList getConstantPool(Type Ty) const; |
88 | 90 |
| 91 const ClFlags &getFlags() const { return Flags; } |
| 92 |
89 // Allocate data of type T using the global allocator. | 93 // Allocate data of type T using the global allocator. |
90 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } | 94 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } |
91 | 95 |
92 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } | 96 const Intrinsics &getIntrinsicsInfo() const { return IntrinsicsInfo; } |
93 | 97 |
94 private: | 98 private: |
95 Ostream *StrDump; // Stream for dumping / diagnostics | 99 Ostream *StrDump; // Stream for dumping / diagnostics |
96 Ostream *StrEmit; // Stream for code emission | 100 Ostream *StrEmit; // Stream for code emission |
97 | 101 |
98 llvm::BumpPtrAllocator Allocator; | 102 llvm::BumpPtrAllocator Allocator; |
99 VerboseMask VMask; | 103 VerboseMask VMask; |
100 llvm::OwningPtr<class ConstantPool> ConstPool; | 104 llvm::OwningPtr<class ConstantPool> ConstPool; |
101 Intrinsics IntrinsicsInfo; | 105 Intrinsics IntrinsicsInfo; |
102 const TargetArch Arch; | 106 const TargetArch Arch; |
103 const OptLevel Opt; | 107 const OptLevel Opt; |
104 const IceString TestPrefix; | 108 const IceString TestPrefix; |
| 109 const ClFlags &Flags; |
105 bool HasEmittedFirstMethod; | 110 bool HasEmittedFirstMethod; |
106 GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION; | 111 GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION; |
107 GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION; | 112 GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION; |
108 | 113 |
109 // Private helpers for mangleName() | 114 // Private helpers for mangleName() |
110 typedef llvm::SmallVector<char, 32> ManglerVector; | 115 typedef llvm::SmallVector<char, 32> ManglerVector; |
111 void incrementSubstitutions(ManglerVector &OldName) const; | 116 void incrementSubstitutions(ManglerVector &OldName) const; |
112 }; | 117 }; |
113 | 118 |
114 } // end of namespace Ice | 119 } // end of namespace Ice |
115 | 120 |
116 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 121 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
OLD | NEW |