Let target resolve some relocation results.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58407 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2008-10-29 23:54:46 +00:00
parent 4628186572
commit ef5784ef9b

View File

@ -876,30 +876,32 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
for (unsigned i = 0, e = Relocations.size(); i != e; ++i) { for (unsigned i = 0, e = Relocations.size(); i != e; ++i) {
MachineRelocation &MR = Relocations[i]; MachineRelocation &MR = Relocations[i];
void *ResultPtr; void *ResultPtr;
if (MR.isString()) { if (!MR.letTargetResolve()) {
ResultPtr = TheJIT->getPointerToNamedFunction(MR.getString()); if (MR.isString()) {
ResultPtr = TheJIT->getPointerToNamedFunction(MR.getString());
// If the target REALLY wants a stub for this function, emit it now. // If the target REALLY wants a stub for this function, emit it now.
if (!MR.doesntNeedStub()) if (!MR.doesntNeedStub())
ResultPtr = Resolver.getExternalFunctionStub(ResultPtr); ResultPtr = Resolver.getExternalFunctionStub(ResultPtr);
} else if (MR.isGlobalValue()) { } else if (MR.isGlobalValue()) {
ResultPtr = getPointerToGlobal(MR.getGlobalValue(), ResultPtr = getPointerToGlobal(MR.getGlobalValue(),
BufferBegin+MR.getMachineCodeOffset(), BufferBegin+MR.getMachineCodeOffset(),
MR.doesntNeedStub()); MR.doesntNeedStub());
} else if (MR.isGlobalValueLazyPtr()) { } else if (MR.isGlobalValueLazyPtr()) {
ResultPtr = getPointerToGVLazyPtr(MR.getGlobalValue(), ResultPtr = getPointerToGVLazyPtr(MR.getGlobalValue(),
BufferBegin+MR.getMachineCodeOffset(), BufferBegin+MR.getMachineCodeOffset(),
MR.doesntNeedStub()); MR.doesntNeedStub());
} else if (MR.isBasicBlock()) { } else if (MR.isBasicBlock()) {
ResultPtr = (void*)getMachineBasicBlockAddress(MR.getBasicBlock()); ResultPtr = (void*)getMachineBasicBlockAddress(MR.getBasicBlock());
} else if (MR.isConstantPoolIndex()) { } else if (MR.isConstantPoolIndex()) {
ResultPtr=(void*)getConstantPoolEntryAddress(MR.getConstantPoolIndex()); ResultPtr = (void*)getConstantPoolEntryAddress(MR.getConstantPoolIndex());
} else { } else {
assert(MR.isJumpTableIndex()); assert(MR.isJumpTableIndex());
ResultPtr=(void*)getJumpTableEntryAddress(MR.getJumpTableIndex()); ResultPtr=(void*)getJumpTableEntryAddress(MR.getJumpTableIndex());
} }
MR.setResultPointer(ResultPtr); MR.setResultPointer(ResultPtr);
}
// if we are managing the GOT and the relocation wants an index, // if we are managing the GOT and the relocation wants an index,
// give it one // give it one
@ -1011,11 +1013,6 @@ void* JITEmitter::allocateSpace(intptr_t Size, unsigned Alignment) {
} }
void JITEmitter::emitConstantPool(MachineConstantPool *MCP) { void JITEmitter::emitConstantPool(MachineConstantPool *MCP) {
if (TheJIT->getJITInfo().hasCustomConstantPool()) {
DOUT << "JIT: Target has custom constant pool handling. Omitting standard "
"constant pool\n";
return;
}
const std::vector<MachineConstantPoolEntry> &Constants = MCP->getConstants(); const std::vector<MachineConstantPoolEntry> &Constants = MCP->getConstants();
if (Constants.empty()) return; if (Constants.empty()) return;
@ -1129,10 +1126,6 @@ void *JITEmitter::finishFunctionStub(const GlobalValue* F) {
// method. // method.
// //
intptr_t JITEmitter::getConstantPoolEntryAddress(unsigned ConstantNum) const { intptr_t JITEmitter::getConstantPoolEntryAddress(unsigned ConstantNum) const {
if (TheJIT->getJITInfo().hasCustomConstantPool()) {
return TheJIT->getJITInfo().getCustomConstantPoolEntryAddress(ConstantNum);
}
assert(ConstantNum < ConstantPool->getConstants().size() && assert(ConstantNum < ConstantPool->getConstants().size() &&
"Invalid ConstantPoolIndex!"); "Invalid ConstantPoolIndex!");
return (intptr_t)ConstantPoolBase + return (intptr_t)ConstantPoolBase +