summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-05-09 05:23:12 +0000
committerChris Lattner <sabre@nondot.org>2006-05-09 05:23:12 +0000
commit6341df80693916ba95fe7ff8e98966748393576d (patch)
treebe8cf785a869110367bdcd47b4440c94774b56ba /llvm/lib/CodeGen/AsmPrinter.cpp
parent0b7acaf027b1e86e9875b404a5d33d9d5703f71e (diff)
downloadbcm5719-llvm-6341df80693916ba95fe7ff8e98966748393576d.tar.gz
bcm5719-llvm-6341df80693916ba95fe7ff8e98966748393576d.zip
Setting SwitchToSectionDirective properly in the MASM backend permits a bunch
of code to be unified. llvm-svn: 28191
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter.cpp37
1 files changed, 15 insertions, 22 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp
index 846d41d25f0..dda8fd0d054 100644
--- a/llvm/lib/CodeGen/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter.cpp
@@ -102,34 +102,27 @@ void AsmPrinter::SwitchToTextSection(const char *NewSection,
void AsmPrinter::SwitchToDataSection(const char *NewSection,
const GlobalValue *GV) {
std::string NS;
+ if (GV && GV->hasSection())
+ NS = SwitchToSectionDirective + GV->getSection();
+ else
+ NS = NewSection;
+ // If we're already in this section, we're done.
+ if (CurrentSection == NS) return;
+
// Microsoft ML/MASM has a fundamentally different approach to handling
// sections.
if (MLSections) {
- if (GV && GV->hasSection())
- NS = GV->getSection();
- else
- NS = NewSection;
-
- if (CurrentSection != NS) {
- if (!CurrentSection.empty())
- O << CurrentSection << "\tends\n\n";
- CurrentSection = NS;
- if (!CurrentSection.empty())
- O << CurrentSection << "\tsegment 'DATA'\n";
- }
+ if (!CurrentSection.empty())
+ O << CurrentSection << "\tends\n\n";
+ CurrentSection = NS;
+ if (!CurrentSection.empty())
+ O << CurrentSection << "\tsegment 'DATA'\n";
} else {
- if (GV && GV->hasSection())
- NS = SwitchToSectionDirective + GV->getSection();
- else
- NS = NewSection;
-
- if (CurrentSection != NS) {
- CurrentSection = NS;
- if (!CurrentSection.empty())
- O << CurrentSection << '\n';
- }
+ CurrentSection = NS;
+ if (!CurrentSection.empty())
+ O << CurrentSection << '\n';
}
}
OpenPOWER on IntegriCloud