MCize a bunch more stuff, eliminating a lot of uses of the mangler

and CurrentFnName.

llvm-svn: 93594
This commit is contained in:
Chris Lattner 2010-01-16 00:21:18 +00:00
parent c35c4386a0
commit 40eb58664f
10 changed files with 367 additions and 196 deletions

View File

@ -256,7 +256,9 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
case Function::InternalLinkage: case Function::InternalLinkage:
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.globl\t";
CurrentFnSym->print(O, MAI);
O << "\n";
break; break;
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
@ -264,29 +266,38 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage: case Function::LinkOnceODRLinkage:
if (Subtarget->isTargetDarwin()) { if (Subtarget->isTargetDarwin()) {
O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.globl\t";
O << "\t.weak_definition\t" << CurrentFnName << "\n"; CurrentFnSym->print(O, MAI);
O << "\n";
O << "\t.weak_definition\t";
CurrentFnSym->print(O, MAI);
O << "\n";
} else { } else {
O << MAI->getWeakRefDirective() << CurrentFnName << "\n"; O << MAI->getWeakRefDirective();
CurrentFnSym->print(O, MAI);
O << "\n";
} }
break; break;
} }
printVisibility(CurrentFnName, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
unsigned FnAlign = 1 << MF.getAlignment(); // MF alignment is log2. unsigned FnAlign = 1 << MF.getAlignment(); // MF alignment is log2.
if (AFI->isThumbFunction()) { if (AFI->isThumbFunction()) {
EmitAlignment(FnAlign, F, AFI->getAlign()); EmitAlignment(FnAlign, F, AFI->getAlign());
O << "\t.code\t16\n"; O << "\t.code\t16\n";
O << "\t.thumb_func"; O << "\t.thumb_func";
if (Subtarget->isTargetDarwin()) if (Subtarget->isTargetDarwin()) {
O << "\t" << CurrentFnName; O << "\t";
CurrentFnSym->print(O, MAI);
}
O << "\n"; O << "\n";
} else { } else {
EmitAlignment(FnAlign, F); EmitAlignment(FnAlign, F);
} }
O << CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << ":\n";
// Emit pre-function debug information. // Emit pre-function debug information.
DW->BeginFunction(&MF); DW->BeginFunction(&MF);
@ -313,8 +324,13 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
printMachineInstruction(II); printMachineInstruction(II);
} }
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n"; O << "\t.size ";
CurrentFnSym->print(O, MAI);
O << ", .-";
CurrentFnSym->print(O, MAI);
O << "\n";
}
// Emit post-function debug information. // Emit post-function debug information.
DW->EndFunction(&MF); DW->EndFunction(&MF);

View File

@ -147,22 +147,29 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
case Function::PrivateLinkage: case Function::PrivateLinkage:
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl " << CurrentFnName << "\n"; O << "\t.globl ";
break; CurrentFnSym->print(O, MAI);
O << "\n";
break;
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
case Function::WeakODRLinkage: case Function::WeakODRLinkage:
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage: case Function::LinkOnceODRLinkage:
O << MAI->getWeakRefDirective() << CurrentFnName << "\n"; O << MAI->getWeakRefDirective();
CurrentFnSym->print(O, MAI);
O << "\n";
break; break;
} }
printVisibility(CurrentFnName, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
O << "\t.ent " << CurrentFnName << "\n"; O << "\t.ent ";
CurrentFnSym->print(O, MAI);
O << "\n";
O << CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << ":\n";
// Print out code for the function. // Print out code for the function.
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
@ -184,7 +191,9 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
} }
} }
O << "\t.end " << CurrentFnName << "\n"; O << "\t.end ";
CurrentFnSym->print(O, MAI);
O << "\n";
// We didn't modify anything. // We didn't modify anything.
return false; return false;

View File

@ -39,7 +39,6 @@
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
using namespace llvm; using namespace llvm;
@ -329,30 +328,25 @@ void SPUAsmPrinter::printOp(const MachineOperand &MO) {
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
// Computing the address of an external symbol, not calling it. // Computing the address of an external symbol, not calling it.
if (TM.getRelocationModel() != Reloc::Static) { if (TM.getRelocationModel() != Reloc::Static) {
std::string Name(MAI->getGlobalPrefix()); Name += MO.getSymbolName(); O << "L" << MAI->getGlobalPrefix() << MO.getSymbolName()
O << "L" << Name << "$non_lazy_ptr"; << "$non_lazy_ptr";
return; return;
} }
O << MAI->getGlobalPrefix() << MO.getSymbolName(); GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI);
return; return;
case MachineOperand::MO_GlobalAddress: { case MachineOperand::MO_GlobalAddress:
// Computing the address of a global symbol, not calling it.
GlobalValue *GV = MO.getGlobal();
std::string Name = Mang->getMangledName(GV);
// External or weakly linked global variables need non-lazily-resolved // External or weakly linked global variables need non-lazily-resolved
// stubs // stubs
if (TM.getRelocationModel() != Reloc::Static) { if (TM.getRelocationModel() != Reloc::Static) {
GlobalValue *GV = MO.getGlobal();
if (((GV->isDeclaration() || GV->hasWeakLinkage() || if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) { GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) {
O << "L" << Name << "$non_lazy_ptr"; GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr")->print(O, MAI);
return; return;
} }
} }
O << Name; GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
return; return;
}
default: default:
O << "<unknown operand type: " << MO.getType() << ">"; O << "<unknown operand type: " << MO.getType() << ">";
return; return;
@ -505,9 +499,9 @@ void LinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
if (EmitSpecialLLVMGlobal(GVar)) if (EmitSpecialLLVMGlobal(GVar))
return; return;
std::string name = Mang->getMangledName(GVar); MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
printVisibility(name, GVar->getVisibility()); printVisibility(GVarSym, GVar->getVisibility());
Constant *C = GVar->getInitializer(); Constant *C = GVar->getInitializer();
const Type *Type = C->getType(); const Type *Type = C->getType();
@ -524,14 +518,23 @@ void LinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (GVar->hasExternalLinkage()) { if (GVar->hasExternalLinkage()) {
O << "\t.global " << name << '\n'; O << "\t.global ";
O << "\t.type " << name << ", @object\n"; GVarSym->print(O, MAI);
O << name << ":\n"; O << '\n';
O << "\t.type ";
GVarSym->print(O, MAI);
O << ", @object\n";
GVarSym->print(O, MAI);
O << ":\n";
O << "\t.zero " << Size << '\n'; O << "\t.zero " << Size << '\n';
} else if (GVar->hasLocalLinkage()) { } else if (GVar->hasLocalLinkage()) {
O << MAI->getLCOMMDirective() << name << ',' << Size; O << MAI->getLCOMMDirective();
GVarSym->print(O, MAI);
O << ',' << Size;
} else { } else {
O << ".comm " << name << ',' << Size; O << ".comm ";
GVarSym->print(O, MAI);
O << ',' << Size;
} }
O << "\t\t" << MAI->getCommentString() << " '"; O << "\t\t" << MAI->getCommentString() << " '";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
@ -540,34 +543,42 @@ void LinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
} }
switch (GVar->getLinkage()) { switch (GVar->getLinkage()) {
// Should never be seen for the CellSPU platform... // Should never be seen for the CellSPU platform...
case GlobalValue::LinkOnceAnyLinkage: case GlobalValue::LinkOnceAnyLinkage:
case GlobalValue::LinkOnceODRLinkage: case GlobalValue::LinkOnceODRLinkage:
case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::CommonLinkage: case GlobalValue::CommonLinkage:
O << "\t.global " << name << '\n' O << "\t.global ";
<< "\t.type " << name << ", @object\n" GVarSym->print(O, MAI);
<< "\t.weak " << name << '\n'; O << "\n\t.type ";
GVarSym->print(O, MAI);
O << ", @object\n" << "\t.weak ";
GVarSym->print(O, MAI);
O << '\n';
break; break;
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of // FIXME: appending linkage variables should go into a section of
// their name or something. For now, just emit them as external. // their name or something. For now, just emit them as external.
case GlobalValue::ExternalLinkage: case GlobalValue::ExternalLinkage:
// If external or appending, declare as a global symbol // If external or appending, declare as a global symbol
O << "\t.global " << name << '\n' O << "\t.global ";
<< "\t.type " << name << ", @object\n"; GVarSym->print(O, MAI);
// FALL THROUGH O << "\n\t.type ";
case GlobalValue::PrivateLinkage: GVarSym->print(O, MAI);
case GlobalValue::LinkerPrivateLinkage: O << ", @object\n";
case GlobalValue::InternalLinkage:
break; break;
default: case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage:
case GlobalValue::InternalLinkage:
break;
default:
llvm_report_error("Unknown linkage type!"); llvm_report_error("Unknown linkage type!");
} }
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
O << name << ":\t\t\t\t" << MAI->getCommentString() << " '"; GVarSym->print(O, MAI);
O << ":\t\t\t\t" << MAI->getCommentString() << " '";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
O << "'\n"; O << "'\n";

View File

@ -38,9 +38,7 @@
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
using namespace llvm; using namespace llvm;
STATISTIC(EmittedInsts, "Number of machine instrs printed"); STATISTIC(EmittedInsts, "Number of machine instrs printed");
@ -101,14 +99,16 @@ void MSP430AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
const TargetData *TD = TM.getTargetData(); const TargetData *TD = TM.getTargetData();
std::string name = Mang->getMangledName(GVar); MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
Constant *C = GVar->getInitializer(); Constant *C = GVar->getInitializer();
unsigned Size = TD->getTypeAllocSize(C->getType()); unsigned Size = TD->getTypeAllocSize(C->getType());
unsigned Align = TD->getPreferredAlignmentLog(GVar); unsigned Align = TD->getPreferredAlignmentLog(GVar);
printVisibility(name, GVar->getVisibility()); printVisibility(GVarSym, GVar->getVisibility());
O << "\t.type\t" << name << ",@object\n"; O << "\t.type\t";
GVarSym->print(O, MAI);
O << ",@object\n";
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang, OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
TM)); TM));
@ -119,10 +119,15 @@ void MSP430AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (GVar->hasLocalLinkage()) if (GVar->hasLocalLinkage()) {
O << "\t.local\t" << name << '\n'; O << "\t.local\t";
GVarSym->print(O, MAI);
O << '\n';
}
O << MAI->getCOMMDirective() << name << ',' << Size; O << MAI->getCOMMDirective();
GVarSym->print(O, MAI);
O << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
@ -141,7 +146,9 @@ void MSP430AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
case GlobalValue::LinkOnceODRLinkage: case GlobalValue::LinkOnceODRLinkage:
case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
O << "\t.weak\t" << name << '\n'; O << "\t.weak\t";
GVarSym->print(O, MAI);
O << '\n';
break; break;
case GlobalValue::DLLExportLinkage: case GlobalValue::DLLExportLinkage:
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
@ -149,7 +156,9 @@ void MSP430AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
// their name or something. For now, just emit them as external. // their name or something. For now, just emit them as external.
case GlobalValue::ExternalLinkage: case GlobalValue::ExternalLinkage:
// If external or appending, declare as a global symbol // If external or appending, declare as a global symbol
O << "\t.globl " << name << '\n'; O << "\t.globl ";
GVarSym->print(O, MAI);
O << '\n';
// FALL THROUGH // FALL THROUGH
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
@ -161,7 +170,8 @@ void MSP430AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
// Use 16-bit alignment by default to simplify bunch of stuff // Use 16-bit alignment by default to simplify bunch of stuff
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
O << name << ":"; GVarSym->print(O, MAI);
O << ":";
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' '; O << MAI->getCommentString() << ' ';
@ -171,8 +181,11 @@ void MSP430AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
EmitGlobalConstant(C); EmitGlobalConstant(C);
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.size\t" << name << ", " << Size << '\n'; O << "\t.size\t";
GVarSym->print(O, MAI);
O << ", " << Size << '\n';
}
} }
void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) { void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
@ -190,20 +203,27 @@ void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl\t" << CurrentFnName << '\n'; O << "\t.globl\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage: case Function::LinkOnceODRLinkage:
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
case Function::WeakODRLinkage: case Function::WeakODRLinkage:
O << "\t.weak\t" << CurrentFnName << '\n'; O << "\t.weak\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
} }
printVisibility(CurrentFnName, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
O << "\t.type\t" << CurrentFnName << ",@function\n" O << "\t.type\t";
<< CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << ",@function\n";
CurrentFnSym->print(O, MAI);
O << ":\n";
} }
bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) { bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
@ -225,8 +245,13 @@ bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
printMachineInstruction(II); printMachineInstruction(II);
} }
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; O << "\t.size\t";
CurrentFnSym->print(O, MAI);
O << ", .-";
CurrentFnSym->print(O, MAI);
O << '\n';
}
// We didn't modify anything // We didn't modify anything
return false; return false;
@ -263,14 +288,14 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
return; return;
case MachineOperand::MO_GlobalAddress: { case MachineOperand::MO_GlobalAddress: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool isMemOp = Modifier && !strcmp(Modifier, "mem");
std::string Name = Mang->getMangledName(MO.getGlobal());
uint64_t Offset = MO.getOffset(); uint64_t Offset = MO.getOffset();
O << (isMemOp ? '&' : '#'); O << (isMemOp ? '&' : '#');
if (Offset) if (Offset)
O << '(' << Offset << '+'; O << '(' << Offset << '+';
O << Name; GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
if (Offset) if (Offset)
O << ')'; O << ')';
@ -278,11 +303,8 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
} }
case MachineOperand::MO_ExternalSymbol: { case MachineOperand::MO_ExternalSymbol: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool isMemOp = Modifier && !strcmp(Modifier, "mem");
std::string Name(MAI->getGlobalPrefix()); O << (isMemOp ? '&' : '#');
Name += MO.getSymbolName(); O << MAI->getGlobalPrefix() << MO.getSymbolName();
O << (isMemOp ? '&' : '#') << Name;
return; return;
} }
default: default:

View File

@ -37,7 +37,6 @@
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Mangler.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
@ -45,7 +44,6 @@
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/FormattedStream.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
#include <cctype> #include <cctype>
using namespace llvm; using namespace llvm;
STATISTIC(EmittedInsts, "Number of machine instrs printed"); STATISTIC(EmittedInsts, "Number of machine instrs printed");
@ -219,15 +217,23 @@ void MipsAsmPrinter::emitFunctionStart(MachineFunction &MF) {
// 2 bits aligned // 2 bits aligned
EmitAlignment(MF.getAlignment(), F); EmitAlignment(MF.getAlignment(), F);
O << "\t.globl\t" << CurrentFnName << '\n'; O << "\t.globl\t";
O << "\t.ent\t" << CurrentFnName << '\n'; CurrentFnSym->print(O, MAI);
O << '\n';
O << "\t.ent\t";
CurrentFnSym->print(O, MAI);
O << '\n';
printVisibility(CurrentFnName, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
if ((MAI->hasDotTypeDotSizeDirective()) && Subtarget->isLinux()) if ((MAI->hasDotTypeDotSizeDirective()) && Subtarget->isLinux()) {
O << "\t.type\t" << CurrentFnName << ", @function\n"; O << "\t.type\t";
CurrentFnSym->print(O, MAI);
O << ", @function\n";
}
O << CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << ":\n";
emitFrameDirective(MF); emitFrameDirective(MF);
printSavedRegsBitmask(MF); printSavedRegsBitmask(MF);
@ -243,9 +249,16 @@ void MipsAsmPrinter::emitFunctionEnd(MachineFunction &MF) {
O << "\t.set\tmacro\n"; O << "\t.set\tmacro\n";
O << "\t.set\treorder\n"; O << "\t.set\treorder\n";
O << "\t.end\t" << CurrentFnName << '\n'; O << "\t.end\t";
if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux()) CurrentFnSym->print(O, MAI);
O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; O << '\n';
if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux()) {
O << "\t.size\t";
CurrentFnSym->print(O, MAI);
O << ", .-";
CurrentFnSym->print(O, MAI);
O << '\n';
}
} }
/// runOnMachineFunction - This uses the printMachineInstruction() /// runOnMachineFunction - This uses the printMachineInstruction()
@ -350,16 +363,16 @@ void MipsAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
return; return;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
O << Mang->getMangledName(MO.getGlobal()); GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
break; break;
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
O << MO.getSymbolName(); GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI);
break; break;
case MachineOperand::MO_JumpTableIndex: case MachineOperand::MO_JumpTableIndex:
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << MO.getIndex(); << '_' << MO.getIndex();
break; break;
case MachineOperand::MO_ConstantPoolIndex: case MachineOperand::MO_ConstantPoolIndex:
@ -436,7 +449,7 @@ void MipsAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
return; return;
O << "\n\n"; O << "\n\n";
std::string name = Mang->getMangledName(GVar); MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
Constant *C = GVar->getInitializer(); Constant *C = GVar->getInitializer();
const Type *CTy = C->getType(); const Type *CTy = C->getType();
unsigned Size = TD->getTypeAllocSize(CTy); unsigned Size = TD->getTypeAllocSize(CTy);
@ -455,7 +468,7 @@ void MipsAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
} else } else
Align = TD->getPreferredTypeAlignmentShift(CTy); Align = TD->getPreferredTypeAlignmentShift(CTy);
printVisibility(name, GVar->getVisibility()); printVisibility(GVarSym, GVar->getVisibility());
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang, OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
TM)); TM));
@ -465,10 +478,15 @@ void MipsAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
(GVar->hasLocalLinkage() || GVar->isWeakForLinker())) { (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (GVar->hasLocalLinkage()) if (GVar->hasLocalLinkage()) {
O << "\t.local\t" << name << '\n'; O << "\t.local\t";
GVarSym->print(O, MAI);
O << '\n';
}
O << MAI->getCOMMDirective() << name << ',' << Size; O << MAI->getCOMMDirective();
GVarSym->print(O, MAI);
O << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (1 << Align); O << ',' << (1 << Align);
@ -484,14 +502,18 @@ void MipsAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
// FIXME: Verify correct for weak. // FIXME: Verify correct for weak.
// Nonnull linkonce -> weak // Nonnull linkonce -> weak
O << "\t.weak " << name << '\n'; O << "\t.weak ";
GVarSym->print(O, MAI);
O << '\n';
break; break;
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of their name // FIXME: appending linkage variables should go into a section of their name
// or something. For now, just emit them as external. // or something. For now, just emit them as external.
case GlobalValue::ExternalLinkage: case GlobalValue::ExternalLinkage:
// If external or appending, declare as a global symbol // If external or appending, declare as a global symbol
O << MAI->getGlobalDirective() << name << '\n'; O << MAI->getGlobalDirective();
GVarSym->print(O, MAI);
O << '\n';
// Fall Through // Fall Through
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
@ -512,11 +534,16 @@ void MipsAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
if (MAI->hasDotTypeDotSizeDirective() && printSizeAndType) { if (MAI->hasDotTypeDotSizeDirective() && printSizeAndType) {
O << "\t.type " << name << ",@object\n"; O << "\t.type ";
O << "\t.size " << name << ',' << Size << '\n'; GVarSym->print(O, MAI);
O << ",@object\n";
O << "\t.size ";
GVarSym->print(O, MAI);
O << ',' << Size << '\n';
} }
O << name << ":\n"; GVarSym->print(O, MAI);
O << ":\n";
EmitGlobalConstant(C); EmitGlobalConstant(C);
} }

View File

@ -641,34 +641,47 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
case Function::InternalLinkage: // Symbols default to internal. case Function::InternalLinkage: // Symbols default to internal.
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.global\t" << CurrentFnName << '\n' O << "\t.global\t";
<< "\t.type\t" << CurrentFnName << ", @function\n"; CurrentFnSym->print(O, MAI);
O << '\n' << "\t.type\t";
CurrentFnSym->print(O, MAI);
O << ", @function\n";
break; break;
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
case Function::WeakODRLinkage: case Function::WeakODRLinkage:
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage: case Function::LinkOnceODRLinkage:
O << "\t.global\t" << CurrentFnName << '\n'; O << "\t.global\t";
O << "\t.weak\t" << CurrentFnName << '\n'; CurrentFnSym->print(O, MAI);
O << '\n';
O << "\t.weak\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
} }
printVisibility(CurrentFnName, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
EmitAlignment(MF.getAlignment(), F); EmitAlignment(MF.getAlignment(), F);
if (Subtarget.isPPC64()) { if (Subtarget.isPPC64()) {
// Emit an official procedure descriptor. // Emit an official procedure descriptor.
// FIXME 64-bit SVR4: Use MCSection here? // FIXME 64-bit SVR4: Use MCSection here!
O << "\t.section\t\".opd\",\"aw\"\n"; O << "\t.section\t\".opd\",\"aw\"\n";
O << "\t.align 3\n"; O << "\t.align 3\n";
O << CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << "\t.quad .L." << CurrentFnName << ",.TOC.@tocbase\n"; O << ":\n";
O << "\t.quad .L.";
CurrentFnSym->print(O, MAI);
O << ",.TOC.@tocbase\n";
O << "\t.previous\n"; O << "\t.previous\n";
O << ".L." << CurrentFnName << ":\n"; O << ".L.";
CurrentFnSym->print(O, MAI);
O << ":\n";
} else { } else {
O << CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << ":\n";
} }
// Emit pre-function debug information. // Emit pre-function debug information.
@ -688,7 +701,11 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
} }
} }
O << "\t.size\t" << CurrentFnName << ",.-" << CurrentFnName << '\n'; O << "\t.size\t";
CurrentFnSym->print(O, MAI);
O << ",.-";
CurrentFnSym->print(O, MAI);
O << '\n';
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
@ -829,22 +846,29 @@ bool PPCDarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
case Function::InternalLinkage: // Symbols default to internal. case Function::InternalLinkage: // Symbols default to internal.
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl\t" << CurrentFnName << '\n'; O << "\t.globl\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
case Function::WeakODRLinkage: case Function::WeakODRLinkage:
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage: case Function::LinkOnceODRLinkage:
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
O << "\t.globl\t" << CurrentFnName << '\n'; O << "\t.globl\t";
O << "\t.weak_definition\t" << CurrentFnName << '\n'; CurrentFnSym->print(O, MAI);
O << '\n';
O << "\t.weak_definition\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
} }
printVisibility(CurrentFnName, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
EmitAlignment(MF.getAlignment(), F); EmitAlignment(MF.getAlignment(), F);
O << CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << ":\n";
// Emit pre-function debug information. // Emit pre-function debug information.
DW->BeginFunction(&MF); DW->BeginFunction(&MF);

View File

@ -138,7 +138,11 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
DW->EndFunction(&MF); DW->EndFunction(&MF);
// We didn't modify anything. // We didn't modify anything.
O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; O << "\t.size\t";
CurrentFnSym->print(O, MAI);
O << ", .-";
CurrentFnSym->print(O, MAI);
O << '\n';
return false; return false;
} }
@ -156,7 +160,9 @@ void SparcAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
case Function::DLLExportLinkage: case Function::DLLExportLinkage:
case Function::ExternalLinkage: case Function::ExternalLinkage:
// Function is externally visible // Function is externally visible
O << "\t.global\t" << CurrentFnName << '\n'; O << "\t.global\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
@ -164,14 +170,18 @@ void SparcAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
case Function::WeakODRLinkage: case Function::WeakODRLinkage:
// Function is weak // Function is weak
O << "\t.weak\t" << CurrentFnName << '\n' ; O << "\t.weak\t";CurrentFnSym->print(O, MAI);
O << '\n' ;
break; break;
} }
printVisibility(CurrentFnName, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
O << "\t.type\t" << CurrentFnName << ", #function\n"; O << "\t.type\t";
O << CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << ", #function\n";
CurrentFnSym->print(O, MAI);
O << ":\n";
} }

View File

@ -99,20 +99,27 @@ void SystemZAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl\t" << CurrentFnName << '\n'; O << "\t.globl\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage: case Function::LinkOnceODRLinkage:
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
case Function::WeakODRLinkage: case Function::WeakODRLinkage:
O << "\t.weak\t" << CurrentFnName << '\n'; O << "\t.weak\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
} }
printVisibility(CurrentFnName, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
O << "\t.type\t" << CurrentFnName << ",@function\n" O << "\t.type\t";
<< CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << ",@function\n";
CurrentFnSym->print(O, MAI);
O << ":\n";
} }
bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) { bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
@ -137,8 +144,13 @@ bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
printMachineInstruction(II); printMachineInstruction(II);
} }
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; O << "\t.size\t";
CurrentFnSym->print(O, MAI);
O << ", .-";
CurrentFnSym->print(O, MAI);
O << '\n';
}
// Print out jump tables referenced by the function. // Print out jump tables referenced by the function.
EmitJumpTableInfo(MF.getJumpTableInfo(), MF); EmitJumpTableInfo(MF.getJumpTableInfo(), MF);

View File

@ -84,7 +84,9 @@ void X86AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
break; break;
case Function::DLLExportLinkage: case Function::DLLExportLinkage:
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl\t" << CurrentFnName << '\n'; O << "\t.globl\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
@ -92,30 +94,41 @@ void X86AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
case Function::WeakODRLinkage: case Function::WeakODRLinkage:
if (Subtarget->isTargetDarwin()) { if (Subtarget->isTargetDarwin()) {
O << "\t.globl\t" << CurrentFnName << '\n'; O << "\t.globl\t";
O << MAI->getWeakDefDirective() << CurrentFnName << '\n'; CurrentFnSym->print(O, MAI);
O << '\n';
O << MAI->getWeakDefDirective();
CurrentFnSym->print(O, MAI);
O << '\n';
} else if (Subtarget->isTargetCygMing()) { } else if (Subtarget->isTargetCygMing()) {
O << "\t.globl\t" << CurrentFnName << "\n" O << "\t.globl\t";
"\t.linkonce discard\n"; CurrentFnSym->print(O, MAI);
O << "\n\t.linkonce discard\n";
} else { } else {
O << "\t.weak\t" << CurrentFnName << '\n'; O << "\t.weak\t";
CurrentFnSym->print(O, MAI);
O << '\n';
} }
break; break;
} }
printVisibility(CurrentFnName, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
if (Subtarget->isTargetELF()) if (Subtarget->isTargetELF()) {
O << "\t.type\t" << CurrentFnName << ",@function\n"; O << "\t.type\t";
else if (Subtarget->isTargetCygMing()) { CurrentFnSym->print(O, MAI);
O << "\t.def\t " << CurrentFnName O << ",@function\n";
<< ";\t.scl\t" << } else if (Subtarget->isTargetCygMing()) {
O << "\t.def\t ";
CurrentFnSym->print(O, MAI);
O << ";\t.scl\t" <<
(F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT) (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT)
<< ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT) << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
<< ";\t.endef\n"; << ";\t.endef\n";
} }
O << CurrentFnName << ':'; CurrentFnSym->print(O, MAI);
O << ':';
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' '; O << MAI->getCommentString() << ' ';
@ -125,8 +138,11 @@ void X86AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
// Add some workaround for linkonce linkage on Cygwin\MinGW // Add some workaround for linkonce linkage on Cygwin\MinGW
if (Subtarget->isTargetCygMing() && if (Subtarget->isTargetCygMing() &&
(F->hasLinkOnceLinkage() || F->hasWeakLinkage())) (F->hasLinkOnceLinkage() || F->hasWeakLinkage())) {
O << "Lllvm$workaround$fake$stub$" << CurrentFnName << ":\n"; O << "Lllvm$workaround$fake$stub$";
CurrentFnSym->print(O, MAI);
O << ":\n";
}
} }
/// runOnMachineFunction - This uses the printMachineInstruction() /// runOnMachineFunction - This uses the printMachineInstruction()
@ -183,8 +199,13 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
O << "\tnop\n"; O << "\tnop\n";
} }
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; O << "\t.size\t";
CurrentFnSym->print(O, MAI);
O << ", .-";
CurrentFnSym->print(O, MAI);
O << '\n';
}
// Emit post-function debug information. // Emit post-function debug information.
if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling()) if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())

View File

@ -69,10 +69,9 @@ namespace {
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
unsigned AsmVariant, const char *ExtraCode); unsigned AsmVariant, const char *ExtraCode);
void emitGlobalDirective(const std::string &name); void emitGlobalDirective(const MCSymbol *Sym);
void emitExternDirective(const std::string &name);
void emitArrayBound(const std::string &name, const GlobalVariable *GV); void emitArrayBound(const MCSymbol *Sym, const GlobalVariable *GV);
virtual void PrintGlobalVariable(const GlobalVariable *GV); virtual void PrintGlobalVariable(const GlobalVariable *GV);
void emitFunctionStart(MachineFunction &MF); void emitFunctionStart(MachineFunction &MF);
@ -95,35 +94,31 @@ namespace {
#include "XCoreGenAsmWriter.inc" #include "XCoreGenAsmWriter.inc"
void XCoreAsmPrinter:: void XCoreAsmPrinter::emitGlobalDirective(const MCSymbol *Sym) {
emitGlobalDirective(const std::string &name) O << MAI->getGlobalDirective();
{ Sym->print(O, MAI);
O << MAI->getGlobalDirective() << name;
O << "\n"; O << "\n";
} }
void XCoreAsmPrinter:: void XCoreAsmPrinter::emitArrayBound(const MCSymbol *Sym,
emitExternDirective(const std::string &name) const GlobalVariable *GV) {
{
O << "\t.extern\t" << name;
O << '\n';
}
void XCoreAsmPrinter::
emitArrayBound(const std::string &name, const GlobalVariable *GV)
{
assert(((GV->hasExternalLinkage() || assert(((GV->hasExternalLinkage() ||
GV->hasWeakLinkage()) || GV->hasWeakLinkage()) ||
GV->hasLinkOnceLinkage()) && "Unexpected linkage"); GV->hasLinkOnceLinkage()) && "Unexpected linkage");
if (const ArrayType *ATy = dyn_cast<ArrayType>( if (const ArrayType *ATy = dyn_cast<ArrayType>(
cast<PointerType>(GV->getType())->getElementType())) cast<PointerType>(GV->getType())->getElementType())) {
{ O << MAI->getGlobalDirective();
O << MAI->getGlobalDirective() << name << ".globound" << "\n"; Sym->print(O, MAI);
O << MAI->getSetDirective() << name << ".globound" << "," O << ".globound" << "\n";
O << MAI->getSetDirective();
Sym->print(O, MAI);
O << ".globound" << ","
<< ATy->getNumElements() << "\n"; << ATy->getNumElements() << "\n";
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) { if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
// TODO Use COMDAT groups for LinkOnceLinkage // TODO Use COMDAT groups for LinkOnceLinkage
O << MAI->getWeakDefDirective() << name << ".globound" << "\n"; O << MAI->getWeakDefDirective();
Sym->print(O, MAI);
O << ".globound" << "\n";
} }
} }
} }
@ -135,15 +130,19 @@ void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
return; return;
const TargetData *TD = TM.getTargetData(); const TargetData *TD = TM.getTargetData();
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GV, Mang,TM)); OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GV, Mang,TM));
std::string name = Mang->getMangledName(GV); MCSymbol *GVSym = GetGlobalValueSymbol(GV);
Constant *C = GV->getInitializer(); Constant *C = GV->getInitializer();
unsigned Align = (unsigned)TD->getPreferredTypeAlignmentShift(C->getType()); unsigned Align = (unsigned)TD->getPreferredTypeAlignmentShift(C->getType());
// Mark the start of the global // Mark the start of the global
O << "\t.cc_top " << name << ".data," << name << "\n"; O << "\t.cc_top ";
GVSym->print(O, MAI);
O << ".data,";
GVSym->print(O, MAI);
O << "\n";
switch (GV->getLinkage()) { switch (GV->getLinkage()) {
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
@ -153,11 +152,13 @@ void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::ExternalLinkage: case GlobalValue::ExternalLinkage:
emitArrayBound(name, GV); emitArrayBound(GVSym, GV);
emitGlobalDirective(name); emitGlobalDirective(GVSym);
// TODO Use COMDAT groups for LinkOnceLinkage // TODO Use COMDAT groups for LinkOnceLinkage
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) { if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
O << MAI->getWeakDefDirective() << name << "\n"; O << MAI->getWeakDefDirective();
GVSym->print(O, MAI);
O << "\n";
} }
// FALL THROUGH // FALL THROUGH
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
@ -181,10 +182,15 @@ void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
Size *= MaxThreads; Size *= MaxThreads;
} }
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.type " << name << ",@object\n"; O << "\t.type ";
O << "\t.size " << name << "," << Size << "\n"; GVSym->print(O, MAI);
O << ",@object\n";
O << "\t.size ";
GVSym->print(O, MAI);
O << "," << Size << "\n";
} }
O << name << ":\n"; GVSym->print(O, MAI);
O << ":\n";
EmitGlobalConstant(C); EmitGlobalConstant(C);
if (GV->isThreadLocal()) { if (GV->isThreadLocal()) {
@ -199,7 +205,9 @@ void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
} }
// Mark the end of the global // Mark the end of the global
O << "\t.cc_bottom " << name << ".data\n"; O << "\t.cc_bottom ";
GVSym->print(O, MAI);
O << ".data\n";
} }
/// Emit the directives on the start of functions /// Emit the directives on the start of functions
@ -210,7 +218,11 @@ void XCoreAsmPrinter::emitFunctionStart(MachineFunction &MF) {
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
// Mark the start of the function // Mark the start of the function
O << "\t.cc_top " << CurrentFnName << ".function," << CurrentFnName << "\n"; O << "\t.cc_top ";
CurrentFnSym->print(O, MAI);
O << ".function,";
CurrentFnSym->print(O, MAI);
O << "\n";
switch (F->getLinkage()) { switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!"); default: llvm_unreachable("Unknown linkage type!");
@ -219,31 +231,38 @@ void XCoreAsmPrinter::emitFunctionStart(MachineFunction &MF) {
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
emitGlobalDirective(CurrentFnName); emitGlobalDirective(CurrentFnSym);
break; break;
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage: case Function::LinkOnceODRLinkage:
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
case Function::WeakODRLinkage: case Function::WeakODRLinkage:
// TODO Use COMDAT groups for LinkOnceLinkage // TODO Use COMDAT groups for LinkOnceLinkage
O << MAI->getGlobalDirective() << CurrentFnName << "\n"; O << MAI->getGlobalDirective();
O << MAI->getWeakDefDirective() << CurrentFnName << "\n"; CurrentFnSym->print(O, MAI);
O << "\n";
O << MAI->getWeakDefDirective();
CurrentFnSym->print(O, MAI);
O << "\n";
break; break;
} }
// (1 << 1) byte aligned // (1 << 1) byte aligned
EmitAlignment(MF.getAlignment(), F, 1); EmitAlignment(MF.getAlignment(), F, 1);
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.type " << CurrentFnName << ",@function\n"; O << "\t.type ";
CurrentFnSym->print(O, MAI);
O << ",@function\n";
} }
O << CurrentFnName << ":\n"; CurrentFnSym->print(O, MAI);
O << ":\n";
} }
/// Emit the directives on the end of functions /// Emit the directives on the end of functions
void XCoreAsmPrinter:: void XCoreAsmPrinter::emitFunctionEnd(MachineFunction &MF) {
emitFunctionEnd(MachineFunction &MF)
{
// Mark the end of the function // Mark the end of the function
O << "\t.cc_bottom " << CurrentFnName << ".function\n"; O << "\t.cc_bottom ";
CurrentFnSym->print(O, MAI);
O << ".function\n";
} }
/// runOnMachineFunction - This uses the printMachineInstruction() /// runOnMachineFunction - This uses the printMachineInstruction()