f16cintrin.h revision 249423
1243791Sdim/*===---- f16cintrin.h - F16C intrinsics ---------------------------------===
2243791Sdim *
3249423Sdim * Permission is hereby granted, free of charge, to any person obtaining __a copy
4243791Sdim * of this software and associated documentation files (the "Software"), to deal
5243791Sdim * in the Software without restriction, including without limitation the rights
6243791Sdim * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7243791Sdim * copies of the Software, and to permit persons to whom the Software is
8243791Sdim * furnished to do so, subject to the following conditions:
9243791Sdim *
10243791Sdim * The above copyright notice and this permission notice shall be included in
11243791Sdim * all copies or substantial portions of the Software.
12243791Sdim *
13243791Sdim * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14243791Sdim * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15243791Sdim * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16243791Sdim * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17243791Sdim * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18243791Sdim * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19243791Sdim * THE SOFTWARE.
20243791Sdim *
21243791Sdim *===-----------------------------------------------------------------------===
22243791Sdim */
23243791Sdim
24243791Sdim#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
25243791Sdim#error "Never use <f16cintrin.h> directly; include <x86intrin.h> instead."
26243791Sdim#endif
27243791Sdim
28243791Sdim#ifndef __F16C__
29243791Sdim# error "F16C instruction is not enabled"
30243791Sdim#endif /* __F16C__ */
31243791Sdim
32243791Sdim#ifndef __F16CINTRIN_H
33243791Sdim#define __F16CINTRIN_H
34243791Sdim
35243791Sdimtypedef float __v8sf __attribute__ ((__vector_size__ (32)));
36243791Sdimtypedef float __m256 __attribute__ ((__vector_size__ (32)));
37243791Sdim
38243791Sdim#define _mm_cvtps_ph(a, imm) __extension__ ({ \
39243791Sdim  __m128 __a = (a); \
40243791Sdim (__m128i)__builtin_ia32_vcvtps2ph((__v4sf)__a, (imm)); })
41243791Sdim
42243791Sdim#define _mm256_cvtps_ph(a, imm) __extension__ ({ \
43243791Sdim  __m256 __a = (a); \
44243791Sdim (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (imm)); })
45243791Sdim
46243791Sdimstatic __inline __m128 __attribute__((__always_inline__, __nodebug__))
47249423Sdim_mm_cvtph_ps(__m128i __a)
48243791Sdim{
49249423Sdim  return (__m128)__builtin_ia32_vcvtph2ps((__v8hi)__a);
50243791Sdim}
51243791Sdim
52243791Sdimstatic __inline __m256 __attribute__((__always_inline__, __nodebug__))
53249423Sdim_mm256_cvtph_ps(__m128i __a)
54243791Sdim{
55249423Sdim  return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
56243791Sdim}
57243791Sdim
58243791Sdim#endif /* __F16CINTRIN_H */
59