mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-13 09:33:50 +00:00
Added jump table address relocation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28908 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
74cb064a35
commit
52b510b4c4
@ -39,7 +39,8 @@ class MachineRelocation {
|
|||||||
isResult, // Relocation has be transformed into its result pointer.
|
isResult, // Relocation has be transformed into its result pointer.
|
||||||
isGV, // The Target.GV field is valid.
|
isGV, // The Target.GV field is valid.
|
||||||
isExtSym, // The Target.ExtSym field is valid.
|
isExtSym, // The Target.ExtSym field is valid.
|
||||||
isConstPool, // The Target.ConstPool field is valid.
|
isConstPool, // Relocation of constant pool address.
|
||||||
|
isJumpTable, // Relocation of jump table address.
|
||||||
isGOTIndex // The Target.GOTIndex field is valid.
|
isGOTIndex // The Target.GOTIndex field is valid.
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ class MachineRelocation {
|
|||||||
void *Result; // If this has been resolved to a resolved pointer
|
void *Result; // If this has been resolved to a resolved pointer
|
||||||
GlobalValue *GV; // If this is a pointer to an LLVM global
|
GlobalValue *GV; // If this is a pointer to an LLVM global
|
||||||
const char *ExtSym; // If this is a pointer to a named symbol
|
const char *ExtSym; // If this is a pointer to a named symbol
|
||||||
unsigned ConstPool; // In this is a pointer to a constant pool entry
|
unsigned Index; // Constant pool / jump table index
|
||||||
unsigned GOTIndex; // Index in the GOT of this symbol/global
|
unsigned GOTIndex; // Index in the GOT of this symbol/global
|
||||||
} Target;
|
} Target;
|
||||||
|
|
||||||
@ -113,7 +114,24 @@ public:
|
|||||||
Result.AddrType = isConstPool;
|
Result.AddrType = isConstPool;
|
||||||
Result.DoesntNeedFnStub = false;
|
Result.DoesntNeedFnStub = false;
|
||||||
Result.GOTRelative = false;
|
Result.GOTRelative = false;
|
||||||
Result.Target.ConstPool = CPI;
|
Result.Target.Index = CPI;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// MachineRelocation::getJumpTable - Return a relocation entry for a jump
|
||||||
|
/// table entry.
|
||||||
|
///
|
||||||
|
static MachineRelocation getJumpTable(intptr_t offset,unsigned RelocationType,
|
||||||
|
unsigned JTI, intptr_t cst = 0) {
|
||||||
|
assert((RelocationType & ~63) == 0 && "Relocation type too large!");
|
||||||
|
MachineRelocation Result;
|
||||||
|
Result.Offset = offset;
|
||||||
|
Result.ConstantVal = cst;
|
||||||
|
Result.TargetReloType = RelocationType;
|
||||||
|
Result.AddrType = isJumpTable;
|
||||||
|
Result.DoesntNeedFnStub = false;
|
||||||
|
Result.GOTRelative = false;
|
||||||
|
Result.Target.Index = JTI;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +172,12 @@ public:
|
|||||||
return AddrType == isConstPool;
|
return AddrType == isConstPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// isJumpTableIndex - Return true if this is a jump table reference.
|
||||||
|
///
|
||||||
|
bool isJumpTableIndex() const {
|
||||||
|
return AddrType == isJumpTable;
|
||||||
|
}
|
||||||
|
|
||||||
/// isGOTRelative - Return true the target wants the index into the GOT of
|
/// isGOTRelative - Return true the target wants the index into the GOT of
|
||||||
/// the symbol rather than the address of the symbol.
|
/// the symbol rather than the address of the symbol.
|
||||||
bool isGOTRelative() const {
|
bool isGOTRelative() const {
|
||||||
@ -187,7 +211,14 @@ public:
|
|||||||
/// the index into the constant pool.
|
/// the index into the constant pool.
|
||||||
unsigned getConstantPoolIndex() const {
|
unsigned getConstantPoolIndex() const {
|
||||||
assert(isConstantPoolIndex() && "This is not a constant pool reference!");
|
assert(isConstantPoolIndex() && "This is not a constant pool reference!");
|
||||||
return Target.ConstPool;
|
return Target.Index;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getJumpTableIndex - If this is a jump table reference, return
|
||||||
|
/// the index into the jump table.
|
||||||
|
unsigned getJumpTableIndex() const {
|
||||||
|
assert(isJumpTableIndex() && "This is not a jump table reference!");
|
||||||
|
return Target.Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getResultPointer - Once this has been resolved to point to an actual
|
/// getResultPointer - Once this has been resolved to point to an actual
|
||||||
|
@ -786,9 +786,13 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
|
|||||||
ResultPtr = getPointerToGlobal(MR.getGlobalValue(),
|
ResultPtr = getPointerToGlobal(MR.getGlobalValue(),
|
||||||
BufferBegin+MR.getMachineCodeOffset(),
|
BufferBegin+MR.getMachineCodeOffset(),
|
||||||
MR.doesntNeedFunctionStub());
|
MR.doesntNeedFunctionStub());
|
||||||
} else {
|
} else if (MR.isConstantPoolIndex()){
|
||||||
assert(MR.isConstantPoolIndex());
|
assert(MR.isConstantPoolIndex());
|
||||||
ResultPtr=(void*)getConstantPoolEntryAddress(MR.getConstantPoolIndex());
|
ResultPtr=(void*)getConstantPoolEntryAddress(MR.getConstantPoolIndex());
|
||||||
|
} else {
|
||||||
|
assert(MR.isJumpTableIndex());
|
||||||
|
ResultPtr=(void*)getJumpTableEntryAddress(MR.getJumpTableIndex());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MR.setResultPointer(ResultPtr);
|
MR.setResultPointer(ResultPtr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user