Split UniqueSectionForGlobal()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53301 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov 2008-07-09 13:21:29 +00:00
parent b9e58efdb9
commit b9a02fcaf6
2 changed files with 29 additions and 33 deletions

View File

@ -221,6 +221,15 @@ X86DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
return DW_EH_PE_absptr;
}
std::string
X86DarwinTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const {
if (kind == SectionKind::Text)
return "__TEXT,__textcoal_nt,coalesced,pure_instructions";
else
return "__DATA,__datacoal_nt,coalesced";
}
X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
X86TargetAsmInfo(TM) {
bool is64Bit = X86TM->getSubtarget<X86Subtarget>().is64Bit();
@ -401,41 +410,26 @@ X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
}
}
std::string X86TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const {
const X86Subtarget *Subtarget = &X86TM->getSubtarget<X86Subtarget>();
switch (Subtarget->TargetType) {
case X86Subtarget::isDarwin:
if (kind == SectionKind::Text)
return "__TEXT,__textcoal_nt,coalesced,pure_instructions";
else
return "__DATA,__datacoal_nt,coalesced";
case X86Subtarget::isCygwin:
case X86Subtarget::isMingw:
switch (kind) {
case SectionKind::Text:
return ".text$linkonce" + GV->getName();
case SectionKind::Data:
case SectionKind::BSS:
case SectionKind::ThreadData:
case SectionKind::ThreadBSS:
return ".data$linkonce" + GV->getName();
case SectionKind::ROData:
case SectionKind::RODataMergeConst:
case SectionKind::RODataMergeStr:
return ".rdata$linkonce" + GV->getName();
default:
assert(0 && "Unknown section kind");
}
case X86Subtarget::isELF:
return TargetAsmInfo::UniqueSectionForGlobal(GV, kind);
std::string
X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const {
switch (kind) {
case SectionKind::Text:
return ".text$linkonce" + GV->getName();
case SectionKind::Data:
case SectionKind::BSS:
case SectionKind::ThreadData:
case SectionKind::ThreadBSS:
return ".data$linkonce" + GV->getName();
case SectionKind::ROData:
case SectionKind::RODataMergeConst:
case SectionKind::RODataMergeStr:
return ".rdata$linkonce" + GV->getName();
default:
return "";
assert(0 && "Unknown section kind");
}
}
std::string X86TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
SectionKind::Kind kind = SectionKindForGlobal(GV);
unsigned flags = SectionFlagsForGlobal(GV, GV->getSection().c_str());

View File

@ -26,8 +26,6 @@ namespace llvm {
virtual bool ExpandInlineAsm(CallInst *CI) const;
virtual std::string SectionForGlobal(const GlobalValue *GV) const;
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const;
virtual std::string PrintSectionFlags(unsigned flags) const;
private:
@ -40,6 +38,8 @@ namespace llvm {
explicit X86DarwinTargetAsmInfo(const X86TargetMachine &TM);
virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const;
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const;
};
struct X86ELFTargetAsmInfo : public X86TargetAsmInfo {
@ -52,6 +52,8 @@ namespace llvm {
explicit X86COFFTargetAsmInfo(const X86TargetMachine &TM);
virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const;
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const;
};
struct X86WinTargetAsmInfo : public X86TargetAsmInfo {