OLD | NEW |
1 //===- subzero/src/IceGlobalInits.h - Global declarations -------*- C++ -*-===// | 1 //===- subzero/src/IceGlobalInits.h - Global declarations -------*- 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 /// \file | 10 /// \file |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 /// should have ExternalLinkage (as a special case). | 102 /// should have ExternalLinkage (as a special case). |
103 virtual bool isPNaClABIExternalName(const std::string &Name) const = 0; | 103 virtual bool isPNaClABIExternalName(const std::string &Name) const = 0; |
104 | 104 |
105 protected: | 105 protected: |
106 GlobalDeclaration(GlobalDeclarationKind Kind, | 106 GlobalDeclaration(GlobalDeclarationKind Kind, |
107 llvm::GlobalValue::LinkageTypes Linkage) | 107 llvm::GlobalValue::LinkageTypes Linkage) |
108 : Kind(Kind), Linkage(Linkage) {} | 108 : Kind(Kind), Linkage(Linkage) {} |
109 | 109 |
110 /// Returns true if linkage is defined correctly for the global declaration, | 110 /// Returns true if linkage is defined correctly for the global declaration, |
111 /// based on default rules. | 111 /// based on default rules. |
112 bool verifyLinkageDefault(const GlobalContext *Ctx) const { | 112 bool verifyLinkageDefault() const { |
113 switch (Linkage) { | 113 switch (Linkage) { |
114 default: | 114 default: |
115 return false; | 115 return false; |
116 case llvm::GlobalValue::InternalLinkage: | 116 case llvm::GlobalValue::InternalLinkage: |
117 return true; | 117 return true; |
118 case llvm::GlobalValue::ExternalLinkage: | 118 case llvm::GlobalValue::ExternalLinkage: |
119 return Ctx->getFlags().getAllowExternDefinedSymbols(); | 119 return getFlags().getAllowExternDefinedSymbols(); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 const GlobalDeclarationKind Kind; | 123 const GlobalDeclarationKind Kind; |
124 llvm::GlobalValue::LinkageTypes Linkage; | 124 llvm::GlobalValue::LinkageTypes Linkage; |
125 GlobalString Name; | 125 GlobalString Name; |
126 }; | 126 }; |
127 | 127 |
128 /// Models a function declaration. This includes the type signature of the | 128 /// Models a function declaration. This includes the type signature of the |
129 /// function, its calling conventions, and its linkage. | 129 /// function, its calling conventions, and its linkage. |
(...skipping 23 matching lines...) Expand all Loading... |
153 bool getSuppressMangling() const final { return isExternal() && IsProto; } | 153 bool getSuppressMangling() const final { return isExternal() && IsProto; } |
154 | 154 |
155 /// Returns true if linkage is correct for the function declaration. | 155 /// Returns true if linkage is correct for the function declaration. |
156 bool verifyLinkageCorrect(const GlobalContext *Ctx) const { | 156 bool verifyLinkageCorrect(const GlobalContext *Ctx) const { |
157 if (getName().hasStdString()) { | 157 if (getName().hasStdString()) { |
158 if (isPNaClABIExternalName(getName().toString()) || | 158 if (isPNaClABIExternalName(getName().toString()) || |
159 isIntrinsicName(Ctx)) { | 159 isIntrinsicName(Ctx)) { |
160 return Linkage == llvm::GlobalValue::ExternalLinkage; | 160 return Linkage == llvm::GlobalValue::ExternalLinkage; |
161 } | 161 } |
162 } | 162 } |
163 return verifyLinkageDefault(Ctx); | 163 return verifyLinkageDefault(); |
164 } | 164 } |
165 | 165 |
166 /// Validates that the type signature of the function is correct. Returns true | 166 /// Validates that the type signature of the function is correct. Returns true |
167 /// if valid. | 167 /// if valid. |
168 bool validateTypeSignature(const GlobalContext *Ctx) const { | 168 bool validateTypeSignature(const GlobalContext *Ctx) const { |
169 bool IsIntrinsic; | 169 bool IsIntrinsic; |
170 if (const Intrinsics::FullIntrinsicInfo *Info = | 170 if (const Intrinsics::FullIntrinsicInfo *Info = |
171 getIntrinsicInfo(Ctx, &IsIntrinsic)) | 171 getIntrinsicInfo(Ctx, &IsIntrinsic)) |
172 return validateIntrinsicTypeSignature(Info); | 172 return validateIntrinsicTypeSignature(Info); |
173 return !IsIntrinsic && validateRegularTypeSignature(); | 173 return !IsIntrinsic && validateRegularTypeSignature(); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 } | 454 } |
455 | 455 |
456 /// Prints out type for initializer associated with the declaration to Stream. | 456 /// Prints out type for initializer associated with the declaration to Stream. |
457 void dumpType(Ostream &Stream) const final; | 457 void dumpType(Ostream &Stream) const final; |
458 | 458 |
459 /// Prints out the definition of the global variable declaration (including | 459 /// Prints out the definition of the global variable declaration (including |
460 /// initialization). | 460 /// initialization). |
461 virtual void dump(Ostream &Stream) const override; | 461 virtual void dump(Ostream &Stream) const override; |
462 | 462 |
463 /// Returns true if linkage is correct for the variable declaration. | 463 /// Returns true if linkage is correct for the variable declaration. |
464 bool verifyLinkageCorrect(const GlobalContext *Ctx) const { | 464 bool verifyLinkageCorrect() const { |
465 if (getName().hasStdString()) { | 465 if (getName().hasStdString()) { |
466 if (isPNaClABIExternalName(getName().toString())) { | 466 if (isPNaClABIExternalName(getName().toString())) { |
467 return Linkage == llvm::GlobalValue::ExternalLinkage; | 467 return Linkage == llvm::GlobalValue::ExternalLinkage; |
468 } | 468 } |
469 } | 469 } |
470 return verifyLinkageDefault(Ctx); | 470 return verifyLinkageDefault(); |
471 } | 471 } |
472 | 472 |
473 static bool classof(const GlobalDeclaration *Addr) { | 473 static bool classof(const GlobalDeclaration *Addr) { |
474 return Addr->getKind() == VariableDeclarationKind; | 474 return Addr->getKind() == VariableDeclarationKind; |
475 } | 475 } |
476 | 476 |
477 bool getSuppressMangling() const final { | 477 bool getSuppressMangling() const final { |
478 if (ForceSuppressMangling) | 478 if (ForceSuppressMangling) |
479 return true; | 479 return true; |
480 return isExternal() && !hasInitializer(); | 480 return isExternal() && !hasInitializer(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 template <class StreamType> | 513 template <class StreamType> |
514 inline StreamType &operator<<(StreamType &Stream, | 514 inline StreamType &operator<<(StreamType &Stream, |
515 const GlobalDeclaration &Addr) { | 515 const GlobalDeclaration &Addr) { |
516 Addr.dump(Stream); | 516 Addr.dump(Stream); |
517 return Stream; | 517 return Stream; |
518 } | 518 } |
519 | 519 |
520 } // end of namespace Ice | 520 } // end of namespace Ice |
521 | 521 |
522 #endif // SUBZERO_SRC_ICEGLOBALINITS_H | 522 #endif // SUBZERO_SRC_ICEGLOBALINITS_H |
OLD | NEW |