implement DarwinTargetAsmInfo::getSectionForFunction, use it when outputting

function bodies

llvm-svn: 30733
This commit is contained in:
Chris Lattner 2006-10-05 00:35:50 +00:00
parent afe6d7a179
commit 0d236450aa
3 changed files with 21 additions and 6 deletions

View File

@ -422,19 +422,17 @@ bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Print out labels for the function. // Print out labels for the function.
const Function *F = MF.getFunction(); const Function *F = MF.getFunction();
SwitchToTextSection(TAI->getSectionForFunction(*F), F);
switch (F->getLinkage()) { switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!"); default: assert(0 && "Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal. case Function::InternalLinkage: // Symbols default to internal.
SwitchToTextSection("\t.text", F);
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
SwitchToTextSection("\t.text", F);
O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.globl\t" << CurrentFnName << "\n";
break; break;
case Function::WeakLinkage: case Function::WeakLinkage:
case Function::LinkOnceLinkage: case Function::LinkOnceLinkage:
SwitchToTextSection(
".section __TEXT,__textcoal_nt,coalesced,pure_instructions", F);
O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.globl\t" << CurrentFnName << "\n";
O << "\t.weak_definition\t" << CurrentFnName << "\n"; O << "\t.weak_definition\t" << CurrentFnName << "\n";
break; break;

View File

@ -13,7 +13,7 @@
#include "PPCTargetAsmInfo.h" #include "PPCTargetAsmInfo.h"
#include "PPCTargetMachine.h" #include "PPCTargetMachine.h"
#include "llvm/Function.h"
using namespace llvm; using namespace llvm;
DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM) { DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM) {
@ -50,3 +50,15 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM) {
DwarfRangesSection = ".section __DWARF,__debug_ranges"; DwarfRangesSection = ".section __DWARF,__debug_ranges";
DwarfMacInfoSection = ".section __DWARF,__debug_macinfo"; DwarfMacInfoSection = ".section __DWARF,__debug_macinfo";
} }
const char *DarwinTargetAsmInfo::getSectionForFunction(const Function &F) const{
switch (F.getLinkage()) {
default: assert(0 && "Unknown linkage type!");
case Function::ExternalLinkage:
case Function::InternalLinkage: return TextSection;
case Function::WeakLinkage:
case Function::LinkOnceLinkage:
return ".section __TEXT,__textcoal_nt,coalesced,pure_instructions";
}
}

View File

@ -23,9 +23,14 @@ namespace llvm {
struct DarwinTargetAsmInfo : public TargetAsmInfo { struct DarwinTargetAsmInfo : public TargetAsmInfo {
DarwinTargetAsmInfo(const PPCTargetMachine &TM); DarwinTargetAsmInfo(const PPCTargetMachine &TM);
/// getSectionForFunction - Return the section that we should emit the
/// specified function body into. This defaults to 'TextSection'. This
/// should most likely be overridden by the target to put linkonce/weak
/// functions into special sections.
virtual const char *getSectionForFunction(const Function &F) const;
}; };
} // namespace llvm } // namespace llvm
#endif #endif