diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2008-09-24 22:12:10 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2008-09-24 22:12:10 +0000 |
commit | 801e0fd4ead5fe89dc7ced7f7d6c4278a607f580 (patch) | |
tree | babe952c23545f7ce13d6dfa1e6b808fedb26c83 /lib | |
parent | d913a1b0c15b2d96432fbcf712eac85ad705eca8 (diff) | |
download | external_llvm-801e0fd4ead5fe89dc7ced7f7d6c4278a607f580.zip external_llvm-801e0fd4ead5fe89dc7ced7f7d6c4278a607f580.tar.gz external_llvm-801e0fd4ead5fe89dc7ced7f7d6c4278a607f580.tar.bz2 |
Provide direct function to switch to Section
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index de856c1..6e9d935 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -105,6 +105,26 @@ void AsmPrinter::SwitchToDataSection(const char *NewSection, IsInTextSection = false; } +/// 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(); + + // If we're already in this section, we're done. + if (CurrentSection == NewSection) return; + + // Close the current section, if applicable. + if (TAI->getSectionEndDirectiveSuffix() && !CurrentSection.empty()) + O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << '\n'; + + // FIXME: Make CurrentSection a Section* in the future + CurrentSection = NewSection; + + if (!CurrentSection.empty()) + O << CurrentSection << TAI->getDataSectionStartSuffix() << '\n'; + + IsInTextSection = (NS->getFlags() & SectionFlags::Code); +} void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { MachineFunctionPass::getAnalysisUsage(AU); |