Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceGlobalInits.h - Global declarations -------*- C++ -*-===// |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 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 | // |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 10 | // This file declares the representation of function declarations, |
| 11 | // global variable declarations, and the corresponding variable |
| 12 | // initializers in Subzero. Global variable initializers are |
| 13 | // represented as a sequence of simple initializers. |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #ifndef SUBZERO_SRC_ICEGLOBALINITS_H |
| 18 | #define SUBZERO_SRC_ICEGLOBALINITS_H |
| 19 | |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 20 | #include "llvm/IR/CallingConv.h" |
| 21 | #include "llvm/IR/GlobalValue.h" // for GlobalValue::LinkageTypes |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 22 | |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 23 | #include "IceDefs.h" |
| 24 | #include "IceTypes.h" |
| 25 | |
| 26 | // TODO(kschimpf): Remove ourselves from using LLVM representation for calling |
| 27 | // conventions and linkage types. |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 28 | |
| 29 | namespace Ice { |
| 30 | |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 31 | /// Base class for global variable and function declarations. |
| 32 | class GlobalDeclaration { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 33 | GlobalDeclaration() = delete; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 34 | GlobalDeclaration(const GlobalDeclaration &) = delete; |
| 35 | GlobalDeclaration &operator=(const GlobalDeclaration &) = delete; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 36 | |
| 37 | public: |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 38 | /// Discriminator for LLVM-style RTTI. |
| 39 | enum GlobalDeclarationKind { |
| 40 | FunctionDeclarationKind, |
| 41 | VariableDeclarationKind |
| 42 | }; |
| 43 | GlobalDeclarationKind getKind() const { return Kind; } |
| 44 | const IceString &getName() const { return Name; } |
| 45 | void setName(const IceString &NewName) { Name = NewName; } |
| 46 | bool hasName() const { return !Name.empty(); } |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 47 | bool isInternal() const { |
| 48 | return Linkage == llvm::GlobalValue::InternalLinkage; |
| 49 | } |
| 50 | llvm::GlobalValue::LinkageTypes getLinkage() const { return Linkage; } |
| 51 | bool isExternal() const { |
| 52 | return Linkage == llvm::GlobalValue::ExternalLinkage; |
| 53 | } |
| 54 | void setLinkage(llvm::GlobalValue::LinkageTypes NewLinkage) { |
| 55 | Linkage = NewLinkage; |
| 56 | } |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 57 | virtual ~GlobalDeclaration() {} |
| 58 | |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 59 | /// Prints out type of the global declaration. |
| 60 | virtual void dumpType(Ostream &Stream) const = 0; |
| 61 | |
| 62 | /// Prints out the global declaration. |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 63 | virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0; |
| 64 | void dump(Ostream &Stream) const { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 65 | if (!ALLOW_DUMP) |
| 66 | return; |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 67 | GlobalContext *const Ctx = nullptr; |
| 68 | dump(Ctx, Stream); |
| 69 | } |
| 70 | |
| 71 | /// Returns true if when emitting names, we should suppress mangling. |
| 72 | virtual bool getSuppressMangling() const = 0; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 73 | |
| 74 | // Mangles name for cross tests, unless external and not defined locally |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 75 | // (so that relocations accross pnacl-sz and pnacl-llc will work). |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 76 | virtual IceString mangleName(GlobalContext *Ctx) const { |
| 77 | return getSuppressMangling() ? Name : Ctx->mangleName(Name); |
| 78 | } |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 79 | |
| 80 | protected: |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 81 | GlobalDeclaration(GlobalDeclarationKind Kind, |
| 82 | llvm::GlobalValue::LinkageTypes Linkage) |
| 83 | : Kind(Kind), Linkage(Linkage) {} |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 84 | |
| 85 | const GlobalDeclarationKind Kind; |
| 86 | IceString Name; |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 87 | llvm::GlobalValue::LinkageTypes Linkage; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | // Models a function declaration. This includes the type signature of |
| 91 | // the function, its calling conventions, and its linkage. |
| 92 | class FunctionDeclaration : public GlobalDeclaration { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 93 | FunctionDeclaration() = delete; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 94 | FunctionDeclaration(const FunctionDeclaration &) = delete; |
| 95 | FunctionDeclaration &operator=(const FunctionDeclaration &) = delete; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 96 | |
| 97 | public: |
Jim Stichnoth | a086b91 | 2015-01-20 14:53:57 -0800 | [diff] [blame] | 98 | static FunctionDeclaration *create(const FuncSigType &Signature, |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 99 | llvm::CallingConv::ID CallingConv, |
| 100 | llvm::GlobalValue::LinkageTypes Linkage, |
| 101 | bool IsProto); |
| 102 | ~FunctionDeclaration() final {} |
| 103 | const FuncSigType &getSignature() const { return Signature; } |
| 104 | llvm::CallingConv::ID getCallingConv() const { return CallingConv; } |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 105 | // isProto implies that there isn't a (local) definition for the function. |
| 106 | bool isProto() const { return IsProto; } |
| 107 | static bool classof(const GlobalDeclaration *Addr) { |
| 108 | return Addr->getKind() == FunctionDeclarationKind; |
| 109 | } |
| 110 | void dumpType(Ostream &Stream) const final; |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 111 | void dump(GlobalContext *Ctx, Ostream &Stream) const final; |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 112 | bool getSuppressMangling() const final { return isExternal() && IsProto; } |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 113 | |
| 114 | private: |
| 115 | const Ice::FuncSigType Signature; |
| 116 | llvm::CallingConv::ID CallingConv; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 117 | bool IsProto; |
| 118 | |
| 119 | FunctionDeclaration(const FuncSigType &Signature, |
| 120 | llvm::CallingConv::ID CallingConv, |
| 121 | llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 122 | : GlobalDeclaration(FunctionDeclarationKind, Linkage), |
| 123 | Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {} |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | /// Models a global variable declaration, and its initializers. |
| 127 | class VariableDeclaration : public GlobalDeclaration { |
| 128 | VariableDeclaration(const VariableDeclaration &) = delete; |
| 129 | VariableDeclaration &operator=(const VariableDeclaration &) = delete; |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 130 | |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 131 | public: |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 132 | /// Base class for a global variable initializer. |
| 133 | class Initializer { |
| 134 | Initializer(const Initializer &) = delete; |
| 135 | Initializer &operator=(const Initializer &) = delete; |
| 136 | |
| 137 | public: |
| 138 | /// Discriminator for LLVM-style RTTI. |
| 139 | enum InitializerKind { |
| 140 | DataInitializerKind, |
| 141 | ZeroInitializerKind, |
| 142 | RelocInitializerKind |
| 143 | }; |
| 144 | InitializerKind getKind() const { return Kind; } |
| 145 | virtual ~Initializer() {} |
| 146 | virtual SizeT getNumBytes() const = 0; |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 147 | virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0; |
| 148 | void dump(Ostream &Stream) const { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 149 | if (ALLOW_DUMP) |
| 150 | dump(nullptr, Stream); |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 151 | } |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 152 | virtual void dumpType(Ostream &Stream) const; |
| 153 | |
| 154 | protected: |
| 155 | explicit Initializer(InitializerKind Kind) : Kind(Kind) {} |
| 156 | |
| 157 | private: |
| 158 | const InitializerKind Kind; |
| 159 | }; |
| 160 | |
| 161 | // Models the data in a data initializer. |
Jan Voung | 72984d8 | 2015-01-29 14:42:38 -0800 | [diff] [blame] | 162 | typedef std::vector<char> DataVecType; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 163 | |
| 164 | /// Defines a sequence of byte values as a data initializer. |
| 165 | class DataInitializer : public Initializer { |
| 166 | DataInitializer(const DataInitializer &) = delete; |
| 167 | DataInitializer &operator=(const DataInitializer &) = delete; |
| 168 | |
| 169 | public: |
| 170 | template <class IntContainer> |
| 171 | DataInitializer(const IntContainer &Values) |
| 172 | : Initializer(DataInitializerKind), Contents(Values.size()) { |
| 173 | size_t i = 0; |
| 174 | for (auto &V : Values) { |
Jan Voung | 72984d8 | 2015-01-29 14:42:38 -0800 | [diff] [blame] | 175 | Contents[i] = static_cast<int8_t>(V); |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 176 | ++i; |
| 177 | } |
| 178 | } |
| 179 | DataInitializer(const char *Str, size_t StrLen) |
| 180 | : Initializer(DataInitializerKind), Contents(StrLen) { |
| 181 | for (size_t i = 0; i < StrLen; ++i) |
Jan Voung | 72984d8 | 2015-01-29 14:42:38 -0800 | [diff] [blame] | 182 | Contents[i] = Str[i]; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 183 | } |
| 184 | ~DataInitializer() override {} |
| 185 | const DataVecType &getContents() const { return Contents; } |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 186 | SizeT getNumBytes() const final { return Contents.size(); } |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 187 | void dump(GlobalContext *Ctx, Ostream &Stream) const final; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 188 | static bool classof(const Initializer *D) { |
| 189 | return D->getKind() == DataInitializerKind; |
| 190 | } |
| 191 | |
| 192 | private: |
| 193 | // The byte contents of the data initializer. |
| 194 | DataVecType Contents; |
| 195 | }; |
| 196 | |
| 197 | /// Defines a sequence of bytes initialized to zero. |
| 198 | class ZeroInitializer : public Initializer { |
| 199 | ZeroInitializer(const ZeroInitializer &) = delete; |
| 200 | ZeroInitializer &operator=(const ZeroInitializer &) = delete; |
| 201 | |
| 202 | public: |
| 203 | explicit ZeroInitializer(SizeT Size) |
| 204 | : Initializer(ZeroInitializerKind), Size(Size) {} |
| 205 | ~ZeroInitializer() override {} |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 206 | SizeT getNumBytes() const final { return Size; } |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 207 | void dump(GlobalContext *Ctx, Ostream &Stream) const final; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 208 | static bool classof(const Initializer *Z) { |
| 209 | return Z->getKind() == ZeroInitializerKind; |
| 210 | } |
| 211 | |
| 212 | private: |
| 213 | // The number of bytes to be zero initialized. |
| 214 | SizeT Size; |
| 215 | }; |
| 216 | |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 217 | /// Defines the relocation value of another global declaration. |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 218 | class RelocInitializer : public Initializer { |
| 219 | RelocInitializer(const RelocInitializer &) = delete; |
| 220 | RelocInitializer &operator=(const RelocInitializer &) = delete; |
| 221 | |
| 222 | public: |
Jan Voung | c0d965f | 2014-11-04 16:55:01 -0800 | [diff] [blame] | 223 | RelocInitializer(const GlobalDeclaration *Declaration, RelocOffsetT Offset) |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 224 | : Initializer(RelocInitializerKind), Declaration(Declaration), |
| 225 | Offset(Offset) {} |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 226 | ~RelocInitializer() override {} |
Jan Voung | c0d965f | 2014-11-04 16:55:01 -0800 | [diff] [blame] | 227 | RelocOffsetT getOffset() const { return Offset; } |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 228 | const GlobalDeclaration *getDeclaration() const { return Declaration; } |
| 229 | SizeT getNumBytes() const final { return RelocAddrSize; } |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 230 | void dump(GlobalContext *Ctx, Ostream &Stream) const final; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 231 | void dumpType(Ostream &Stream) const final; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 232 | static bool classof(const Initializer *R) { |
| 233 | return R->getKind() == RelocInitializerKind; |
| 234 | } |
| 235 | |
| 236 | private: |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 237 | // The global declaration used in the relocation. |
| 238 | const GlobalDeclaration *Declaration; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 239 | // The offset to add to the relocation. |
Jan Voung | c0d965f | 2014-11-04 16:55:01 -0800 | [diff] [blame] | 240 | const RelocOffsetT Offset; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 241 | }; |
| 242 | |
| 243 | /// Models the list of initializers. |
| 244 | typedef std::vector<Initializer *> InitializerListType; |
| 245 | |
Jim Stichnoth | a086b91 | 2015-01-20 14:53:57 -0800 | [diff] [blame] | 246 | static VariableDeclaration *create(); |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 247 | ~VariableDeclaration() final; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 248 | |
| 249 | const InitializerListType &getInitializers() const { return Initializers; } |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 250 | bool getIsConstant() const { return IsConstant; } |
| 251 | void setIsConstant(bool NewValue) { IsConstant = NewValue; } |
| 252 | uint32_t getAlignment() const { return Alignment; } |
| 253 | void setAlignment(uint32_t NewAlignment) { Alignment = NewAlignment; } |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 254 | bool hasInitializer() const { return !Initializers.empty(); } |
| 255 | bool hasNonzeroInitializer() const { |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 256 | return !(Initializers.size() == 1 && |
| 257 | llvm::isa<ZeroInitializer>(Initializers[0])); |
| 258 | } |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 259 | |
| 260 | /// Returns the number of bytes for the initializer of the global |
| 261 | /// address. |
| 262 | SizeT getNumBytes() const { |
| 263 | SizeT Count = 0; |
| 264 | for (Initializer *Init : Initializers) { |
| 265 | Count += Init->getNumBytes(); |
| 266 | } |
| 267 | return Count; |
| 268 | } |
| 269 | |
| 270 | /// Adds Initializer to the list of initializers. Takes ownership of |
| 271 | /// the initializer. |
| 272 | void addInitializer(Initializer *Initializer) { |
| 273 | Initializers.push_back(Initializer); |
| 274 | } |
| 275 | |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 276 | /// Prints out type for initializer associated with the declaration |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 277 | /// to Stream. |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 278 | void dumpType(Ostream &Stream) const final; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 279 | |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 280 | /// Prints out the definition of the global variable declaration |
| 281 | /// (including initialization). |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 282 | void dump(GlobalContext *Ctx, Ostream &Stream) const final; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 283 | |
| 284 | static bool classof(const GlobalDeclaration *Addr) { |
| 285 | return Addr->getKind() == VariableDeclarationKind; |
| 286 | } |
| 287 | |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 288 | bool getSuppressMangling() const final { |
Jim Stichnoth | d9f1f9f | 2015-06-11 10:19:32 -0700 | [diff] [blame] | 289 | if (ForceSuppressMangling) |
| 290 | return true; |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 291 | return isExternal() && !hasInitializer(); |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Jim Stichnoth | 0933c0c | 2015-06-12 10:41:16 -0700 | [diff] [blame^] | 294 | void setSuppressMangling() { ForceSuppressMangling = true; } |
Jim Stichnoth | d9f1f9f | 2015-06-11 10:19:32 -0700 | [diff] [blame] | 295 | |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 296 | private: |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 297 | // list of initializers for the declared variable. |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 298 | InitializerListType Initializers; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 299 | // The alignment of the declared variable. |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 300 | uint32_t Alignment; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 301 | // True if a declared (global) constant. |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 302 | bool IsConstant; |
Jim Stichnoth | d9f1f9f | 2015-06-11 10:19:32 -0700 | [diff] [blame] | 303 | // If set to true, force getSuppressMangling() to return true. |
| 304 | bool ForceSuppressMangling; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 305 | |
| 306 | VariableDeclaration() |
Karl Schimpf | df6f9d1 | 2014-10-20 14:09:00 -0700 | [diff] [blame] | 307 | : GlobalDeclaration(VariableDeclarationKind, |
| 308 | llvm::GlobalValue::InternalLinkage), |
Jim Stichnoth | d9f1f9f | 2015-06-11 10:19:32 -0700 | [diff] [blame] | 309 | Alignment(0), IsConstant(false), ForceSuppressMangling(false) {} |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | template <class StreamType> |
| 313 | inline StreamType &operator<<(StreamType &Stream, |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 314 | const VariableDeclaration::Initializer &Init) { |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 315 | Init.dump(Stream); |
| 316 | return Stream; |
| 317 | } |
| 318 | |
| 319 | template <class StreamType> |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 320 | inline StreamType &operator<<(StreamType &Stream, |
| 321 | const GlobalDeclaration &Addr) { |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 322 | Addr.dump(Stream); |
| 323 | return Stream; |
| 324 | } |
| 325 | |
| 326 | } // end of namespace Ice |
| 327 | |
| 328 | #endif // SUBZERO_SRC_ICEGLOBALINITS_H |