Skip to content

Commit 1ed6be6

Browse files
authored
[Headers][X86][F16C] All f16c methods are now constexpr (#160317)
Merge the function attributes as they are all constexpr - the CVTPS2PH will stay as macros wrapping the builtin functions as we need to enforce compile time rounding mode constraints.
1 parent 0ebcc9d commit 1ed6be6

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

clang/lib/Headers/f16cintrin.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@
1515
#define __F16CINTRIN_H
1616

1717
/* Define the default attributes for the functions in this file. */
18-
#define __DEFAULT_FN_ATTRS128 \
19-
__attribute__((__always_inline__, __nodebug__, __target__("f16c"), __min_vector_width__(128)))
20-
#define __DEFAULT_FN_ATTRS256 \
21-
__attribute__((__always_inline__, __nodebug__, __target__("f16c"), __min_vector_width__(256)))
22-
2318
#if defined(__cplusplus) && (__cplusplus >= 201103L)
24-
#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 constexpr
25-
#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256 constexpr
19+
#define __DEFAULT_FN_ATTRS128 \
20+
__attribute__((__always_inline__, __nodebug__, __target__("f16c"), \
21+
__min_vector_width__(128))) constexpr
22+
#define __DEFAULT_FN_ATTRS256 \
23+
__attribute__((__always_inline__, __nodebug__, __target__("f16c"), \
24+
__min_vector_width__(256))) constexpr
2625
#else
27-
#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128
28-
#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256
26+
#define __DEFAULT_FN_ATTRS128 \
27+
__attribute__((__always_inline__, __nodebug__, __target__("f16c"), \
28+
__min_vector_width__(128)))
29+
#define __DEFAULT_FN_ATTRS256 \
30+
__attribute__((__always_inline__, __nodebug__, __target__("f16c"), \
31+
__min_vector_width__(256)))
2932
#endif
3033

3134
/* NOTE: Intel documents the 128-bit versions of these as being in emmintrin.h,
@@ -43,7 +46,7 @@
4346
/// \param __a
4447
/// A 16-bit half-precision float value.
4548
/// \returns The converted 32-bit float value.
46-
static __inline float __DEFAULT_FN_ATTRS128_CONSTEXPR
49+
static __inline float __DEFAULT_FN_ATTRS128
4750
_cvtsh_ss(unsigned short __a)
4851
{
4952
return (float)__builtin_bit_cast(__fp16, __a);
@@ -112,7 +115,7 @@ _cvtsh_ss(unsigned short __a)
112115
/// A 128-bit vector containing 16-bit half-precision float values. The lower
113116
/// 64 bits are used in the conversion.
114117
/// \returns A 128-bit vector of [4 x float] containing converted float values.
115-
static __inline __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR
118+
static __inline __m128 __DEFAULT_FN_ATTRS128
116119
_mm_cvtph_ps(__m128i __a)
117120
{
118121
typedef __fp16 __v4fp16 __attribute__((__vector_size__(8)));
@@ -159,7 +162,7 @@ _mm_cvtph_ps(__m128i __a)
159162
/// converted to 32-bit single-precision float values.
160163
/// \returns A vector of [8 x float] containing the converted 32-bit
161164
/// single-precision float values.
162-
static __inline __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR
165+
static __inline __m256 __DEFAULT_FN_ATTRS256
163166
_mm256_cvtph_ps(__m128i __a)
164167
{
165168
typedef __fp16 __v8fp16 __attribute__((__vector_size__(16), __aligned__(16)));
@@ -169,7 +172,5 @@ _mm256_cvtph_ps(__m128i __a)
169172

170173
#undef __DEFAULT_FN_ATTRS128
171174
#undef __DEFAULT_FN_ATTRS256
172-
#undef __DEFAULT_FN_ATTRS128_CONSTEXPR
173-
#undef __DEFAULT_FN_ATTRS256_CONSTEXPR
174175

175176
#endif /* __F16CINTRIN_H */

0 commit comments

Comments
 (0)