diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-21 23:34:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-21 23:34:23 +0000 |
commit | 8f3f851edb0f3339c8913f666492d3be9843e854 (patch) | |
tree | 5bd26e1b7a48d8a44712c5982038743158ad0bf1 /lib/CodeGen/MachineFunction.cpp | |
parent | a80e2711403eec377906ba16b0e1591bb6834c94 (diff) | |
download | external_llvm-8f3f851edb0f3339c8913f666492d3be9843e854.tar.gz external_llvm-8f3f851edb0f3339c8913f666492d3be9843e854.tar.bz2 external_llvm-8f3f851edb0f3339c8913f666492d3be9843e854.zip |
add an API so target-independent codegen can determine if a constant
pool entry will require relocations against it. I implemented this
conservatively for ARM, someone who is knowledgable about it should
see if this can be improved.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | lib/CodeGen/MachineFunction.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 599efb8bd2..e6ae7dc224 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -539,10 +539,29 @@ void MachineJumpTableInfo::dump() const { print(*cerr.stream()); } const Type *MachineConstantPoolEntry::getType() const { if (isMachineConstantPoolEntry()) - return Val.MachineCPVal->getType(); + return Val.MachineCPVal->getType(); return Val.ConstVal->getType(); } + +unsigned MachineConstantPoolEntry::getRelocatationInfo() const { + if (isMachineConstantPoolEntry()) + return Val.MachineCPVal->getRelocatationInfo(); + + // FIXME: This API sucks. + + // If no relocations, return 0. + if (!Val.ConstVal->ContainsRelocations()) + return 0; + + // If it contains no global relocations, return 1. + if (!Val.ConstVal->ContainsRelocations(Reloc::Global)) + return 1; + + // Otherwise, it has general relocations. + return 2; +} + MachineConstantPool::~MachineConstantPool() { for (unsigned i = 0, e = Constants.size(); i != e; ++i) if (Constants[i].isMachineConstantPoolEntry()) |