mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
add a AsmPrinter::GetGlobalValueSymbol and GetExternalSymbolSymbol
helper method, use it to simplify some code. llvm-svn: 93575
This commit is contained in:
parent
0e9c12f44a
commit
ea4d444561
@ -339,6 +339,14 @@ namespace llvm {
|
||||
/// EmitComments - Pretty-print comments for basic blocks
|
||||
void EmitComments(const MachineBasicBlock &MBB) const;
|
||||
|
||||
/// GetGlobalValueSymbol - Return the MCSymbol for the specified global
|
||||
/// value.
|
||||
MCSymbol *GetGlobalValueSymbol(const GlobalValue *GV) const;
|
||||
|
||||
/// GetExternalSymbolSymbol - Return the MCSymbol for the specified
|
||||
/// ExternalSymbol.
|
||||
MCSymbol *GetExternalSymbolSymbol(StringRef Sym) const;
|
||||
|
||||
/// GetMBBSymbol - Return the MCSymbol corresponding to the specified basic
|
||||
/// block label.
|
||||
MCSymbol *GetMBBSymbol(unsigned MBBID) const;
|
||||
|
@ -1698,6 +1698,22 @@ MCSymbol *AsmPrinter::GetMBBSymbol(unsigned MBBID) const {
|
||||
return OutContext.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
/// GetGlobalValueSymbol - Return the MCSymbol for the specified global
|
||||
/// value.
|
||||
MCSymbol *AsmPrinter::GetGlobalValueSymbol(const GlobalValue *GV) const {
|
||||
SmallString<60> NameStr;
|
||||
Mang->getNameWithPrefix(NameStr, GV, false);
|
||||
return OutContext.GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
|
||||
/// GetExternalSymbolSymbol - Return the MCSymbol for the specified
|
||||
/// ExternalSymbol.
|
||||
MCSymbol *AsmPrinter::GetExternalSymbolSymbol(StringRef Sym) const {
|
||||
SmallString<60> NameStr;
|
||||
Mang->getNameWithPrefix(NameStr, Sym);
|
||||
return OutContext.GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
|
||||
|
||||
/// EmitBasicBlockStart - This method prints the label for the specified
|
||||
/// MachineBasicBlock, an alignment (if present) and a comment describing
|
||||
|
@ -201,15 +201,13 @@ namespace {
|
||||
GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(Sym) :
|
||||
MMIMachO.getGVStubEntry(Sym);
|
||||
if (StubSym == 0) {
|
||||
Mang->getNameWithPrefix(TmpNameStr, GV, false);
|
||||
StubSym = OutContext.GetOrCreateSymbol(TmpNameStr.str());
|
||||
StubSym = GetGlobalValueSymbol(GV);
|
||||
}
|
||||
}
|
||||
O << Name;
|
||||
} else {
|
||||
assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
|
||||
Mang->getNameWithPrefix(TmpNameStr, ACPV->getSymbol());
|
||||
OutContext.GetOrCreateSymbol(TmpNameStr.str())->print(O, MAI);
|
||||
GetExternalSymbolSymbol(ACPV->getSymbol())->print(O, MAI);
|
||||
}
|
||||
|
||||
if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")";
|
||||
|
@ -181,12 +181,9 @@ void BlackfinAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
O << Mang->getMangledName(MO.getGlobal());
|
||||
printOffset(MO.getOffset());
|
||||
break;
|
||||
case MachineOperand::MO_ExternalSymbol: {
|
||||
SmallString<60> NameStr;
|
||||
Mang->getNameWithPrefix(NameStr, MO.getSymbolName());
|
||||
OutContext.GetOrCreateSymbol(NameStr.str())->print(O, MAI);
|
||||
case MachineOperand::MO_ExternalSymbol:
|
||||
GetExternalSymbolSymbol(MO.getSymbolName())->print(O, MAI);
|
||||
break;
|
||||
}
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
|
||||
<< MO.getIndex();
|
||||
|
@ -198,7 +198,7 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
GetMBBSymbol(MO.getMBB()->getNumber())->print(O, MAI);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << Mang->getMangledName(MO.getGlobal());
|
||||
GetGlobalValueSymbol(MO.getGlobal())->print(O, MAI);
|
||||
break;
|
||||
case MachineOperand::MO_ExternalSymbol:
|
||||
O << MO.getSymbolName();
|
||||
|
Loading…
Reference in New Issue
Block a user