It is no longer legal to initialize arrays and structs with single
scalar values (that ispc used to smear across the array/struct
elements). Now, initializers in variable declarations must be
{ }-delimited lists, with one element per struct member or array
element, respectively.
There were a few problems with the previous implementation of the
functionality to initialize from scalars. First, the expression
would be evaluated once per value initialized, so if it had side-effects,
the wrong thing would happen. Next, for large multidimensional arrays,
the generated code would be a long series of move instructions, rather
than loops (and this in turn made LLVM take a long time.)
While both of these problems are fixable, it's a non-trivial
amount of re-plumbing for a questionable feature anyway.
Fixes issue #50.
This commit is contained in:
13
stmt.cpp
13
stmt.cpp
@@ -217,21 +217,10 @@ lInitSymbol(llvm::Value *lvalue, const char *symName, const Type *type,
|
||||
exprList->exprs[i], ctx, pos);
|
||||
}
|
||||
}
|
||||
else if (initExpr->GetType()->IsNumericType() ||
|
||||
initExpr->GetType()->IsBoolType()) {
|
||||
// Otherwise initialize all of the elements in turn with the
|
||||
// initExpr.
|
||||
for (int i = 0; i < collectionType->GetElementCount(); ++i) {
|
||||
llvm::Value *ep = ctx->GetElementPtrInst(lvalue, 0, i, "element");
|
||||
lInitSymbol(ep, symName, collectionType->GetElementType(i),
|
||||
initExpr, ctx, pos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
Error(initExpr->pos, "Can't assign type \"%s\" to \"%s\".",
|
||||
initExpr->GetType()->GetString().c_str(),
|
||||
collectionType->GetString().c_str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user