From 9ba13e4aeff453cdc8ed26fb927ec65dd44625b4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 17 Nov 2005 19:25:59 +0000 Subject: [PATCH] refactor call operand handling to eliminate special cases from printOp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24401 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPCAsmPrinter.cpp | 36 +++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index 0b6fa5a3b30..7367c41274c 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -103,7 +103,7 @@ namespace { bool printInstruction(const MachineInstr *MI); void printMachineInstruction(const MachineInstr *MI); - void printOp(const MachineOperand &MO, bool IsCallOp = false); + void printOp(const MachineOperand &MO); void printOperand(const MachineInstr *MI, unsigned OpNo, MVT::ValueType VT){ const MachineOperand &MO = MI->getOperand(OpNo); @@ -153,7 +153,21 @@ namespace { } void printCallOperand(const MachineInstr *MI, unsigned OpNo, MVT::ValueType VT) { - printOp(MI->getOperand(OpNo), true); + const MachineOperand &MO = MI->getOperand(OpNo); + if (MO.getType() == MachineOperand::MO_ExternalSymbol) { + std::string Name(GlobalPrefix); Name += MO.getSymbolName(); + FnStubs.insert(Name); + O << "L" << Name << "$stub"; + } else if (MO.getType() == MachineOperand::MO_GlobalAddress && + isa(MO.getGlobal()) && + cast(MO.getGlobal())->isExternal()) { + // Dynamically-resolved functions need a stub for the function. + std::string Name = Mang->getValueName(MO.getGlobal()); + FnStubs.insert(Name); + O << "L" << Name << "$stub"; + } else { + printOp(MI->getOperand(OpNo)); + } } void printAbsAddrOperand(const MachineInstr *MI, unsigned OpNo, MVT::ValueType VT) { @@ -273,7 +287,7 @@ FunctionPass *llvm::createAIXAsmPrinter(std::ostream &o, TargetMachine &tm) { // Include the auto-generated portion of the assembly writer #include "PPCGenAsmWriter.inc" -void PPCAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) { +void PPCAsmPrinter::printOp(const MachineOperand &MO) { const MRegisterInfo &RI = *TM.getRegisterInfo(); int new_symbol; @@ -312,12 +326,6 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) { return; case MachineOperand::MO_ExternalSymbol: - if (IsCallOp) { - std::string Name(GlobalPrefix); Name += MO.getSymbolName(); - FnStubs.insert(Name); - O << "L" << Name << "$stub"; - return; - } O << GlobalPrefix << MO.getSymbolName(); return; @@ -325,16 +333,6 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) { GlobalValue *GV = MO.getGlobal(); std::string Name = Mang->getValueName(GV); - // Dynamically-resolved functions need a stub for the function. Be - // wary however not to output $stub for external functions whose addresses - // are taken. Those should be emitted as $non_lazy_ptr below. - Function *F = dyn_cast(GV); - if (F && IsCallOp && F->isExternal()) { - FnStubs.insert(Name); - O << "L" << Name << "$stub"; - return; - } - // External or weakly linked global variables need non-lazily-resolved stubs if ((GV->isExternal() || GV->hasWeakLinkage() || GV->hasLinkOnceLinkage())){ if (GV->hasLinkOnceLinkage())