diff options
| author | Jeff Cohen <jeffc@jolt-lang.org> | 2006-05-02 03:58:45 +0000 |
|---|---|---|
| committer | Jeff Cohen <jeffc@jolt-lang.org> | 2006-05-02 03:58:45 +0000 |
| commit | 470f431f44279208768c5c0080913d1243fe891b (patch) | |
| tree | 33b3e29f827882724bbbc45b8dad3a457feaf349 /llvm/lib | |
| parent | f34ddb1e0dafacb760f13e739c999971023a8b11 (diff) | |
| download | bcm5719-llvm-470f431f44279208768c5c0080913d1243fe891b.tar.gz bcm5719-llvm-470f431f44279208768c5c0080913d1243fe891b.zip | |
De-virtualize SwitchSection.
llvm-svn: 28047
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter.cpp | 52 | ||||
| -rwxr-xr-x | llvm/lib/Target/X86/X86IntelAsmPrinter.cpp | 28 | ||||
| -rwxr-xr-x | llvm/lib/Target/X86/X86IntelAsmPrinter.h | 1 |
3 files changed, 44 insertions, 37 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp index aad02327c64..1753160e1f0 100644 --- a/llvm/lib/CodeGen/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter.cpp @@ -47,6 +47,7 @@ AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm) AlignDirective("\t.align\t"), AlignmentIsInBytes(true), SwitchToSectionDirective("\t.section\t"), + MLSections(false), ConstantPoolSection("\t.section .rodata\n"), JumpTableSection("\t.section .rodata\n"), StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"), @@ -63,16 +64,47 @@ AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm) /// void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) { std::string NS; - - if (GV && GV->hasSection()) - NS = SwitchToSectionDirective + GV->getSection(); - else - NS = std::string("\t")+NewSection; - - if (CurrentSection != NS) { - CurrentSection = NS; - if (!CurrentSection.empty()) - O << CurrentSection << '\n'; + + // Microsoft ML/MASM has a fundamentally different approach to handling + // sections. + + if (MLSections) { + if (*NewSection == 0) { + // Simply end the current section, if any. + if (CurrentSection != "") { + O << CurrentSection << "\tends\n"; + CurrentSection = ""; + } + return; + } + + bool isData = strcmp(NewSection , ".data") == 0; + + if (GV && GV->hasSection()) + NS = GV->getSection(); + else if (isData) + NS = "_data"; + else + NS = "_text"; + + if (CurrentSection != NS) { + if (CurrentSection != "") + O << CurrentSection << "\tends\n"; + CurrentSection = NS; + O << CurrentSection << (isData ? "\tsegment 'DATA'\n" + : "\tsegment 'CODE'\n"); + } + } else { + if (GV && GV->hasSection()) + NS = SwitchToSectionDirective + GV->getSection(); + else + NS = std::string("\t")+NewSection; + + if (CurrentSection != NS) { + CurrentSection = NS; + if (!CurrentSection.empty()) + O << CurrentSection << '\n'; + } } } diff --git a/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp b/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp index 900f67e9b8e..747d576695d 100755 --- a/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp @@ -28,6 +28,7 @@ X86IntelAsmPrinter::X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM) GlobalPrefix = "_"; PrivateGlobalPrefix = "$"; AlignDirective = "\talign\t"; + MLSections = true; ZeroDirective = "\tdb\t"; ZeroDirectiveSuffix = " dup(0)"; AsciiDirective = "\tdb\t"; @@ -443,36 +444,11 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) { bool X86IntelAsmPrinter::doFinalization(Module &M) { X86SharedAsmPrinter::doFinalization(M); - if (CurrentSection != "") - O << CurrentSection << "\tends\n"; + SwitchSection("", 0); O << "\tend\n"; return false; } -void X86IntelAsmPrinter::SwitchSection(const char *NewSection, - const GlobalValue *GV) { - if (*NewSection == 0) - return; - - std::string NS; - bool isData = strcmp(NewSection , ".data") == 0; - - if (GV && GV->hasSection()) - NS = GV->getSection(); - else if (isData) - NS = "_data"; - else - NS = "_text"; - - if (CurrentSection != NS) { - if (CurrentSection != "") - O << CurrentSection << "\tends\n"; - CurrentSection = NS; - O << CurrentSection << (isData ? "\tsegment 'DATA'\n" - : "\tsegment 'CODE'\n"); - } -} - void X86IntelAsmPrinter::EmitString(const ConstantArray *CVA) const { unsigned NumElts = CVA->getNumOperands(); if (NumElts) { diff --git a/llvm/lib/Target/X86/X86IntelAsmPrinter.h b/llvm/lib/Target/X86/X86IntelAsmPrinter.h index 34a7110d587..b408ea3903b 100755 --- a/llvm/lib/Target/X86/X86IntelAsmPrinter.h +++ b/llvm/lib/Target/X86/X86IntelAsmPrinter.h @@ -92,7 +92,6 @@ struct X86IntelAsmPrinter : public X86SharedAsmPrinter { bool doInitialization(Module &M); bool doFinalization(Module &M); - virtual void SwitchSection(const char *NewSection, const GlobalValue *GV); virtual void EmitString(const ConstantArray *CVA) const; }; |

