Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: src/IceGlobalInits.h

Issue 1745783002: Revert "Force __pnacl_pso_root to be an external declaration." (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/PNaClTranslator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 /// that relocations across pnacl-sz and pnacl-llc will work). 95 /// that relocations across pnacl-sz and pnacl-llc will work).
96 virtual IceString mangleName(GlobalContext *Ctx) const { 96 virtual IceString mangleName(GlobalContext *Ctx) const {
97 return getSuppressMangling() ? Name : Ctx->mangleName(Name); 97 return getSuppressMangling() ? Name : Ctx->mangleName(Name);
98 } 98 }
99 99
100 /// Returns textual name of linkage. 100 /// Returns textual name of linkage.
101 const char *getLinkageName() const { 101 const char *getLinkageName() const {
102 return isInternal() ? "internal" : "external"; 102 return isInternal() ? "internal" : "external";
103 } 103 }
104 104
105 /// Returns true if the name of this GlobalDeclaration indicates that it
106 /// should have ExternalLinkage (as a special case).
107 virtual bool isPNaClABIExternalName() const = 0;
108
109 protected: 105 protected:
110 GlobalDeclaration(GlobalDeclarationKind Kind, 106 GlobalDeclaration(GlobalDeclarationKind Kind,
111 llvm::GlobalValue::LinkageTypes Linkage) 107 llvm::GlobalValue::LinkageTypes Linkage)
112 : Kind(Kind), Linkage(Linkage) {} 108 : Kind(Kind), Linkage(Linkage) {}
113 109
114 /// Returns true if linkage is defined correctly for the global declaration, 110 /// Returns true if linkage is defined correctly for the global declaration,
115 /// based on default rules. 111 /// based on default rules.
116 bool verifyLinkageDefault(const GlobalContext *Ctx) const { 112 bool verifyLinkageDefault(const GlobalContext *Ctx) const {
117 switch (Linkage) { 113 switch (Linkage) {
118 default: 114 default:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 bool isProto() const { return IsProto; } 147 bool isProto() const { return IsProto; }
152 static bool classof(const GlobalDeclaration *Addr) { 148 static bool classof(const GlobalDeclaration *Addr) {
153 return Addr->getKind() == FunctionDeclarationKind; 149 return Addr->getKind() == FunctionDeclarationKind;
154 } 150 }
155 void dumpType(Ostream &Stream) const final; 151 void dumpType(Ostream &Stream) const final;
156 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 152 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
157 bool getSuppressMangling() const final { return isExternal() && IsProto; } 153 bool getSuppressMangling() const final { return isExternal() && IsProto; }
158 154
159 /// Returns true if linkage is correct for the function declaration. 155 /// Returns true if linkage is correct for the function declaration.
160 bool verifyLinkageCorrect(const GlobalContext *Ctx) const { 156 bool verifyLinkageCorrect(const GlobalContext *Ctx) const {
161 if (isIntrinsicName(Ctx)) 157 if (isPNaClABIExternalName() || isIntrinsicName(Ctx))
162 return Linkage == llvm::GlobalValue::ExternalLinkage; 158 return Linkage == llvm::GlobalValue::ExternalLinkage;
163 else if (Linkage == llvm::GlobalValue::ExternalLinkage) 159 return verifyLinkageDefault(Ctx);
164 return isPNaClABIExternalName();
165 else
166 return verifyLinkageDefault(Ctx);
167 } 160 }
168 161
169 /// Validates that the type signature of the function is correct. Returns true 162 /// Validates that the type signature of the function is correct. Returns true
170 /// if valid. 163 /// if valid.
171 bool validateTypeSignature(const GlobalContext *Ctx) const { 164 bool validateTypeSignature(const GlobalContext *Ctx) const {
172 bool IsIntrinsic; 165 bool IsIntrinsic;
173 if (const Intrinsics::FullIntrinsicInfo *Info = 166 if (const Intrinsics::FullIntrinsicInfo *Info =
174 getIntrinsicInfo(Ctx, &IsIntrinsic)) 167 getIntrinsicInfo(Ctx, &IsIntrinsic))
175 return validateIntrinsicTypeSignature(Info); 168 return validateIntrinsicTypeSignature(Info);
176 return !IsIntrinsic && validateRegularTypeSignature(); 169 return !IsIntrinsic && validateRegularTypeSignature();
(...skipping 19 matching lines...) Expand all
196 const Ice::FuncSigType Signature; 189 const Ice::FuncSigType Signature;
197 llvm::CallingConv::ID CallingConv; 190 llvm::CallingConv::ID CallingConv;
198 bool IsProto; 191 bool IsProto;
199 192
200 FunctionDeclaration(const FuncSigType &Signature, 193 FunctionDeclaration(const FuncSigType &Signature,
201 llvm::CallingConv::ID CallingConv, 194 llvm::CallingConv::ID CallingConv,
202 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) 195 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto)
203 : GlobalDeclaration(FunctionDeclarationKind, Linkage), 196 : GlobalDeclaration(FunctionDeclarationKind, Linkage),
204 Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {} 197 Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {}
205 198
206 bool isPNaClABIExternalName() const override { 199 bool isPNaClABIExternalName() const {
207 static constexpr char Start[] = "_start"; 200 const char *Name = getName().c_str();
208 return getName() == Start; 201 return strcmp(Name, "_start") == 0 || strcmp(Name, "__pnacl_pso_root") == 0;
209 } 202 }
210 203
211 bool isIntrinsicName(const GlobalContext *Ctx) const { 204 bool isIntrinsicName(const GlobalContext *Ctx) const {
212 bool IsIntrinsic; 205 bool IsIntrinsic;
213 getIntrinsicInfo(Ctx, &IsIntrinsic); 206 getIntrinsicInfo(Ctx, &IsIntrinsic);
214 return IsIntrinsic; 207 return IsIntrinsic;
215 } 208 }
216 209
217 bool validateRegularTypeSignature() const; 210 bool validateRegularTypeSignature() const;
218 211
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 409
417 /// Prints out type for initializer associated with the declaration to Stream. 410 /// Prints out type for initializer associated with the declaration to Stream.
418 void dumpType(Ostream &Stream) const final; 411 void dumpType(Ostream &Stream) const final;
419 412
420 /// Prints out the definition of the global variable declaration (including 413 /// Prints out the definition of the global variable declaration (including
421 /// initialization). 414 /// initialization).
422 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 415 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
423 416
424 /// Returns true if linkage is correct for the variable declaration. 417 /// Returns true if linkage is correct for the variable declaration.
425 bool verifyLinkageCorrect(const GlobalContext *Ctx) const { 418 bool verifyLinkageCorrect(const GlobalContext *Ctx) const {
426 if (isPNaClABIExternalName()) {
427 return Linkage == llvm::GlobalValue::ExternalLinkage;
428 }
429 return verifyLinkageDefault(Ctx); 419 return verifyLinkageDefault(Ctx);
430 } 420 }
431 421
432 static bool classof(const GlobalDeclaration *Addr) { 422 static bool classof(const GlobalDeclaration *Addr) {
433 return Addr->getKind() == VariableDeclarationKind; 423 return Addr->getKind() == VariableDeclarationKind;
434 } 424 }
435 425
436 bool getSuppressMangling() const final { 426 bool getSuppressMangling() const final {
437 if (ForceSuppressMangling) 427 if (ForceSuppressMangling)
438 return true; 428 return true;
439 return isExternal() && !hasInitializer(); 429 return isExternal() && !hasInitializer();
440 } 430 }
441 431
442 void setSuppressMangling() { ForceSuppressMangling = true; } 432 void setSuppressMangling() { ForceSuppressMangling = true; }
443 433
444 void discardInitializers() { Initializers = nullptr; } 434 void discardInitializers() { Initializers = nullptr; }
445 435
446 bool isPNaClABIExternalName() const override {
447 static constexpr char PnaclPsoRoot[] = "__pnacl_pso_root";
448 return getName() == PnaclPsoRoot;
449 }
450
451 private: 436 private:
452 /// List of initializers for the declared variable. 437 /// List of initializers for the declared variable.
453 std::unique_ptr<InitializerListType> Initializers; 438 std::unique_ptr<InitializerListType> Initializers;
454 bool HasInitializer; 439 bool HasInitializer;
455 /// The alignment of the declared variable. 440 /// The alignment of the declared variable.
456 uint32_t Alignment; 441 uint32_t Alignment;
457 /// True if a declared (global) constant. 442 /// True if a declared (global) constant.
458 bool IsConstant; 443 bool IsConstant;
459 /// If set to true, force getSuppressMangling() to return true. 444 /// If set to true, force getSuppressMangling() to return true.
460 bool ForceSuppressMangling; 445 bool ForceSuppressMangling;
(...skipping 15 matching lines...) Expand all
476 template <class StreamType> 461 template <class StreamType>
477 inline StreamType &operator<<(StreamType &Stream, 462 inline StreamType &operator<<(StreamType &Stream,
478 const GlobalDeclaration &Addr) { 463 const GlobalDeclaration &Addr) {
479 Addr.dump(Stream); 464 Addr.dump(Stream);
480 return Stream; 465 return Stream;
481 } 466 }
482 467
483 } // end of namespace Ice 468 } // end of namespace Ice
484 469
485 #endif // SUBZERO_SRC_ICEGLOBALINITS_H 470 #endif // SUBZERO_SRC_ICEGLOBALINITS_H
OLDNEW
« no previous file with comments | « no previous file | src/PNaClTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698