1/* 2 * Copyright (c) 2017 The WebM project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11#ifndef VPX_DSP_PPC_TYPES_VSX_H_ 12#define VPX_DSP_PPC_TYPES_VSX_H_ 13 14#include <altivec.h> 15 16typedef vector signed char int8x16_t; 17typedef vector unsigned char uint8x16_t; 18typedef vector signed short int16x8_t; 19typedef vector unsigned short uint16x8_t; 20typedef vector signed int int32x4_t; 21typedef vector unsigned int uint32x4_t; 22 23#ifdef __clang__ 24static const uint8x16_t xxpermdi0_perm = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 25 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 26 0x14, 0x15, 0x16, 0x17 }; 27static const uint8x16_t xxpermdi1_perm = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 28 0x06, 0x07, 0x18, 0x19, 0x1A, 0x1B, 29 0x1C, 0x1D, 0x1E, 0x1F }; 30static const uint8x16_t xxpermdi2_perm = { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 31 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 32 0x14, 0x15, 0x16, 0x17 }; 33static const uint8x16_t xxpermdi3_perm = { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 34 0x0E, 0x0F, 0x18, 0x19, 0x1A, 0x1B, 35 0x1C, 0x1D, 0x1E, 0x1F }; 36#define xxpermdi(a, b, c) vec_perm(a, b, xxpermdi##c##_perm) 37#elif defined(__GNUC__) && \ 38 (__GNUC__ > 6 || (__GNUC__ == 6 && __GNUC_MINOR__ >= 3)) 39#define xxpermdi(a, b, c) vec_xxpermdi(a, b, c) 40#endif 41 42#ifdef WORDS_BIGENDIAN 43#define unpack_to_u16_h(v) \ 44 (uint16x8_t) vec_mergeh(vec_splat_u8(0), (uint8x16_t)v) 45#define unpack_to_u16_l(v) \ 46 (uint16x8_t) vec_mergel(vec_splat_u8(0), (uint8x16_t)v) 47#define unpack_to_s16_h(v) \ 48 (int16x8_t) vec_mergeh(vec_splat_u8(0), (uint8x16_t)v) 49#define unpack_to_s16_l(v) \ 50 (int16x8_t) vec_mergel(vec_splat_u8(0), (uint8x16_t)v) 51#ifndef xxpermdi 52#define xxpermdi(a, b, c) vec_xxpermdi(a, b, c) 53#endif 54#else 55#define unpack_to_u16_h(v) \ 56 (uint16x8_t) vec_mergeh((uint8x16_t)v, vec_splat_u8(0)) 57#define unpack_to_u16_l(v) \ 58 (uint16x8_t) vec_mergel((uint8x16_t)v, vec_splat_u8(0)) 59#define unpack_to_s16_h(v) \ 60 (int16x8_t) vec_mergeh((uint8x16_t)v, vec_splat_u8(0)) 61#define unpack_to_s16_l(v) \ 62 (int16x8_t) vec_mergel((uint8x16_t)v, vec_splat_u8(0)) 63#ifndef xxpermdi 64#define xxpermdi(a, b, c) vec_xxpermdi(b, a, ((c >> 1) | (c & 1) << 1) ^ 3) 65#endif 66#endif 67 68#endif // VPX_DSP_PPC_TYPES_VSX_H_ 69