Home | History | Annotate | Line # | Download | only in rs6000
smmintrin.h revision 1.1
      1  1.1  mrg /* Copyright (C) 2018-2019 Free Software Foundation, Inc.
      2  1.1  mrg 
      3  1.1  mrg    This file is part of GCC.
      4  1.1  mrg 
      5  1.1  mrg    GCC is free software; you can redistribute it and/or modify
      6  1.1  mrg    it under the terms of the GNU General Public License as published by
      7  1.1  mrg    the Free Software Foundation; either version 3, or (at your option)
      8  1.1  mrg    any later version.
      9  1.1  mrg 
     10  1.1  mrg    GCC is distributed in the hope that it will be useful,
     11  1.1  mrg    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  1.1  mrg    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  1.1  mrg    GNU General Public License for more details.
     14  1.1  mrg 
     15  1.1  mrg    Under Section 7 of GPL version 3, you are granted additional
     16  1.1  mrg    permissions described in the GCC Runtime Library Exception, version
     17  1.1  mrg    3.1, as published by the Free Software Foundation.
     18  1.1  mrg 
     19  1.1  mrg    You should have received a copy of the GNU General Public License and
     20  1.1  mrg    a copy of the GCC Runtime Library Exception along with this program;
     21  1.1  mrg    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     22  1.1  mrg    <http://www.gnu.org/licenses/>.  */
     23  1.1  mrg 
     24  1.1  mrg /* Implemented from the specification included in the Intel C++ Compiler
     25  1.1  mrg    User Guide and Reference, version 9.0.
     26  1.1  mrg 
     27  1.1  mrg    NOTE: This is NOT a complete implementation of the SSE4 intrinsics!  */
     28  1.1  mrg 
     29  1.1  mrg #ifndef NO_WARN_X86_INTRINSICS
     30  1.1  mrg /* This header is distributed to simplify porting x86_64 code that
     31  1.1  mrg    makes explicit use of Intel intrinsics to powerpc64le.
     32  1.1  mrg    It is the user's responsibility to determine if the results are
     33  1.1  mrg    acceptable and make additional changes as necessary.
     34  1.1  mrg    Note that much code that uses Intel intrinsics can be rewritten in
     35  1.1  mrg    standard C or GNU C extensions, which are more portable and better
     36  1.1  mrg    optimized across multiple targets.  */
     37  1.1  mrg #endif
     38  1.1  mrg 
     39  1.1  mrg #ifndef SMMINTRIN_H_
     40  1.1  mrg #define SMMINTRIN_H_
     41  1.1  mrg 
     42  1.1  mrg #include <altivec.h>
     43  1.1  mrg #include <tmmintrin.h>
     44  1.1  mrg 
     45  1.1  mrg extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     46  1.1  mrg _mm_extract_epi8 (__m128i __X, const int __N)
     47  1.1  mrg {
     48  1.1  mrg   return (unsigned char) ((__v16qi)__X)[__N & 15];
     49  1.1  mrg }
     50  1.1  mrg 
     51  1.1  mrg extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     52  1.1  mrg _mm_extract_epi32 (__m128i __X, const int __N)
     53  1.1  mrg {
     54  1.1  mrg   return ((__v4si)__X)[__N & 3];
     55  1.1  mrg }
     56  1.1  mrg 
     57  1.1  mrg extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     58  1.1  mrg _mm_extract_epi64 (__m128i __X, const int __N)
     59  1.1  mrg {
     60  1.1  mrg   return ((__v2di)__X)[__N & 1];
     61  1.1  mrg }
     62  1.1  mrg 
     63  1.1  mrg extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     64  1.1  mrg _mm_extract_ps (__m128 __X, const int __N)
     65  1.1  mrg {
     66  1.1  mrg   return ((__v4si)__X)[__N & 3];
     67  1.1  mrg }
     68  1.1  mrg 
     69  1.1  mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     70  1.1  mrg _mm_blend_epi16 (__m128i __A, __m128i __B, const int __imm8)
     71  1.1  mrg {
     72  1.1  mrg   __v16qi __charmask = vec_splats ((signed char) __imm8);
     73  1.1  mrg   __charmask = vec_gb (__charmask);
     74  1.1  mrg   __v8hu __shortmask = (__v8hu) vec_unpackh (__charmask);
     75  1.1  mrg   #ifdef __BIG_ENDIAN__
     76  1.1  mrg   __shortmask = vec_reve (__shortmask);
     77  1.1  mrg   #endif
     78  1.1  mrg   return (__m128i) vec_sel ((__v8hu) __A, (__v8hu) __B, __shortmask);
     79  1.1  mrg }
     80  1.1  mrg 
     81  1.1  mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     82  1.1  mrg _mm_blendv_epi8 (__m128i __A, __m128i __B, __m128i __mask)
     83  1.1  mrg {
     84  1.1  mrg   const __v16qu __seven = vec_splats ((unsigned char) 0x07);
     85  1.1  mrg   __v16qu __lmask = vec_sra ((__v16qu) __mask, __seven);
     86  1.1  mrg   return (__m128i) vec_sel ((__v16qu) __A, (__v16qu) __B, __lmask);
     87  1.1  mrg }
     88  1.1  mrg 
     89  1.1  mrg #endif
     90