[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Nov 17 11:26:11 PST 2005
Changes in directory llvm/lib/Target/PowerPC:
PPCAsmPrinter.cpp updated: 1.111 -> 1.112
---
Log message:
refactor call operand handling to eliminate special cases from printOp.
---
Diffs of the changes: (+17 -19)
PPCAsmPrinter.cpp | 36 +++++++++++++++++-------------------
1 files changed, 17 insertions(+), 19 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.111 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.112
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.111 Thu Nov 17 13:16:08 2005
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Thu Nov 17 13:25:59 2005
@@ -103,7 +103,7 @@
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 @@
}
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<Function>(MO.getGlobal()) &&
+ cast<Function>(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 @@
// 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 @@
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 @@
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<Function>(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())
More information about the llvm-commits
mailing list