summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-21 23:34:23 +0000
committerChris Lattner <sabre@nondot.org>2009-07-21 23:34:23 +0000
commitcfb01e26bc5c5c485e7f1248ce336b0318983f49 (patch)
tree3cf3e0e681657eecd32b1e39bd283b99789201e6 /llvm/lib
parent8be513822cc382337c9bfc33d3c8b220628ab6bc (diff)
downloadbcm5719-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')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp21
-rw-r--r--llvm/lib/Target/ARM/ARMConstantPoolValue.h7
2 files changed, 27 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())
diff --git a/llvm/lib/Target/ARM/ARMConstantPoolValue.h b/llvm/lib/Target/ARM/ARMConstantPoolValue.h
index abf7339646b..a9308898c86 100644
--- a/llvm/lib/Target/ARM/ARMConstantPoolValue.h
+++ b/llvm/lib/Target/ARM/ARMConstantPoolValue.h
@@ -65,6 +65,13 @@ public:
bool isStub() const { return Kind == ARMCP::CPStub; }
unsigned char getPCAdjustment() const { return PCAdjust; }
+ virtual unsigned getRelocatationInfo() const {
+ // FIXME: This is conservatively claiming that these entries require a
+ // relocation, we may be able to do better than this.
+ return 2;
+ }
+
+
virtual int getExistingMachineCPValue(MachineConstantPool *CP,
unsigned Alignment);
OpenPOWER on IntegriCloud