Vector Literals

Linux Mac OS X A vector literal is a constant expression for which the value is interpreted as a vector type. The data type of a vector literal is represented by a parenthesized vector type, and its value is represented by a parenthesized set of constant expressions that represent the vector elements. When all vector elements have the same value, the value of the literal can be represented by a single parenthesized constant expression. Vector literals allow the initialization of vector types.

A vector literal is of the following form:

                         .-,-----------------------.
                         V                         |
>>-(--vector_type--)--(------constant_expression---+--)--------><
 
 

where vector_type is a supported vector type.

The constant_expression or multiple constant expressions must be appropriate for the vector literal type. The type also determines how many comma-separated constant expressions must be present in the declaration.

 When multiple constant expressions are specified, the number of constant expressions must be exactly:  
  
4
For vector int, vector long, and vector float types.
8
For vector short and vector pixel types.
16
For vector char types.

A vector literal can be initialized through an initialization list. The syntax is:

>>---vector_type----identifier--=--{--+-initializer_list---+--}--;-><
                                      '-initializer_list ,-'
 
 

Vector Literal Cast

A vector literal can be cast to another vector type. A vector literal cast does not change the bit pattern of the operand: the 128 bits representing the value remains the same before and after the cast.

Related References

IBM Copyright 2003