1146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren/*===---- f16cintrin.h - F16C intrinsics ---------------------------------=== 2146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * 34f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie * Permission is hereby granted, free of charge, to any person obtaining __a copy 4146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * of this software and associated documentation files (the "Software"), to deal 5146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * in the Software without restriction, including without limitation the rights 6146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * copies of the Software, and to permit persons to whom the Software is 8146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * furnished to do so, subject to the following conditions: 9146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * 10146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * The above copyright notice and this permission notice shall be included in 11146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * all copies or substantial portions of the Software. 12146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * 13146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * THE SOFTWARE. 20146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren * 21146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren *===-----------------------------------------------------------------------=== 22146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren */ 23146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren 24146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H 25146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#error "Never use <f16cintrin.h> directly; include <x86intrin.h> instead." 26146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#endif 27146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren 28146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#ifndef __F16C__ 29146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren# error "F16C instruction is not enabled" 30146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#endif /* __F16C__ */ 31146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren 32146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#ifndef __F16CINTRIN_H 33146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#define __F16CINTRIN_H 34146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren 35146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Rentypedef float __v8sf __attribute__ ((__vector_size__ (32))); 36146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Rentypedef float __m256 __attribute__ ((__vector_size__ (32))); 37146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren 38146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#define _mm_cvtps_ph(a, imm) __extension__ ({ \ 39146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren __m128 __a = (a); \ 40146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren (__m128i)__builtin_ia32_vcvtps2ph((__v4sf)__a, (imm)); }) 41146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren 42146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#define _mm256_cvtps_ph(a, imm) __extension__ ({ \ 43146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren __m256 __a = (a); \ 44146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (imm)); }) 45146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren 46146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Renstatic __inline __m128 __attribute__((__always_inline__, __nodebug__)) 474f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm_cvtph_ps(__m128i __a) 48146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren{ 494f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie return (__m128)__builtin_ia32_vcvtph2ps((__v8hi)__a); 50146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren} 51146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren 52146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Renstatic __inline __m256 __attribute__((__always_inline__, __nodebug__)) 534f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie_mm256_cvtph_ps(__m128i __a) 54146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren{ 554f918aed75d4927e88365541c7200f0b5fe5014bDavid Blaikie return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a); 56146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren} 57146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren 58146e5a4a787a2ebfe89a6b74e7c22d850bf1c858Manman Ren#endif /* __F16CINTRIN_H */ 59