diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-27 05:32:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-27 05:32:16 +0000 |
commit | d8310520a75c10de2678e931f984e0c500e0ee43 (patch) | |
tree | 416ba3b4b1c715725a43935b710b6245dd809608 /lib/CodeGen | |
parent | 7b8b13ae655c54cfa770e74d11c02b04e2728dc6 (diff) | |
download | external_llvm-d8310520a75c10de2678e931f984e0c500e0ee43.tar.gz external_llvm-d8310520a75c10de2678e931f984e0c500e0ee43.tar.bz2 external_llvm-d8310520a75c10de2678e931f984e0c500e0ee43.zip |
Eliminate SectionFlags, just embed a SectionKind into Section
instead and drive things based off of that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77184 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 20 | ||||
-rw-r--r-- | lib/CodeGen/ELFWriter.cpp | 14 | ||||
-rw-r--r-- | lib/CodeGen/ELFWriter.h | 3 |
3 files changed, 19 insertions, 18 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 082bce565a..792db22b2d 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -117,8 +117,8 @@ void AsmPrinter::SwitchToDataSection(const char *NewSection, /// SwitchToSection - Switch to the specified section of the executable if we /// are not already in it! -void AsmPrinter::SwitchToSection(const Section* NS) { - const std::string& NewSection = NS->getName(); +void AsmPrinter::SwitchToSection(const Section *NS) { + const std::string &NewSection = NS->getName(); // If we're already in this section, we're done. if (CurrentSection == NewSection) return; @@ -135,20 +135,20 @@ void AsmPrinter::SwitchToSection(const Section* NS) { // If section is named we need to switch into it via special '.section' // directive and also append funky flags. Otherwise - section name is just // some magic assembler directive. - if (NS->hasFlag(SectionFlags::Named)) { - O << TAI->getSwitchToSectionDirective() - << CurrentSection; - + if (NS->getKind().hasExplicitSection()) { SmallString<32> FlagsStr; - TAI->getSectionFlags(NS->getFlags(), FlagsStr); - O << FlagsStr.c_str(); + TAI->getSectionFlagsAsString(NS->getKind(), FlagsStr); + + O << TAI->getSwitchToSectionDirective() + << CurrentSection + << FlagsStr.c_str(); } else { O << CurrentSection; } O << TAI->getDataSectionStartSuffix() << '\n'; } - IsInTextSection = (NS->getFlags() & SectionFlags::Code); + IsInTextSection = NS->getKind().isText(); } void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { @@ -404,7 +404,7 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI, bool JTInDiffSection = false; if ((IsPic && !(LoweringInfo && LoweringInfo->usesGlobalOffsetTable())) || !JumpTableDataSection || - FuncSection->hasFlag(SectionFlags::Linkonce)) { + FuncSection->getKind().isWeak()) { // In PIC mode, we need to emit the jump table to the same section as the // function body itself, otherwise the label differences won't make sense. // We should also do if the section name is NULL or function is declared in diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index c0e7b93cf1..c61d4210cb 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -228,18 +228,18 @@ unsigned ELFWriter::getGlobalELFType(const GlobalValue *GV) { // getElfSectionFlags - Get the ELF Section Header flags based // on the flags defined in ELFTargetAsmInfo. -unsigned ELFWriter::getElfSectionFlags(unsigned Flags) { +unsigned ELFWriter::getElfSectionFlags(SectionKind Kind) { unsigned ElfSectionFlags = ELFSection::SHF_ALLOC; - if (Flags & SectionFlags::Code) + if (Kind.isText()) ElfSectionFlags |= ELFSection::SHF_EXECINSTR; - if (Flags & SectionFlags::Writable) + if (Kind.isWriteable()) ElfSectionFlags |= ELFSection::SHF_WRITE; - if (Flags & SectionFlags::Mergeable) + if (Kind.isMergeableConst()) ElfSectionFlags |= ELFSection::SHF_MERGE; - if (Flags & SectionFlags::TLS) + if (Kind.isThreadLocal()) ElfSectionFlags |= ELFSection::SHF_TLS; - if (Flags & SectionFlags::Strings) + if (Kind.isMergeableCString()) ElfSectionFlags |= ELFSection::SHF_STRINGS; return ElfSectionFlags; @@ -293,7 +293,7 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) { // Get ELF section from TAI const Section *S = TAI->SectionForGlobal(GV); - unsigned SectionFlags = getElfSectionFlags(S->getFlags()); + unsigned SectionFlags = getElfSectionFlags(S->getKind()); // The symbol align should update the section alignment if needed const TargetData *TD = TM.getTargetData(); diff --git a/lib/CodeGen/ELFWriter.h b/lib/CodeGen/ELFWriter.h index 6f083b925a..8dcd970cfc 100644 --- a/lib/CodeGen/ELFWriter.h +++ b/lib/CodeGen/ELFWriter.h @@ -34,6 +34,7 @@ namespace llvm { class TargetAsmInfo; class TargetELFWriterInfo; class raw_ostream; + class SectionKind; typedef std::vector<ELFSym*>::iterator ELFSymIter; typedef std::vector<ELFSection*>::iterator ELFSectionIter; @@ -209,7 +210,7 @@ namespace llvm { unsigned getGlobalELFBinding(const GlobalValue *GV); unsigned getGlobalELFType(const GlobalValue *GV); unsigned getGlobalELFVisibility(const GlobalValue *GV); - unsigned getElfSectionFlags(unsigned Flags); + unsigned getElfSectionFlags(SectionKind Kind); // setGlobalSymLookup - Set global value 'GV' with 'Index' in the lookup map void setGlobalSymLookup(const GlobalValue *GV, unsigned Index) { |