1 /* 2 (C) Copyright 2001,2006, 3 International Business Machines Corporation, 4 Sony Computer Entertainment, Incorporated, 5 Toshiba Corporation, 6 7 All rights reserved. 8 9 Redistribution and use in source and binary forms, with or without 10 modification, are permitted provided that the following conditions are met: 11 12 * Redistributions of source code must retain the above copyright notice, 13 this list of conditions and the following disclaimer. 14 * Redistributions in binary form must reproduce the above copyright 15 notice, this list of conditions and the following disclaimer in the 16 documentation and/or other materials provided with the distribution. 17 * Neither the names of the copyright holders nor the names of their 18 contributors may be used to endorse or promote products derived from this 19 software without specific prior written permission. 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #ifndef _VEC_LITERAL_H_ 35 #define _VEC_LITERAL_H_ 36 37 /* This header files provides an abstraction for the various implementations 38 * of vector literal construction. The two formats are: 39 * 40 * 1) Altivec styled using parenthesis 41 * 2) C grammer friendly styled using curly braces 42 * 43 * The macro, VEC_LITERAL has been developed to provide some portability 44 * in these two styles. To achieve true portability, user must specify all 45 * elements of the vector being initialized. A single element can be provided 46 * but only the first element guarenteed across both construction styles. 47 * 48 * The VEC_SPLAT_* macros have been provided for portability of vector literal 49 * construction when all the elements of the vector contain the same value. 50 */ 51 52 /* Use curly brace style. 53 */ 54 #define VEC_LITERAL(_type, ...) ((_type){__VA_ARGS__}) 55 56 #define VEC_SPLAT_U8(_val) ((__vector unsigned char){_val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val}) 57 #define VEC_SPLAT_S8(_val) ((__vector signed char){_val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val}) 58 59 #define VEC_SPLAT_U16(_val) ((__vector unsigned short){_val, _val, _val, _val, _val, _val, _val, _val}) 60 #define VEC_SPLAT_S16(_val) ((__vector signed short){_val, _val, _val, _val, _val, _val, _val, _val}) 61 62 #define VEC_SPLAT_U32(_val) ((__vector unsigned int){_val, _val, _val, _val}) 63 #define VEC_SPLAT_S32(_val) ((__vector signed int){_val, _val, _val, _val}) 64 #define VEC_SPLAT_F32(_val) ((__vector float){_val, _val, _val, _val}) 65 66 #define VEC_SPLAT_U64(_val) ((__vector unsigned long long){_val, _val}) 67 #define VEC_SPLAT_S64(_val) ((__vector signed long long){_val, _val}) 68 #define VEC_SPLAT_F64(_val) ((__vector double){_val, _val}) 69 70 #endif /* _VEC_LITERAL_H_ */ 71