mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-15 19:24:33 +00:00
switch jump table entry emission to be based on EntryKind
instead of magic variables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94500 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -543,31 +543,54 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
|
|||||||
|
|
||||||
void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
|
void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
|
||||||
const MachineBasicBlock *MBB,
|
const MachineBasicBlock *MBB,
|
||||||
unsigned uid) const {
|
unsigned uid) const {
|
||||||
// If the target supports GPRel, use it.
|
const MCExpr *Value = 0;
|
||||||
if (MAI->getGPRel32Directive() != 0) {
|
switch (MJTI->getEntryKind()) {
|
||||||
|
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);
|
||||||
|
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 = GetMBBSymbol(MBB->getNumber());
|
||||||
OutStreamer.EmitGPRel32Value(MCSymbolRefExpr::Create(MBBSym, OutContext));
|
OutStreamer.EmitGPRel32Value(MCSymbolRefExpr::Create(MBBSym, OutContext));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have emitted set directives for the jump table entries, print
|
case MachineJumpTableInfo::EK_LabelDifference32: {
|
||||||
// them rather than the entries themselves. If we're emitting PIC, then
|
// EK_LabelDifference32 - Each entry is the address of the block minus
|
||||||
// emit the table entries as differences between two text section labels.
|
// the address of the jump table. This is used for PIC jump tables where
|
||||||
const MCExpr *Val;
|
// gprel32 is not supported. e.g.:
|
||||||
if (MAI->getSetDirective()) {
|
// .word LBB123 - LJTI1_2
|
||||||
// If we used .set, reference the .set's symbol.
|
// If the .set directive is supported, this is emitted as:
|
||||||
Val = MCSymbolRefExpr::Create(GetJTSetSymbol(uid, MBB->getNumber()),
|
// .set L4_5_set_123, LBB123 - LJTI1_2
|
||||||
OutContext);
|
// .word L4_5_set_123
|
||||||
} else {
|
|
||||||
|
// If we have emitted set directives for the jump table entries, print
|
||||||
|
// them rather than the entries themselves. If we're emitting PIC, then
|
||||||
|
// emit the table entries as differences between two text section labels.
|
||||||
|
if (MAI->getSetDirective()) {
|
||||||
|
// If we used .set, reference the .set's symbol.
|
||||||
|
Value = MCSymbolRefExpr::Create(GetJTSetSymbol(uid, MBB->getNumber()),
|
||||||
|
OutContext);
|
||||||
|
break;
|
||||||
|
}
|
||||||
// Otherwise, use the difference as the jump table entry.
|
// Otherwise, use the difference as the jump table entry.
|
||||||
Val = MCSymbolRefExpr::Create(GetMBBSymbol(MBB->getNumber()), OutContext);
|
Value = MCSymbolRefExpr::Create(GetMBBSymbol(MBB->getNumber()), OutContext);
|
||||||
const MCExpr *JTI = MCSymbolRefExpr::Create(GetJTISymbol(uid), OutContext);
|
const MCExpr *JTI = MCSymbolRefExpr::Create(GetJTISymbol(uid), OutContext);
|
||||||
Val = MCBinaryExpr::CreateSub(Val, JTI, OutContext);
|
Value = MCBinaryExpr::CreateSub(Value, JTI, OutContext);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(Value && "Unknown entry kind!");
|
||||||
|
|
||||||
unsigned EntrySize = MJTI->getEntrySize(*TM.getTargetData());
|
unsigned EntrySize = MJTI->getEntrySize(*TM.getTargetData());
|
||||||
OutStreamer.EmitValue(Val, EntrySize, /*addrspace*/0);
|
OutStreamer.EmitValue(Value, EntrySize, /*addrspace*/0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user