From 2ae5446b62689e5e1a8092024791f319f4e3ccd8 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Sat, 16 Aug 2008 12:58:12 +0000 Subject: [PATCH] Add interface for section override. Use this for Sparc, since it should use named BSS section. llvm-svn: 54844 --- llvm/include/llvm/Target/TargetAsmInfo.h | 6 ++++-- llvm/lib/Target/Sparc/SparcTargetAsmInfo.cpp | 5 +++++ llvm/lib/Target/TargetAsmInfo.cpp | 10 ++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/Target/TargetAsmInfo.h b/llvm/include/llvm/Target/TargetAsmInfo.h index c346d0ed9870..ff2491e7ab32 100644 --- a/llvm/include/llvm/Target/TargetAsmInfo.h +++ b/llvm/include/llvm/Target/TargetAsmInfo.h @@ -520,9 +520,11 @@ namespace llvm { virtual ~TargetAsmInfo(); const Section* getNamedSection(const char *Name, - unsigned Flags = SectionFlags::None) const; + unsigned Flags = SectionFlags::None, + bool Override = false) const; const Section* getUnnamedSection(const char *Directive, - unsigned Flags = SectionFlags::None) const; + unsigned Flags = SectionFlags::None, + bool Override = false) const; /// Measure the specified inline asm to determine an approximation of its /// length. diff --git a/llvm/lib/Target/Sparc/SparcTargetAsmInfo.cpp b/llvm/lib/Target/Sparc/SparcTargetAsmInfo.cpp index afa5327d9525..c13d45ceec7c 100644 --- a/llvm/lib/Target/Sparc/SparcTargetAsmInfo.cpp +++ b/llvm/lib/Target/Sparc/SparcTargetAsmInfo.cpp @@ -25,6 +25,11 @@ SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM): ConstantPoolSection = "\t.section \".rodata\",#alloc\n"; COMMDirectiveTakesAlignment = true; CStringSection=".rodata.str"; + + // Sparc normally uses named section for BSS. + BSSSection_ = getNamedSection("\t.bss", + SectionFlags::Writeable | SectionFlags::BSS, + /* Override */ true); } std::string SparcELFTargetAsmInfo::printSectionFlags(unsigned flags) const { diff --git a/llvm/lib/Target/TargetAsmInfo.cpp b/llvm/lib/Target/TargetAsmInfo.cpp index cc0745f680a2..6baebd0ffe76 100644 --- a/llvm/lib/Target/TargetAsmInfo.cpp +++ b/llvm/lib/Target/TargetAsmInfo.cpp @@ -352,11 +352,12 @@ TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV, } const Section* -TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags) const { +TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags, + bool Override) const { Section& S = Sections[Name]; // This is newly-created section, set it up properly. - if (S.Flags == SectionFlags::Invalid) { + if (S.Flags == SectionFlags::Invalid || Override) { S.Flags = Flags | SectionFlags::Named; S.Name = Name; } @@ -365,11 +366,12 @@ TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags) const { } const Section* -TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags) const { +TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags, + bool Override) const { Section& S = Sections[Directive]; // This is newly-created section, set it up properly. - if (S.Flags == SectionFlags::Invalid) { + if (S.Flags == SectionFlags::Invalid || Override) { S.Flags = Flags & ~SectionFlags::Named; S.Name = Directive; }