CodeGen: Add a getSectionKind method to MachineConstantPoolEntry

This is just a helper routine, no functionality has changed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212993 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2014-07-14 22:06:29 +00:00
parent 26a4201636
commit a539d7b4df
3 changed files with 35 additions and 15 deletions

View File

@@ -836,6 +836,37 @@ unsigned MachineConstantPoolEntry::getRelocationInfo() const {
return Val.ConstVal->getRelocationInfo();
}
SectionKind
MachineConstantPoolEntry::getSectionKind(const DataLayout *DL) const {
SectionKind Kind;
switch (getRelocationInfo()) {
default:
llvm_unreachable("Unknown section kind");
case 2:
Kind = SectionKind::getReadOnlyWithRel();
break;
case 1:
Kind = SectionKind::getReadOnlyWithRelLocal();
break;
case 0:
switch (DL->getTypeAllocSize(getType())) {
case 4:
Kind = SectionKind::getMergeableConst4();
break;
case 8:
Kind = SectionKind::getMergeableConst8();
break;
case 16:
Kind = SectionKind::getMergeableConst16();
break;
default:
Kind = SectionKind::getMergeableConst();
break;
}
}
return Kind;
}
MachineConstantPool::~MachineConstantPool() {
for (unsigned i = 0, e = Constants.size(); i != e; ++i)
if (Constants[i].isMachineConstantPoolEntry())