mcize the non-gprel cases of AsmPrinter::printPICJumpTableEntry

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94450 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2010-01-25 21:22:22 +00:00
parent 798d125659
commit 1aca249252

View File

@@ -525,6 +525,8 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
OutStreamer.EmitLabel(GetJTISymbol(i)); OutStreamer.EmitLabel(GetJTISymbol(i));
if (!IsPic) { if (!IsPic) {
// In non-pic mode, the entries in the jump table are direct references
// to the basic blocks.
unsigned EntrySize = MJTI->getEntrySize(); unsigned EntrySize = MJTI->getEntrySize();
for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) { for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
MCSymbol *MBBSym = GetMBBSymbol(JTBBs[ii]->getNumber()); MCSymbol *MBBSym = GetMBBSymbol(JTBBs[ii]->getNumber());
@@ -546,25 +548,23 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
O << GPRel32Dir << *GetMBBSymbol(MBB->getNumber()) << '\n'; O << GPRel32Dir << *GetMBBSymbol(MBB->getNumber()) << '\n';
return; return;
} }
const char *JTEntryDirective = MJTI->getEntrySize() == 4 ?
MAI->getData32bitsDirective() : MAI->getData64bitsDirective();
O << JTEntryDirective << ' ';
// If we have emitted set directives for the jump table entries, print // If we have emitted set directives for the jump table entries, print
// them rather than the entries themselves. If we're emitting PIC, then // them rather than the entries themselves. If we're emitting PIC, then
// 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 const MCExpr *Val;
// references to the target basic blocks.
if (MAI->getSetDirective()) { if (MAI->getSetDirective()) {
O << *GetJTSetSymbol(uid, MBB->getNumber()); // If we used .set, reference the .set's symbol.
Val = MCSymbolRefExpr::Create(GetJTSetSymbol(uid, MBB->getNumber()),
OutContext);
} else { } else {
O << *GetMBBSymbol(MBB->getNumber()); // Otherwise, use the difference as the jump table entry.
// If the arch uses custom Jump Table directives, don't calc relative to Val = MCSymbolRefExpr::Create(GetMBBSymbol(MBB->getNumber()), OutContext);
// JT. const MCExpr *JTI = MCSymbolRefExpr::Create(GetJTISymbol(uid), OutContext);
O << '-' << *GetJTISymbol(uid); Val = MCBinaryExpr::CreateSub(Val, JTI, OutContext);
} }
O << '\n';
OutStreamer.EmitValue(Val, MJTI->getEntrySize(), /*addrspace*/0);
} }