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:
Matt Pharr
2011-07-01 13:45:58 +01:00
parent a2940d63b4
commit d2d5858be1
40 changed files with 114 additions and 57 deletions

View File

@@ -1,4 +1,12 @@
=== v1.0.2 ===
=== v1.0.3 === (not yet released)
In initializer expressions with variable declarations, it is no longer
legal to initialize arrays and structs with single scalar values that then
initialize their members; they now must be initialized with initializer
lists in braces (or initialized after of the initializer with a loop over
array elements, etc.)
=== v1.0.2 === (1 July 2011)
Floating-point hexidecimal constants are now parsed correctly on Windows
(fixes issue #16).

View File

@@ -766,22 +766,18 @@ Variables can also be declared in ``for`` statement initializers:
for (int i = 0; ...)
Arrays can be initialized with either a scalar value or with individual
element values in braces:
Arrays can be initialized with individual element values in braces:
::
int foo[10] = x; // all ten elements take the value of x
int bar[2][4] = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } };
Structures can also be initialized both with scalar values or with element
values in braces:
Structures can also be initialized only with element values in braces:
::
struct Color { float r, g, b; };
....
Color c = 1; // all are one
Color d = { 0.5, .75, 1.0 }; // r = 0.5, ...