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