diff options
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 78 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfException.cpp | 40 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp | 2 |
3 files changed, 41 insertions, 79 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index bb1f1d31d14..3beb4d66ac8 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -156,16 +156,12 @@ bool AsmPrinter::doFinalization(Module &M) { for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) { if (!I->hasExternalWeakLinkage()) continue; - O << MAI->getWeakRefDirective(); - GetGlobalValueSymbol(I)->print(O, MAI); - O << '\n'; + O << MAI->getWeakRefDirective() << *GetGlobalValueSymbol(I) << '\n'; } for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I) { if (!I->hasExternalWeakLinkage()) continue; - O << MAI->getWeakRefDirective(); - GetGlobalValueSymbol(I)->print(O, MAI); - O << '\n'; + O << MAI->getWeakRefDirective() << *GetGlobalValueSymbol(I) << '\n'; } } @@ -178,25 +174,16 @@ bool AsmPrinter::doFinalization(Module &M) { const GlobalValue *GV = cast<GlobalValue>(I->getAliasedGlobal()); MCSymbol *Target = GetGlobalValueSymbol(GV); - if (I->hasExternalLinkage() || !MAI->getWeakRefDirective()) { - O << "\t.globl\t"; - Name->print(O, MAI); - O << '\n'; - } else if (I->hasWeakLinkage()) { - O << MAI->getWeakRefDirective(); - Name->print(O, MAI); - O << '\n'; - } else { + if (I->hasExternalLinkage() || !MAI->getWeakRefDirective()) + O << "\t.globl\t" << *Name << '\n'; + else if (I->hasWeakLinkage()) + O << MAI->getWeakRefDirective() << *Name << '\n'; + else assert(I->hasLocalLinkage() && "Invalid alias linkage"); - } printVisibility(Name, I->getVisibility()); - O << MAI->getSetDirective() << ' '; - Name->print(O, MAI); - O << ", "; - Target->print(O, MAI); - O << '\n'; + O << MAI->getSetDirective() << ' ' << *Name << ", " << *Target << '\n'; } } @@ -422,12 +409,12 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI, // If we're emitting non-PIC code, then emit the entries as direct // references to the target basic blocks. if (!isPIC) { - GetMBBSymbol(MBB->getNumber())->print(O, MAI); + O << *GetMBBSymbol(MBB->getNumber()); } else if (MAI->getSetDirective()) { O << MAI->getPrivateGlobalPrefix() << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber(); } else { - GetMBBSymbol(MBB->getNumber())->print(O, MAI); + O << *GetMBBSymbol(MBB->getNumber()); // If the arch uses custom Jump Table directives, don't calc relative to // JT if (!HadJTEntryDirective) @@ -812,12 +799,12 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) { if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) { // This is a constant address for a global variable or function. Use the // name of the variable or function as the address value. - GetGlobalValueSymbol(GV)->print(O, MAI); + O << *GetGlobalValueSymbol(GV); return; } if (const BlockAddress *BA = dyn_cast<BlockAddress>(CV)) { - GetBlockAddressSymbol(BA)->print(O, MAI); + O << *GetBlockAddressSymbol(BA); return; } @@ -1580,9 +1567,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { unsigned OpFlags = MI->getOperand(OpNo).getImm(); ++OpNo; // Skip over the ID number. - if (Modifier[0]=='l') // labels are target independent - GetMBBSymbol(MI->getOperand(OpNo).getMBB() - ->getNumber())->print(O, MAI); + if (Modifier[0] == 'l') // labels are target independent + O << *GetMBBSymbol(MI->getOperand(OpNo).getMBB()->getNumber()); else { AsmPrinter *AP = const_cast<AsmPrinter*>(this); if ((OpFlags & 7) == 4) { @@ -1597,8 +1583,7 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { if (Error) { std::string msg; raw_string_ostream Msg(msg); - Msg << "Invalid operand found in inline asm: '" - << AsmStr << "'\n"; + Msg << "Invalid operand found in inline asm: '" << AsmStr << "'\n"; MI->print(Msg); 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 // will be. if (MBB->hasAddressTaken()) { - GetBlockAddressSymbol(MBB->getBasicBlock()->getParent(), - MBB->getBasicBlock())->print(O, MAI); + O << *GetBlockAddressSymbol(MBB->getBasicBlock()->getParent(), + MBB->getBasicBlock()); O << ':'; if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); @@ -1749,8 +1734,7 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const { if (VerboseAsm) O << MAI->getCommentString() << " BB#" << MBB->getNumber() << ':'; } else { - GetMBBSymbol(MBB->getNumber())->print(O, MAI); - O << ':'; + O << *GetMBBSymbol(MBB->getNumber()) << ':'; if (!VerboseAsm) O << '\n'; } @@ -1777,9 +1761,9 @@ void AsmPrinter::printPICJumpTableSetLabel(unsigned uid, return; O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix() - << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ','; - GetMBBSymbol(MBB->getNumber())->print(O, MAI); - O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() + << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',' + << *GetMBBSymbol(MBB->getNumber()) + << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' << uid << '\n'; } @@ -1790,9 +1774,9 @@ void AsmPrinter::printPICJumpTableSetLabel(unsigned uid, unsigned uid2, O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix() << getFunctionNumber() << '_' << uid << '_' << uid2 - << "_set_" << MBB->getNumber() << ','; - GetMBBSymbol(MBB->getNumber())->print(O, MAI); - O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() + << "_set_" << MBB->getNumber() << ',' + << *GetMBBSymbol(MBB->getNumber()) + << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' << uid << '_' << uid2 << '\n'; } @@ -1842,17 +1826,11 @@ void AsmPrinter::printDataDirective(const Type *type, unsigned AddrSpace) { void AsmPrinter::printVisibility(const MCSymbol *Sym, unsigned Visibility) const { if (Visibility == GlobalValue::HiddenVisibility) { - if (const char *Directive = MAI->getHiddenDirective()) { - O << Directive; - Sym->print(O, MAI); - O << '\n'; - } + if (const char *Directive = MAI->getHiddenDirective()) + O << Directive << *Sym << '\n'; } else if (Visibility == GlobalValue::ProtectedVisibility) { - if (const char *Directive = MAI->getProtectedDirective()) { - O << Directive; - Sym->print(O, MAI); - O << '\n'; - } + if (const char *Directive = MAI->getProtectedDirective()) + O << Directive << *Sym << '\n'; } } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfException.cpp index a51ea2d7b2e..ad6df15c443 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfException.cpp @@ -231,26 +231,17 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) { // Externally visible entry into the functions eh frame info. If the // corresponding function is static, this should not be externally visible. if (!TheFunc->hasLocalLinkage()) - if (const char *GlobalEHDirective = MAI->getGlobalEHDirective()) { - O << GlobalEHDirective; - EHFrameInfo.FunctionEHSym->print(O, MAI); - O << '\n'; - } + if (const char *GlobalEHDirective = MAI->getGlobalEHDirective()) + O << GlobalEHDirective << *EHFrameInfo.FunctionEHSym << '\n'; // If corresponding function is weak definition, this should be too. - if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective()) { - O << MAI->getWeakDefDirective(); - EHFrameInfo.FunctionEHSym->print(O, MAI); - O << '\n'; - } + if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective()) + O << MAI->getWeakDefDirective() << *EHFrameInfo.FunctionEHSym << '\n'; // If corresponding function is hidden, this should be too. if (TheFunc->hasHiddenVisibility()) - if (const char *HiddenDirective = MAI->getHiddenDirective()) { - O << HiddenDirective; - EHFrameInfo.FunctionEHSym->print(O, MAI); - O << '\n'; - } + if (const char *HiddenDirective = MAI->getHiddenDirective()) + O << HiddenDirective << *EHFrameInfo.FunctionEHSym << '\n'; // 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 @@ -260,19 +251,14 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) { (!TheFunc->isWeakForLinker() || !MAI->getWeakDefDirective() || MAI->getSupportsWeakOmittedEHFrame())) { - EHFrameInfo.FunctionEHSym->print(O, MAI); - O << " = 0\n"; + O << *EHFrameInfo.FunctionEHSym << " = 0\n"; // This name has no connection to the function, so it might get // dead-stripped when the function is not, erroneously. Prohibit // dead-stripping unconditionally. - if (const char *UsedDirective = MAI->getUsedDirective()) { - O << UsedDirective; - EHFrameInfo.FunctionEHSym->print(O, MAI); - O << "\n\n"; - } + if (const char *UsedDirective = MAI->getUsedDirective()) + O << UsedDirective << *EHFrameInfo.FunctionEHSym << "\n\n"; } else { - EHFrameInfo.FunctionEHSym->print(O, MAI); - O << ":\n"; + O << *EHFrameInfo.FunctionEHSym << ":\n"; // EH frame header. EmitDifference("eh_frame_end", EHFrameInfo.Number, @@ -344,9 +330,7 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) { // link correctly. Yes, there really is. if (MMI->isUsedFunction(EHFrameInfo.function)) if (const char *UsedDirective = MAI->getUsedDirective()) { - O << UsedDirective; - EHFrameInfo.FunctionEHSym->print(O, MAI); - O << "\n\n"; + O << UsedDirective << *EHFrameInfo.FunctionEHSym << "\n\n"; } } @@ -946,7 +930,7 @@ void DwarfException::EmitExceptionTable() { PrintRelDirective(); if (GV) { - Asm->GetGlobalValueSymbol(GV)->print(O, MAI); + O << *Asm->GetGlobalValueSymbol(GV); } else { O << "0x0"; } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp index 7aca41ed1e8..093b1960a66 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp @@ -79,7 +79,7 @@ void Dwarf::EmitReference(const std::string &Name, bool IsPCRelative, void Dwarf::EmitReference(const MCSymbol *Sym, bool IsPCRelative, bool Force32Bit) const { PrintRelDirective(Force32Bit); - Sym->print(O, MAI); + O << *Sym; if (IsPCRelative) O << "-" << MAI->getPCSymbol(); } |