mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-24 04:45:00 +00:00
add a new MachineBasicBlock::getSymbol method, replacing
the AsmPrinter::GetMBBSymbol. llvm-svn: 94515
This commit is contained in:
parent
91856859d6
commit
b4a5d00176
@ -301,10 +301,6 @@ namespace llvm {
|
||||
/// ExternalSymbol.
|
||||
MCSymbol *GetExternalSymbolSymbol(StringRef Sym) const;
|
||||
|
||||
/// GetMBBSymbol - Return the MCSymbol corresponding to the specified basic
|
||||
/// block label.
|
||||
MCSymbol *GetMBBSymbol(unsigned MBBID) const;
|
||||
|
||||
/// GetCPISymbol - Return the symbol for the specified constant pool entry.
|
||||
MCSymbol *GetCPISymbol(unsigned CPID) const;
|
||||
|
||||
|
@ -352,6 +352,10 @@ public:
|
||||
int getNumber() const { return Number; }
|
||||
void setNumber(int N) { Number = N; }
|
||||
|
||||
/// getSymbol - Return the MCSymbol for this basic block.
|
||||
///
|
||||
MCSymbol *getSymbol(MCContext &Ctx) const;
|
||||
|
||||
private: // Methods used to maintain doubly linked list of blocks...
|
||||
friend struct ilist_traits<MachineBasicBlock>;
|
||||
|
||||
|
@ -534,7 +534,7 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
|
||||
// In non-pic mode, the entries in the jump table are direct references
|
||||
// to the basic blocks.
|
||||
for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
|
||||
MCSymbol *MBBSym = GetMBBSymbol(JTBBs[ii]->getNumber());
|
||||
MCSymbol *MBBSym = JTBBs[ii]->getSymbol(OutContext);
|
||||
OutStreamer.EmitValue(MCSymbolRefExpr::Create(MBBSym, OutContext),
|
||||
EntrySize, /*addrspace*/0);
|
||||
}
|
||||
@ -557,13 +557,13 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
|
||||
case MachineJumpTableInfo::EK_BlockAddress:
|
||||
// EK_BlockAddress - Each entry is a plain address of block, e.g.:
|
||||
// .word LBB123
|
||||
Value = MCSymbolRefExpr::Create(GetMBBSymbol(MBB->getNumber()), OutContext);
|
||||
Value = MCSymbolRefExpr::Create(MBB->getSymbol(OutContext), OutContext);
|
||||
break;
|
||||
case MachineJumpTableInfo::EK_GPRel32BlockAddress: {
|
||||
// EK_GPRel32BlockAddress - Each entry is an address of block, encoded
|
||||
// with a relocation as gp-relative, e.g.:
|
||||
// .gprel32 LBB123
|
||||
MCSymbol *MBBSym = GetMBBSymbol(MBB->getNumber());
|
||||
MCSymbol *MBBSym = MBB->getSymbol(OutContext);
|
||||
OutStreamer.EmitGPRel32Value(MCSymbolRefExpr::Create(MBBSym, OutContext));
|
||||
return;
|
||||
}
|
||||
@ -587,7 +587,7 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
|
||||
break;
|
||||
}
|
||||
// Otherwise, use the difference as the jump table entry.
|
||||
Value = MCSymbolRefExpr::Create(GetMBBSymbol(MBB->getNumber()), OutContext);
|
||||
Value = MCSymbolRefExpr::Create(MBB->getSymbol(OutContext), OutContext);
|
||||
const MCExpr *JTI = MCSymbolRefExpr::Create(GetJTISymbol(uid), OutContext);
|
||||
Value = MCBinaryExpr::CreateSub(Value, JTI, OutContext);
|
||||
break;
|
||||
@ -1286,7 +1286,7 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
|
||||
++OpNo; // Skip over the ID number.
|
||||
|
||||
if (Modifier[0] == 'l') // labels are target independent
|
||||
O << *GetMBBSymbol(MI->getOperand(OpNo).getMBB()->getNumber());
|
||||
O << *MI->getOperand(OpNo).getMBB()->getSymbol(OutContext);
|
||||
else {
|
||||
AsmPrinter *AP = const_cast<AsmPrinter*>(this);
|
||||
if ((OpFlags & 7) == 4) {
|
||||
@ -1386,13 +1386,6 @@ MCSymbol *AsmPrinter::GetBlockAddressSymbol(const Function *F,
|
||||
return OutContext.GetOrCreateSymbol(NameResult.str());
|
||||
}
|
||||
|
||||
MCSymbol *AsmPrinter::GetMBBSymbol(unsigned MBBID) const {
|
||||
SmallString<60> Name;
|
||||
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "BB"
|
||||
<< getFunctionNumber() << '_' << MBBID;
|
||||
return OutContext.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
/// GetCPISymbol - Return the symbol for the specified constant pool entry.
|
||||
MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
|
||||
SmallString<60> Name;
|
||||
@ -1555,7 +1548,7 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
|
||||
PrintBasicBlockLoopComments(*MBB, LI, *this);
|
||||
}
|
||||
|
||||
OutStreamer.EmitLabel(GetMBBSymbol(MBB->getNumber()));
|
||||
OutStreamer.EmitLabel(MBB->getSymbol(OutContext));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1568,7 +1561,7 @@ void AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
|
||||
|
||||
O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
|
||||
<< *GetJTSetSymbol(uid, MBB->getNumber()) << ','
|
||||
<< *GetMBBSymbol(MBB->getNumber()) << '-' << *GetJTISymbol(uid) << '\n';
|
||||
<< *MBB->getSymbol(OutContext) << '-' << *GetJTISymbol(uid) << '\n';
|
||||
}
|
||||
|
||||
void AsmPrinter::printVisibility(MCSymbol *Sym, unsigned Visibility) const {
|
||||
|
@ -14,15 +14,18 @@
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/BasicBlock.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetInstrDesc.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/LeakDetector.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
#include <algorithm>
|
||||
using namespace llvm;
|
||||
|
||||
@ -36,6 +39,18 @@ MachineBasicBlock::~MachineBasicBlock() {
|
||||
LeakDetector::removeGarbageObject(this);
|
||||
}
|
||||
|
||||
/// getSymbol - Return the MCSymbol for this basic block.
|
||||
///
|
||||
MCSymbol *MachineBasicBlock::getSymbol(MCContext &Ctx) const {
|
||||
SmallString<60> Name;
|
||||
const MachineFunction *MF = getParent();
|
||||
raw_svector_ostream(Name)
|
||||
<< MF->getTarget().getMCAsmInfo()->getPrivateGlobalPrefix() << "BB"
|
||||
<< MF->getFunctionNumber() << '_' << getNumber();
|
||||
return Ctx.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
|
||||
raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineBasicBlock &MBB) {
|
||||
MBB.print(OS);
|
||||
return OS;
|
||||
|
@ -369,7 +369,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||
break;
|
||||
}
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress: {
|
||||
bool isCallOp = Modifier && !strcmp(Modifier, "call");
|
||||
@ -948,16 +948,16 @@ void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNum) {
|
||||
if (UseSet && isNew) {
|
||||
O << MAI->getSetDirective() << ' '
|
||||
<< *GetARMSetPICJumpTableLabel2(JTI, MO2.getImm(), MBB) << ','
|
||||
<< *GetMBBSymbol(MBB->getNumber()) << '-' << *JTISymbol << '\n';
|
||||
<< *MBB->getSymbol(OutContext) << '-' << *JTISymbol << '\n';
|
||||
}
|
||||
|
||||
O << JTEntryDirective << ' ';
|
||||
if (UseSet)
|
||||
O << *GetARMSetPICJumpTableLabel2(JTI, MO2.getImm(), MBB);
|
||||
else if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
O << *GetMBBSymbol(MBB->getNumber()) << '-' << *JTISymbol;
|
||||
O << *MBB->getSymbol(OutContext) << '-' << *JTISymbol;
|
||||
else
|
||||
O << *GetMBBSymbol(MBB->getNumber());
|
||||
O << *MBB->getSymbol(OutContext);
|
||||
|
||||
if (i != e-1)
|
||||
O << '\n';
|
||||
@ -989,9 +989,9 @@ void ARMAsmPrinter::printJT2BlockOperand(const MachineInstr *MI, int OpNum) {
|
||||
O << MAI->getData16bitsDirective();
|
||||
|
||||
if (ByteOffset || HalfWordOffset)
|
||||
O << '(' << *GetMBBSymbol(MBB->getNumber()) << "-" << *JTISymbol << ")/2";
|
||||
O << '(' << *MBB->getSymbol(OutContext) << "-" << *JTISymbol << ")/2";
|
||||
else
|
||||
O << "\tb.w " << *GetMBBSymbol(MBB->getNumber());
|
||||
O << "\tb.w " << *MBB->getSymbol(OutContext);
|
||||
|
||||
if (i != e-1)
|
||||
O << '\n';
|
||||
|
@ -135,7 +135,7 @@ void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
|
||||
Printer.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
|
||||
MO.getMBB()->getSymbol(Ctx), Ctx));
|
||||
break;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
|
||||
|
@ -93,7 +93,7 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
|
||||
return;
|
||||
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
|
@ -152,7 +152,7 @@ void BlackfinAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
O << MO.getImm();
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << *GetGlobalValueSymbol(MO.getGlobal());
|
||||
|
@ -312,7 +312,7 @@ void SPUAsmPrinter::printOp(const MachineOperand &MO) {
|
||||
return;
|
||||
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
|
||||
|
@ -173,7 +173,7 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||
O << MO.getImm();
|
||||
return;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress: {
|
||||
bool isMemOp = Modifier && !strcmp(Modifier, "mem");
|
||||
|
@ -116,7 +116,7 @@ void MSP430MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
|
||||
Printer.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
|
||||
MO.getMBB()->getSymbol(Printer.OutContext), Ctx));
|
||||
break;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
|
||||
|
@ -341,7 +341,7 @@ void MipsAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
break;
|
||||
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
|
@ -209,7 +209,7 @@ void PIC16AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
break;
|
||||
}
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
|
||||
default:
|
||||
|
@ -382,7 +382,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
||||
llvm_unreachable("printOp() does not handle immediate values");
|
||||
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
|
||||
|
@ -191,7 +191,7 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
O << (int)MO.getImm();
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << *GetGlobalValueSymbol(MO.getGlobal());
|
||||
|
@ -166,7 +166,7 @@ void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum){
|
||||
O << MO.getImm();
|
||||
return;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress: {
|
||||
const GlobalValue *GV = MO.getGlobal();
|
||||
@ -221,7 +221,7 @@ void SystemZAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||
O << MO.getImm();
|
||||
return;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
|
||||
|
@ -340,7 +340,7 @@ void X86AsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
|
||||
O << MO.getImm();
|
||||
return;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
case MachineOperand::MO_ExternalSymbol:
|
||||
@ -465,7 +465,7 @@ void X86AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
|
||||
O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
|
||||
<< getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
|
||||
|
||||
O << *GetMBBSymbol(MBB->getNumber());
|
||||
O << *MBB->getSymbol(OutContext);
|
||||
|
||||
if (Subtarget->isPICStyleRIPRel())
|
||||
O << '-' << *GetJTISymbol(uid) << '\n';
|
||||
@ -495,9 +495,9 @@ void X86AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
|
||||
if (Subtarget->isPICStyleRIPRel() || Subtarget->isPICStyleStubPIC()) {
|
||||
O << *GetJTSetSymbol(uid, MBB->getNumber());
|
||||
} else if (Subtarget->isPICStyleGOT())
|
||||
O << *GetMBBSymbol(MBB->getNumber()) << "@GOTOFF";
|
||||
O << *MBB->getSymbol(OutContext) << "@GOTOFF";
|
||||
else // mdynamic-no-pic
|
||||
O << *GetMBBSymbol(MBB->getNumber());
|
||||
O << *MBB->getSymbol(OutContext);
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
|
||||
AsmPrinter.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
|
||||
MO.getMBB()->getSymbol(Ctx), Ctx));
|
||||
break;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
|
||||
|
@ -297,7 +297,7 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
O << MO.getImm();
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *GetMBBSymbol(MO.getMBB()->getNumber());
|
||||
O << *MO.getMBB()->getSymbol(OutContext);
|
||||
break;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << *GetGlobalValueSymbol(MO.getGlobal());
|
||||
|
Loading…
x
Reference in New Issue
Block a user