diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-24 18:34:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-24 18:34:27 +0000 |
commit | bf9ac228f7f90c776434db4ca8be457632fd225d (patch) | |
tree | 9f3ce3ee93e7a94031ac4586999744437622b624 /llvm/lib | |
parent | 0b5be94c791854c57ab027176f34f7c79a9e7e69 (diff) | |
download | llvm-bf9ac228f7f90c776434db4ca8be457632fd225d.zip llvm-bf9ac228f7f90c776434db4ca8be457632fd225d.tar.gz llvm-bf9ac228f7f90c776434db4ca8be457632fd225d.tar.bz2 |
make SectionForGlobal non-virtual, add a hook for pic16 to do its "address=" hack.
llvm-svn: 76989
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp | 23 | ||||
-rw-r--r-- | llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h | 8 | ||||
-rw-r--r-- | llvm/lib/Target/TargetAsmInfo.cpp | 17 |
3 files changed, 30 insertions, 18 deletions
diff --git a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp index c2b519d..fedb0b8 100644 --- a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp +++ b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.cpp @@ -203,15 +203,13 @@ PIC16TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV1) const { // First, if this is an automatic variable for a function, get the section // name for it and return. - const std::string name = GV->getName(); - if (PAN::isLocalName(name)) { + std::string name = GV->getName(); + if (PAN::isLocalName(name)) return getSectionForAuto(GV); - } // Record Exteranl Var Defs. - if (GV->hasExternalLinkage() || GV->hasCommonLinkage()) { + if (GV->hasExternalLinkage() || GV->hasCommonLinkage()) ExternalVarDefs->Items.push_back(GV); - } // See if this is an uninitialized global. const Constant *C = GV->getInitializer(); @@ -243,10 +241,12 @@ PIC16TargetAsmInfo::~PIC16TargetAsmInfo() { delete ExternalVarDefs; } -// Override the default implementation. Create PIC16sections for variables -// which have a section name or address. -const Section* -PIC16TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const { + +/// getSpecialCasedSectionGlobals - Allow the target to completely override +/// section assignment of a global. +const Section * +PIC16TargetAsmInfo::getSpecialCasedSectionGlobals(const GlobalValue *GV, + SectionKind::Kind Kind) const{ // If GV has a sectin name or section address create that section now. if (GV->hasSection()) { if (const GlobalVariable *GVar = cast<GlobalVariable>(GV)) { @@ -260,9 +260,8 @@ PIC16TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const { } } } - - // Use section depending on the 'type' of variable - return SelectSectionForGlobal(GV); + + return 0; } // Create a new section for global variable. If Addr is given then create diff --git a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h index abbb504..9b934b0 100644 --- a/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h +++ b/llvm/lib/Target/PIC16/PIC16TargetAsmInfo.h @@ -91,7 +91,13 @@ namespace llvm { const std::vector<PIC16Section*> &getROSections() const { return ROSections; } - virtual const Section *SectionForGlobal(const GlobalValue *GV) const; + + /// getSpecialCasedSectionGlobals - Allow the target to completely override + /// section assignment of a global. + virtual const Section * + getSpecialCasedSectionGlobals(const GlobalValue *GV, + SectionKind::Kind Kind) const; + }; } // namespace llvm diff --git a/llvm/lib/Target/TargetAsmInfo.cpp b/llvm/lib/Target/TargetAsmInfo.cpp index 985f415..1ed9a71 100644 --- a/llvm/lib/Target/TargetAsmInfo.cpp +++ b/llvm/lib/Target/TargetAsmInfo.cpp @@ -263,10 +263,18 @@ TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const { const Section *TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const { - // Select section name + SectionKind::Kind Kind = SectionKindForGlobal(GV); + + // Select section name. if (GV->hasSection()) { + + // If the target has special section hacks for specifically named globals, + // return them now. + if (const Section *TS = getSpecialCasedSectionGlobals(GV, Kind)) + return TS; + // Honour section already set, if any. - unsigned Flags = SectionFlagsForGlobal(GV, SectionKindForGlobal(GV)); + unsigned Flags = SectionFlagsForGlobal(GV, Kind); // This is an explicitly named section. Flags |= SectionFlags::Named; @@ -282,9 +290,8 @@ const Section *TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const { // If this global is linkonce/weak and the target handles this by emitting it // into a 'uniqued' section name, create and return the section now. if (GV->isWeakForLinker()) { - if (const char *Prefix = - getSectionPrefixForUniqueGlobal(SectionKindForGlobal(GV))) { - unsigned Flags = SectionFlagsForGlobal(GV, SectionKindForGlobal(GV)); + if (const char *Prefix = getSectionPrefixForUniqueGlobal(Kind)) { + unsigned Flags = SectionFlagsForGlobal(GV, Kind); // FIXME: Use mangler interface (PR4584). std::string Name = Prefix+GV->getNameStr(); |