diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-11-07 09:06:08 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-11-07 09:06:08 +0000 |
commit | 4df60f5491ff35c8a48c2cf14e18a33c9793b3bb (patch) | |
tree | 97057d1e9ba1b772dde79b066801707d949da016 /lib/Target/ARM/ARMJITInfo.cpp | |
parent | 47c01a0099c10c031f8c544baf44b1c3a1de3fad (diff) |
Jump table JIT support. Work in progress.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58836 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMJITInfo.cpp')
-rw-r--r-- | lib/Target/ARM/ARMJITInfo.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/Target/ARM/ARMJITInfo.cpp b/lib/Target/ARM/ARMJITInfo.cpp index c57477baf4..96918fd325 100644 --- a/lib/Target/ARM/ARMJITInfo.cpp +++ b/lib/Target/ARM/ARMJITInfo.cpp @@ -168,9 +168,11 @@ void *ARMJITInfo::emitFunctionStub(const Function* F, void *Fn, return MCE.finishFunctionStub(F); } -intptr_t ARMJITInfo::resolveRelocationAddr(MachineRelocation *MR) const { +intptr_t ARMJITInfo::resolveRelocDestAddr(MachineRelocation *MR) const { ARM::RelocationType RT = (ARM::RelocationType)MR->getRelocationType(); - if (RT == ARM::reloc_arm_cp_entry) + if (RT == ARM::reloc_arm_jt_base) + return getJumpTableBaseAddr(MR->getJumpTableIndex()); + else if (RT == ARM::reloc_arm_cp_entry) return getConstantPoolEntryAddr(MR->getConstantPoolIndex()); else if (RT == ARM::reloc_arm_machine_cp_entry) { const MachineConstantPoolEntry &MCPE = (*MCPEs)[MR->getConstantVal()]; @@ -196,7 +198,7 @@ void ARMJITInfo::relocate(void *Function, MachineRelocation *MR, void *RelocPos = (char*)Function + MR->getMachineCodeOffset(); // If this is a constpool relocation, get the address of the // constpool_entry instruction. - intptr_t ResultPtr = resolveRelocationAddr(MR); + intptr_t ResultPtr = resolveRelocDestAddr(MR); switch ((ARM::RelocationType)MR->getRelocationType()) { case ARM::reloc_arm_cp_entry: case ARM::reloc_arm_relative: { @@ -221,7 +223,7 @@ void ARMJITInfo::relocate(void *Function, MachineRelocation *MR, case ARM::reloc_arm_machine_cp_entry: case ARM::reloc_arm_absolute: { // These addresses have already been resolved. - *((unsigned*)RelocPos) += (unsigned)ResultPtr; + *((unsigned*)RelocPos) |= (unsigned)ResultPtr; break; } case ARM::reloc_arm_branch: { @@ -230,12 +232,24 @@ void ARMJITInfo::relocate(void *Function, MachineRelocation *MR, // byte offset, which must be inside the range -33554432 and +33554428. // Then, we set the signed_immed_24 field of the instruction to bits // [25:2] of the byte offset. More details ARM-ARM p. A4-11. - ResultPtr = ResultPtr-(intptr_t)RelocPos-8; + ResultPtr = ResultPtr - (intptr_t)RelocPos - 8; ResultPtr = (ResultPtr & 0x03FFFFFC) >> 2; assert(ResultPtr >= -33554432 && ResultPtr <= 33554428); *((unsigned*)RelocPos) |= ResultPtr; break; } + case ARM::reloc_arm_jt_base: { + // JT base - (instruction addr + 8) + ResultPtr = ResultPtr - (intptr_t)RelocPos - 8; + *((unsigned*)RelocPos) |= ResultPtr; + break; + } + case ARM::reloc_arm_pic_jt: { + // PIC JT entry is destination - JT base. + ResultPtr = ResultPtr - (intptr_t)RelocPos; + *((unsigned*)RelocPos) |= ResultPtr; + break; + } } } } |