summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-11-21 07:11:11 +0000
committerChris Lattner <sabre@nondot.org>2005-11-21 07:11:11 +0000
commit024e32e1184ed29c2ec8d20fc02b42c5e291f583 (patch)
tree09215241cffc8cc68eee95fccac8328200174507 /llvm/lib
parentb650241f8b86021074eb30470c1579b2d65cc0db (diff)
downloadbcm5719-llvm-024e32e1184ed29c2ec8d20fc02b42c5e291f583.tar.gz
bcm5719-llvm-024e32e1184ed29c2ec8d20fc02b42c5e291f583.zip
Start using the AsmPrinter shared SwitchSection code. This allows the X86
backend to implement global variables in sections. llvm-svn: 24447
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86AsmPrinter.cpp10
-rwxr-xr-xllvm/lib/Target/X86/X86AsmPrinter.h11
2 files changed, 3 insertions, 18 deletions
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index af805766db4..dc12d87d96b 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -105,7 +105,6 @@ void X86SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
bool X86SharedAsmPrinter::doFinalization(Module &M) {
const TargetData &TD = TM.getTargetData();
- std::string CurSection;
// Print out module-level global variables here.
for (Module::const_global_iterator I = M.global_begin(),
@@ -120,7 +119,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
- switchSection(O, CurSection, ".data");
+ SwitchSection(".data", I);
if (!forCygwin && !forDarwin && I->hasInternalLinkage())
O << "\t.local " << name << "\n";
if (forDarwin && I->hasInternalLinkage())
@@ -139,8 +138,8 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak.
// Nonnull linkonce -> weak
O << "\t.weak " << name << "\n";
- switchSection(O, CurSection, "");
O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
+ SwitchSection("", I);
break;
case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of
@@ -150,10 +149,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
O << "\t.globl " << name << "\n";
// FALL THROUGH
case GlobalValue::InternalLinkage:
- if (C->isNullValue())
- switchSection(O, CurSection, ".bss");
- else
- switchSection(O, CurSection, ".data");
+ SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
break;
}
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.h b/llvm/lib/Target/X86/X86AsmPrinter.h
index 06b4225c32f..ff6597d0b2c 100755
--- a/llvm/lib/Target/X86/X86AsmPrinter.h
+++ b/llvm/lib/Target/X86/X86AsmPrinter.h
@@ -55,17 +55,6 @@ struct X86SharedAsmPrinter : public AsmPrinter {
MI->getOperand(Op+2).isRegister() && (MI->getOperand(Op+3).isImmediate()||
MI->getOperand(Op+3).isGlobalAddress());
}
-
- // switchSection - Switch to the specified section of the executable if we are
- // not already in it!
- inline static void switchSection(std::ostream &OS, std::string &CurSection,
- const char *NewSection) {
- if (CurSection != NewSection) {
- CurSection = NewSection;
- if (!CurSection.empty())
- OS << "\t" << NewSection << "\n";
- }
- }
};
} // end namespace x86
OpenPOWER on IntegriCloud