This commit is contained in:
Dmitry Babokin
2013-06-18 22:15:49 +04:00
parent 2fdaba53c1
commit 27daab2f1b

View File

@@ -6802,7 +6802,23 @@ TypeCastExpr::GetValue(FunctionEmitContext *ctx) const {
if (!conv)
return NULL;
llvm::Value *cast = ctx->BroadcastValue(conv, toType->LLVMType(g->ctx));
llvm::Value *cast = NULL;
llvm::Type* toTypeLLVM = toType->LLVMType(g->ctx);
if (llvm::isa<llvm::VectorType>(toTypeLLVM)) {
// Example uniform float => uniform float<3>
cast = ctx->BroadcastValue(conv, toTypeLLVM);
}
else if (llvm::isa<llvm::ArrayType>(toTypeLLVM)) {
// Example varying float => varying float<3>
cast = llvm::UndefValue::get(toType->LLVMType(g->ctx));
for (int i = 0; i < toVector->GetElementCount(); ++i) {
// Here's InsertInst produces InsertValueInst.
cast = ctx->InsertInst(cast, conv, i);
}
}
else {
FATAL("TypeCastExpr::GetValue: problem with cast");
}
return cast;
}