summaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineRelocation.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-05-03 20:30:20 +0000
committerChris Lattner <sabre@nondot.org>2006-05-03 20:30:20 +0000
commit5a032de387831b9de3a707292eade95934938da9 (patch)
treef5ec4fba3a29470e1903e446970170690f26d5af /include/llvm/CodeGen/MachineRelocation.h
parentd2d5c76753b132c34c71248db2f136b38531bc6d (diff)
downloadllvm-5a032de387831b9de3a707292eade95934938da9.tar.gz
llvm-5a032de387831b9de3a707292eade95934938da9.tar.bz2
llvm-5a032de387831b9de3a707292eade95934938da9.tar.xz
Change from using MachineRelocation ctors to using static methods
in MachineRelocation to create Relocations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineRelocation.h')
-rw-r--r--include/llvm/CodeGen/MachineRelocation.h73
1 files changed, 50 insertions, 23 deletions
diff --git a/include/llvm/CodeGen/MachineRelocation.h b/include/llvm/CodeGen/MachineRelocation.h
index c43fcb64e0..c23b999e2e 100644
--- a/include/llvm/CodeGen/MachineRelocation.h
+++ b/include/llvm/CodeGen/MachineRelocation.h
@@ -45,7 +45,7 @@ class MachineRelocation {
/// Offset - This is the offset from the start of the code buffer of the
/// relocation to perform.
- unsigned Offset;
+ intptr_t Offset;
/// ConstantVal - A field that may be used by the target relocation type.
intptr_t ConstantVal;
@@ -64,35 +64,62 @@ class MachineRelocation {
bool GOTRelative : 1; // Should this relocation be relative to the GOT?
public:
- MachineRelocation(unsigned offset, unsigned RelocationType, GlobalValue *GV,
- intptr_t cst = 0, bool DoesntNeedFunctionStub = 0,
- bool GOTrelative = 0)
- : Offset(offset), ConstantVal(cst), TargetReloType(RelocationType),
- AddrType(isGV), DoesntNeedFnStub(DoesntNeedFunctionStub),
- GOTRelative(GOTrelative){
+ /// MachineRelocation::getGV - Return a relocation entry for a GlobalValue.
+ ///
+ static MachineRelocation getGV(intptr_t offset, unsigned RelocationType,
+ GlobalValue *GV, intptr_t cst = 0,
+ bool DoesntNeedFunctionStub = 0,
+ bool GOTrelative = 0) {
assert((RelocationType & ~63) == 0 && "Relocation type too large!");
- Target.GV = GV;
- }
-
- MachineRelocation(unsigned offset, unsigned RelocationType, const char *ES,
- intptr_t cst = 0, bool GOTrelative = 0)
- : Offset(offset), ConstantVal(cst), TargetReloType(RelocationType),
- AddrType(isExtSym), DoesntNeedFnStub(false), GOTRelative(GOTrelative) {
+ MachineRelocation Result;
+ Result.Offset = offset;
+ Result.ConstantVal = cst;
+ Result.TargetReloType = RelocationType;
+ Result.AddrType = isGV;
+ Result.DoesntNeedFnStub = DoesntNeedFunctionStub;
+ Result.GOTRelative = GOTrelative;
+ Result.Target.GV = GV;
+ return Result;
+ }
+
+ /// MachineRelocation::getExtSym - Return a relocation entry for an external
+ /// symbol, like "free".
+ ///
+ static MachineRelocation getExtSym(intptr_t offset, unsigned RelocationType,
+ const char *ES, intptr_t cst = 0,
+ bool GOTrelative = 0) {
assert((RelocationType & ~63) == 0 && "Relocation type too large!");
- Target.ExtSym = ES;
- }
-
- MachineRelocation(unsigned offset, unsigned RelocationType, unsigned CPI,
- intptr_t cst = 0)
- : Offset(offset), ConstantVal(cst), TargetReloType(RelocationType),
- AddrType(isConstPool), DoesntNeedFnStub(false), GOTRelative(0) {
+ MachineRelocation Result;
+ Result.Offset = offset;
+ Result.ConstantVal = cst;
+ Result.TargetReloType = RelocationType;
+ Result.AddrType = isExtSym;
+ Result.DoesntNeedFnStub = false;
+ Result.GOTRelative = GOTrelative;
+ Result.Target.ExtSym = ES;
+ return Result;
+ }
+
+ /// MachineRelocation::getConstPool - Return a relocation entry for a constant
+ /// pool entry.
+ ///
+ static MachineRelocation getConstPool(intptr_t offset,unsigned RelocationType,
+ unsigned CPI, intptr_t cst = 0) {
assert((RelocationType & ~63) == 0 && "Relocation type too large!");
- Target.ConstPool = CPI;
+ MachineRelocation Result;
+ Result.Offset = offset;
+ Result.ConstantVal = cst;
+ Result.TargetReloType = RelocationType;
+ Result.AddrType = isConstPool;
+ Result.DoesntNeedFnStub = false;
+ Result.GOTRelative = false;
+ Result.Target.ConstPool = CPI;
+ return Result;
}
/// getMachineCodeOffset - Return the offset into the code buffer that the
/// relocation should be performed.
- unsigned getMachineCodeOffset() const {
+ intptr_t getMachineCodeOffset() const {
return Offset;
}