mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Change the PPC JIT to use a Static relocation model
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27937 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
99d3c276cc
commit
6fcbd6961d
@ -157,11 +157,6 @@ int PPCCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
|
|||||||
} else if (MO.isImmediate()) {
|
} else if (MO.isImmediate()) {
|
||||||
rv = MO.getImmedValue();
|
rv = MO.getImmedValue();
|
||||||
} else if (MO.isGlobalAddress() || MO.isExternalSymbol()) {
|
} else if (MO.isGlobalAddress() || MO.isExternalSymbol()) {
|
||||||
bool isExternal = MO.isExternalSymbol() ||
|
|
||||||
MO.getGlobal()->hasWeakLinkage() ||
|
|
||||||
MO.getGlobal()->hasLinkOnceLinkage() ||
|
|
||||||
(MO.getGlobal()->isExternal() &&
|
|
||||||
!MO.getGlobal()->hasNotBeenReadFromBytecode());
|
|
||||||
unsigned Reloc = 0;
|
unsigned Reloc = 0;
|
||||||
if (MI.getOpcode() == PPC::BL)
|
if (MI.getOpcode() == PPC::BL)
|
||||||
Reloc = PPC::reloc_pcrel_bx;
|
Reloc = PPC::reloc_pcrel_bx;
|
||||||
@ -169,15 +164,9 @@ int PPCCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
|
|||||||
switch (MI.getOpcode()) {
|
switch (MI.getOpcode()) {
|
||||||
default: MI.dump(); assert(0 && "Unknown instruction for relocation!");
|
default: MI.dump(); assert(0 && "Unknown instruction for relocation!");
|
||||||
case PPC::LIS:
|
case PPC::LIS:
|
||||||
if (isExternal)
|
Reloc = PPC::reloc_absolute_high; // Pointer to symbol
|
||||||
Reloc = PPC::reloc_absolute_ptr_high; // Pointer to stub
|
|
||||||
else
|
|
||||||
Reloc = PPC::reloc_absolute_high; // Pointer to symbol
|
|
||||||
break;
|
break;
|
||||||
case PPC::LA:
|
case PPC::LA:
|
||||||
assert(!isExternal && "Something in the ISEL changed\n");
|
|
||||||
Reloc = PPC::reloc_absolute_low;
|
|
||||||
break;
|
|
||||||
case PPC::LBZ:
|
case PPC::LBZ:
|
||||||
case PPC::LHA:
|
case PPC::LHA:
|
||||||
case PPC::LHZ:
|
case PPC::LHZ:
|
||||||
@ -189,10 +178,7 @@ int PPCCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
|
|||||||
case PPC::STW:
|
case PPC::STW:
|
||||||
case PPC::STFS:
|
case PPC::STFS:
|
||||||
case PPC::STFD:
|
case PPC::STFD:
|
||||||
if (isExternal)
|
Reloc = PPC::reloc_absolute_low;
|
||||||
Reloc = PPC::reloc_absolute_ptr_low;
|
|
||||||
else
|
|
||||||
Reloc = PPC::reloc_absolute_low;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,19 +201,8 @@ void PPCJITInfo::relocate(void *Function, MachineRelocation *MR,
|
|||||||
"Relocation out of range!");
|
"Relocation out of range!");
|
||||||
*RelocPos |= (ResultPtr & ((1 << 24)-1)) << 2;
|
*RelocPos |= (ResultPtr & ((1 << 24)-1)) << 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPC::reloc_absolute_ptr_high: // Pointer relocations.
|
case PPC::reloc_absolute_ptr_high: // Pointer relocations.
|
||||||
case PPC::reloc_absolute_ptr_low: {
|
case PPC::reloc_absolute_ptr_low:
|
||||||
// Pointer relocations are used for the PPC external stubs and lazy
|
|
||||||
// resolver pointers that the Darwin ABI likes to use. Basically, the
|
|
||||||
// address of the global is actually stored in memory, and the address of
|
|
||||||
// the pointer is relocated into instructions instead of the pointer
|
|
||||||
// itself. Because we have to keep the mapping anyway, we just return
|
|
||||||
// pointers to the values in the map as our new location.
|
|
||||||
static std::set<void*> Pointers;
|
|
||||||
ResultPtr = (intptr_t)&*Pointers.insert((void*)ResultPtr).first;
|
|
||||||
}
|
|
||||||
// FALL THROUGH
|
|
||||||
case PPC::reloc_absolute_high: // high bits of ref -> low 16 of instr
|
case PPC::reloc_absolute_high: // high bits of ref -> low 16 of instr
|
||||||
case PPC::reloc_absolute_low: // low bits of ref -> low 16 of instr
|
case PPC::reloc_absolute_low: // low bits of ref -> low 16 of instr
|
||||||
ResultPtr += MR->getConstantVal();
|
ResultPtr += MR->getConstantVal();
|
||||||
|
@ -130,7 +130,7 @@ bool PPCTargetMachine::addPassesToEmitFile(PassManager &PM,
|
|||||||
|
|
||||||
void PPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
|
void PPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
|
||||||
// The JIT should use dynamic-no-pic relocation model.
|
// The JIT should use dynamic-no-pic relocation model.
|
||||||
TM.setRelocationModel(Reloc::DynamicNoPIC);
|
TM.setRelocationModel(Reloc::Static);
|
||||||
|
|
||||||
// Run loop strength reduction before anything else.
|
// Run loop strength reduction before anything else.
|
||||||
PM.add(createLoopStrengthReducePass(TM.getTargetLowering()));
|
PM.add(createLoopStrengthReducePass(TM.getTargetLowering()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user