now that MCSymbol::print doesn't use it's MAI argument, we can

remove it and change all the code that prints MCSymbols to use 
<< instead, which is much simpler and cleaner.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93695 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-17 21:43:43 +00:00
parent 6edec7b34a
commit 10b318bcb3
21 changed files with 377 additions and 867 deletions

View File

@ -19,7 +19,6 @@
#include "llvm/System/DataTypes.h" #include "llvm/System/DataTypes.h"
namespace llvm { namespace llvm {
class MCAsmInfo;
class MCExpr; class MCExpr;
class MCSection; class MCSection;
class MCContext; class MCContext;
@ -133,12 +132,16 @@ namespace llvm {
/// @} /// @}
/// print - Print the value to the stream \arg OS. /// print - Print the value to the stream \arg OS.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const; void print(raw_ostream &OS) const;
/// dump - Print the value to stderr. /// dump - Print the value to stderr.
void dump() const; void dump() const;
}; };
inline raw_ostream &operator<<(raw_ostream &OS, const MCSymbol &Sym) {
Sym.print(OS);
return OS;
}
} // end namespace llvm } // end namespace llvm
#endif #endif

View File

@ -20,6 +20,7 @@
namespace llvm { namespace llvm {
class MCSymbol; class MCSymbol;
class MCAsmInfo;
class raw_ostream; class raw_ostream;
/// MCValue - This represents an "assembler immediate". In its most general /// MCValue - This represents an "assembler immediate". In its most general

View File

@ -156,16 +156,12 @@ bool AsmPrinter::doFinalization(Module &M) {
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) { I != E; ++I) {
if (!I->hasExternalWeakLinkage()) continue; if (!I->hasExternalWeakLinkage()) continue;
O << MAI->getWeakRefDirective(); O << MAI->getWeakRefDirective() << *GetGlobalValueSymbol(I) << '\n';
GetGlobalValueSymbol(I)->print(O, MAI);
O << '\n';
} }
for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I) { for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I) {
if (!I->hasExternalWeakLinkage()) continue; if (!I->hasExternalWeakLinkage()) continue;
O << MAI->getWeakRefDirective(); O << MAI->getWeakRefDirective() << *GetGlobalValueSymbol(I) << '\n';
GetGlobalValueSymbol(I)->print(O, MAI);
O << '\n';
} }
} }
@ -178,25 +174,16 @@ bool AsmPrinter::doFinalization(Module &M) {
const GlobalValue *GV = cast<GlobalValue>(I->getAliasedGlobal()); const GlobalValue *GV = cast<GlobalValue>(I->getAliasedGlobal());
MCSymbol *Target = GetGlobalValueSymbol(GV); MCSymbol *Target = GetGlobalValueSymbol(GV);
if (I->hasExternalLinkage() || !MAI->getWeakRefDirective()) { if (I->hasExternalLinkage() || !MAI->getWeakRefDirective())
O << "\t.globl\t"; O << "\t.globl\t" << *Name << '\n';
Name->print(O, MAI); else if (I->hasWeakLinkage())
O << '\n'; O << MAI->getWeakRefDirective() << *Name << '\n';
} else if (I->hasWeakLinkage()) { else
O << MAI->getWeakRefDirective();
Name->print(O, MAI);
O << '\n';
} else {
assert(I->hasLocalLinkage() && "Invalid alias linkage"); assert(I->hasLocalLinkage() && "Invalid alias linkage");
}
printVisibility(Name, I->getVisibility()); printVisibility(Name, I->getVisibility());
O << MAI->getSetDirective() << ' '; O << MAI->getSetDirective() << ' ' << *Name << ", " << *Target << '\n';
Name->print(O, MAI);
O << ", ";
Target->print(O, MAI);
O << '\n';
} }
} }
@ -422,12 +409,12 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
// If we're emitting non-PIC code, then emit the entries as direct // If we're emitting non-PIC code, then emit the entries as direct
// references to the target basic blocks. // references to the target basic blocks.
if (!isPIC) { if (!isPIC) {
GetMBBSymbol(MBB->getNumber())->print(O, MAI); O << *GetMBBSymbol(MBB->getNumber());
} else if (MAI->getSetDirective()) { } else if (MAI->getSetDirective()) {
O << MAI->getPrivateGlobalPrefix() << getFunctionNumber() O << MAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< '_' << uid << "_set_" << MBB->getNumber(); << '_' << uid << "_set_" << MBB->getNumber();
} else { } else {
GetMBBSymbol(MBB->getNumber())->print(O, MAI); O << *GetMBBSymbol(MBB->getNumber());
// If the arch uses custom Jump Table directives, don't calc relative to // If the arch uses custom Jump Table directives, don't calc relative to
// JT // JT
if (!HadJTEntryDirective) if (!HadJTEntryDirective)
@ -812,12 +799,12 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) { if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
// This is a constant address for a global variable or function. Use the // This is a constant address for a global variable or function. Use the
// name of the variable or function as the address value. // name of the variable or function as the address value.
GetGlobalValueSymbol(GV)->print(O, MAI); O << *GetGlobalValueSymbol(GV);
return; return;
} }
if (const BlockAddress *BA = dyn_cast<BlockAddress>(CV)) { if (const BlockAddress *BA = dyn_cast<BlockAddress>(CV)) {
GetBlockAddressSymbol(BA)->print(O, MAI); O << *GetBlockAddressSymbol(BA);
return; return;
} }
@ -1580,9 +1567,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
unsigned OpFlags = MI->getOperand(OpNo).getImm(); unsigned OpFlags = MI->getOperand(OpNo).getImm();
++OpNo; // Skip over the ID number. ++OpNo; // Skip over the ID number.
if (Modifier[0]=='l') // labels are target independent if (Modifier[0] == 'l') // labels are target independent
GetMBBSymbol(MI->getOperand(OpNo).getMBB() O << *GetMBBSymbol(MI->getOperand(OpNo).getMBB()->getNumber());
->getNumber())->print(O, MAI);
else { else {
AsmPrinter *AP = const_cast<AsmPrinter*>(this); AsmPrinter *AP = const_cast<AsmPrinter*>(this);
if ((OpFlags & 7) == 4) { if ((OpFlags & 7) == 4) {
@ -1597,8 +1583,7 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
if (Error) { if (Error) {
std::string msg; std::string msg;
raw_string_ostream Msg(msg); raw_string_ostream Msg(msg);
Msg << "Invalid operand found in inline asm: '" Msg << "Invalid operand found in inline asm: '" << AsmStr << "'\n";
<< AsmStr << "'\n";
MI->print(Msg); MI->print(Msg);
llvm_report_error(Msg.str()); llvm_report_error(Msg.str());
} }
@ -1734,8 +1719,8 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
// forward references to labels without knowing what their numbers // forward references to labels without knowing what their numbers
// will be. // will be.
if (MBB->hasAddressTaken()) { if (MBB->hasAddressTaken()) {
GetBlockAddressSymbol(MBB->getBasicBlock()->getParent(), O << *GetBlockAddressSymbol(MBB->getBasicBlock()->getParent(),
MBB->getBasicBlock())->print(O, MAI); MBB->getBasicBlock());
O << ':'; O << ':';
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
@ -1749,8 +1734,7 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
if (VerboseAsm) if (VerboseAsm)
O << MAI->getCommentString() << " BB#" << MBB->getNumber() << ':'; O << MAI->getCommentString() << " BB#" << MBB->getNumber() << ':';
} else { } else {
GetMBBSymbol(MBB->getNumber())->print(O, MAI); O << *GetMBBSymbol(MBB->getNumber()) << ':';
O << ':';
if (!VerboseAsm) if (!VerboseAsm)
O << '\n'; O << '\n';
} }
@ -1777,9 +1761,9 @@ void AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
return; return;
O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix() O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
<< getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ','; << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ','
GetMBBSymbol(MBB->getNumber())->print(O, MAI); << *GetMBBSymbol(MBB->getNumber())
O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << uid << '\n'; << '_' << uid << '\n';
} }
@ -1790,9 +1774,9 @@ void AsmPrinter::printPICJumpTableSetLabel(unsigned uid, unsigned uid2,
O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix() O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
<< getFunctionNumber() << '_' << uid << '_' << uid2 << getFunctionNumber() << '_' << uid << '_' << uid2
<< "_set_" << MBB->getNumber() << ','; << "_set_" << MBB->getNumber() << ','
GetMBBSymbol(MBB->getNumber())->print(O, MAI); << *GetMBBSymbol(MBB->getNumber())
O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << uid << '_' << uid2 << '\n'; << '_' << uid << '_' << uid2 << '\n';
} }
@ -1842,17 +1826,11 @@ void AsmPrinter::printDataDirective(const Type *type, unsigned AddrSpace) {
void AsmPrinter::printVisibility(const MCSymbol *Sym, void AsmPrinter::printVisibility(const MCSymbol *Sym,
unsigned Visibility) const { unsigned Visibility) const {
if (Visibility == GlobalValue::HiddenVisibility) { if (Visibility == GlobalValue::HiddenVisibility) {
if (const char *Directive = MAI->getHiddenDirective()) { if (const char *Directive = MAI->getHiddenDirective())
O << Directive; O << Directive << *Sym << '\n';
Sym->print(O, MAI);
O << '\n';
}
} else if (Visibility == GlobalValue::ProtectedVisibility) { } else if (Visibility == GlobalValue::ProtectedVisibility) {
if (const char *Directive = MAI->getProtectedDirective()) { if (const char *Directive = MAI->getProtectedDirective())
O << Directive; O << Directive << *Sym << '\n';
Sym->print(O, MAI);
O << '\n';
}
} }
} }

View File

@ -231,26 +231,17 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
// Externally visible entry into the functions eh frame info. If the // Externally visible entry into the functions eh frame info. If the
// corresponding function is static, this should not be externally visible. // corresponding function is static, this should not be externally visible.
if (!TheFunc->hasLocalLinkage()) if (!TheFunc->hasLocalLinkage())
if (const char *GlobalEHDirective = MAI->getGlobalEHDirective()) { if (const char *GlobalEHDirective = MAI->getGlobalEHDirective())
O << GlobalEHDirective; O << GlobalEHDirective << *EHFrameInfo.FunctionEHSym << '\n';
EHFrameInfo.FunctionEHSym->print(O, MAI);
O << '\n';
}
// If corresponding function is weak definition, this should be too. // If corresponding function is weak definition, this should be too.
if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective()) { if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective())
O << MAI->getWeakDefDirective(); O << MAI->getWeakDefDirective() << *EHFrameInfo.FunctionEHSym << '\n';
EHFrameInfo.FunctionEHSym->print(O, MAI);
O << '\n';
}
// If corresponding function is hidden, this should be too. // If corresponding function is hidden, this should be too.
if (TheFunc->hasHiddenVisibility()) if (TheFunc->hasHiddenVisibility())
if (const char *HiddenDirective = MAI->getHiddenDirective()) { if (const char *HiddenDirective = MAI->getHiddenDirective())
O << HiddenDirective; O << HiddenDirective << *EHFrameInfo.FunctionEHSym << '\n';
EHFrameInfo.FunctionEHSym->print(O, MAI);
O << '\n';
}
// If there are no calls then you can't unwind. This may mean we can omit the // If there are no calls then you can't unwind. This may mean we can omit the
// EH Frame, but some environments do not handle weak absolute symbols. If // EH Frame, but some environments do not handle weak absolute symbols. If
@ -260,19 +251,14 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
(!TheFunc->isWeakForLinker() || (!TheFunc->isWeakForLinker() ||
!MAI->getWeakDefDirective() || !MAI->getWeakDefDirective() ||
MAI->getSupportsWeakOmittedEHFrame())) { MAI->getSupportsWeakOmittedEHFrame())) {
EHFrameInfo.FunctionEHSym->print(O, MAI); O << *EHFrameInfo.FunctionEHSym << " = 0\n";
O << " = 0\n";
// This name has no connection to the function, so it might get // This name has no connection to the function, so it might get
// dead-stripped when the function is not, erroneously. Prohibit // dead-stripped when the function is not, erroneously. Prohibit
// dead-stripping unconditionally. // dead-stripping unconditionally.
if (const char *UsedDirective = MAI->getUsedDirective()) { if (const char *UsedDirective = MAI->getUsedDirective())
O << UsedDirective; O << UsedDirective << *EHFrameInfo.FunctionEHSym << "\n\n";
EHFrameInfo.FunctionEHSym->print(O, MAI);
O << "\n\n";
}
} else { } else {
EHFrameInfo.FunctionEHSym->print(O, MAI); O << *EHFrameInfo.FunctionEHSym << ":\n";
O << ":\n";
// EH frame header. // EH frame header.
EmitDifference("eh_frame_end", EHFrameInfo.Number, EmitDifference("eh_frame_end", EHFrameInfo.Number,
@ -344,9 +330,7 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
// link correctly. Yes, there really is. // link correctly. Yes, there really is.
if (MMI->isUsedFunction(EHFrameInfo.function)) if (MMI->isUsedFunction(EHFrameInfo.function))
if (const char *UsedDirective = MAI->getUsedDirective()) { if (const char *UsedDirective = MAI->getUsedDirective()) {
O << UsedDirective; O << UsedDirective << *EHFrameInfo.FunctionEHSym << "\n\n";
EHFrameInfo.FunctionEHSym->print(O, MAI);
O << "\n\n";
} }
} }
@ -946,7 +930,7 @@ void DwarfException::EmitExceptionTable() {
PrintRelDirective(); PrintRelDirective();
if (GV) { if (GV) {
Asm->GetGlobalValueSymbol(GV)->print(O, MAI); O << *Asm->GetGlobalValueSymbol(GV);
} else { } else {
O << "0x0"; O << "0x0";
} }

View File

@ -79,7 +79,7 @@ void Dwarf::EmitReference(const std::string &Name, bool IsPCRelative,
void Dwarf::EmitReference(const MCSymbol *Sym, bool IsPCRelative, void Dwarf::EmitReference(const MCSymbol *Sym, bool IsPCRelative,
bool Force32Bit) const { bool Force32Bit) const {
PrintRelDirective(Force32Bit); PrintRelDirective(Force32Bit);
Sym->print(O, MAI); O << *Sym;
if (IsPCRelative) O << "-" << MAI->getPCSymbol(); if (IsPCRelative) O << "-" << MAI->getPCSymbol();
} }

View File

@ -101,8 +101,7 @@ void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
assert(CurSection && "Cannot emit before setting section!"); assert(CurSection && "Cannot emit before setting section!");
Symbol->print(OS, &MAI); OS << *Symbol << ":\n";
OS << ":\n";
Symbol->setSection(*CurSection); Symbol->setSection(*CurSection);
} }
@ -119,8 +118,7 @@ void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
assert((Symbol->isUndefined() || Symbol->isAbsolute()) && assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
"Cannot define a symbol twice!"); "Cannot define a symbol twice!");
Symbol->print(OS, &MAI); OS << *Symbol << " = ";
OS << " = ";
Value->print(OS, &MAI); Value->print(OS, &MAI);
OS << '\n'; OS << '\n';
@ -146,22 +144,16 @@ void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
case WeakReference: OS << ".weak_reference"; break; case WeakReference: OS << ".weak_reference"; break;
} }
OS << ' '; OS << ' ' << *Symbol << '\n';
Symbol->print(OS, &MAI);
OS << '\n';
} }
void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
OS << ".desc" << ' '; OS << ".desc" << ' ' << *Symbol << ',' << DescValue << '\n';
Symbol->print(OS, &MAI);
OS << ',' << DescValue << '\n';
} }
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size, void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
unsigned ByteAlignment) { unsigned ByteAlignment) {
OS << ".comm "; OS << ".comm " << *Symbol << ',' << Size;
Symbol->print(OS, &MAI);
OS << ',' << Size;
if (ByteAlignment != 0) if (ByteAlignment != 0)
OS << ',' << Log2_32(ByteAlignment); OS << ',' << Log2_32(ByteAlignment);
OS << '\n'; OS << '\n';
@ -177,9 +169,7 @@ void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
OS << MOSection->getSegmentName() << "," << MOSection->getSectionName(); OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
if (Symbol != NULL) { if (Symbol != NULL) {
OS << ','; OS << ',' << *Symbol << ',' << Size;
Symbol->print(OS, &MAI);
OS << ',' << Size;
if (ByteAlignment != 0) if (ByteAlignment != 0)
OS << ',' << Log2_32(ByteAlignment); OS << ',' << Log2_32(ByteAlignment);
} }

View File

@ -26,13 +26,10 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
// Parenthesize names that start with $ so that they don't look like // Parenthesize names that start with $ so that they don't look like
// absolute names. // absolute names.
if (Sym.getName()[0] == '$') { if (Sym.getName()[0] == '$')
OS << '('; OS << '(' << Sym << ')';
Sym.print(OS, MAI); else
OS << ')'; OS << Sym;
} else {
Sym.print(OS, MAI);
}
return; return;
} }

View File

@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
using namespace llvm; using namespace llvm;
@ -39,7 +38,7 @@ static bool NameNeedsQuoting(StringRef Str) {
return false; return false;
} }
void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const { void MCSymbol::print(raw_ostream &OS) const {
// The name for this MCSymbol is required to be a valid target name. However, // The name for this MCSymbol is required to be a valid target name. However,
// some targets support quoting names with funny characters. If the name // some targets support quoting names with funny characters. If the name
// contains a funny character, then print it quoted. // contains a funny character, then print it quoted.
@ -52,5 +51,5 @@ void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
} }
void MCSymbol::dump() const { void MCSymbol::dump() const {
print(dbgs(), 0); print(dbgs());
} }

View File

@ -19,12 +19,10 @@ void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
return; return;
} }
getSymA()->print(OS, MAI); OS << *getSymA();
if (getSymB()) { if (getSymB())
OS << " - "; OS << " - " << *getSymB();
getSymB()->print(OS, MAI);
}
if (getConstant()) if (getConstant())
OS << " + " << getConstant(); OS << " + " << getConstant();

View File

@ -187,11 +187,11 @@ namespace {
bool isIndirect = Subtarget->isTargetDarwin() && bool isIndirect = Subtarget->isTargetDarwin() &&
Subtarget->GVIsIndirectSymbol(GV, TM.getRelocationModel()); Subtarget->GVIsIndirectSymbol(GV, TM.getRelocationModel());
if (!isIndirect) if (!isIndirect)
GetGlobalValueSymbol(GV)->print(O, MAI); O << *GetGlobalValueSymbol(GV);
else { else {
// FIXME: Remove this when Darwin transition to @GOT like syntax. // FIXME: Remove this when Darwin transition to @GOT like syntax.
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
Sym->print(O, MAI); O << *Sym;
MachineModuleInfoMachO &MMIMachO = MachineModuleInfoMachO &MMIMachO =
MMI->getObjFileInfo<MachineModuleInfoMachO>(); MMI->getObjFileInfo<MachineModuleInfoMachO>();
@ -203,7 +203,7 @@ namespace {
} }
} else { } else {
assert(ACPV->isExtSymbol() && "unrecognized constant pool value"); assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
GetExternalSymbolSymbol(ACPV->getSymbol())->print(O, MAI); O << *GetExternalSymbolSymbol(ACPV->getSymbol());
} }
if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")"; if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")";
@ -256,9 +256,7 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
case Function::InternalLinkage: case Function::InternalLinkage:
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl\t"; O << "\t.globl\t" << *CurrentFnSym << "\n";
CurrentFnSym->print(O, MAI);
O << "\n";
break; break;
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
case Function::WeakAnyLinkage: case Function::WeakAnyLinkage:
@ -266,16 +264,10 @@ 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"; O << "\t.globl\t" << *CurrentFnSym << "\n";
CurrentFnSym->print(O, MAI); O << "\t.weak_definition\t" << *CurrentFnSym << "\n";
O << "\n";
O << "\t.weak_definition\t";
CurrentFnSym->print(O, MAI);
O << "\n";
} else { } else {
O << MAI->getWeakRefDirective(); O << MAI->getWeakRefDirective() << *CurrentFnSym << "\n";
CurrentFnSym->print(O, MAI);
O << "\n";
} }
break; break;
} }
@ -287,17 +279,14 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
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"; O << "\t" << *CurrentFnSym;
CurrentFnSym->print(O, MAI);
}
O << "\n"; O << "\n";
} else { } else {
EmitAlignment(FnAlign, F); EmitAlignment(FnAlign, F);
} }
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ":\n";
// Emit pre-function debug information. // Emit pre-function debug information.
DW->BeginFunction(&MF); DW->BeginFunction(&MF);
@ -324,13 +313,8 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
printMachineInstruction(II); printMachineInstruction(II);
} }
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective())
O << "\t.size "; O << "\t.size " << *CurrentFnSym << ", .-" << *CurrentFnSym << "\n";
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);
@ -379,7 +363,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
break; break;
} }
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_GlobalAddress: { case MachineOperand::MO_GlobalAddress: {
bool isCallOp = Modifier && !strcmp(Modifier, "call"); bool isCallOp = Modifier && !strcmp(Modifier, "call");
@ -391,7 +375,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
else if ((Modifier && strcmp(Modifier, "hi16") == 0) || else if ((Modifier && strcmp(Modifier, "hi16") == 0) ||
(TF & ARMII::MO_HI16)) (TF & ARMII::MO_HI16))
O << ":upper16:"; O << ":upper16:";
GetGlobalValueSymbol(GV)->print(O, MAI); O << *GetGlobalValueSymbol(GV);
printOffset(MO.getOffset()); printOffset(MO.getOffset());
@ -402,7 +386,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
} }
case MachineOperand::MO_ExternalSymbol: { case MachineOperand::MO_ExternalSymbol: {
bool isCallOp = Modifier && !strcmp(Modifier, "call"); bool isCallOp = Modifier && !strcmp(Modifier, "call");
GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); O << *GetExternalSymbolSymbol(MO.getSymbolName());
if (isCallOp && Subtarget->isTargetELF() && if (isCallOp && Subtarget->isTargetELF() &&
TM.getRelocationModel() == Reloc::PIC_) TM.getRelocationModel() == Reloc::PIC_)
@ -949,11 +933,11 @@ void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNum) {
<< '_' << JTI << '_' << MO2.getImm() << '_' << JTI << '_' << MO2.getImm()
<< "_set_" << MBB->getNumber(); << "_set_" << MBB->getNumber();
else if (TM.getRelocationModel() == Reloc::PIC_) { else if (TM.getRelocationModel() == Reloc::PIC_) {
GetMBBSymbol(MBB->getNumber())->print(O, MAI); O << *GetMBBSymbol(MBB->getNumber())
O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << '-' << MAI->getPrivateGlobalPrefix() << "JTI"
<< getFunctionNumber() << '_' << JTI << '_' << MO2.getImm(); << getFunctionNumber() << '_' << JTI << '_' << MO2.getImm();
} else { } else {
GetMBBSymbol(MBB->getNumber())->print(O, MAI); O << *GetMBBSymbol(MBB->getNumber());
} }
if (i != e-1) if (i != e-1)
O << '\n'; O << '\n';
@ -984,13 +968,11 @@ void ARMAsmPrinter::printJT2BlockOperand(const MachineInstr *MI, int OpNum) {
else if (HalfWordOffset) else if (HalfWordOffset)
O << MAI->getData16bitsDirective(); O << MAI->getData16bitsDirective();
if (ByteOffset || HalfWordOffset) { if (ByteOffset || HalfWordOffset) {
O << '('; O << '(' << GetMBBSymbol(MBB->getNumber());
GetMBBSymbol(MBB->getNumber())->print(O, MAI);
O << "-" << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() O << "-" << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << JTI << '_' << MO2.getImm() << ")/2"; << '_' << JTI << '_' << MO2.getImm() << ")/2";
} else { } else {
O << "\tb.w "; O << "\tb.w " << *GetMBBSymbol(MBB->getNumber());
GetMBBSymbol(MBB->getNumber())->print(O, MAI);
} }
if (i != e-1) if (i != e-1)
O << '\n'; O << '\n';
@ -1211,11 +1193,8 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
printVisibility(GVarSym, GVar->getVisibility()); printVisibility(GVarSym, GVar->getVisibility());
if (Subtarget->isTargetELF()) { if (Subtarget->isTargetELF())
O << "\t.type "; O << "\t.type " << *GVarSym << ",%object\n";
GVarSym->print(O, MAI);
O << ",%object\n";
}
const MCSection *TheSection = const MCSection *TheSection =
getObjFileLowering().SectionForGlobal(GVar, Mang, TM); getObjFileLowering().SectionForGlobal(GVar, Mang, TM);
@ -1227,12 +1206,9 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
!TheSection->getKind().isMergeableCString()) { !TheSection->getKind().isMergeableCString()) {
if (GVar->hasExternalLinkage()) { if (GVar->hasExternalLinkage()) {
if (const char *Directive = MAI->getZeroFillDirective()) { if (const char *Directive = MAI->getZeroFillDirective()) {
O << "\t.globl\t"; O << "\t.globl\t" << *GVarSym << "\n";
GVarSym->print(O, MAI); O << Directive << "__DATA, __common, " << *GVarSym
O << "\n"; << ", " << Size << ", " << Align << "\n";
O << Directive << "__DATA, __common, ";
GVarSym->print(O, MAI);
O << ", " << Size << ", " << Align << "\n";
return; return;
} }
} }
@ -1242,23 +1218,17 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (isDarwin) { if (isDarwin) {
if (GVar->hasLocalLinkage()) { if (GVar->hasLocalLinkage()) {
O << MAI->getLCOMMDirective(); O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size
GVarSym->print(O, MAI); << ',' << Align;
O << ',' << Size << ',' << Align;
} else if (GVar->hasCommonLinkage()) { } else if (GVar->hasCommonLinkage()) {
O << MAI->getCOMMDirective(); O << MAI->getCOMMDirective() << *GVarSym << ',' << Size
GVarSym->print(O, MAI); << ',' << Align;
O << ',' << Size << ',' << Align;
} else { } else {
OutStreamer.SwitchSection(TheSection); OutStreamer.SwitchSection(TheSection);
O << "\t.globl "; O << "\t.globl " << *GVarSym << '\n' << MAI->getWeakDefDirective();
GVarSym->print(O, MAI); O << *GVarSym << '\n';
O << '\n' << MAI->getWeakDefDirective();
GVarSym->print(O, MAI);
O << '\n';
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
GVarSym->print(O, MAI); O << *GVarSym << ":";
O << ":";
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' '; O << MAI->getCommentString() << ' ';
@ -1270,25 +1240,16 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
} }
} else if (MAI->getLCOMMDirective() != NULL) { } else if (MAI->getLCOMMDirective() != NULL) {
if (GVar->hasLocalLinkage()) { if (GVar->hasLocalLinkage()) {
O << MAI->getLCOMMDirective(); O << MAI->getLCOMMDirective() << *GVarSym << "," << Size;
GVarSym->print(O, MAI);
O << "," << Size;
} else { } else {
O << MAI->getCOMMDirective(); O << MAI->getCOMMDirective() << *GVarSym << "," << Size;
GVarSym->print(O, MAI);
O << "," << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
} }
} else { } else {
if (GVar->hasLocalLinkage()) { if (GVar->hasLocalLinkage())
O << "\t.local\t"; O << "\t.local\t" << *GVarSym << '\n';
GVarSym->print(O, MAI); O << MAI->getCOMMDirective() << *GVarSym << "," << Size;
O << '\n';
}
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);
} }
@ -1310,24 +1271,17 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
if (isDarwin) { if (isDarwin) {
O << "\t.globl "; O << "\t.globl " << *GVarSym
GVarSym->print(O, MAI); << "\n\t.weak_definition " << *GVarSym << "\n";
O << "\n\t.weak_definition ";
GVarSym->print(O, MAI);
O << "\n";
} else { } else {
O << "\t.weak "; O << "\t.weak " << *GVarSym << "\n";
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:
O << "\t.globl "; O << "\t.globl " << *GVarSym << "\n";
GVarSym->print(O, MAI);
O << "\n";
break; break;
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
@ -1337,19 +1291,15 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
} }
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
GVarSym->print(O, MAI); O << *GVarSym << ":";
O << ":";
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' '; O << MAI->getCommentString() << ' ';
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << "\n"; O << "\n";
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective())
O << "\t.size "; O << "\t.size " << *GVarSym << ", " << Size << "\n";
GVarSym->print(O, MAI);
O << ", " << Size << "\n";
}
EmitGlobalConstant(C); EmitGlobalConstant(C);
O << '\n'; O << '\n';
@ -1374,10 +1324,8 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
EmitAlignment(2); EmitAlignment(2);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
Stubs[i].first->print(O, MAI); O << *Stubs[i].first << ":\n\t.indirect_symbol ";
O << ":\n\t.indirect_symbol "; O << *Stubs[i].second << "\n\t.long\t0\n";
Stubs[i].second->print(O, MAI);
O << "\n\t.long\t0\n";
} }
} }
@ -1385,12 +1333,8 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
if (!Stubs.empty()) { if (!Stubs.empty()) {
OutStreamer.SwitchSection(getObjFileLowering().getDataSection()); OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
EmitAlignment(2); EmitAlignment(2);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i)
Stubs[i].first->print(O, MAI); O << *Stubs[i].first << ":\n\t.long " << *Stubs[i].second << "\n";
O << ":\n\t.long ";
Stubs[i].second->print(O, MAI);
O << "\n";
}
} }
// Funny Darwin hack: This flag tells the linker that no global symbols // Funny Darwin hack: This flag tells the linker that no global symbols

View File

@ -94,7 +94,7 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
return; return;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_ConstantPoolIndex: case MachineOperand::MO_ConstantPoolIndex:
@ -107,7 +107,7 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
return; return;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); O << *GetGlobalValueSymbol(MO.getGlobal());
return; return;
case MachineOperand::MO_JumpTableIndex: case MachineOperand::MO_JumpTableIndex:
@ -148,35 +148,28 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl "; O << "\t.globl " << *CurrentFnSym << '\n';
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:
O << MAI->getWeakRefDirective(); O << MAI->getWeakRefDirective() << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI);
O << "\n";
break; break;
} }
printVisibility(CurrentFnSym, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
O << "\t.ent "; O << "\t.ent " << *CurrentFnSym << "\n";
CurrentFnSym->print(O, MAI);
O << "\n";
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
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();
I != E; ++I) { I != E; ++I) {
if (I != MF.begin()) { if (I != MF.begin())
EmitBasicBlockStart(I); EmitBasicBlockStart(I);
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) { II != E; ++II) {
// Print the assembly for the instruction. // Print the assembly for the instruction.
@ -191,9 +184,7 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
} }
} }
O << "\t.end "; O << "\t.end " << *CurrentFnSym << "\n";
CurrentFnSym->print(O, MAI);
O << "\n";
// We didn't modify anything. // We didn't modify anything.
return false; return false;
@ -235,15 +226,11 @@ void AlphaAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::CommonLinkage: case GlobalValue::CommonLinkage:
O << MAI->getWeakRefDirective(); O << MAI->getWeakRefDirective() << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
break; break;
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
case GlobalValue::ExternalLinkage: case GlobalValue::ExternalLinkage:
O << MAI->getGlobalDirective(); O << MAI->getGlobalDirective() << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
break; break;
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
@ -255,18 +242,13 @@ void AlphaAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
// 3: Type, Size, Align // 3: Type, Size, Align
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.type\t"; O << "\t.type\t" << *GVarSym << ", @object\n";
GVarSym->print(O, MAI); O << "\t.size\t" << *GVarSym << ", " << Size << "\n";
O << ", @object\n";
O << "\t.size\t";
GVarSym->print(O, MAI);
O << ", " << Size << "\n";
} }
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
GVarSym->print(O, MAI); O << *GVarSym << ":\n";
O << ":\n";
EmitGlobalConstant(C); EmitGlobalConstant(C);
O << '\n'; O << '\n';

View File

@ -79,20 +79,14 @@ void BlackfinAsmPrinter::emitLinkage(const MCSymbol *GVSym,
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
break; break;
case GlobalValue::ExternalLinkage: case GlobalValue::ExternalLinkage:
O << MAI->getGlobalDirective(); O << MAI->getGlobalDirective() << *GVSym << "\n";
GVSym->print(O, MAI);
O << "\n";
break; break;
case GlobalValue::LinkOnceAnyLinkage: case GlobalValue::LinkOnceAnyLinkage:
case GlobalValue::LinkOnceODRLinkage: case GlobalValue::LinkOnceODRLinkage:
case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
O << MAI->getGlobalDirective(); O << MAI->getGlobalDirective() << *GVSym << "\n";
GVSym->print(O, MAI); O << MAI->getWeakDefDirective() << *GVSym << "\n";
O << "\n";
O << MAI->getWeakDefDirective();
GVSym->print(O, MAI);
O << "\n";
break; break;
} }
} }
@ -112,15 +106,10 @@ void BlackfinAsmPrinter::PrintGlobalVariable(const GlobalVariable* GV) {
EmitAlignment(TD->getPreferredAlignmentLog(GV), GV); EmitAlignment(TD->getPreferredAlignmentLog(GV), GV);
printVisibility(GVSym, GV->getVisibility()); printVisibility(GVSym, GV->getVisibility());
O << "\t.type "; O << "\t.type " << *GVSym << ", STT_OBJECT\n";
GVSym->print(O, MAI); O << "\t.size " << *GVSym << "\n";
O << ", STT_OBJECT\n";
O << "\t.size ";
GVSym->print(O, MAI);
O << "\n";
O << ',' << TD->getTypeAllocSize(C->getType()) << '\n'; O << ',' << TD->getTypeAllocSize(C->getType()) << '\n';
GVSym->print(O, MAI); O << *GVSym << ":\n";
O << ":\n";
EmitGlobalConstant(C); EmitGlobalConstant(C);
} }
@ -138,11 +127,8 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
emitLinkage(CurrentFnSym, F->getLinkage()); emitLinkage(CurrentFnSym, F->getLinkage());
printVisibility(CurrentFnSym, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
O << "\t.type\t"; O << "\t.type\t" << *CurrentFnSym << ", STT_FUNC\n";
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ", STT_FUNC\n";
CurrentFnSym->print(O, MAI);
O << ":\n";
if (DW) if (DW)
DW->BeginFunction(&MF); DW->BeginFunction(&MF);
@ -168,11 +154,7 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
} }
} }
O << "\t.size "; O << "\t.size " << *CurrentFnSym << ", .-" << *CurrentFnSym << "\n";
CurrentFnSym->print(O, MAI);
O << ", .-";
CurrentFnSym->print(O, MAI);
O << "\n";
if (DW) if (DW)
DW->EndFunction(&MF); DW->EndFunction(&MF);
@ -193,14 +175,14 @@ void BlackfinAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
O << MO.getImm(); O << MO.getImm();
break; break;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); O << *GetGlobalValueSymbol(MO.getGlobal());
printOffset(MO.getOffset()); printOffset(MO.getOffset());
break; break;
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); O << *GetExternalSymbolSymbol(MO.getSymbolName());
break; break;
case MachineOperand::MO_ConstantPoolIndex: case MachineOperand::MO_ConstantPoolIndex:
O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_" O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"

View File

@ -315,7 +315,7 @@ void SPUAsmPrinter::printOp(const MachineOperand &MO) {
return; return;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_JumpTableIndex: case MachineOperand::MO_JumpTableIndex:
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
@ -332,7 +332,7 @@ void SPUAsmPrinter::printOp(const MachineOperand &MO) {
<< "$non_lazy_ptr"; << "$non_lazy_ptr";
return; return;
} }
GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); O << *GetExternalSymbolSymbol(MO.getSymbolName());
return; return;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
// External or weakly linked global variables need non-lazily-resolved // External or weakly linked global variables need non-lazily-resolved
@ -341,11 +341,11 @@ void SPUAsmPrinter::printOp(const MachineOperand &MO) {
GlobalValue *GV = MO.getGlobal(); GlobalValue *GV = MO.getGlobal();
if (((GV->isDeclaration() || GV->hasWeakLinkage() || if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) { GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) {
GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr")->print(O, MAI); O << *GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
return; return;
} }
} }
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); O << *GetGlobalValueSymbol(MO.getGlobal());
return; return;
default: default:
O << "<unknown operand type: " << MO.getType() << ">"; O << "<unknown operand type: " << MO.getType() << ">";
@ -427,27 +427,19 @@ bool LinuxAsmPrinter::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"; O << "\t.global\t" << *CurrentFnSym << "\n" << "\t.type\t";
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ", @function\n";
O << "\n" << "\t.type\t";
CurrentFnSym->print(O, MAI);
O << ", @function\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:
O << "\t.global\t"; O << "\t.global\t" << *CurrentFnSym << "\n";
CurrentFnSym->print(O, MAI); O << "\t.weak_definition\t" << *CurrentFnSym << "\n";
O << "\n";
O << "\t.weak_definition\t";
CurrentFnSym->print(O, MAI);
O << "\n";
break; break;
} }
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ":\n";
// Emit pre-function debug information. // Emit pre-function debug information.
DW->BeginFunction(&MF); DW->BeginFunction(&MF);
@ -466,11 +458,7 @@ bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
} }
} }
O << "\t.size\t"; O << "\t.size\t" << *CurrentFnSym << ",.-" << *CurrentFnSym << "\n";
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);
@ -518,23 +506,14 @@ 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 "; O << "\t.global " << *GVarSym << '\n';
GVarSym->print(O, MAI); O << "\t.type " << *GVarSym << ", @object\n";
O << '\n'; O << *GVarSym << ":\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(); O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size;
GVarSym->print(O, MAI);
O << ',' << Size;
} else { } else {
O << ".comm "; O << ".comm " << *GVarSym << ',' << Size;
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());
@ -549,24 +528,15 @@ void LinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::CommonLinkage: case GlobalValue::CommonLinkage:
O << "\t.global "; O << "\t.global " << *GVarSym << "\n\t.type " << *GVarSym << ", @object\n";
GVarSym->print(O, MAI); O << "\t.weak " << *GVarSym << '\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 "; O << "\t.global " << *GVarSym << "\n\t.type " << *GVarSym << ", @object\n";
GVarSym->print(O, MAI);
O << "\n\t.type ";
GVarSym->print(O, MAI);
O << ", @object\n";
break; break;
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
@ -577,8 +547,7 @@ void LinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
} }
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
GVarSym->print(O, MAI); O << *GVarSym << ":\t\t\t\t" << MAI->getCommentString() << " '";
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

@ -106,9 +106,7 @@ void MSP430AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
printVisibility(GVarSym, GVar->getVisibility()); printVisibility(GVarSym, GVar->getVisibility());
O << "\t.type\t"; O << "\t.type\t" << *GVarSym << ",@object\n";
GVarSym->print(O, MAI);
O << ",@object\n";
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang, OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
TM)); TM));
@ -119,15 +117,10 @@ 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"; O << "\t.local\t" << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
}
O << MAI->getCOMMDirective(); O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
GVarSym->print(O, MAI);
O << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
@ -146,9 +139,7 @@ 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"; O << "\t.weak\t" << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
break; break;
case GlobalValue::DLLExportLinkage: case GlobalValue::DLLExportLinkage:
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
@ -156,9 +147,7 @@ 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 "; O << "\t.globl " << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
// FALL THROUGH // FALL THROUGH
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
@ -170,8 +159,7 @@ 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);
GVarSym->print(O, MAI); O << *GVarSym << ":";
O << ":";
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' '; O << MAI->getCommentString() << ' ';
@ -181,11 +169,8 @@ void MSP430AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
EmitGlobalConstant(C); EmitGlobalConstant(C);
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective())
O << "\t.size\t"; O << "\t.size\t" << *GVarSym << ", " << Size << '\n';
GVarSym->print(O, MAI);
O << ", " << Size << '\n';
}
} }
void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) { void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
@ -203,27 +188,20 @@ void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl\t"; O << "\t.globl\t" << *CurrentFnSym << '\n';
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"; O << "\t.weak\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
} }
printVisibility(CurrentFnSym, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
O << "\t.type\t"; O << "\t.type\t" << *CurrentFnSym << ",@function\n";
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ",@function\n";
CurrentFnSym->print(O, MAI);
O << ":\n";
} }
bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) { bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
@ -245,13 +223,8 @@ bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
printMachineInstruction(II); printMachineInstruction(II);
} }
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective())
O << "\t.size\t"; O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
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;
@ -284,7 +257,7 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
O << MO.getImm(); O << MO.getImm();
return; return;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_GlobalAddress: { case MachineOperand::MO_GlobalAddress: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool isMemOp = Modifier && !strcmp(Modifier, "mem");
@ -294,7 +267,7 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
if (Offset) if (Offset)
O << '(' << Offset << '+'; O << '(' << Offset << '+';
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); O << *GetGlobalValueSymbol(MO.getGlobal());
if (Offset) if (Offset)
O << ')'; O << ')';

View File

@ -217,23 +217,15 @@ void MipsAsmPrinter::emitFunctionStart(MachineFunction &MF) {
// 2 bits aligned // 2 bits aligned
EmitAlignment(MF.getAlignment(), F); EmitAlignment(MF.getAlignment(), F);
O << "\t.globl\t"; O << "\t.globl\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI); O << "\t.ent\t" << *CurrentFnSym << '\n';
O << '\n';
O << "\t.ent\t";
CurrentFnSym->print(O, MAI);
O << '\n';
printVisibility(CurrentFnSym, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
if ((MAI->hasDotTypeDotSizeDirective()) && Subtarget->isLinux()) { if ((MAI->hasDotTypeDotSizeDirective()) && Subtarget->isLinux())
O << "\t.type\t"; O << "\t.type\t" << *CurrentFnSym << ", @function\n";
CurrentFnSym->print(O, MAI);
O << ", @function\n";
}
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ":\n";
emitFrameDirective(MF); emitFrameDirective(MF);
printSavedRegsBitmask(MF); printSavedRegsBitmask(MF);
@ -249,16 +241,9 @@ 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"; O << "\t.end\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI); if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux())
O << '\n'; O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\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()
@ -359,15 +344,15 @@ void MipsAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
break; break;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); O << *GetGlobalValueSymbol(MO.getGlobal());
break; break;
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); O << *GetExternalSymbolSymbol(MO.getSymbolName());
break; break;
case MachineOperand::MO_JumpTableIndex: case MachineOperand::MO_JumpTableIndex:
@ -478,15 +463,10 @@ 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"; O << "\t.local\t" << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
}
O << MAI->getCOMMDirective(); O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
GVarSym->print(O, MAI);
O << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (1 << Align); O << ',' << (1 << Align);
@ -502,18 +482,14 @@ 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 "; O << "\t.weak " << *GVarSym << '\n';
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(); O << MAI->getGlobalDirective() << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
// Fall Through // Fall Through
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
@ -534,16 +510,11 @@ void MipsAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
if (MAI->hasDotTypeDotSizeDirective() && printSizeAndType) { if (MAI->hasDotTypeDotSizeDirective() && printSizeAndType) {
O << "\t.type "; O << "\t.type " << *GVarSym << ",@object\n";
GVarSym->print(O, MAI); O << "\t.size " << *GVarSym << ',' << Size << '\n';
O << ",@object\n";
O << "\t.size ";
GVarSym->print(O, MAI);
O << ',' << Size << '\n';
} }
GVarSym->print(O, MAI); O << *GVarSym << ":\n";
O << ":\n";
EmitGlobalConstant(C); EmitGlobalConstant(C);
} }

View File

@ -124,8 +124,7 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
O << "\tretlw high(" << PAN::getFrameLabel(CurrentFnSym->getName()) << ")\n"; O << "\tretlw high(" << PAN::getFrameLabel(CurrentFnSym->getName()) << ")\n";
// Emit function start label. // Emit function start label.
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ":\n";
DebugLoc CurDL; DebugLoc CurDL;
O << "\n"; O << "\n";
@ -191,7 +190,7 @@ void PIC16AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
if (PAN::isMemIntrinsic(Sym->getName())) if (PAN::isMemIntrinsic(Sym->getName()))
LibcallDecls.push_back(createESName(Sym->getName())); LibcallDecls.push_back(createESName(Sym->getName()));
Sym->print(O, MAI); O << *Sym;
break; break;
} }
case MachineOperand::MO_ExternalSymbol: { case MachineOperand::MO_ExternalSymbol: {
@ -212,7 +211,7 @@ void PIC16AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
break; break;
} }
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
default: default:
@ -349,11 +348,8 @@ void PIC16AsmPrinter::EmitUndefinedVars(Module &M) {
if (!Items.size()) return; if (!Items.size()) return;
O << "\n" << MAI->getCommentString() << "Imported Variables - BEGIN" << "\n"; O << "\n" << MAI->getCommentString() << "Imported Variables - BEGIN" << "\n";
for (unsigned j = 0; j < Items.size(); j++) { for (unsigned j = 0; j < Items.size(); j++)
O << MAI->getExternDirective(); O << MAI->getExternDirective() << *GetGlobalValueSymbol(Items[j]) << "\n";
GetGlobalValueSymbol(Items[j])->print(O, MAI);
O << "\n";
}
O << MAI->getCommentString() << "Imported Variables - END" << "\n"; O << MAI->getCommentString() << "Imported Variables - END" << "\n";
} }
@ -363,11 +359,8 @@ void PIC16AsmPrinter::EmitDefinedVars(Module &M) {
if (!Items.size()) return; if (!Items.size()) return;
O << "\n" << MAI->getCommentString() << "Exported Variables - BEGIN" << "\n"; O << "\n" << MAI->getCommentString() << "Exported Variables - BEGIN" << "\n";
for (unsigned j = 0; j < Items.size(); j++) { for (unsigned j = 0; j < Items.size(); j++)
O << MAI->getGlobalDirective(); O << MAI->getGlobalDirective() << *GetGlobalValueSymbol(Items[j]) << "\n";
GetGlobalValueSymbol(Items[j])->print(O, MAI);
O << "\n";
}
O << MAI->getCommentString() << "Exported Variables - END" << "\n"; O << MAI->getCommentString() << "Exported Variables - END" << "\n";
} }
@ -446,7 +439,7 @@ void PIC16AsmPrinter::EmitInitializedDataSection(const PIC16Section *S) {
for (unsigned j = 0; j < Items.size(); j++) { for (unsigned j = 0; j < Items.size(); j++) {
Constant *C = Items[j]->getInitializer(); Constant *C = Items[j]->getInitializer();
int AddrSpace = Items[j]->getType()->getAddressSpace(); int AddrSpace = Items[j]->getType()->getAddressSpace();
GetGlobalValueSymbol(Items[j])->print(O, MAI); O << *GetGlobalValueSymbol(Items[j]);
EmitGlobalConstant(C, AddrSpace); EmitGlobalConstant(C, AddrSpace);
} }
} }
@ -465,8 +458,7 @@ EmitUninitializedDataSection(const PIC16Section *S) {
Constant *C = Items[j]->getInitializer(); Constant *C = Items[j]->getInitializer();
const Type *Ty = C->getType(); const Type *Ty = C->getType();
unsigned Size = TD->getTypeAllocSize(Ty); unsigned Size = TD->getTypeAllocSize(Ty);
GetGlobalValueSymbol(Items[j])->print(O, MAI); O << *GetGlobalValueSymbol(Items[j]) << " RES " << Size << "\n";
O << " RES " << Size << "\n";
} }
} }

View File

@ -238,7 +238,7 @@ namespace {
// Dynamically-resolved functions need a stub for the function. // Dynamically-resolved functions need a stub for the function.
FnStubInfo &FnInfo = FnStubs[GetGlobalValueSymbol(GV)]; FnStubInfo &FnInfo = FnStubs[GetGlobalValueSymbol(GV)];
FnInfo.Init(GV, this); FnInfo.Init(GV, this);
FnInfo.Stub->print(O, MAI); O << *FnInfo.Stub;
return; return;
} }
} }
@ -246,7 +246,7 @@ namespace {
FnStubInfo &FnInfo = FnStubInfo &FnInfo =
FnStubs[GetExternalSymbolSymbol(MO.getSymbolName())]; FnStubs[GetExternalSymbolSymbol(MO.getSymbolName())];
FnInfo.Init(MO.getSymbolName(), Mang, OutContext); FnInfo.Init(MO.getSymbolName(), Mang, OutContext);
FnInfo.Stub->print(O, MAI); O << *FnInfo.Stub;
return; return;
} }
} }
@ -342,8 +342,7 @@ namespace {
GetOrCreateSymbol(StringRef(MAI->getPrivateGlobalPrefix()) + "C" + GetOrCreateSymbol(StringRef(MAI->getPrivateGlobalPrefix()) + "C" +
Twine(LabelID++)); Twine(LabelID++));
TOCEntry->print(O, MAI); O << *TOCEntry << "@toc";
O << "@toc";
} }
void printPredicateOperand(const MachineInstr *MI, unsigned OpNo, void printPredicateOperand(const MachineInstr *MI, unsigned OpNo,
@ -413,7 +412,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
llvm_unreachable("printOp() does not handle immediate values"); llvm_unreachable("printOp() does not handle immediate values");
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_JumpTableIndex: case MachineOperand::MO_JumpTableIndex:
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
@ -425,20 +424,20 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
<< '_' << MO.getIndex(); << '_' << MO.getIndex();
return; return;
case MachineOperand::MO_BlockAddress: case MachineOperand::MO_BlockAddress:
GetBlockAddressSymbol(MO.getBlockAddress())->print(O, MAI); O << *GetBlockAddressSymbol(MO.getBlockAddress());
return; return;
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.
const MCSymbol *SymName = GetExternalSymbolSymbol(MO.getSymbolName()); const MCSymbol *SymName = GetExternalSymbolSymbol(MO.getSymbolName());
if (TM.getRelocationModel() == Reloc::Static) { if (TM.getRelocationModel() == Reloc::Static) {
SymName->print(O, MAI); O << *SymName;
return; return;
} }
const MCSymbol *NLPSym = const MCSymbol *NLPSym =
OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+ OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+
MO.getSymbolName()+"$non_lazy_ptr"); MO.getSymbolName()+"$non_lazy_ptr");
GVStubs[SymName] = NLPSym; GVStubs[SymName] = NLPSym;
NLPSym->print(O, MAI); O << *NLPSym;
return; return;
} }
case MachineOperand::MO_GlobalAddress: { case MachineOperand::MO_GlobalAddress: {
@ -463,7 +462,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
SymToPrint = GetGlobalValueSymbol(GV); SymToPrint = GetGlobalValueSymbol(GV);
} }
SymToPrint->print(O, MAI); O << *SymToPrint;
printOffset(MO.getOffset()); printOffset(MO.getOffset());
return; return;
@ -635,23 +634,16 @@ 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"; O << "\t.global\t" << *CurrentFnSym << '\n' << "\t.type\t";
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ", @function\n";
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"; O << "\t.global\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI); O << "\t.weak\t" << *CurrentFnSym << '\n';
O << '\n';
O << "\t.weak\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
} }
@ -664,18 +656,12 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// 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";
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ":\n"; O << "\t.quad .L." << *CurrentFnSym << ",.TOC.@tocbase\n";
O << "\t.quad .L.";
CurrentFnSym->print(O, MAI);
O << ",.TOC.@tocbase\n";
O << "\t.previous\n"; O << "\t.previous\n";
O << ".L."; O << ".L." << *CurrentFnSym << ":\n";
CurrentFnSym->print(O, MAI);
O << ":\n";
} else { } else {
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ":\n";
} }
// Emit pre-function debug information. // Emit pre-function debug information.
@ -695,11 +681,7 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
} }
} }
O << "\t.size\t"; O << "\t.size\t" << *CurrentFnSym << ",.-" << *CurrentFnSym << '\n';
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));
@ -742,23 +724,14 @@ void PPCLinuxAsmPrinter::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 "; O << "\t.global " << *GVarSym << '\n';
GVarSym->print(O, MAI); O << "\t.type " << *GVarSym << ", @object\n";
O << '\n'; O << *GVarSym << ":\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(); O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size;
GVarSym->print(O, MAI);
O << ',' << Size;
} else { } else {
O << ".comm "; O << ".comm " << *GVarSym << ',' << Size;
GVarSym->print(O, MAI);
O << ',' << Size;
} }
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t" << MAI->getCommentString() << " '"; O << "\t\t" << MAI->getCommentString() << " '";
@ -776,24 +749,16 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::CommonLinkage: case GlobalValue::CommonLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
O << "\t.global "; O << "\t.global " << *GVarSym;
GVarSym->print(O, MAI); O << "\n\t.type " << *GVarSym << ", @object\n\t.weak " << *GVarSym << '\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 "; O << "\t.global " << *GVarSym;
GVarSym->print(O, MAI); O << "\n\t.type " << *GVarSym << ", @object\n";
O << "\n\t.type ";
GVarSym->print(O, MAI);
O << ", @object\n";
// FALL THROUGH // FALL THROUGH
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
@ -803,8 +768,7 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
} }
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
GVarSym->print(O, MAI); O << *GVarSym << ":";
O << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << MAI->getCommentString() << " '"; O << "\t\t\t\t" << MAI->getCommentString() << " '";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
@ -828,13 +792,8 @@ bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
// FIXME: This is nondeterminstic! // FIXME: This is nondeterminstic!
for (DenseMap<const MCSymbol*, const MCSymbol*>::iterator I = TOC.begin(), for (DenseMap<const MCSymbol*, const MCSymbol*>::iterator I = TOC.begin(),
E = TOC.end(); I != E; ++I) { E = TOC.end(); I != E; ++I) {
I->second->print(O, MAI); O << *I->second << ":\n";
O << ":\n"; O << "\t.tc " << *I->first << "[TC]," << *I->first << '\n';
O << "\t.tc ";
I->first->print(O, MAI);
O << "[TC],";
I->first->print(O, MAI);
O << '\n';
} }
} }
@ -863,29 +822,22 @@ 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"; O << "\t.globl\t" << *CurrentFnSym << '\n';
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"; O << "\t.globl\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI); O << "\t.weak_definition\t" << *CurrentFnSym << '\n';
O << '\n';
O << "\t.weak_definition\t";
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
} }
printVisibility(CurrentFnSym, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
EmitAlignment(MF.getAlignment(), F); EmitAlignment(MF.getAlignment(), F);
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ":\n";
// Emit pre-function debug information. // Emit pre-function debug information.
DW->BeginFunction(&MF); DW->BeginFunction(&MF);
@ -1006,25 +958,16 @@ void PPCDarwinAsmPrinter::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.globl "; O << "\t.globl " << *GVarSym << '\n';
GVarSym->print(O, MAI); O << "\t.zerofill __DATA, __common, " << *GVarSym << ", "
O << '\n'; << Size << ", " << Align;
O << "\t.zerofill __DATA, __common, ";
GVarSym->print(O, MAI);
O << ", " << Size << ", " << Align;
} else if (GVar->hasLocalLinkage()) { } else if (GVar->hasLocalLinkage()) {
O << MAI->getLCOMMDirective(); O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align;
GVarSym->print(O, MAI);
O << ',' << Size << ',' << Align;
} else if (!GVar->hasCommonLinkage()) { } else if (!GVar->hasCommonLinkage()) {
O << "\t.globl "; O << "\t.globl " << *GVarSym << '\n' << MAI->getWeakDefDirective();
GVarSym->print(O, MAI); O << *GVarSym << '\n';
O << '\n' << MAI->getWeakDefDirective();
GVarSym->print(O, MAI);
O << '\n';
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
GVarSym->print(O, MAI); O << *GVarSym << ":";
O << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << MAI->getCommentString() << " "; O << "\t\t\t\t" << MAI->getCommentString() << " ";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
@ -1033,9 +976,7 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
EmitGlobalConstant(C); EmitGlobalConstant(C);
return; return;
} else { } else {
O << ".comm "; O << ".comm " << *GVarSym << ',' << Size;
GVarSym->print(O, MAI);
O << ',' << Size;
// Darwin 9 and above support aligned common data. // Darwin 9 and above support aligned common data.
if (Subtarget.isDarwin9()) if (Subtarget.isDarwin9())
O << ',' << Align; O << ',' << Align;
@ -1056,20 +997,14 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::CommonLinkage: case GlobalValue::CommonLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
O << "\t.globl "; O << "\t.globl " << *GVarSym << "\n\t.weak_definition " << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << "\n\t.weak_definition ";
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.globl "; O << "\t.globl " << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
// FALL THROUGH // FALL THROUGH
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
@ -1079,8 +1014,7 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
} }
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
GVarSym->print(O, MAI); O << *GVarSym << ":";
O << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << MAI->getCommentString() << " '"; O << "\t\t\t\t" << MAI->getCommentString() << " '";
WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
@ -1120,38 +1054,23 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
OutStreamer.SwitchSection(StubSection); OutStreamer.SwitchSection(StubSection);
EmitAlignment(4); EmitAlignment(4);
const FnStubInfo &Info = I->second; const FnStubInfo &Info = I->second;
Info.Stub->print(O, MAI); O << *Info.Stub << ":\n";
O << ":\n"; O << "\t.indirect_symbol " << *I->first << '\n';
O << "\t.indirect_symbol ";
I->first->print(O, MAI);
O << '\n';
O << "\tmflr r0\n"; O << "\tmflr r0\n";
O << "\tbcl 20,31,"; O << "\tbcl 20,31," << *Info.AnonSymbol << '\n';
Info.AnonSymbol->print(O, MAI); O << *Info.AnonSymbol << ":\n";
O << '\n';
Info.AnonSymbol->print(O, MAI);
O << ":\n";
O << "\tmflr r11\n"; O << "\tmflr r11\n";
O << "\taddis r11,r11,ha16("; O << "\taddis r11,r11,ha16(" << *Info.LazyPtr << '-' << *Info.AnonSymbol
Info.LazyPtr->print(O, MAI); << ")\n";
O << '-';
Info.AnonSymbol->print(O, MAI);
O << ")\n";
O << "\tmtlr r0\n"; O << "\tmtlr r0\n";
O << (isPPC64 ? "\tldu" : "\tlwzu") << " r12,lo16("; O << (isPPC64 ? "\tldu" : "\tlwzu") << " r12,lo16(" << *Info.LazyPtr
Info.LazyPtr->print(O, MAI); << '-' << *Info.AnonSymbol << ")(r11)\n";
O << '-';
Info.AnonSymbol->print(O, MAI);
O << ")(r11)\n";
O << "\tmtctr r12\n"; O << "\tmtctr r12\n";
O << "\tbctr\n"; O << "\tbctr\n";
OutStreamer.SwitchSection(LSPSection); OutStreamer.SwitchSection(LSPSection);
Info.LazyPtr->print(O, MAI); O << *Info.LazyPtr << ":\n";
O << ":\n"; O << "\t.indirect_symbol " << *I->first << '\n';
O << "\t.indirect_symbol ";
I->first->print(O, MAI);
O << '\n';
O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n";
} }
} else if (!FnStubs.empty()) { } else if (!FnStubs.empty()) {
@ -1167,25 +1086,16 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
OutStreamer.SwitchSection(StubSection); OutStreamer.SwitchSection(StubSection);
EmitAlignment(4); EmitAlignment(4);
const FnStubInfo &Info = I->second; const FnStubInfo &Info = I->second;
Info.Stub->print(O, MAI); O << *Info.Stub << ":\n";
O << ":\n"; O << "\t.indirect_symbol " << *I->first << '\n';
O << "\t.indirect_symbol "; O << "\tlis r11,ha16(" << *Info.LazyPtr << ")\n";
I->first->print(O, MAI); O << (isPPC64 ? "\tldu" : "\tlwzu") << " r12,lo16(" << *Info.LazyPtr
O << '\n'; << ")(r11)\n";
O << "\tlis r11,ha16(";
Info.LazyPtr->print(O, MAI);
O << ")\n";
O << (isPPC64 ? "\tldu" : "\tlwzu") << " r12,lo16(";
Info.LazyPtr->print(O, MAI);
O << ")(r11)\n";
O << "\tmtctr r12\n"; O << "\tmtctr r12\n";
O << "\tbctr\n"; O << "\tbctr\n";
OutStreamer.SwitchSection(LSPSection); OutStreamer.SwitchSection(LSPSection);
Info.LazyPtr->print(O, MAI); O << *Info.LazyPtr << ":\n";
O << ":\n"; O << "\t.indirect_symbol " << *I->first << '\n';
O << "\t.indirect_symbol ";
I->first->print(O, MAI);
O << '\n';
O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n";
} }
} }
@ -1213,11 +1123,8 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
// FIXME: This is nondeterminstic. // FIXME: This is nondeterminstic.
for (DenseMap<const MCSymbol *, const MCSymbol *>::iterator for (DenseMap<const MCSymbol *, const MCSymbol *>::iterator
I = GVStubs.begin(), E = GVStubs.end(); I != E; ++I) { I = GVStubs.begin(), E = GVStubs.end(); I != E; ++I) {
I->second->print(O, MAI); O << *I->second << ":\n";
O << ":\n"; O << "\t.indirect_symbol " << *I->first << '\n';
O << "\t.indirect_symbol ";
I->first->print(O, MAI);
O << '\n';
O << (isPPC64 ? "\t.quad\t0\n" : "\t.long\t0\n"); O << (isPPC64 ? "\t.quad\t0\n" : "\t.long\t0\n");
} }
} }
@ -1228,11 +1135,8 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
// FIXME: This is nondeterminstic. // FIXME: This is nondeterminstic.
for (DenseMap<const MCSymbol *, const MCSymbol *>::iterator for (DenseMap<const MCSymbol *, const MCSymbol *>::iterator
I = HiddenGVStubs.begin(), E = HiddenGVStubs.end(); I != E; ++I) { I = HiddenGVStubs.begin(), E = HiddenGVStubs.end(); I != E; ++I) {
I->second->print(O, MAI); O << *I->second << ":\n";
O << ":\n"; O << (isPPC64 ? "\t.quad\t" : "\t.long\t") << *I->first << '\n';
O << (isPPC64 ? "\t.quad\t" : "\t.long\t");
I->first->print(O, MAI);
O << '\n';
} }
} }

View File

@ -137,11 +137,7 @@ 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"; O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI);
O << ", .-";
CurrentFnSym->print(O, MAI);
O << '\n';
return false; return false;
} }
@ -159,9 +155,7 @@ 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"; O << "\t.global\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
@ -169,19 +163,14 @@ 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"; O << "\t.weak\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
} }
printVisibility(CurrentFnSym, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
O << "\t.type\t"; O << "\t.type\t" << *CurrentFnSym << ", #function\n";
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ", #function\n";
CurrentFnSym->print(O, MAI);
O << ":\n";
} }
@ -205,10 +194,10 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
O << (int)MO.getImm(); O << (int)MO.getImm();
break; break;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); O << *GetGlobalValueSymbol(MO.getGlobal());
break; break;
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
O << MO.getSymbolName(); O << MO.getSymbolName();
@ -314,14 +303,10 @@ void SparcAsmPrinter::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 "; O << "\t.local " << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
} }
O << MAI->getCOMMDirective(); O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
GVarSym->print(O, MAI);
O << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (1 << Align); O << ',' << (1 << Align);
@ -337,18 +322,14 @@ void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
case GlobalValue::WeakAnyLinkage: // FIXME: Verify correct for weak. case GlobalValue::WeakAnyLinkage: // FIXME: Verify correct for weak.
case GlobalValue::WeakODRLinkage: // FIXME: Verify correct for weak. case GlobalValue::WeakODRLinkage: // FIXME: Verify correct for weak.
// Nonnull linkonce -> weak // Nonnull linkonce -> weak
O << "\t.weak "; O << "\t.weak " << *GVarSym << '\n';
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 << MAI->getGlobalDirective(); O << MAI->getGlobalDirective() << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
// FALL THROUGH // FALL THROUGH
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
@ -367,16 +348,11 @@ void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.type "; O << "\t.type " << *GVarSym << ",#object\n";
GVarSym->print(O, MAI); O << "\t.size " << *GVarSym << ',' << Size << '\n';
O << ",#object\n";
O << "\t.size ";
GVarSym->print(O, MAI);
O << ',' << Size << '\n';
} }
GVarSym->print(O, MAI); O << *GVarSym << ":\n";
O << ":\n";
EmitGlobalConstant(C); EmitGlobalConstant(C);
} }

View File

@ -97,27 +97,20 @@ void SystemZAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
break; break;
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl\t"; O << "\t.globl\t" << *CurrentFnSym << '\n';
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"; O << "\t.weak\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
} }
printVisibility(CurrentFnSym, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
O << "\t.type\t"; O << "\t.type\t" << *CurrentFnSym << ",@function\n";
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ":\n";
O << ",@function\n";
CurrentFnSym->print(O, MAI);
O << ":\n";
} }
bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) { bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
@ -142,13 +135,8 @@ bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
printMachineInstruction(II); printMachineInstruction(II);
} }
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective())
O << "\t.size\t"; O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
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);
@ -179,11 +167,11 @@ void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum){
O << MO.getImm(); O << MO.getImm();
return; return;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_GlobalAddress: { case MachineOperand::MO_GlobalAddress: {
const GlobalValue *GV = MO.getGlobal(); const GlobalValue *GV = MO.getGlobal();
GetGlobalValueSymbol(GV)->print(O, MAI); O << *GetGlobalValueSymbol(GV);
// Assemble calls via PLT for externally visible symbols if PIC. // Assemble calls via PLT for externally visible symbols if PIC.
if (TM.getRelocationModel() == Reloc::PIC_ && if (TM.getRelocationModel() == Reloc::PIC_ &&
@ -234,7 +222,7 @@ void SystemZAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
O << MO.getImm(); O << MO.getImm();
return; return;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_JumpTableIndex: case MachineOperand::MO_JumpTableIndex:
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
@ -248,10 +236,10 @@ void SystemZAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
printOffset(MO.getOffset()); printOffset(MO.getOffset());
break; break;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); O << *GetGlobalValueSymbol(MO.getGlobal());
break; break;
case MachineOperand::MO_ExternalSymbol: { case MachineOperand::MO_ExternalSymbol: {
GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI); O << *GetExternalSymbolSymbol(MO.getSymbolName());
break; break;
} }
default: default:
@ -323,9 +311,7 @@ void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
printVisibility(GVarSym, GVar->getVisibility()); printVisibility(GVarSym, GVar->getVisibility());
O << "\t.type\t"; O << "\t.type\t" << *GVarSym << ",@object\n";
GVarSym->print(O, MAI);
O << ",@object\n";
OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang, OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
TM)); TM));
@ -336,15 +322,10 @@ void SystemZAsmPrinter::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"; O << "\t.local\t" << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
}
O << MAI->getCOMMDirective(); O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
GVarSym->print(O, MAI);
O << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
@ -362,9 +343,7 @@ void SystemZAsmPrinter::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"; O << "\t.weak\t" << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
break; break;
case GlobalValue::DLLExportLinkage: case GlobalValue::DLLExportLinkage:
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
@ -372,9 +351,7 @@ void SystemZAsmPrinter::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 "; O << "\t.globl " << *GVarSym << '\n';
GVarSym->print(O, MAI);
O << '\n';
// FALL THROUGH // FALL THROUGH
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
@ -386,18 +363,14 @@ void SystemZAsmPrinter::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, 1); EmitAlignment(Align, GVar, 1);
GVarSym->print(O, MAI); O << *GVarSym << ":";
O << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << MAI->getCommentString() << ' '; 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';
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective())
O << "\t.size\t"; O << "\t.size\t" << *GVarSym << ", " << Size << '\n';
GVarSym->print(O, MAI);
O << ", " << Size << '\n';
}
EmitGlobalConstant(C); EmitGlobalConstant(C);
} }

View File

@ -60,7 +60,7 @@ void X86AsmPrinter::printMCInst(const MCInst *MI) {
void X86AsmPrinter::PrintPICBaseSymbol() const { void X86AsmPrinter::PrintPICBaseSymbol() const {
// FIXME: Gross const cast hack. // FIXME: Gross const cast hack.
X86AsmPrinter *AP = const_cast<X86AsmPrinter*>(this); X86AsmPrinter *AP = const_cast<X86AsmPrinter*>(this);
X86MCInstLower(OutContext, 0, *AP).GetPICBaseSymbol()->print(O, MAI); O << *X86MCInstLower(OutContext, 0, *AP).GetPICBaseSymbol();
} }
void X86AsmPrinter::emitFunctionHeader(const MachineFunction &MF) { void X86AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
@ -84,9 +84,7 @@ void X86AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
break; break;
case Function::DLLExportLinkage: case Function::DLLExportLinkage:
case Function::ExternalLinkage: case Function::ExternalLinkage:
O << "\t.globl\t"; O << "\t.globl\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI);
O << '\n';
break; break;
case Function::LinkerPrivateLinkage: case Function::LinkerPrivateLinkage:
case Function::LinkOnceAnyLinkage: case Function::LinkOnceAnyLinkage:
@ -94,20 +92,13 @@ 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"; O << "\t.globl\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI); O << MAI->getWeakDefDirective() << *CurrentFnSym << '\n';
O << '\n';
O << MAI->getWeakDefDirective();
CurrentFnSym->print(O, MAI);
O << '\n';
} else if (Subtarget->isTargetCygMing()) { } else if (Subtarget->isTargetCygMing()) {
O << "\t.globl\t"; O << "\t.globl\t" << *CurrentFnSym;
CurrentFnSym->print(O, MAI);
O << "\n\t.linkonce discard\n"; O << "\n\t.linkonce discard\n";
} else { } else {
O << "\t.weak\t"; O << "\t.weak\t" << *CurrentFnSym << '\n';
CurrentFnSym->print(O, MAI);
O << '\n';
} }
break; break;
} }
@ -115,20 +106,16 @@ void X86AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
printVisibility(CurrentFnSym, F->getVisibility()); printVisibility(CurrentFnSym, F->getVisibility());
if (Subtarget->isTargetELF()) { if (Subtarget->isTargetELF()) {
O << "\t.type\t"; O << "\t.type\t" << *CurrentFnSym << ",@function\n";
CurrentFnSym->print(O, MAI);
O << ",@function\n";
} else if (Subtarget->isTargetCygMing()) { } else if (Subtarget->isTargetCygMing()) {
O << "\t.def\t "; O << "\t.def\t " << *CurrentFnSym;
CurrentFnSym->print(O, MAI);
O << ";\t.scl\t" << 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";
} }
CurrentFnSym->print(O, MAI); O << *CurrentFnSym << ':';
O << ':';
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' '; O << MAI->getCommentString() << ' ';
@ -138,11 +125,8 @@ 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$"; O << "Lllvm$workaround$fake$stub$" << *CurrentFnSym << ":\n";
CurrentFnSym->print(O, MAI);
O << ":\n";
}
} }
/// runOnMachineFunction - This uses the printMachineInstruction() /// runOnMachineFunction - This uses the printMachineInstruction()
@ -199,13 +183,8 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
O << "\tnop\n"; O << "\tnop\n";
} }
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective())
O << "\t.size\t"; O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
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())
@ -282,12 +261,9 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
// If the name begins with a dollar-sign, enclose it in parens. We do this // If the name begins with a dollar-sign, enclose it in parens. We do this
// to avoid having it look like an integer immediate to the assembler. // to avoid having it look like an integer immediate to the assembler.
if (GVSym->getName()[0] != '$') if (GVSym->getName()[0] != '$')
GVSym->print(O, MAI); O << *GVSym;
else { else
O << '('; O << '(' << *GVSym << ')';
GVSym->print(O, MAI);
O << ')';
}
printOffset(MO.getOffset()); printOffset(MO.getOffset());
break; break;
} }
@ -313,12 +289,9 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
// If the name begins with a dollar-sign, enclose it in parens. We do this // If the name begins with a dollar-sign, enclose it in parens. We do this
// to avoid having it look like an integer immediate to the assembler. // to avoid having it look like an integer immediate to the assembler.
if (SymToPrint->getName()[0] != '$') if (SymToPrint->getName()[0] != '$')
SymToPrint->print(O, MAI); O << *SymToPrint;
else { else
O << '('; O << '(' << *SymToPrint << '(';
SymToPrint->print(O, MAI);
O << '(';
}
break; break;
} }
} }
@ -367,7 +340,7 @@ void X86AsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
O << MO.getImm(); O << MO.getImm();
return; return;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
return; return;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
@ -492,7 +465,7 @@ void X86AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix() O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
<< getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ','; << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
GetMBBSymbol(MBB->getNumber())->print(O, MAI); O << GetMBBSymbol(MBB->getNumber());
if (Subtarget->isPICStyleRIPRel()) if (Subtarget->isPICStyleRIPRel())
O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
@ -523,11 +496,10 @@ void X86AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
if (Subtarget->isPICStyleRIPRel() || Subtarget->isPICStyleStubPIC()) { if (Subtarget->isPICStyleRIPRel() || Subtarget->isPICStyleStubPIC()) {
O << MAI->getPrivateGlobalPrefix() << getFunctionNumber() O << MAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< '_' << uid << "_set_" << MBB->getNumber(); << '_' << uid << "_set_" << MBB->getNumber();
} else if (Subtarget->isPICStyleGOT()) { } else if (Subtarget->isPICStyleGOT())
GetMBBSymbol(MBB->getNumber())->print(O, MAI); O << *GetMBBSymbol(MBB->getNumber()) << "@GOTOFF";
O << "@GOTOFF"; else
} else O << *GetMBBSymbol(MBB->getNumber());
GetMBBSymbol(MBB->getNumber())->print(O, MAI);
} }
bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode) { bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode) {
@ -700,12 +672,8 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
printVisibility(GVSym, GVar->getVisibility()); printVisibility(GVSym, GVar->getVisibility());
if (Subtarget->isTargetELF()) { if (Subtarget->isTargetELF())
O << "\t.type\t"; O << "\t.type\t" << *GVSym << ",@object\n";
GVSym->print(O, MAI);
O << ",@object\n";
}
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM); SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM);
const MCSection *TheSection = const MCSection *TheSection =
@ -718,11 +686,8 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
!TheSection->getKind().isMergeableCString()) { !TheSection->getKind().isMergeableCString()) {
if (GVar->hasExternalLinkage()) { if (GVar->hasExternalLinkage()) {
if (const char *Directive = MAI->getZeroFillDirective()) { if (const char *Directive = MAI->getZeroFillDirective()) {
O << "\t.globl "; O << "\t.globl " << *GVSym << '\n';
GVSym->print(O, MAI); O << Directive << "__DATA, __common, " << *GVSym;
O << '\n';
O << Directive << "__DATA, __common, ";
GVSym->print(O, MAI);
O << ", " << Size << ", " << Align << '\n'; O << ", " << Size << ", " << Align << '\n';
return; return;
} }
@ -734,20 +699,14 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (MAI->getLCOMMDirective() != NULL) { if (MAI->getLCOMMDirective() != NULL) {
if (GVar->hasLocalLinkage()) { if (GVar->hasLocalLinkage()) {
O << MAI->getLCOMMDirective(); O << MAI->getLCOMMDirective() << *GVSym << ',' << Size;
GVSym->print(O, MAI);
O << ',' << Size;
if (Subtarget->isTargetDarwin()) if (Subtarget->isTargetDarwin())
O << ',' << Align; O << ',' << Align;
} else if (Subtarget->isTargetDarwin() && !GVar->hasCommonLinkage()) { } else if (Subtarget->isTargetDarwin() && !GVar->hasCommonLinkage()) {
O << "\t.globl "; O << "\t.globl " << *GVSym << '\n';
GVSym->print(O, MAI); O << MAI->getWeakDefDirective() << *GVSym << '\n';
O << '\n' << MAI->getWeakDefDirective();
GVSym->print(O, MAI);
O << '\n';
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
GVSym->print(O, MAI); O << *GVSym << ":";
O << ":";
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' '; O << MAI->getCommentString() << ' ';
@ -757,23 +716,16 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
EmitGlobalConstant(C); EmitGlobalConstant(C);
return; return;
} else { } else {
O << MAI->getCOMMDirective(); O << MAI->getCOMMDirective() << *GVSym << ',' << Size;
GVSym->print(O, MAI);
O << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
} }
} else { } else {
if (!Subtarget->isTargetCygMing()) { if (!Subtarget->isTargetCygMing()) {
if (GVar->hasLocalLinkage()) { if (GVar->hasLocalLinkage())
O << "\t.local\t"; O << "\t.local\t" << *GVSym << '\n';
GVSym->print(O, MAI);
O << '\n';
}
} }
O << MAI->getCOMMDirective(); O << MAI->getCOMMDirective() << *GVSym << ',' << Size;
GVSym->print(O, MAI);
O << ',' << Size;
if (MAI->getCOMMDirectiveTakesAlignment()) if (MAI->getCOMMDirectiveTakesAlignment())
O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
} }
@ -795,20 +747,13 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
case GlobalValue::LinkerPrivateLinkage: case GlobalValue::LinkerPrivateLinkage:
if (Subtarget->isTargetDarwin()) { if (Subtarget->isTargetDarwin()) {
O << "\t.globl "; O << "\t.globl " << *GVSym << '\n';
GVSym->print(O, MAI); O << MAI->getWeakDefDirective() << *GVSym << '\n';
O << '\n' << MAI->getWeakDefDirective();
GVSym->print(O, MAI);
O << '\n';
} else if (Subtarget->isTargetCygMing()) { } else if (Subtarget->isTargetCygMing()) {
O << "\t.globl\t"; O << "\t.globl\t" << *GVSym;
GVSym->print(O, MAI);
O << "\n\t.linkonce same_size\n"; O << "\n\t.linkonce same_size\n";
} else { } else
O << "\t.weak\t"; O << "\t.weak\t" << *GVSym << '\n';
GVSym->print(O, MAI);
O << '\n';
}
break; break;
case GlobalValue::DLLExportLinkage: case GlobalValue::DLLExportLinkage:
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
@ -816,9 +761,7 @@ void X86AsmPrinter::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 "; O << "\t.globl " << *GVSym << '\n';
GVSym->print(O, MAI);
O << '\n';
// FALL THROUGH // FALL THROUGH
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
@ -828,8 +771,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
} }
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
GVSym->print(O, MAI); O << *GVSym << ":";
O << ":";
if (VerboseAsm){ if (VerboseAsm){
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << ' '; O << MAI->getCommentString() << ' ';
@ -839,11 +781,8 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
EmitGlobalConstant(C); EmitGlobalConstant(C);
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective())
O << "\t.size\t"; O << "\t.size\t" << *GVSym << ", " << Size << '\n';
GVSym->print(O, MAI);
O << ", " << Size << '\n';
}
} }
void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
@ -869,10 +808,9 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
OutStreamer.SwitchSection(TheSection); OutStreamer.SwitchSection(TheSection);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
Stubs[i].first->print(O, MAI); O << *Stubs[i].first << ":\n";
O << ":\n" << "\t.indirect_symbol ";
// Get the MCSymbol without the $stub suffix. // Get the MCSymbol without the $stub suffix.
Stubs[i].second->print(O, MAI); O << "\t.indirect_symbol " << *Stubs[i].second;
O << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n"; O << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n";
} }
O << '\n'; O << '\n';
@ -890,9 +828,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
OutStreamer.SwitchSection(TheSection); OutStreamer.SwitchSection(TheSection);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
Stubs[i].first->print(O, MAI); O << *Stubs[i].first << ":\n\t.indirect_symbol " << *Stubs[i].second;
O << ":\n\t.indirect_symbol ";
Stubs[i].second->print(O, MAI);
O << "\n\t.long\t0\n"; O << "\n\t.long\t0\n";
} }
Stubs.clear(); Stubs.clear();
@ -904,10 +840,8 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
EmitAlignment(2); EmitAlignment(2);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
Stubs[i].first->print(O, MAI); O << *Stubs[i].first << ":\n" << MAI->getData32bitsDirective();
O << ":\n" << MAI->getData32bitsDirective(); O << *Stubs[i].second << '\n';
Stubs[i].second->print(O, MAI);
O << '\n';
} }
Stubs.clear(); Stubs.clear();
} }
@ -957,17 +891,11 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve", OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
true, true,
SectionKind::getMetadata())); SectionKind::getMetadata()));
for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i) { for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i)
O << "\t.ascii \" -export:"; O << "\t.ascii \" -export:" << *DLLExportedGlobals[i] << ",data\"\n";
DLLExportedGlobals[i]->print(O, MAI);
O << ",data\"\n";
}
for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i) { for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i)
O << "\t.ascii \" -export:"; O << "\t.ascii \" -export:" << *DLLExportedFns[i] << "\"\n";
DLLExportedFns[i]->print(O, MAI);
O << "\"\n";
}
} }
} }
} }

View File

@ -94,9 +94,7 @@ namespace {
#include "XCoreGenAsmWriter.inc" #include "XCoreGenAsmWriter.inc"
void XCoreAsmPrinter::emitGlobalDirective(const MCSymbol *Sym) { void XCoreAsmPrinter::emitGlobalDirective(const MCSymbol *Sym) {
O << MAI->getGlobalDirective(); O << MAI->getGlobalDirective() << *Sym << "\n";
Sym->print(O, MAI);
O << "\n";
} }
void XCoreAsmPrinter::emitArrayBound(const MCSymbol *Sym, void XCoreAsmPrinter::emitArrayBound(const MCSymbol *Sym,
@ -106,18 +104,13 @@ void XCoreAsmPrinter::emitArrayBound(const MCSymbol *Sym,
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() << *Sym;
Sym->print(O, MAI);
O << ".globound" << "\n"; O << ".globound" << "\n";
O << MAI->getSetDirective(); O << MAI->getSetDirective() << *Sym;
Sym->print(O, MAI); O << ".globound" << "," << ATy->getNumElements() << "\n";
O << ".globound" << ","
<< 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(); O << MAI->getWeakDefDirective() << *Sym << ".globound" << "\n";
Sym->print(O, MAI);
O << ".globound" << "\n";
} }
} }
} }
@ -137,11 +130,7 @@ void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
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 "; O << "\t.cc_top " << *GVSym << ".data," << *GVSym << "\n";
GVSym->print(O, MAI);
O << ".data,";
GVSym->print(O, MAI);
O << "\n";
switch (GV->getLinkage()) { switch (GV->getLinkage()) {
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
@ -154,11 +143,8 @@ void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
emitArrayBound(GVSym, GV); emitArrayBound(GVSym, GV);
emitGlobalDirective(GVSym); 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(); O << MAI->getWeakDefDirective() << *GVSym << "\n";
GVSym->print(O, MAI);
O << "\n";
}
// FALL THROUGH // FALL THROUGH
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
@ -181,15 +167,10 @@ void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
Size *= MaxThreads; Size *= MaxThreads;
} }
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective()) {
O << "\t.type "; O << "\t.type " << *GVSym << ",@object\n";
GVSym->print(O, MAI); O << "\t.size " << *GVSym << "," << Size << "\n";
O << ",@object\n";
O << "\t.size ";
GVSym->print(O, MAI);
O << "," << Size << "\n";
} }
GVSym->print(O, MAI); O << *GVSym << ":\n";
O << ":\n";
EmitGlobalConstant(C); EmitGlobalConstant(C);
if (GV->isThreadLocal()) { if (GV->isThreadLocal()) {
@ -204,9 +185,7 @@ void XCoreAsmPrinter::PrintGlobalVariable(const GlobalVariable *GV) {
} }
// Mark the end of the global // Mark the end of the global
O << "\t.cc_bottom "; O << "\t.cc_bottom " << *GVSym << ".data\n";
GVSym->print(O, MAI);
O << ".data\n";
} }
/// Emit the directives on the start of functions /// Emit the directives on the start of functions
@ -217,11 +196,7 @@ 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 "; O << "\t.cc_top " << *CurrentFnSym << ".function," << *CurrentFnSym << "\n";
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!");
@ -237,31 +212,22 @@ void XCoreAsmPrinter::emitFunctionStart(MachineFunction &MF) {
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(); O << MAI->getGlobalDirective() << *CurrentFnSym << "\n";
CurrentFnSym->print(O, MAI); O << MAI->getWeakDefDirective() << *CurrentFnSym << "\n";
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 "; O << "\t.type " << *CurrentFnSym << ",@function\n";
CurrentFnSym->print(O, MAI);
O << ",@function\n"; O << *CurrentFnSym << ":\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::emitFunctionEnd(MachineFunction &MF) { void XCoreAsmPrinter::emitFunctionEnd(MachineFunction &MF) {
// Mark the end of the function // Mark the end of the function
O << "\t.cc_bottom "; O << "\t.cc_bottom " << *CurrentFnSym << ".function\n";
CurrentFnSym->print(O, MAI);
O << ".function\n";
} }
/// runOnMachineFunction - This uses the printMachineInstruction() /// runOnMachineFunction - This uses the printMachineInstruction()
@ -336,10 +302,10 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
O << MO.getImm(); O << MO.getImm();
break; break;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI); O << *GetMBBSymbol(MO.getMBB()->getNumber());
break; break;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI); O << *GetGlobalValueSymbol(MO.getGlobal());
break; break;
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
O << MO.getSymbolName(); O << MO.getSymbolName();
@ -352,7 +318,7 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << MO.getIndex(); << '_' << MO.getIndex();
case MachineOperand::MO_BlockAddress: case MachineOperand::MO_BlockAddress:
GetBlockAddressSymbol(MO.getBlockAddress())->print(O, MAI); O << *GetBlockAddressSymbol(MO.getBlockAddress());
break; break;
default: default:
llvm_unreachable("not implemented"); llvm_unreachable("not implemented");