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.

llvm-svn: 213104
This commit is contained in:
David Majnemer 2014-07-15 23:01:10 +00:00
parent a2f658d69d
commit 3821ff03cd
1 changed files with 3 additions and 9 deletions

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)
for (int I = VTy->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));
}
scalarConstantToHexString(C->getAggregateElement(I));
}
}
if (!COMDATSymName.empty()) {