diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-26 06:28:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-26 06:28:43 +0000 |
commit | 8a785d7a67b98f4e33c83b6a4462e5fa7f1243b8 (patch) | |
tree | d8c89fc7bab209fa45041861cadcd5452c33ad77 /llvm/lib/CodeGen | |
parent | d6b21e484241adc5d56770360806e52d073bb351 (diff) | |
download | bcm5719-llvm-8a785d7a67b98f4e33c83b6a4462e5fa7f1243b8.tar.gz bcm5719-llvm-8a785d7a67b98f4e33c83b6a4462e5fa7f1243b8.zip |
Move getJTISymbol from MachineJumpTableInfo to MachineFunction,
which is more convenient, and change getPICJumpTableRelocBaseExpr
to take a MachineFunction to match.
Next, move the X86 code that create a PICBase symbol to
X86TargetLowering::getPICBaseSymbol from
X86MCInstLower::GetPICBaseSymbol, which was an asmprinter specific
library. This eliminates a 'gross hack', and allows us to
implement X86ISelLowering::getPICJumpTableRelocBaseExpr which now
calls it.
This in turn allows us to eliminate the
X86AsmPrinter::printPICJumpTableSetLabel method, which was the
only overload of printPICJumpTableSetLabel.
llvm-svn: 94526
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 39 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 8 |
3 files changed, 27 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 35a77db43d0..6676289e1a0 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1391,7 +1391,7 @@ MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const { /// GetJTISymbol - Return the symbol for the specified jump table entry. MCSymbol *AsmPrinter::GetJTISymbol(unsigned JTID, bool isLinkerPrivate) const { - return MF->getJumpTableInfo()->getJTISymbol(JTID, OutContext,isLinkerPrivate); + return MF->getJTISymbol(JTID, OutContext, isLinkerPrivate); } /// GetJTSetSymbol - Return the symbol for the specified jump table .set @@ -1546,12 +1546,11 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const { /// specified MachineBasicBlock for a jumptable entry. void AsmPrinter::printPICJumpTableSetLabel(unsigned uid, const MachineBasicBlock *MBB) const { - const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo(); const TargetLowering *TLI = TM.getTargetLowering(); O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix() << *GetJTSetSymbol(uid, MBB->getNumber()) << ',' << *MBB->getSymbol(OutContext) << '-' - << *TLI->getPICJumpTableRelocBaseExpr(MJTI,uid,OutContext) + << *TLI->getPICJumpTableRelocBaseExpr(MF, uid, OutContext) << '\n'; } diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index deb639d542f..511f4aed4cd 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -445,6 +445,27 @@ DILocation MachineFunction::getDILocation(DebugLoc DL) const { return DILocation(DebugLocInfo.DebugLocations[Idx]); } + +/// getJTISymbol - Return the MCSymbol for the specified non-empty jump table. +/// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a +/// normal 'L' label is returned. +MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx, + bool isLinkerPrivate) const { + assert(JumpTableInfo && "No jump tables"); + + const std::vector<MachineJumpTableEntry> &JTs =JumpTableInfo->getJumpTables(); + assert(JTI < JTs.size() && "Invalid JTI!"); + const MCAsmInfo &MAI = *getTarget().getMCAsmInfo(); + + const char *Prefix = isLinkerPrivate ? MAI.getLinkerPrivateGlobalPrefix() : + MAI.getPrivateGlobalPrefix(); + SmallString<60> Name; + raw_svector_ostream(Name) + << Prefix << "JTI" << getFunctionNumber() << '_' << JTI; + return Ctx.GetOrCreateSymbol(Name.str()); +} + + //===----------------------------------------------------------------------===// // MachineFrameInfo implementation //===----------------------------------------------------------------------===// @@ -581,24 +602,6 @@ unsigned MachineJumpTableInfo::getJumpTableIndex( return JumpTables.size()-1; } -/// getJTISymbol - Return the MCSymbol for the specified non-empty jump table. -/// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a -/// normal 'L' label is returned. -MCSymbol *MachineJumpTableInfo::getJTISymbol(unsigned JTI, MCContext &Ctx, - bool isLinkerPrivate) const { - assert(JTI < JumpTables.size() && !JumpTables[JTI].MBBs.empty() && - "Invalid JTI!"); - const MachineFunction *MF = JumpTables[JTI].MBBs[0]->getParent(); - const MCAsmInfo &MAI = *MF->getTarget().getMCAsmInfo(); - - const char *Prefix = isLinkerPrivate ? MAI.getLinkerPrivateGlobalPrefix() : - MAI.getPrivateGlobalPrefix(); - SmallString<60> Name; - raw_svector_ostream(Name) - << Prefix << "JTI" << MF->getFunctionNumber() << '_' << JTI; - return Ctx.GetOrCreateSymbol(Name.str()); -} - /// ReplaceMBBInJumpTables - If Old is the target of any jump tables, update /// the jump tables to branch to New instead. diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index ccdedded90d..5a0bdb47d1b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -23,6 +23,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h" @@ -823,11 +824,10 @@ SDValue TargetLowering::getPICJumpTableRelocBase(SDValue Table, /// given PIC jumptable, the same as getPICJumpTableRelocBase, but as an /// MCExpr. const MCExpr * -TargetLowering::getPICJumpTableRelocBaseExpr(const MachineJumpTableInfo *MJTI, - unsigned JTI, - MCContext &Ctx) const { +TargetLowering::getPICJumpTableRelocBaseExpr(const MachineFunction *MF, + unsigned JTI,MCContext &Ctx) const{ // The normal PIC reloc base is the label at the start of the jump table. - return MCSymbolRefExpr::Create(MJTI->getJTISymbol(JTI, Ctx), Ctx); + return MCSymbolRefExpr::Create(MF->getJTISymbol(JTI, Ctx), Ctx); } bool |