Move the definition of a native float from qfloat16.h to qtypes.h
... and put it into QtPrivate namespace as NativeFloat16Type. Keep the qfloat16::NativeFloat definition for SC. This is in preparation of Qt::compareThreeWay() for NativeFloat16Type (where available and mis-classified as non-is_floating_point). Amends 99c7f0419e66692260be56c0385badeacb3f6760. Pick-to: 6.5 Task-number: QTBUG-104113 Change-Id: Ie12c42c86f8dc9e233fe39776b0f0e28088de9e2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 43d3d037605bac4e13a1282c4eb363cdee98eb74) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4f979ec945
commit
9eb1eb10c1
@ -9,15 +9,11 @@
|
|||||||
#include <QtCore/qhashfunctions.h>
|
#include <QtCore/qhashfunctions.h>
|
||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
#include <QtCore/qnamespace.h>
|
#include <QtCore/qnamespace.h>
|
||||||
|
#include <QtCore/qtypes.h>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(__STDCPP_FLOAT16_T__) && __has_include(<stdfloat>)
|
|
||||||
// P1467 implementation - https://wg21.link/p1467
|
|
||||||
# include <stdfloat>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__AVX2__) && !defined(__F16C__)
|
#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__AVX2__) && !defined(__F16C__)
|
||||||
// All processors that support AVX2 do support F16C too, so we could enable the
|
// All processors that support AVX2 do support F16C too, so we could enable the
|
||||||
// feature unconditionally if __AVX2__ is defined. However, all currently
|
// feature unconditionally if __AVX2__ is defined. However, all currently
|
||||||
@ -55,24 +51,8 @@ class qfloat16
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if defined(__STDCPP_FLOAT16_T__)
|
using NativeType = QtPrivate::NativeFloat16Type;
|
||||||
# define QFLOAT16_IS_NATIVE 1
|
|
||||||
using NativeType = std::float16_t;
|
|
||||||
#elif defined(Q_CC_CLANG) && defined(__FLT16_MAX__) && 0
|
|
||||||
// disabled due to https://github.com/llvm/llvm-project/issues/56963
|
|
||||||
# define QFLOAT16_IS_NATIVE 1
|
|
||||||
using NativeType = decltype(__FLT16_MAX__);
|
|
||||||
#elif defined(Q_CC_GNU_ONLY) && defined(__FLT16_MAX__)
|
|
||||||
# define QFLOAT16_IS_NATIVE 1
|
|
||||||
# ifdef __ARM_FP16_FORMAT_IEEE
|
|
||||||
using NativeType = __fp16;
|
|
||||||
# else
|
|
||||||
using NativeType = _Float16;
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define QFLOAT16_IS_NATIVE 0
|
|
||||||
using NativeType = void;
|
|
||||||
#endif
|
|
||||||
static constexpr bool IsNative = QFLOAT16_IS_NATIVE;
|
static constexpr bool IsNative = QFLOAT16_IS_NATIVE;
|
||||||
using NearestFloat = std::conditional_t<IsNative, NativeType, float>;
|
using NearestFloat = std::conditional_t<IsNative, NativeType, float>;
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# include <cstddef>
|
# include <cstddef>
|
||||||
# include <cstdint>
|
# include <cstdint>
|
||||||
|
# if defined(__STDCPP_FLOAT16_T__) && __has_include(<stdfloat>)
|
||||||
|
// P1467 implementation - https://wg21.link/p1467
|
||||||
|
# include <stdfloat>
|
||||||
|
# endif // defined(__STDCPP_FLOAT16_T__) && __has_include(<stdfloat>)
|
||||||
#else
|
#else
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
@ -250,6 +254,28 @@ using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
|
|||||||
#error Unsupported platform (unknown value for SIZE_MAX)
|
#error Unsupported platform (unknown value for SIZE_MAX)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Define a native float16 type
|
||||||
|
namespace QtPrivate {
|
||||||
|
#if defined(__STDCPP_FLOAT16_T__)
|
||||||
|
# define QFLOAT16_IS_NATIVE 1
|
||||||
|
using NativeFloat16Type = std::float16_t;
|
||||||
|
#elif defined(Q_CC_CLANG) && defined(__FLT16_MAX__) && 0
|
||||||
|
// disabled due to https://github.com/llvm/llvm-project/issues/56963
|
||||||
|
# define QFLOAT16_IS_NATIVE 1
|
||||||
|
using NativeFloat16Type = decltype(__FLT16_MAX__);
|
||||||
|
#elif defined(Q_CC_GNU_ONLY) && defined(__FLT16_MAX__)
|
||||||
|
# define QFLOAT16_IS_NATIVE 1
|
||||||
|
# ifdef __ARM_FP16_FORMAT_IEEE
|
||||||
|
using NativeFloat16Type = __fp16;
|
||||||
|
# else
|
||||||
|
using NativeFloat16Type = _Float16;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define QFLOAT16_IS_NATIVE 0
|
||||||
|
using NativeFloat16Type = void;
|
||||||
|
#endif
|
||||||
|
} // QtPrivate
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user