mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 10:55:58 +08:00
Refactor DenseElementsAttr to support auto-splatting the dense data on construction. This essentially means that we always auto-detect splat data and only store the minimum amount of data necessary. Support for parsing dense splats, and removing SplatElementsAttr(now that it is redundant) will come in followup cls
PiperOrigin-RevId: 252720561
This commit is contained in:
committed by
Mehdi Amini
parent
5da741f671
commit
d8cd96bc8b
@@ -97,6 +97,13 @@ llvm::Constant *ModuleTranslation::getLLVMConstant(llvm::Type *llvmType,
|
||||
}
|
||||
if (auto denseAttr = attr.dyn_cast<DenseElementsAttr>()) {
|
||||
auto *vectorType = cast<llvm::VectorType>(llvmType);
|
||||
if (denseAttr.isSplat()) {
|
||||
auto *child = getLLVMConstant(vectorType->getElementType(),
|
||||
denseAttr.getSplatValue(), loc);
|
||||
return llvm::ConstantVector::getSplat(vectorType->getNumElements(),
|
||||
child);
|
||||
}
|
||||
|
||||
SmallVector<llvm::Constant *, 8> constants;
|
||||
uint64_t numElements = vectorType->getNumElements();
|
||||
constants.reserve(numElements);
|
||||
|
||||
Reference in New Issue
Block a user