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 | cfb01e26bc5c5c485e7f1248ce336b0318983f49 (patch) | |
tree | 3cf3e0e681657eecd32b1e39bd283b99789201e6 /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | 8be513822cc382337c9bfc33d3c8b220628ab6bc (diff) | |
download | bcm5719-llvm-cfb01e26bc5c5c485e7f1248ce336b0318983f49.tar.gz bcm5719-llvm-cfb01e26bc5c5c485e7f1248ce336b0318983f49.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.
llvm-svn: 76678
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 599efb8bd27..e6ae7dc2245 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/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()) |