Chromium Code Reviews| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 bool isProto() const { return IsProto; } | 147 bool isProto() const { return IsProto; } |
| 148 static bool classof(const GlobalDeclaration *Addr) { | 148 static bool classof(const GlobalDeclaration *Addr) { |
| 149 return Addr->getKind() == FunctionDeclarationKind; | 149 return Addr->getKind() == FunctionDeclarationKind; |
| 150 } | 150 } |
| 151 void dumpType(Ostream &Stream) const final; | 151 void dumpType(Ostream &Stream) const final; |
| 152 void dump(GlobalContext *Ctx, Ostream &Stream) const final; | 152 void dump(GlobalContext *Ctx, Ostream &Stream) const final; |
| 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 (isPNaClABIExternalName() || isIntrinsicName(Ctx)) | 157 if (isIntrinsicName(Ctx)) |
| 158 return Linkage == llvm::GlobalValue::ExternalLinkage; | 158 return Linkage == llvm::GlobalValue::ExternalLinkage; |
| 159 return verifyLinkageDefault(Ctx); | 159 else if (Linkage == llvm::GlobalValue::ExternalLinkage) |
| 160 return isPNaClABIExternalName(); | |
| 161 else | |
| 162 return verifyLinkageDefault(Ctx); | |
| 160 } | 163 } |
| 161 | 164 |
| 162 /// Validates that the type signature of the function is correct. Returns true | 165 /// Validates that the type signature of the function is correct. Returns true |
| 163 /// if valid. | 166 /// if valid. |
| 164 bool validateTypeSignature(const GlobalContext *Ctx) const { | 167 bool validateTypeSignature(const GlobalContext *Ctx) const { |
| 165 bool IsIntrinsic; | 168 bool IsIntrinsic; |
| 166 if (const Intrinsics::FullIntrinsicInfo *Info = | 169 if (const Intrinsics::FullIntrinsicInfo *Info = |
| 167 getIntrinsicInfo(Ctx, &IsIntrinsic)) | 170 getIntrinsicInfo(Ctx, &IsIntrinsic)) |
| 168 return validateIntrinsicTypeSignature(Info); | 171 return validateIntrinsicTypeSignature(Info); |
| 169 return !IsIntrinsic && validateRegularTypeSignature(); | 172 return !IsIntrinsic && validateRegularTypeSignature(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 191 bool IsProto; | 194 bool IsProto; |
| 192 | 195 |
| 193 FunctionDeclaration(const FuncSigType &Signature, | 196 FunctionDeclaration(const FuncSigType &Signature, |
| 194 llvm::CallingConv::ID CallingConv, | 197 llvm::CallingConv::ID CallingConv, |
| 195 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) | 198 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) |
| 196 : GlobalDeclaration(FunctionDeclarationKind, Linkage), | 199 : GlobalDeclaration(FunctionDeclarationKind, Linkage), |
| 197 Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {} | 200 Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {} |
| 198 | 201 |
| 199 bool isPNaClABIExternalName() const { | 202 bool isPNaClABIExternalName() const { |
| 200 const char *Name = getName().c_str(); | 203 const char *Name = getName().c_str(); |
| 201 return strcmp(Name, "_start") == 0 || strcmp(Name, "__pnacl_pso_root") == 0; | 204 return strcmp(Name, "_start") == 0; |
| 202 } | 205 } |
| 203 | 206 |
| 204 bool isIntrinsicName(const GlobalContext *Ctx) const { | 207 bool isIntrinsicName(const GlobalContext *Ctx) const { |
| 205 bool IsIntrinsic; | 208 bool IsIntrinsic; |
| 206 getIntrinsicInfo(Ctx, &IsIntrinsic); | 209 getIntrinsicInfo(Ctx, &IsIntrinsic); |
| 207 return IsIntrinsic; | 210 return IsIntrinsic; |
| 208 } | 211 } |
| 209 | 212 |
| 210 bool validateRegularTypeSignature() const; | 213 bool validateRegularTypeSignature() const; |
| 211 | 214 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 | 412 |
| 410 /// Prints out type for initializer associated with the declaration to Stream. | 413 /// Prints out type for initializer associated with the declaration to Stream. |
| 411 void dumpType(Ostream &Stream) const final; | 414 void dumpType(Ostream &Stream) const final; |
| 412 | 415 |
| 413 /// Prints out the definition of the global variable declaration (including | 416 /// Prints out the definition of the global variable declaration (including |
| 414 /// initialization). | 417 /// initialization). |
| 415 void dump(GlobalContext *Ctx, Ostream &Stream) const final; | 418 void dump(GlobalContext *Ctx, Ostream &Stream) const final; |
| 416 | 419 |
| 417 /// Returns true if linkage is correct for the variable declaration. | 420 /// Returns true if linkage is correct for the variable declaration. |
| 418 bool verifyLinkageCorrect(const GlobalContext *Ctx) const { | 421 bool verifyLinkageCorrect(const GlobalContext *Ctx) const { |
| 422 if (isPNaClABIExternalName()) { | |
| 423 return Linkage == llvm::GlobalValue::ExternalLinkage; | |
| 424 } | |
| 419 return verifyLinkageDefault(Ctx); | 425 return verifyLinkageDefault(Ctx); |
| 420 } | 426 } |
| 421 | 427 |
| 428 /// Returns true if the linkage was updated. | |
| 429 bool forcePNaClABILinkage() { | |
| 430 if (isPNaClABIExternalName()) { | |
| 431 // Force linkage to be external for the PNaCl ABI. PNaCl bitcode has a | |
| 432 // linkage field for Functions, but not for GlobalVariables (because the | |
| 433 // latter is not needed for pexes, so it has been removed). | |
| 434 setLinkage(llvm::GlobalValue::ExternalLinkage); | |
| 435 return true; | |
| 436 } | |
| 437 return false; | |
| 438 } | |
| 439 | |
| 422 static bool classof(const GlobalDeclaration *Addr) { | 440 static bool classof(const GlobalDeclaration *Addr) { |
| 423 return Addr->getKind() == VariableDeclarationKind; | 441 return Addr->getKind() == VariableDeclarationKind; |
| 424 } | 442 } |
| 425 | 443 |
| 426 bool getSuppressMangling() const final { | 444 bool getSuppressMangling() const final { |
| 427 if (ForceSuppressMangling) | 445 if (ForceSuppressMangling) |
| 428 return true; | 446 return true; |
| 429 return isExternal() && !hasInitializer(); | 447 return isExternal() && !hasInitializer(); |
| 430 } | 448 } |
| 431 | 449 |
| 432 void setSuppressMangling() { ForceSuppressMangling = true; } | 450 void setSuppressMangling() { ForceSuppressMangling = true; } |
| 433 | 451 |
| 434 void discardInitializers() { Initializers = nullptr; } | 452 void discardInitializers() { Initializers = nullptr; } |
| 435 | 453 |
| 436 private: | 454 private: |
| 455 bool isPNaClABIExternalName() const { | |
| 456 const char *Name = getName().c_str(); | |
|
John
2016/02/26 18:40:53
static constexpr char PnaclPsoRoot[] = "__pnacl_ps
Sean Klein
2016/02/26 19:45:04
Done.
| |
| 457 return strcmp(Name, "__pnacl_pso_root") == 0; | |
| 458 } | |
| 459 | |
| 437 /// List of initializers for the declared variable. | 460 /// List of initializers for the declared variable. |
| 438 std::unique_ptr<InitializerListType> Initializers; | 461 std::unique_ptr<InitializerListType> Initializers; |
| 439 bool HasInitializer; | 462 bool HasInitializer; |
| 440 /// The alignment of the declared variable. | 463 /// The alignment of the declared variable. |
| 441 uint32_t Alignment; | 464 uint32_t Alignment; |
| 442 /// True if a declared (global) constant. | 465 /// True if a declared (global) constant. |
| 443 bool IsConstant; | 466 bool IsConstant; |
| 444 /// If set to true, force getSuppressMangling() to return true. | 467 /// If set to true, force getSuppressMangling() to return true. |
| 445 bool ForceSuppressMangling; | 468 bool ForceSuppressMangling; |
| 446 | 469 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 461 template <class StreamType> | 484 template <class StreamType> |
| 462 inline StreamType &operator<<(StreamType &Stream, | 485 inline StreamType &operator<<(StreamType &Stream, |
| 463 const GlobalDeclaration &Addr) { | 486 const GlobalDeclaration &Addr) { |
| 464 Addr.dump(Stream); | 487 Addr.dump(Stream); |
| 465 return Stream; | 488 return Stream; |
| 466 } | 489 } |
| 467 | 490 |
| 468 } // end of namespace Ice | 491 } // end of namespace Ice |
| 469 | 492 |
| 470 #endif // SUBZERO_SRC_ICEGLOBALINITS_H | 493 #endif // SUBZERO_SRC_ICEGLOBALINITS_H |
| OLD | NEW |