Home | History | Annotate | Line # | Download | only in i386
f16cintrin.h revision 1.1
      1  1.1  mrg /* Copyright (C) 2011-2013 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 #if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
     25  1.1  mrg # error "Never use <f16intrin.h> directly; include <x86intrin.h> or <immintrin.h> instead."
     26  1.1  mrg #endif
     27  1.1  mrg 
     28  1.1  mrg #ifndef __F16C__
     29  1.1  mrg # error "F16C instruction set not enabled"
     30  1.1  mrg #else
     31  1.1  mrg 
     32  1.1  mrg #ifndef _F16CINTRIN_H_INCLUDED
     33  1.1  mrg #define _F16CINTRIN_H_INCLUDED
     34  1.1  mrg 
     35  1.1  mrg extern __inline float __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     36  1.1  mrg _cvtsh_ss (unsigned short __S)
     37  1.1  mrg {
     38  1.1  mrg   __v8hi __H = __extension__ (__v8hi){ (short) __S, 0, 0, 0, 0, 0, 0, 0 };
     39  1.1  mrg   __v4sf __A = __builtin_ia32_vcvtph2ps (__H);
     40  1.1  mrg   return __builtin_ia32_vec_ext_v4sf (__A, 0);
     41  1.1  mrg }
     42  1.1  mrg 
     43  1.1  mrg extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     44  1.1  mrg _mm_cvtph_ps (__m128i __A)
     45  1.1  mrg {
     46  1.1  mrg   return (__m128) __builtin_ia32_vcvtph2ps ((__v8hi) __A);
     47  1.1  mrg }
     48  1.1  mrg 
     49  1.1  mrg extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     50  1.1  mrg _mm256_cvtph_ps (__m128i __A)
     51  1.1  mrg {
     52  1.1  mrg   return (__m256) __builtin_ia32_vcvtph2ps256 ((__v8hi) __A);
     53  1.1  mrg }
     54  1.1  mrg 
     55  1.1  mrg #ifdef __OPTIMIZE__
     56  1.1  mrg extern __inline unsigned short __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     57  1.1  mrg _cvtss_sh (float __F, const int __I)
     58  1.1  mrg {
     59  1.1  mrg   __v4sf __A =  __extension__ (__v4sf){ __F, 0, 0, 0 };
     60  1.1  mrg   __v8hi __H = __builtin_ia32_vcvtps2ph (__A, __I);
     61  1.1  mrg   return (unsigned short) __builtin_ia32_vec_ext_v8hi (__H, 0);
     62  1.1  mrg }
     63  1.1  mrg 
     64  1.1  mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     65  1.1  mrg _mm_cvtps_ph (__m128 __A, const int __I)
     66  1.1  mrg {
     67  1.1  mrg   return (__m128i) __builtin_ia32_vcvtps2ph ((__v4sf) __A, __I);
     68  1.1  mrg }
     69  1.1  mrg 
     70  1.1  mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
     71  1.1  mrg _mm256_cvtps_ph (__m256 __A, const int __I)
     72  1.1  mrg {
     73  1.1  mrg   return (__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf) __A, __I);
     74  1.1  mrg }
     75  1.1  mrg #else
     76  1.1  mrg #define _cvtss_sh(__F, __I)						\
     77  1.1  mrg   (__extension__ 							\
     78  1.1  mrg    ({									\
     79  1.1  mrg       __v4sf __A =  __extension__ (__v4sf){ __F, 0, 0, 0 };		\
     80  1.1  mrg       __v8hi __H = __builtin_ia32_vcvtps2ph (__A, __I);			\
     81  1.1  mrg       (unsigned short) __builtin_ia32_vec_ext_v8hi (__H, 0);		\
     82  1.1  mrg     }))
     83  1.1  mrg 
     84  1.1  mrg #define _mm_cvtps_ph(A, I) \
     85  1.1  mrg   ((__m128i) __builtin_ia32_vcvtps2ph ((__v4sf)(__m128) A, (int) (I)))
     86  1.1  mrg 
     87  1.1  mrg #define _mm256_cvtps_ph(A, I) \
     88  1.1  mrg   ((__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf)(__m256) A, (int) (I)))
     89  1.1  mrg #endif /* __OPTIMIZE */
     90  1.1  mrg 
     91  1.1  mrg #endif /* _F16CINTRIN_H_INCLUDED */
     92  1.1  mrg #endif /* __F16C__ */
     93