Split SwitchSection into SwitchTo{Text|Data}Section methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28184 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-05-09 04:59:56 +00:00
parent f668ffc4c2
commit 4632d7a570
9 changed files with 131 additions and 86 deletions

View File

@ -59,10 +59,11 @@ AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm)
}
/// SwitchSection - Switch to the specified section of the executable if we
/// are not already in it!
/// SwitchToTextSection - Switch to the specified text section of the executable
/// if we are not already in it!
///
void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) {
void AsmPrinter::SwitchToTextSection(const char *NewSection,
const GlobalValue *GV) {
std::string NS;
// Microsoft ML/MASM has a fundamentally different approach to handling
@ -78,12 +79,8 @@ void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) {
return;
}
bool isData = strcmp(NewSection , ".data") == 0;
if (GV && GV->hasSection())
NS = GV->getSection();
else if (isData)
NS = "_data";
else
NS = "_text";
@ -91,8 +88,7 @@ void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) {
if (!CurrentSection.empty())
O << CurrentSection << "\tends\n\n";
CurrentSection = NS;
O << CurrentSection << (isData ? "\tsegment 'DATA'\n"
: "\tsegment 'CODE'\n");
O << CurrentSection << "\tsegment 'CODE'\n";
}
} else {
if (GV && GV->hasSection())
@ -108,6 +104,52 @@ void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) {
}
}
/// SwitchToTextSection - Switch to the specified text section of the executable
/// if we are not already in it!
///
void AsmPrinter::SwitchToDataSection(const char *NewSection,
const GlobalValue *GV) {
std::string NS;
// 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.empty()) {
O << CurrentSection << "\tends\n\n";
CurrentSection.clear();
}
return;
}
if (GV && GV->hasSection())
NS = GV->getSection();
else
NS = "_data";
if (CurrentSection != NS) {
if (!CurrentSection.empty())
O << CurrentSection << "\tends\n\n";
CurrentSection = NS;
O << CurrentSection << "\tsegment 'DATA'\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';
}
}
}
bool AsmPrinter::doInitialization(Module &M) {
Mang = new Mangler(M, GlobalPrefix);
@ -116,7 +158,7 @@ bool AsmPrinter::doInitialization(Module &M) {
<< M.getModuleInlineAsm()
<< "\n" << CommentString << " End of file scope inline assembly\n";
SwitchSection("", 0); // Reset back to no section.
SwitchToDataSection("", 0); // Reset back to no section.
if (MachineDebugInfo *DebugInfo = getAnalysisToUpdate<MachineDebugInfo>()) {
DebugInfo->AnalyzeModule(M);
@ -146,7 +188,7 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
if (CP.empty()) return;
const TargetData *TD = TM.getTargetData();
SwitchSection(ConstantPoolSection, 0);
SwitchToDataSection(ConstantPoolSection, 0);
EmitAlignment(MCP->getConstantPoolAlignment());
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
@ -175,7 +217,7 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
TM.getRelocationModel() == Reloc::DynamicNoPIC) &&
"Unhandled relocation model emitting jump table information!");
SwitchSection(JumpTableSection, 0);
SwitchToDataSection(JumpTableSection, 0);
EmitAlignment(Log2_32(TD->getPointerAlignment()));
for (unsigned i = 0, e = JT.size(); i != e; ++i) {
O << PrivateGlobalPrefix << "JTI" << getFunctionNumber() << '_' << i
@ -204,14 +246,14 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
return true; // No need to emit this at all.
if (GV->getName() == "llvm.global_ctors" && GV->use_empty()) {
SwitchSection(StaticCtorsSection, 0);
SwitchToDataSection(StaticCtorsSection, 0);
EmitAlignment(2, 0);
EmitXXStructorList(GV->getInitializer());
return true;
}
if (GV->getName() == "llvm.global_dtors" && GV->use_empty()) {
SwitchSection(StaticDtorsSection, 0);
SwitchToDataSection(StaticDtorsSection, 0);
EmitAlignment(2, 0);
EmitXXStructorList(GV->getInitializer());
return true;

View File

@ -1647,33 +1647,33 @@ void DwarfWriter::ConstructRootScope(DebugScope *RootScope) {
///
void DwarfWriter::EmitInitial() const {
// Dwarf sections base addresses.
Asm->SwitchSection(DwarfFrameSection, 0);
Asm->SwitchToDataSection(DwarfFrameSection, 0);
EmitLabel("section_frame", 0);
Asm->SwitchSection(DwarfInfoSection, 0);
Asm->SwitchToDataSection(DwarfInfoSection, 0);
EmitLabel("section_info", 0);
EmitLabel("info", 0);
Asm->SwitchSection(DwarfAbbrevSection, 0);
Asm->SwitchToDataSection(DwarfAbbrevSection, 0);
EmitLabel("section_abbrev", 0);
EmitLabel("abbrev", 0);
Asm->SwitchSection(DwarfARangesSection, 0);
Asm->SwitchToDataSection(DwarfARangesSection, 0);
EmitLabel("section_aranges", 0);
Asm->SwitchSection(DwarfMacInfoSection, 0);
Asm->SwitchToDataSection(DwarfMacInfoSection, 0);
EmitLabel("section_macinfo", 0);
Asm->SwitchSection(DwarfLineSection, 0);
Asm->SwitchToDataSection(DwarfLineSection, 0);
EmitLabel("section_line", 0);
EmitLabel("line", 0);
Asm->SwitchSection(DwarfLocSection, 0);
Asm->SwitchToDataSection(DwarfLocSection, 0);
EmitLabel("section_loc", 0);
Asm->SwitchSection(DwarfPubNamesSection, 0);
Asm->SwitchToDataSection(DwarfPubNamesSection, 0);
EmitLabel("section_pubnames", 0);
Asm->SwitchSection(DwarfStrSection, 0);
Asm->SwitchToDataSection(DwarfStrSection, 0);
EmitLabel("section_str", 0);
Asm->SwitchSection(DwarfRangesSection, 0);
Asm->SwitchToDataSection(DwarfRangesSection, 0);
EmitLabel("section_ranges", 0);
Asm->SwitchSection(TextSection, 0);
Asm->SwitchToDataSection(TextSection, 0);
EmitLabel("text_begin", 0);
Asm->SwitchSection(DataSection, 0);
Asm->SwitchToDataSection(DataSection, 0);
EmitLabel("data_begin", 0);
}
@ -1849,7 +1849,7 @@ void DwarfWriter::EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
///
void DwarfWriter::EmitDebugInfo() const {
// Start debug info section.
Asm->SwitchSection(DwarfInfoSection, 0);
Asm->SwitchToDataSection(DwarfInfoSection, 0);
// Process each compile unit.
for (unsigned i = 0, N = CompileUnits.size(); i < N; ++i) {
@ -1884,7 +1884,7 @@ void DwarfWriter::EmitAbbreviations() const {
// Check to see if it is worth the effort.
if (!Abbreviations.empty()) {
// Start the debug abbrev section.
Asm->SwitchSection(DwarfAbbrevSection, 0);
Asm->SwitchToDataSection(DwarfAbbrevSection, 0);
EmitLabel("abbrev_begin", 0);
@ -1918,7 +1918,7 @@ void DwarfWriter::EmitDebugLines() const {
const int MaxLineDelta = 255 + MinLineDelta;
// Start the dwarf line section.
Asm->SwitchSection(DwarfLineSection, 0);
Asm->SwitchToDataSection(DwarfLineSection, 0);
// Construct the section header.
@ -2061,7 +2061,7 @@ void DwarfWriter::EmitInitialDebugFrame() {
AddressSize : -AddressSize;
// Start the dwarf frame section.
Asm->SwitchSection(DwarfFrameSection, 0);
Asm->SwitchToDataSection(DwarfFrameSection, 0);
EmitDifference("frame_common_end", 0,
"frame_common_begin", 0);
@ -2090,7 +2090,7 @@ void DwarfWriter::EmitInitialDebugFrame() {
/// section.
void DwarfWriter::EmitFunctionDebugFrame() {
// Start the dwarf frame section.
Asm->SwitchSection(DwarfFrameSection, 0);
Asm->SwitchToDataSection(DwarfFrameSection, 0);
EmitDifference("frame_end", SubprogramCount,
"frame_begin", SubprogramCount);
@ -2119,7 +2119,7 @@ void DwarfWriter::EmitFunctionDebugFrame() {
///
void DwarfWriter::EmitDebugPubNames() {
// Start the dwarf pubnames section.
Asm->SwitchSection(DwarfPubNamesSection, 0);
Asm->SwitchToDataSection(DwarfPubNamesSection, 0);
// Process each compile unit.
for (unsigned i = 0, N = CompileUnits.size(); i < N; ++i) {
@ -2166,7 +2166,7 @@ void DwarfWriter::EmitDebugStr() {
// Check to see if it is worth the effort.
if (!StringPool.empty()) {
// Start the dwarf str section.
Asm->SwitchSection(DwarfStrSection, 0);
Asm->SwitchToDataSection(DwarfStrSection, 0);
// For each of strings in the string pool.
for (unsigned StringID = 1, N = StringPool.size();
@ -2186,7 +2186,7 @@ void DwarfWriter::EmitDebugStr() {
///
void DwarfWriter::EmitDebugLoc() {
// Start the dwarf loc section.
Asm->SwitchSection(DwarfLocSection, 0);
Asm->SwitchToDataSection(DwarfLocSection, 0);
O << "\n";
}
@ -2195,7 +2195,7 @@ void DwarfWriter::EmitDebugLoc() {
///
void DwarfWriter::EmitDebugARanges() {
// Start the dwarf aranges section.
Asm->SwitchSection(DwarfARangesSection, 0);
Asm->SwitchToDataSection(DwarfARangesSection, 0);
// FIXME - Mock up
#if 0
@ -2236,7 +2236,7 @@ void DwarfWriter::EmitDebugARanges() {
///
void DwarfWriter::EmitDebugRanges() {
// Start the dwarf ranges section.
Asm->SwitchSection(DwarfRangesSection, 0);
Asm->SwitchToDataSection(DwarfRangesSection, 0);
O << "\n";
}
@ -2245,7 +2245,7 @@ void DwarfWriter::EmitDebugRanges() {
///
void DwarfWriter::EmitDebugMacInfo() {
// Start the dwarf macinfo section.
Asm->SwitchSection(DwarfMacInfoSection, 0);
Asm->SwitchToDataSection(DwarfMacInfoSection, 0);
O << "\n";
}
@ -2381,9 +2381,9 @@ void DwarfWriter::EndModule() {
EOL("Dwarf End Module");
// Standard sections final addresses.
Asm->SwitchSection(TextSection, 0);
Asm->SwitchToTextSection(TextSection, 0);
EmitLabel("text_end", 0);
Asm->SwitchSection(DataSection, 0);
Asm->SwitchToDataSection(DataSection, 0);
EmitLabel("data_end", 0);
// Compute DIE offsets and sizes.

View File

@ -151,7 +151,7 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Print out labels for the function.
const Function *F = MF.getFunction();
SwitchSection(".text", F);
SwitchToTextSection(".text", F);
EmitAlignment(4, F);
switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!");
@ -221,7 +221,7 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
SwitchSection("\t.section .data", I);
SwitchToDataSection("\t.section .data", I);
if (I->hasInternalLinkage())
O << "\t.local " << name << "\n";
@ -235,7 +235,7 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
// Nonnull linkonce -> weak
O << "\t.weak " << name << "\n";
O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
SwitchSection("", I);
SwitchToDataSection("", I);
break;
case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of
@ -245,8 +245,8 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
O << "\t.globl " << name << "\n";
// FALL THROUGH
case GlobalValue::InternalLinkage:
SwitchSection(C->isNullValue() ? "\t.section .bss" :
"\t.section .data", I);
SwitchToDataSection(C->isNullValue() ? "\t.section .bss" :
"\t.section .data", I);
break;
case GlobalValue::GhostLinkage:
std::cerr << "GhostLinkage cannot appear in AlphaAsmPrinter!\n";

View File

@ -142,7 +142,8 @@ bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
EmitConstantPool(MF.getConstantPool());
// Print out labels for the function.
SwitchSection("\n\t.section .text, \"ax\", \"progbits\"\n", MF.getFunction());
SwitchToTextSection("\n\t.section .text, \"ax\", \"progbits\"\n",
MF.getFunction());
// ^^ means "Allocated instruXions in mem, initialized"
EmitAlignment(5);
O << "\t.global\t" << CurrentFnName << "\n";
@ -282,7 +283,7 @@ bool IA64AsmPrinter::doFinalization(Module &M) {
if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
SwitchSection(".data", I);
SwitchToDataSection(".data", I);
if (I->hasInternalLinkage()) {
O << "\t.lcomm " << name << "#," << TD->getTypeSize(C->getType())
<< "," << (1 << Align);
@ -302,7 +303,7 @@ bool IA64AsmPrinter::doFinalization(Module &M) {
O << "\t.weak " << name << "\n";
O << "\t.section\t.llvm.linkonce.d." << name
<< ", \"aw\", \"progbits\"\n";
SwitchSection("", I);
SwitchToDataSection("", I);
break;
case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of
@ -312,7 +313,7 @@ bool IA64AsmPrinter::doFinalization(Module &M) {
O << "\t.global " << name << "\n";
// FALL THROUGH
case GlobalValue::InternalLinkage:
SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
SwitchToDataSection(C->isNullValue() ? ".bss" : ".data", I);
break;
case GlobalValue::GhostLinkage:
std::cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n";

View File

@ -511,16 +511,16 @@ bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
SwitchSection(".text", F);
SwitchToTextSection(".text", F);
break;
case Function::ExternalLinkage:
SwitchSection(".text", F);
SwitchToTextSection(".text", F);
O << "\t.globl\t" << CurrentFnName << "\n";
break;
case Function::WeakLinkage:
case Function::LinkOnceLinkage:
SwitchSection(".section __TEXT,__textcoal_nt,coalesced,pure_instructions",
F);
SwitchToTextSection(
".section __TEXT,__textcoal_nt,coalesced,pure_instructions", F);
O << "\t.globl\t" << CurrentFnName << "\n";
O << "\t.weak_definition\t" << CurrentFnName << "\n";
break;
@ -595,10 +595,10 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
O << "\t.zerofill __DATA, __common, " << name << ", "
<< Size << ", " << Align;
} else if (I->hasInternalLinkage()) {
SwitchSection(".data", I);
SwitchToDataSection(".data", I);
O << LCOMMDirective << name << "," << Size << "," << Align;
} else {
SwitchSection(".data", I);
SwitchToDataSection(".data", I);
O << ".comm " << name << "," << Size;
}
O << "\t\t; '" << I->getName() << "'\n";
@ -608,7 +608,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
case GlobalValue::WeakLinkage:
O << "\t.globl " << name << '\n'
<< "\t.weak_definition " << name << '\n';
SwitchSection(".section __DATA,__datacoal_nt,coalesced", I);
SwitchToDataSection(".section __DATA,__datacoal_nt,coalesced", I);
break;
case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of
@ -618,7 +618,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
O << "\t.globl " << name << "\n";
// FALL THROUGH
case GlobalValue::InternalLinkage:
SwitchSection(".data", I);
SwitchToDataSection(".data", I);
break;
default:
std::cerr << "Unknown linkage type!";
@ -636,8 +636,8 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
if (TM.getRelocationModel() == Reloc::PIC) {
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
i != e; ++i) {
SwitchSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
"pure_instructions,32", 0);
SwitchToTextSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
"pure_instructions,32", 0);
EmitAlignment(2);
O << "L" << *i << "$stub:\n";
O << "\t.indirect_symbol " << *i << "\n";
@ -650,7 +650,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n";
O << "\tmtctr r12\n";
O << "\tbctr\n";
SwitchSection(".lazy_symbol_pointer", 0);
SwitchToDataSection(".lazy_symbol_pointer", 0);
O << "L" << *i << "$lazy_ptr:\n";
O << "\t.indirect_symbol " << *i << "\n";
O << "\t.long dyld_stub_binding_helper\n";
@ -658,8 +658,8 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
} else {
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
i != e; ++i) {
SwitchSection(".section __TEXT,__symbol_stub1,symbol_stubs,"
"pure_instructions,16", 0);
SwitchToTextSection(".section __TEXT,__symbol_stub1,symbol_stubs,"
"pure_instructions,16", 0);
EmitAlignment(4);
O << "L" << *i << "$stub:\n";
O << "\t.indirect_symbol " << *i << "\n";
@ -667,7 +667,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr)(r11)\n";
O << "\tmtctr r12\n";
O << "\tbctr\n";
SwitchSection(".lazy_symbol_pointer", 0);
SwitchToDataSection(".lazy_symbol_pointer", 0);
O << "L" << *i << "$lazy_ptr:\n";
O << "\t.indirect_symbol " << *i << "\n";
O << "\t.long dyld_stub_binding_helper\n";
@ -678,7 +678,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
// Output stubs for external and common global variables.
if (GVStubs.begin() != GVStubs.end()) {
SwitchSection(".non_lazy_symbol_pointer", 0);
SwitchToDataSection(".non_lazy_symbol_pointer", 0);
for (std::set<std::string>::iterator I = GVStubs.begin(),
E = GVStubs.end(); I != E; ++I) {
O << "L" << *I << "$non_lazy_ptr:\n";
@ -747,7 +747,7 @@ bool AIXAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
}
bool AIXAsmPrinter::doInitialization(Module &M) {
SwitchSection("", 0);
SwitchToDataSection("", 0);
const TargetData *TD = TM.getTargetData();
O << "\t.machine \"ppc64\"\n"

View File

@ -98,8 +98,8 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
CurrentFnName = Mang->getValueName(MF.getFunction());
// Print out labels for the function.
O << "\t.text\n";
O << "\t.align 16\n";
SwitchToTextSection(".text", MF.getFunction());
EmitAlignment(4, MF.getFunction());
O << "\t.globl\t" << CurrentFnName << "\n";
O << "\t.type\t" << CurrentFnName << ", #function\n";
O << CurrentFnName << ":\n";
@ -238,7 +238,7 @@ bool SparcAsmPrinter::doFinalization(Module &M) {
if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
SwitchSection(".data", I);
SwitchToDataSection(".data", I);
if (I->hasInternalLinkage())
O << "\t.local " << name << "\n";
@ -253,7 +253,7 @@ bool SparcAsmPrinter::doFinalization(Module &M) {
case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak.
// Nonnull linkonce -> weak
O << "\t.weak " << name << "\n";
SwitchSection("", I);
SwitchToDataSection("", I);
O << "\t.section\t\".llvm.linkonce.d." << name
<< "\",\"aw\",@progbits\n";
break;
@ -267,9 +267,9 @@ bool SparcAsmPrinter::doFinalization(Module &M) {
// FALL THROUGH
case GlobalValue::InternalLinkage:
if (C->isNullValue())
SwitchSection(".bss", I);
SwitchToDataSection(".bss", I);
else
SwitchSection(".data", I);
SwitchToDataSection(".data", I);
break;
case GlobalValue::GhostLinkage:
std::cerr << "Should not have any unmaterialized functions!\n";

View File

@ -46,25 +46,26 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
SwitchSection(".text", F);
SwitchToTextSection(".text", F);
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
break;
case Function::ExternalLinkage:
SwitchSection(".text", F);
SwitchToTextSection(".text", F);
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
O << "\t.globl\t" << CurrentFnName << "\n";
break;
case Function::WeakLinkage:
case Function::LinkOnceLinkage:
if (forDarwin) {
SwitchSection(".section __TEXT,__textcoal_nt,coalesced,pure_instructions",
F);
SwitchToTextSection(
".section __TEXT,__textcoal_nt,coalesced,pure_instructions", F);
O << "\t.globl\t" << CurrentFnName << "\n";
O << "\t.weak_definition\t" << CurrentFnName << "\n";
} else {
EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
O << "\t.section\t.llvm.linkonce.t." << CurrentFnName
<< ",\"ax\",@progbits\n";
SwitchToTextSection("", F);
O << "\t.weak " << CurrentFnName << "\n";
}
break;

View File

@ -119,7 +119,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
O << "\t.zerofill __DATA__, __common, " << name << ", "
<< Size << ", " << Align;
} else {
SwitchSection(".data", I);
SwitchToDataSection(".data", I);
if (LCOMMDirective != NULL) {
if (I->hasInternalLinkage()) {
O << LCOMMDirective << name << "," << Size;
@ -143,7 +143,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
if (forDarwin) {
O << "\t.globl " << name << "\n"
<< "\t.weak_definition " << name << "\n";
SwitchSection(".section __DATA,__datacoal_nt,coalesced", I);
SwitchToDataSection(".section __DATA,__datacoal_nt,coalesced", I);
} else {
O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
O << "\t.weak " << name << "\n";
@ -157,7 +157,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
O << "\t.globl " << name << "\n";
// FALL THROUGH
case GlobalValue::InternalLinkage:
SwitchSection(".data", I);
SwitchToDataSection(".data", I);
break;
default:
assert(0 && "Unknown linkage type!");
@ -175,14 +175,14 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
}
if (forDarwin) {
SwitchSection("", 0);
SwitchToDataSection("", 0);
// Output stubs for dynamically-linked functions
unsigned j = 1;
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
i != e; ++i, ++j) {
SwitchSection(".section __IMPORT,__jump_table,symbol_stubs,"
"self_modifying_code+pure_instructions,5", 0);
SwitchToDataSection(".section __IMPORT,__jump_table,symbol_stubs,"
"self_modifying_code+pure_instructions,5", 0);
O << "L" << *i << "$stub:\n";
O << "\t.indirect_symbol " << *i << "\n";
O << "\thlt ; hlt ; hlt ; hlt ; hlt\n";
@ -192,7 +192,8 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
// Output stubs for external and common global variables.
if (GVStubs.begin() != GVStubs.end())
SwitchSection(".section __IMPORT,__pointers,non_lazy_symbol_pointers", 0);
SwitchToDataSection(
".section __IMPORT,__pointers,non_lazy_symbol_pointers", 0);
for (std::set<std::string>::iterator i = GVStubs.begin(), e = GVStubs.end();
i != e; ++i) {
O << "L" << *i << "$non_lazy_ptr:\n";

View File

@ -37,7 +37,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
EmitConstantPool(MF.getConstantPool());
// Print out labels for the function.
SwitchSection(".code", MF.getFunction());
SwitchToTextSection(".code", MF.getFunction());
EmitAlignment(4);
if (MF.getFunction()->getLinkage() == GlobalValue::ExternalLinkage)
O << "\tpublic " << CurrentFnName << "\n";
@ -342,14 +342,14 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {
switch (I->getLinkage()) {
case GlobalValue::LinkOnceLinkage:
case GlobalValue::WeakLinkage:
SwitchSection("", 0);
SwitchToDataSection("", 0);
O << name << "?\tsegment common 'COMMON'\n";
bCustomSegment = true;
// FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256
// are also available.
break;
case GlobalValue::AppendingLinkage:
SwitchSection("", 0);
SwitchToDataSection("", 0);
O << name << "?\tsegment public 'DATA'\n";
bCustomSegment = true;
// FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256
@ -359,7 +359,7 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {
O << "\tpublic " << name << "\n";
// FALL THROUGH
case GlobalValue::InternalLinkage:
SwitchSection(".data", I);
SwitchToDataSection(".data", I);
break;
default:
assert(0 && "Unknown linkage type!");
@ -378,7 +378,7 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {
// Bypass X86SharedAsmPrinter::doFinalization().
AsmPrinter::doFinalization(M);
SwitchSection("", 0);
SwitchToDataSection("", 0);
O << "\tend\n";
return false; // success
}