make jit jump table emission be based on the EntryKind instead of magic variables.

JITInfo::getPICJumpTableEntry can probably be removed now, but I don't plan to do 
this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94501 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-26 03:47:15 +00:00
parent ff537cec2e
commit 13af11acbf

View File

@ -1423,25 +1423,11 @@ void JITEmitter::emitJumpTableInfo(MachineJumpTableInfo *MJTI) {
const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables(); const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
if (JT.empty() || JumpTableBase == 0) return; if (JT.empty() || JumpTableBase == 0) return;
// FIXME: This should use MachineJumpTableInfo::getEntryKind() instead of
// checking for PIC etc.
if (TargetMachine::getRelocationModel() == Reloc::PIC_) {
assert(MJTI->getEntrySize(*TheJIT->getTargetData()) == 4&&"Cross JIT'ing?");
// For each jump table, place the offset from the beginning of the table
// to the target address.
int *SlotPtr = (int*)JumpTableBase;
for (unsigned i = 0, e = JT.size(); i != e; ++i) { switch (MJTI->getEntryKind()) {
const std::vector<MachineBasicBlock*> &MBBs = JT[i].MBBs; case MachineJumpTableInfo::EK_BlockAddress: {
// Store the offset of the basic block for this jump table slot in the // EK_BlockAddress - Each entry is a plain address of block, e.g.:
// memory we allocated for the jump table in 'initJumpTableInfo' // .word LBB123
uintptr_t Base = (uintptr_t)SlotPtr;
for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi) {
uintptr_t MBBAddr = getMachineBasicBlockAddress(MBBs[mi]);
*SlotPtr++ = TheJIT->getJITInfo().getPICJumpTableEntry(MBBAddr, Base);
}
}
} else {
assert(MJTI->getEntrySize(*TheJIT->getTargetData()) == sizeof(void*) && assert(MJTI->getEntrySize(*TheJIT->getTargetData()) == sizeof(void*) &&
"Cross JIT'ing?"); "Cross JIT'ing?");
@ -1456,6 +1442,29 @@ void JITEmitter::emitJumpTableInfo(MachineJumpTableInfo *MJTI) {
for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi) for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi)
*SlotPtr++ = getMachineBasicBlockAddress(MBBs[mi]); *SlotPtr++ = getMachineBasicBlockAddress(MBBs[mi]);
} }
break;
}
case MachineJumpTableInfo::EK_GPRel32BlockAddress:
case MachineJumpTableInfo::EK_LabelDifference32: {
assert(MJTI->getEntrySize(*TheJIT->getTargetData()) == 4&&"Cross JIT'ing?");
// For each jump table, place the offset from the beginning of the table
// to the target address.
int *SlotPtr = (int*)JumpTableBase;
for (unsigned i = 0, e = JT.size(); i != e; ++i) {
const std::vector<MachineBasicBlock*> &MBBs = JT[i].MBBs;
// Store the offset of the basic block for this jump table slot in the
// memory we allocated for the jump table in 'initJumpTableInfo'
uintptr_t Base = (uintptr_t)SlotPtr;
for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi) {
uintptr_t MBBAddr = getMachineBasicBlockAddress(MBBs[mi]);
/// FIXME: USe EntryKind instead of magic "getPICJumpTableEntry" hook.
*SlotPtr++ = TheJIT->getJITInfo().getPICJumpTableEntry(MBBAddr, Base);
}
}
break;
}
} }
} }