From b9a02fcaf62ac38fbf93b413a87619f25f2e6e38 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Wed, 9 Jul 2008 13:21:29 +0000 Subject: [PATCH] Split UniqueSectionForGlobal() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53301 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86TargetAsmInfo.cpp | 56 +++++++++++++---------------- lib/Target/X86/X86TargetAsmInfo.h | 6 ++-- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/lib/Target/X86/X86TargetAsmInfo.cpp b/lib/Target/X86/X86TargetAsmInfo.cpp index 67b50f92d81..ea8d0131b5d 100644 --- a/lib/Target/X86/X86TargetAsmInfo.cpp +++ b/lib/Target/X86/X86TargetAsmInfo.cpp @@ -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().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(); - - 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()); diff --git a/lib/Target/X86/X86TargetAsmInfo.h b/lib/Target/X86/X86TargetAsmInfo.h index 045db7aa057..0789bd8e389 100644 --- a/lib/Target/X86/X86TargetAsmInfo.h +++ b/lib/Target/X86/X86TargetAsmInfo.h @@ -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 {