summaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen/MachineRelocation.h
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-06-23 01:02:37 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-06-23 01:02:37 +0000
commit52b510b4c4f36f58c4aa37a1f835eb95e89e0adb (patch)
tree849f77c8561690d908b0083dd43c49b9a3ec5b26 /include/llvm/CodeGen/MachineRelocation.h
parent74cb064a352b2ead0c8f5a40dbf1cd9a82d5354a (diff)
Added jump table address relocation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28908 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineRelocation.h')
-rw-r--r--include/llvm/CodeGen/MachineRelocation.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/include/llvm/CodeGen/MachineRelocation.h b/include/llvm/CodeGen/MachineRelocation.h
index c23b999e2ec9..58b4f87bc532 100644
--- a/include/llvm/CodeGen/MachineRelocation.h
+++ b/include/llvm/CodeGen/MachineRelocation.h
@@ -39,7 +39,8 @@ class MachineRelocation {
isResult, // Relocation has be transformed into its result pointer.
isGV, // The Target.GV 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.
};
@@ -54,7 +55,7 @@ class MachineRelocation {
void *Result; // If this has been resolved to a resolved pointer
GlobalValue *GV; // If this is a pointer to an LLVM global
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
} Target;
@@ -113,7 +114,24 @@ public:
Result.AddrType = isConstPool;
Result.DoesntNeedFnStub = 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;
}
@@ -154,6 +172,12 @@ public:
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
/// the symbol rather than the address of the symbol.
bool isGOTRelative() const {
@@ -187,7 +211,14 @@ public:
/// the index into the constant pool.
unsigned getConstantPoolIndex() const {
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