Handle uniform short-vector types in ExprList::GetConstant()

This commit is contained in:
Matt Pharr
2012-02-14 13:48:43 -08:00
parent 8971baa42b
commit e3c0551129

View File

@@ -3508,11 +3508,24 @@ ExprList::GetConstant(const Type *type) const {
LLVM_TYPE_CONST llvm::Type *lt = type->LLVMType(g->ctx); LLVM_TYPE_CONST llvm::Type *lt = type->LLVMType(g->ctx);
LLVM_TYPE_CONST llvm::ArrayType *lat = LLVM_TYPE_CONST llvm::ArrayType *lat =
llvm::dyn_cast<LLVM_TYPE_CONST llvm::ArrayType>(lt); llvm::dyn_cast<LLVM_TYPE_CONST llvm::ArrayType>(lt);
// FIXME: should the assert below validly fail for uniform vectors if (lat != NULL)
// now? Need a test case to reproduce it and then to be sure we return llvm::ConstantArray::get(lat, cv);
// have the right fix; leave the assert until we can hit it... else {
Assert(lat != NULL); // uniform short vector type
return llvm::ConstantArray::get(lat, cv); Assert(type->IsUniformType() &&
dynamic_cast<const VectorType *>(type) != NULL);
LLVM_TYPE_CONST llvm::VectorType *lvt =
llvm::dyn_cast<LLVM_TYPE_CONST llvm::VectorType>(lt);
Assert(lvt != NULL);
// Uniform short vectors are stored as vectors of length
// rounded up to the native vector width. So we add additional
// undef values here until we get the right size.
while ((cv.size() % g->target.nativeVectorWidth) != 0)
cv.push_back(llvm::UndefValue::get(lvt->getElementType()));
return llvm::ConstantVector::get(cv);
}
} }
return NULL; return NULL;
} }