X86: Simplify X86WindowsTargetObjectFile::getSectionForConstant

There exists a helper function to abstract away the various differences
between ConstantVector, ConstantDataVector, ConstantAggregateZero, etc.

Use it to simplify X86WindowsTargetObjectFile::getSectionForConstant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213104 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2014-07-15 23:01:10 +00:00
parent f7e042324a
commit 6f7532bb97

View File

@ -151,15 +151,9 @@ X86WindowsTargetObjectFile::getSectionForConstant(SectionKind Kind,
uint64_t NumBits = VTy->getBitWidth();
if (NumBits == 128 || NumBits == 256) {
COMDATSymName = NumBits == 128 ? "__xmm@" : "__ymm@";
if (const auto *CDV = dyn_cast<ConstantDataVector>(C)) {
for (int I = CDV->getNumElements() - 1, E = -1; I != E; --I)
COMDATSymName +=
scalarConstantToHexString(CDV->getElementAsConstant(I));
} else {
const auto *CV = cast<ConstantVector>(C);
for (int I = CV->getNumOperands() - 1, E = -1; I != E; --I)
COMDATSymName += scalarConstantToHexString(CV->getOperand(I));
}
for (int I = VTy->getNumElements() - 1, E = -1; I != E; --I)
COMDATSymName +=
scalarConstantToHexString(C->getAggregateElement(I));
}
}
if (!COMDATSymName.empty()) {