pull the non-pic jump table case out of printPICJumpTableEntry

and MCize the non-pic case.  Now printPICJumpTableEntry really
is just about printing PIC entries.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94446 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-25 21:01:58 +00:00
parent cba386ccac
commit a86106ed88
2 changed files with 15 additions and 11 deletions

View File

@ -524,9 +524,16 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
OutStreamer.EmitLabel(GetJTISymbol(i)); OutStreamer.EmitLabel(GetJTISymbol(i));
for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) { if (!IsPic) {
printPICJumpTableEntry(MJTI, JTBBs[ii], i); unsigned EntrySize = MJTI->getEntrySize();
O << '\n'; for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
MCSymbol *MBBSym = GetMBBSymbol(JTBBs[ii]->getNumber());
OutStreamer.EmitValue(MCSymbolRefExpr::Create(MBBSym, OutContext),
EntrySize, /*addrspace*/0);
}
} else {
for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
printPICJumpTableEntry(MJTI, JTBBs[ii], i);
} }
} }
} }
@ -534,12 +541,9 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI, void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
const MachineBasicBlock *MBB, const MachineBasicBlock *MBB,
unsigned uid) const { unsigned uid) const {
bool isPIC = TM.getRelocationModel() == Reloc::PIC_;
// Use JumpTableDirective otherwise honor the entry size from the jump table // Use JumpTableDirective otherwise honor the entry size from the jump table
// info. // info.
const char *JTEntryDirective = 0; const char *JTEntryDirective = MAI->getPICJumpTableDirective();
if (isPIC) JTEntryDirective = MAI->getPICJumpTableDirective();
bool HadJTEntryDirective = JTEntryDirective != NULL; bool HadJTEntryDirective = JTEntryDirective != NULL;
if (!HadJTEntryDirective) { if (!HadJTEntryDirective) {
JTEntryDirective = MJTI->getEntrySize() == 4 ? JTEntryDirective = MJTI->getEntrySize() == 4 ?
@ -553,9 +557,7 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
// emit the table entries as differences between two text section labels. // emit the table entries as differences between two text section labels.
// If we're emitting non-PIC code, then emit the entries as direct // If we're emitting non-PIC code, then emit the entries as direct
// references to the target basic blocks. // references to the target basic blocks.
if (!isPIC) { if (MAI->getSetDirective()) {
O << *GetMBBSymbol(MBB->getNumber());
} else if (MAI->getSetDirective()) {
O << MAI->getPrivateGlobalPrefix() << getFunctionNumber() O << MAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< '_' << uid << "_set_" << MBB->getNumber(); << '_' << uid << "_set_" << MBB->getNumber();
} else { } else {
@ -565,6 +567,7 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
if (!HadJTEntryDirective) if (!HadJTEntryDirective)
O << '-' << *GetJTISymbol(uid); O << '-' << *GetJTISymbol(uid);
} }
O << '\n';
} }

View File

@ -498,8 +498,9 @@ void X86AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
<< '_' << uid << "_set_" << MBB->getNumber(); << '_' << uid << "_set_" << MBB->getNumber();
} else if (Subtarget->isPICStyleGOT()) } else if (Subtarget->isPICStyleGOT())
O << *GetMBBSymbol(MBB->getNumber()) << "@GOTOFF"; O << *GetMBBSymbol(MBB->getNumber()) << "@GOTOFF";
else else // mdynamic-no-pic
O << *GetMBBSymbol(MBB->getNumber()); O << *GetMBBSymbol(MBB->getNumber());
O << '\n';
} }
bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode) { bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode) {