[llvm-commits] [llvm] r93594 - in /llvm/trunk/lib/Target: ARM/AsmPrinter/ARMAsmPrinter.cpp Alpha/AsmPrinter/AlphaAsmPrinter.cpp CellSPU/AsmPrinter/SPUAsmPrinter.cpp MSP430/AsmPrinter/MSP430AsmPrinter.cpp Mips/AsmPrinter/MipsAsmPrinter.cpp PowerPC/AsmPrinter/PPCAsmPrinter.cpp Sparc/AsmPrinter/SparcAsmPrinter.cpp SystemZ/AsmPrinter/SystemZAsmPrinter.cpp X86/AsmPrinter/X86AsmPrinter.cpp XCore/AsmPrinter/XCoreAsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Fri Jan 15 16:21:18 PST 2010
Author: lattner
Date: Fri Jan 15 18:21:18 2010
New Revision: 93594
URL: http://llvm.org/viewvc/llvm-project?rev=93594&view=rev
Log:
MCize a bunch more stuff, eliminating a lot of uses of the mangler
and CurrentFnName.
Modified:
llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -256,7 +256,9 @@
case Function::InternalLinkage:
break;
case Function::ExternalLinkage:
- O << "\t.globl\t" << CurrentFnName << "\n";
+ O << "\t.globl\t";
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
break;
case Function::LinkerPrivateLinkage:
case Function::WeakAnyLinkage:
@@ -264,29 +266,38 @@
case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage:
if (Subtarget->isTargetDarwin()) {
- O << "\t.globl\t" << CurrentFnName << "\n";
- O << "\t.weak_definition\t" << CurrentFnName << "\n";
+ O << "\t.globl\t";
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
+ O << "\t.weak_definition\t";
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
} else {
- O << MAI->getWeakRefDirective() << CurrentFnName << "\n";
+ O << MAI->getWeakRefDirective();
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
}
break;
}
- printVisibility(CurrentFnName, F->getVisibility());
+ printVisibility(CurrentFnSym, F->getVisibility());
unsigned FnAlign = 1 << MF.getAlignment(); // MF alignment is log2.
if (AFI->isThumbFunction()) {
EmitAlignment(FnAlign, F, AFI->getAlign());
O << "\t.code\t16\n";
O << "\t.thumb_func";
- if (Subtarget->isTargetDarwin())
- O << "\t" << CurrentFnName;
+ if (Subtarget->isTargetDarwin()) {
+ O << "\t";
+ CurrentFnSym->print(O, MAI);
+ }
O << "\n";
} else {
EmitAlignment(FnAlign, F);
}
- O << CurrentFnName << ":\n";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
// Emit pre-function debug information.
DW->BeginFunction(&MF);
@@ -313,8 +324,13 @@
printMachineInstruction(II);
}
- if (MAI->hasDotTypeDotSizeDirective())
- O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
+ if (MAI->hasDotTypeDotSizeDirective()) {
+ O << "\t.size ";
+ CurrentFnSym->print(O, MAI);
+ O << ", .-";
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
+ }
// Emit post-function debug information.
DW->EndFunction(&MF);
Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -147,22 +147,29 @@
case Function::PrivateLinkage:
case Function::LinkerPrivateLinkage:
break;
- case Function::ExternalLinkage:
- O << "\t.globl " << CurrentFnName << "\n";
- break;
+ case Function::ExternalLinkage:
+ O << "\t.globl ";
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
+ break;
case Function::WeakAnyLinkage:
case Function::WeakODRLinkage:
case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage:
- O << MAI->getWeakRefDirective() << CurrentFnName << "\n";
+ O << MAI->getWeakRefDirective();
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
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.
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
@@ -184,7 +191,9 @@
}
}
- O << "\t.end " << CurrentFnName << "\n";
+ O << "\t.end ";
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
// We didn't modify anything.
return false;
Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -39,7 +39,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/Mangler.h"
#include "llvm/Support/MathExtras.h"
using namespace llvm;
@@ -329,30 +328,25 @@
case MachineOperand::MO_ExternalSymbol:
// Computing the address of an external symbol, not calling it.
if (TM.getRelocationModel() != Reloc::Static) {
- std::string Name(MAI->getGlobalPrefix()); Name += MO.getSymbolName();
- O << "L" << Name << "$non_lazy_ptr";
+ O << "L" << MAI->getGlobalPrefix() << MO.getSymbolName()
+ << "$non_lazy_ptr";
return;
}
- O << MAI->getGlobalPrefix() << MO.getSymbolName();
+ GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI);
return;
- case MachineOperand::MO_GlobalAddress: {
- // Computing the address of a global symbol, not calling it.
- GlobalValue *GV = MO.getGlobal();
- std::string Name = Mang->getMangledName(GV);
-
+ case MachineOperand::MO_GlobalAddress:
// External or weakly linked global variables need non-lazily-resolved
// stubs
if (TM.getRelocationModel() != Reloc::Static) {
+ GlobalValue *GV = MO.getGlobal();
if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) {
- O << "L" << Name << "$non_lazy_ptr";
+ GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr")->print(O, MAI);
return;
}
}
- O << Name;
+ GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
return;
- }
-
default:
O << "<unknown operand type: " << MO.getType() << ">";
return;
@@ -505,9 +499,9 @@
if (EmitSpecialLLVMGlobal(GVar))
return;
- std::string name = Mang->getMangledName(GVar);
+ MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
- printVisibility(name, GVar->getVisibility());
+ printVisibility(GVarSym, GVar->getVisibility());
Constant *C = GVar->getInitializer();
const Type *Type = C->getType();
@@ -524,14 +518,23 @@
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (GVar->hasExternalLinkage()) {
- O << "\t.global " << name << '\n';
- O << "\t.type " << name << ", @object\n";
- O << name << ":\n";
+ O << "\t.global ";
+ GVarSym->print(O, MAI);
+ O << '\n';
+ O << "\t.type ";
+ GVarSym->print(O, MAI);
+ O << ", @object\n";
+ GVarSym->print(O, MAI);
+ O << ":\n";
O << "\t.zero " << Size << '\n';
} else if (GVar->hasLocalLinkage()) {
- O << MAI->getLCOMMDirective() << name << ',' << Size;
+ O << MAI->getLCOMMDirective();
+ GVarSym->print(O, MAI);
+ O << ',' << Size;
} else {
- O << ".comm " << name << ',' << Size;
+ O << ".comm ";
+ GVarSym->print(O, MAI);
+ O << ',' << Size;
}
O << "\t\t" << MAI->getCommentString() << " '";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
@@ -540,34 +543,42 @@
}
switch (GVar->getLinkage()) {
- // Should never be seen for the CellSPU platform...
- case GlobalValue::LinkOnceAnyLinkage:
- case GlobalValue::LinkOnceODRLinkage:
- case GlobalValue::WeakAnyLinkage:
- case GlobalValue::WeakODRLinkage:
- case GlobalValue::CommonLinkage:
- O << "\t.global " << name << '\n'
- << "\t.type " << name << ", @object\n"
- << "\t.weak " << name << '\n';
+ // Should never be seen for the CellSPU platform...
+ case GlobalValue::LinkOnceAnyLinkage:
+ case GlobalValue::LinkOnceODRLinkage:
+ case GlobalValue::WeakAnyLinkage:
+ case GlobalValue::WeakODRLinkage:
+ case GlobalValue::CommonLinkage:
+ O << "\t.global ";
+ GVarSym->print(O, MAI);
+ O << "\n\t.type ";
+ GVarSym->print(O, MAI);
+ O << ", @object\n" << "\t.weak ";
+ GVarSym->print(O, MAI);
+ O << '\n';
break;
- case GlobalValue::AppendingLinkage:
+ case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of
// 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
- O << "\t.global " << name << '\n'
- << "\t.type " << name << ", @object\n";
- // FALL THROUGH
- case GlobalValue::PrivateLinkage:
- case GlobalValue::LinkerPrivateLinkage:
- case GlobalValue::InternalLinkage:
+ O << "\t.global ";
+ GVarSym->print(O, MAI);
+ O << "\n\t.type ";
+ GVarSym->print(O, MAI);
+ O << ", @object\n";
break;
- default:
+ case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
+ case GlobalValue::InternalLinkage:
+ break;
+ default:
llvm_report_error("Unknown linkage type!");
}
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());
O << "'\n";
Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -38,9 +38,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/Mangler.h"
#include "llvm/Support/ErrorHandling.h"
-
using namespace llvm;
STATISTIC(EmittedInsts, "Number of machine instrs printed");
@@ -101,14 +99,16 @@
const TargetData *TD = TM.getTargetData();
- std::string name = Mang->getMangledName(GVar);
+ MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
Constant *C = GVar->getInitializer();
unsigned Size = TD->getTypeAllocSize(C->getType());
unsigned Align = TD->getPreferredAlignmentLog(GVar);
- printVisibility(name, GVar->getVisibility());
+ printVisibility(GVarSym, GVar->getVisibility());
- O << "\t.type\t" << name << ", at object\n";
+ O << "\t.type\t";
+ GVarSym->print(O, MAI);
+ O << ", at object\n";
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
TM));
@@ -119,10 +119,15 @@
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
- if (GVar->hasLocalLinkage())
- O << "\t.local\t" << name << '\n';
+ if (GVar->hasLocalLinkage()) {
+ 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())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
@@ -141,7 +146,9 @@
case GlobalValue::LinkOnceODRLinkage:
case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage:
- O << "\t.weak\t" << name << '\n';
+ O << "\t.weak\t";
+ GVarSym->print(O, MAI);
+ O << '\n';
break;
case GlobalValue::DLLExportLinkage:
case GlobalValue::AppendingLinkage:
@@ -149,7 +156,9 @@
// their name or something. For now, just emit them as external.
case GlobalValue::ExternalLinkage:
// 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
case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage:
@@ -161,7 +170,8 @@
// Use 16-bit alignment by default to simplify bunch of stuff
EmitAlignment(Align, GVar);
- O << name << ":";
+ GVarSym->print(O, MAI);
+ O << ":";
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' ';
@@ -171,8 +181,11 @@
EmitGlobalConstant(C);
- if (MAI->hasDotTypeDotSizeDirective())
- O << "\t.size\t" << name << ", " << Size << '\n';
+ if (MAI->hasDotTypeDotSizeDirective()) {
+ O << "\t.size\t";
+ GVarSym->print(O, MAI);
+ O << ", " << Size << '\n';
+ }
}
void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
@@ -190,20 +203,27 @@
case Function::LinkerPrivateLinkage:
break;
case Function::ExternalLinkage:
- O << "\t.globl\t" << CurrentFnName << '\n';
+ O << "\t.globl\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
break;
case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage:
case Function::WeakAnyLinkage:
case Function::WeakODRLinkage:
- O << "\t.weak\t" << CurrentFnName << '\n';
+ O << "\t.weak\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
break;
}
- printVisibility(CurrentFnName, F->getVisibility());
+ printVisibility(CurrentFnSym, F->getVisibility());
- O << "\t.type\t" << CurrentFnName << ", at function\n"
- << CurrentFnName << ":\n";
+ O << "\t.type\t";
+ CurrentFnSym->print(O, MAI);
+ O << ", at function\n";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
}
bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
@@ -225,8 +245,13 @@
printMachineInstruction(II);
}
- if (MAI->hasDotTypeDotSizeDirective())
- O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
+ if (MAI->hasDotTypeDotSizeDirective()) {
+ O << "\t.size\t";
+ CurrentFnSym->print(O, MAI);
+ O << ", .-";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
+ }
// We didn't modify anything
return false;
@@ -263,14 +288,14 @@
return;
case MachineOperand::MO_GlobalAddress: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem");
- std::string Name = Mang->getMangledName(MO.getGlobal());
uint64_t Offset = MO.getOffset();
O << (isMemOp ? '&' : '#');
if (Offset)
O << '(' << Offset << '+';
- O << Name;
+ GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
+
if (Offset)
O << ')';
@@ -278,11 +303,8 @@
}
case MachineOperand::MO_ExternalSymbol: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem");
- std::string Name(MAI->getGlobalPrefix());
- Name += MO.getSymbolName();
-
- O << (isMemOp ? '&' : '#') << Name;
-
+ O << (isMemOp ? '&' : '#');
+ O << MAI->getGlobalPrefix() << MO.getSymbolName();
return;
}
default:
Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -37,7 +37,6 @@
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/Mangler.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
@@ -45,7 +44,6 @@
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/MathExtras.h"
#include <cctype>
-
using namespace llvm;
STATISTIC(EmittedInsts, "Number of machine instrs printed");
@@ -219,15 +217,23 @@
// 2 bits aligned
EmitAlignment(MF.getAlignment(), F);
- O << "\t.globl\t" << CurrentFnName << '\n';
- O << "\t.ent\t" << CurrentFnName << '\n';
+ O << "\t.globl\t";
+ 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())
- O << "\t.type\t" << CurrentFnName << ", @function\n";
+ if ((MAI->hasDotTypeDotSizeDirective()) && Subtarget->isLinux()) {
+ O << "\t.type\t";
+ CurrentFnSym->print(O, MAI);
+ O << ", @function\n";
+ }
- O << CurrentFnName << ":\n";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
emitFrameDirective(MF);
printSavedRegsBitmask(MF);
@@ -243,9 +249,16 @@
O << "\t.set\tmacro\n";
O << "\t.set\treorder\n";
- O << "\t.end\t" << CurrentFnName << '\n';
- if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux())
- O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
+ O << "\t.end\t";
+ CurrentFnSym->print(O, MAI);
+ 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()
@@ -350,16 +363,16 @@
return;
case MachineOperand::MO_GlobalAddress:
- O << Mang->getMangledName(MO.getGlobal());
+ GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
break;
case MachineOperand::MO_ExternalSymbol:
- O << MO.getSymbolName();
+ GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI);
break;
case MachineOperand::MO_JumpTableIndex:
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
- << '_' << MO.getIndex();
+ << '_' << MO.getIndex();
break;
case MachineOperand::MO_ConstantPoolIndex:
@@ -436,7 +449,7 @@
return;
O << "\n\n";
- std::string name = Mang->getMangledName(GVar);
+ MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
Constant *C = GVar->getInitializer();
const Type *CTy = C->getType();
unsigned Size = TD->getTypeAllocSize(CTy);
@@ -455,7 +468,7 @@
} else
Align = TD->getPreferredTypeAlignmentShift(CTy);
- printVisibility(name, GVar->getVisibility());
+ printVisibility(GVarSym, GVar->getVisibility());
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
TM));
@@ -465,10 +478,15 @@
(GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
- if (GVar->hasLocalLinkage())
- O << "\t.local\t" << name << '\n';
-
- O << MAI->getCOMMDirective() << name << ',' << Size;
+ if (GVar->hasLocalLinkage()) {
+ O << "\t.local\t";
+ GVarSym->print(O, MAI);
+ O << '\n';
+ }
+
+ O << MAI->getCOMMDirective();
+ GVarSym->print(O, MAI);
+ O << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (1 << Align);
@@ -484,14 +502,18 @@
case GlobalValue::WeakODRLinkage:
// FIXME: Verify correct for weak.
// Nonnull linkonce -> weak
- O << "\t.weak " << name << '\n';
+ O << "\t.weak ";
+ GVarSym->print(O, MAI);
+ O << '\n';
break;
case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of their name
// or something. For now, just emit them as external.
case GlobalValue::ExternalLinkage:
// 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
case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage:
@@ -512,11 +534,16 @@
EmitAlignment(Align, GVar);
if (MAI->hasDotTypeDotSizeDirective() && printSizeAndType) {
- O << "\t.type " << name << ", at object\n";
- O << "\t.size " << name << ',' << Size << '\n';
+ O << "\t.type ";
+ GVarSym->print(O, MAI);
+ O << ", at object\n";
+ O << "\t.size ";
+ GVarSym->print(O, MAI);
+ O << ',' << Size << '\n';
}
- O << name << ":\n";
+ GVarSym->print(O, MAI);
+ O << ":\n";
EmitGlobalConstant(C);
}
Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -641,34 +641,47 @@
case Function::InternalLinkage: // Symbols default to internal.
break;
case Function::ExternalLinkage:
- O << "\t.global\t" << CurrentFnName << '\n'
- << "\t.type\t" << CurrentFnName << ", @function\n";
+ O << "\t.global\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n' << "\t.type\t";
+ CurrentFnSym->print(O, MAI);
+ O << ", @function\n";
break;
case Function::LinkerPrivateLinkage:
case Function::WeakAnyLinkage:
case Function::WeakODRLinkage:
case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage:
- O << "\t.global\t" << CurrentFnName << '\n';
- O << "\t.weak\t" << CurrentFnName << '\n';
+ O << "\t.global\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
+ O << "\t.weak\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
break;
}
- printVisibility(CurrentFnName, F->getVisibility());
+ printVisibility(CurrentFnSym, F->getVisibility());
EmitAlignment(MF.getAlignment(), F);
if (Subtarget.isPPC64()) {
// 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.align 3\n";
- O << CurrentFnName << ":\n";
- O << "\t.quad .L." << CurrentFnName << ",.TOC. at tocbase\n";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
+ O << "\t.quad .L.";
+ CurrentFnSym->print(O, MAI);
+ O << ",.TOC. at tocbase\n";
O << "\t.previous\n";
- O << ".L." << CurrentFnName << ":\n";
+ O << ".L.";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
} else {
- O << CurrentFnName << ":\n";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
}
// Emit pre-function debug information.
@@ -688,7 +701,11 @@
}
}
- 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));
@@ -829,22 +846,29 @@
case Function::InternalLinkage: // Symbols default to internal.
break;
case Function::ExternalLinkage:
- O << "\t.globl\t" << CurrentFnName << '\n';
+ O << "\t.globl\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
break;
case Function::WeakAnyLinkage:
case Function::WeakODRLinkage:
case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage:
case Function::LinkerPrivateLinkage:
- O << "\t.globl\t" << CurrentFnName << '\n';
- O << "\t.weak_definition\t" << CurrentFnName << '\n';
+ O << "\t.globl\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
+ O << "\t.weak_definition\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
break;
}
- printVisibility(CurrentFnName, F->getVisibility());
+ printVisibility(CurrentFnSym, F->getVisibility());
EmitAlignment(MF.getAlignment(), F);
- O << CurrentFnName << ":\n";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
// Emit pre-function debug information.
DW->BeginFunction(&MF);
Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -138,7 +138,11 @@
DW->EndFunction(&MF);
// 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;
}
@@ -156,7 +160,9 @@
case Function::DLLExportLinkage:
case Function::ExternalLinkage:
// Function is externally visible
- O << "\t.global\t" << CurrentFnName << '\n';
+ O << "\t.global\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
break;
case Function::LinkerPrivateLinkage:
case Function::LinkOnceAnyLinkage:
@@ -164,14 +170,18 @@
case Function::WeakAnyLinkage:
case Function::WeakODRLinkage:
// Function is weak
- O << "\t.weak\t" << CurrentFnName << '\n' ;
+ O << "\t.weak\t";CurrentFnSym->print(O, MAI);
+ O << '\n' ;
break;
}
- printVisibility(CurrentFnName, F->getVisibility());
+ printVisibility(CurrentFnSym, F->getVisibility());
- O << "\t.type\t" << CurrentFnName << ", #function\n";
- O << CurrentFnName << ":\n";
+ O << "\t.type\t";
+ CurrentFnSym->print(O, MAI);
+ O << ", #function\n";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
}
Modified: llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -99,20 +99,27 @@
case Function::LinkerPrivateLinkage:
break;
case Function::ExternalLinkage:
- O << "\t.globl\t" << CurrentFnName << '\n';
+ O << "\t.globl\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
break;
case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage:
case Function::WeakAnyLinkage:
case Function::WeakODRLinkage:
- O << "\t.weak\t" << CurrentFnName << '\n';
+ O << "\t.weak\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
break;
}
- printVisibility(CurrentFnName, F->getVisibility());
+ printVisibility(CurrentFnSym, F->getVisibility());
- O << "\t.type\t" << CurrentFnName << ", at function\n"
- << CurrentFnName << ":\n";
+ O << "\t.type\t";
+ CurrentFnSym->print(O, MAI);
+ O << ", at function\n";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
}
bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
@@ -137,8 +144,13 @@
printMachineInstruction(II);
}
- if (MAI->hasDotTypeDotSizeDirective())
- O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
+ if (MAI->hasDotTypeDotSizeDirective()) {
+ O << "\t.size\t";
+ CurrentFnSym->print(O, MAI);
+ O << ", .-";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
+ }
// Print out jump tables referenced by the function.
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -84,7 +84,9 @@
break;
case Function::DLLExportLinkage:
case Function::ExternalLinkage:
- O << "\t.globl\t" << CurrentFnName << '\n';
+ O << "\t.globl\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
break;
case Function::LinkerPrivateLinkage:
case Function::LinkOnceAnyLinkage:
@@ -92,30 +94,41 @@
case Function::WeakAnyLinkage:
case Function::WeakODRLinkage:
if (Subtarget->isTargetDarwin()) {
- O << "\t.globl\t" << CurrentFnName << '\n';
- O << MAI->getWeakDefDirective() << CurrentFnName << '\n';
+ O << "\t.globl\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
+ O << MAI->getWeakDefDirective();
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
} else if (Subtarget->isTargetCygMing()) {
- O << "\t.globl\t" << CurrentFnName << "\n"
- "\t.linkonce discard\n";
+ O << "\t.globl\t";
+ CurrentFnSym->print(O, MAI);
+ O << "\n\t.linkonce discard\n";
} else {
- O << "\t.weak\t" << CurrentFnName << '\n';
+ O << "\t.weak\t";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
}
break;
}
- printVisibility(CurrentFnName, F->getVisibility());
+ printVisibility(CurrentFnSym, F->getVisibility());
- if (Subtarget->isTargetELF())
- O << "\t.type\t" << CurrentFnName << ", at function\n";
- else if (Subtarget->isTargetCygMing()) {
- O << "\t.def\t " << CurrentFnName
- << ";\t.scl\t" <<
+ if (Subtarget->isTargetELF()) {
+ O << "\t.type\t";
+ CurrentFnSym->print(O, MAI);
+ O << ", at function\n";
+ } else if (Subtarget->isTargetCygMing()) {
+ O << "\t.def\t ";
+ CurrentFnSym->print(O, MAI);
+ O << ";\t.scl\t" <<
(F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT)
<< ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
<< ";\t.endef\n";
}
- O << CurrentFnName << ':';
+ CurrentFnSym->print(O, MAI);
+ O << ':';
if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' ';
@@ -125,8 +138,11 @@
// Add some workaround for linkonce linkage on Cygwin\MinGW
if (Subtarget->isTargetCygMing() &&
- (F->hasLinkOnceLinkage() || F->hasWeakLinkage()))
- O << "Lllvm$workaround$fake$stub$" << CurrentFnName << ":\n";
+ (F->hasLinkOnceLinkage() || F->hasWeakLinkage())) {
+ O << "Lllvm$workaround$fake$stub$";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
+ }
}
/// runOnMachineFunction - This uses the printMachineInstruction()
@@ -183,8 +199,13 @@
O << "\tnop\n";
}
- if (MAI->hasDotTypeDotSizeDirective())
- O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
+ if (MAI->hasDotTypeDotSizeDirective()) {
+ O << "\t.size\t";
+ CurrentFnSym->print(O, MAI);
+ O << ", .-";
+ CurrentFnSym->print(O, MAI);
+ O << '\n';
+ }
// Emit post-function debug information.
if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
Modified: llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp?rev=93594&r1=93593&r2=93594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp Fri Jan 15 18:21:18 2010
@@ -69,10 +69,9 @@
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
unsigned AsmVariant, const char *ExtraCode);
- void emitGlobalDirective(const std::string &name);
- void emitExternDirective(const std::string &name);
+ void emitGlobalDirective(const MCSymbol *Sym);
- void emitArrayBound(const std::string &name, const GlobalVariable *GV);
+ void emitArrayBound(const MCSymbol *Sym, const GlobalVariable *GV);
virtual void PrintGlobalVariable(const GlobalVariable *GV);
void emitFunctionStart(MachineFunction &MF);
@@ -95,35 +94,31 @@
#include "XCoreGenAsmWriter.inc"
-void XCoreAsmPrinter::
-emitGlobalDirective(const std::string &name)
-{
- O << MAI->getGlobalDirective() << name;
+void XCoreAsmPrinter::emitGlobalDirective(const MCSymbol *Sym) {
+ O << MAI->getGlobalDirective();
+ Sym->print(O, MAI);
O << "\n";
}
-void XCoreAsmPrinter::
-emitExternDirective(const std::string &name)
-{
- O << "\t.extern\t" << name;
- O << '\n';
-}
-
-void XCoreAsmPrinter::
-emitArrayBound(const std::string &name, const GlobalVariable *GV)
-{
+void XCoreAsmPrinter::emitArrayBound(const MCSymbol *Sym,
+ const GlobalVariable *GV) {
assert(((GV->hasExternalLinkage() ||
GV->hasWeakLinkage()) ||
GV->hasLinkOnceLinkage()) && "Unexpected linkage");
if (const ArrayType *ATy = dyn_cast<ArrayType>(
- cast<PointerType>(GV->getType())->getElementType()))
- {
- O << MAI->getGlobalDirective() << name << ".globound" << "\n";
- O << MAI->getSetDirective() << name << ".globound" << ","
+ cast<PointerType>(GV->getType())->getElementType())) {
+ O << MAI->getGlobalDirective();
+ Sym->print(O, MAI);
+ O << ".globound" << "\n";
+ O << MAI->getSetDirective();
+ Sym->print(O, MAI);
+ O << ".globound" << ","
<< ATy->getNumElements() << "\n";
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
// 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 @@
return;
const TargetData *TD = TM.getTargetData();
-
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GV, Mang,TM));
+
- std::string name = Mang->getMangledName(GV);
+ MCSymbol *GVSym = GetGlobalValueSymbol(GV);
Constant *C = GV->getInitializer();
unsigned Align = (unsigned)TD->getPreferredTypeAlignmentShift(C->getType());
// 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()) {
case GlobalValue::AppendingLinkage:
@@ -153,11 +152,13 @@
case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage:
case GlobalValue::ExternalLinkage:
- emitArrayBound(name, GV);
- emitGlobalDirective(name);
+ emitArrayBound(GVSym, GV);
+ emitGlobalDirective(GVSym);
// TODO Use COMDAT groups for LinkOnceLinkage
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
- O << MAI->getWeakDefDirective() << name << "\n";
+ O << MAI->getWeakDefDirective();
+ GVSym->print(O, MAI);
+ O << "\n";
}
// FALL THROUGH
case GlobalValue::InternalLinkage:
@@ -181,10 +182,15 @@
Size *= MaxThreads;
}
if (MAI->hasDotTypeDotSizeDirective()) {
- O << "\t.type " << name << ", at object\n";
- O << "\t.size " << name << "," << Size << "\n";
+ O << "\t.type ";
+ GVSym->print(O, MAI);
+ O << ", at object\n";
+ O << "\t.size ";
+ GVSym->print(O, MAI);
+ O << "," << Size << "\n";
}
- O << name << ":\n";
+ GVSym->print(O, MAI);
+ O << ":\n";
EmitGlobalConstant(C);
if (GV->isThreadLocal()) {
@@ -199,7 +205,9 @@
}
// 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
@@ -210,7 +218,11 @@
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
// 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()) {
default: llvm_unreachable("Unknown linkage type!");
@@ -219,31 +231,38 @@
case Function::LinkerPrivateLinkage:
break;
case Function::ExternalLinkage:
- emitGlobalDirective(CurrentFnName);
+ emitGlobalDirective(CurrentFnSym);
break;
case Function::LinkOnceAnyLinkage:
case Function::LinkOnceODRLinkage:
case Function::WeakAnyLinkage:
case Function::WeakODRLinkage:
// TODO Use COMDAT groups for LinkOnceLinkage
- O << MAI->getGlobalDirective() << CurrentFnName << "\n";
- O << MAI->getWeakDefDirective() << CurrentFnName << "\n";
+ O << MAI->getGlobalDirective();
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
+ O << MAI->getWeakDefDirective();
+ CurrentFnSym->print(O, MAI);
+ O << "\n";
break;
}
// (1 << 1) byte aligned
EmitAlignment(MF.getAlignment(), F, 1);
if (MAI->hasDotTypeDotSizeDirective()) {
- O << "\t.type " << CurrentFnName << ", at function\n";
+ O << "\t.type ";
+ CurrentFnSym->print(O, MAI);
+ O << ", at function\n";
}
- O << CurrentFnName << ":\n";
+ CurrentFnSym->print(O, MAI);
+ O << ":\n";
}
/// Emit the directives on the end of functions
-void XCoreAsmPrinter::
-emitFunctionEnd(MachineFunction &MF)
-{
+void XCoreAsmPrinter::emitFunctionEnd(MachineFunction &MF) {
// 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()
More information about the llvm-commits
mailing list