From b00cfb54e8771d97be24af7d27ea5037cd4b4d50 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 18 Nov 2024 20:19:31 -0500 Subject: [PATCH] AK: Don't define IsFloatingPoint and the FloatingPoint concept in KERNEL We build KERNEL without floats, so that context switches don't have to save float registers. As a side effect of that, _Float16 results in a "_Float16 is not supported on this target" diagnostic. Having IsFloatingPoint<> be false for the upcoming f16 type but true for other floating point types seems strange, so just stop having these concepts in kernel code altogether. --- AK/Concepts.h | 4 ++++ AK/FixedPoint.h | 2 ++ AK/SIMD.h | 7 ++++++- AK/StdLibExtraDetails.h | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/AK/Concepts.h b/AK/Concepts.h index 51f1644f986..07288d0e274 100644 --- a/AK/Concepts.h +++ b/AK/Concepts.h @@ -15,8 +15,10 @@ namespace AK::Concepts { template concept Integral = IsIntegral; +#ifndef KERNEL template concept FloatingPoint = IsFloatingPoint; +#endif template concept Fundamental = IsFundamental; @@ -168,7 +170,9 @@ using AK::Concepts::ConvertibleTo; using AK::Concepts::DerivedFrom; using AK::Concepts::Enum; using AK::Concepts::FallibleFunction; +#ifndef KERNEL using AK::Concepts::FloatingPoint; +#endif using AK::Concepts::Fundamental; using AK::Concepts::Indexable; using AK::Concepts::Integral; diff --git a/AK/FixedPoint.h b/AK/FixedPoint.h index 708aefdabb7..d09b41ad827 100644 --- a/AK/FixedPoint.h +++ b/AK/FixedPoint.h @@ -403,6 +403,7 @@ public: return *this < other || *this == other; } +#ifndef KERNEL // Casting from a float should be faster than casting to a float template bool operator==(F other) const { return *this == (This)other; } @@ -416,6 +417,7 @@ public: bool operator<(F other) const { return *this < (This)other; } template bool operator<=(F other) const { return *this <= (This)other; } +#endif template operator FixedPoint() const diff --git a/AK/SIMD.h b/AK/SIMD.h index 49a8cbfb98c..28c901016f7 100644 --- a/AK/SIMD.h +++ b/AK/SIMD.h @@ -97,6 +97,7 @@ struct IndexVectorFor { using Type = T; }; +#ifndef KERNEL template requires(IsFloatingPoint>) struct IndexVectorFor { @@ -105,6 +106,7 @@ struct IndexVectorFor { u32 __attribute__((vector_size(sizeof(T)))), u64 __attribute__((vector_size(sizeof(T))))>; }; +#endif } @@ -114,10 +116,13 @@ using IndexVectorFor = typename Detail::IndexVectorFor::Type; static_assert(IsSame, i8x16>); static_assert(IsSame, u32x4>); static_assert(IsSame, u64x4>); -#if defined(AK_COMPILER_CLANG) + +#ifndef KERNEL +# if defined(AK_COMPILER_CLANG) // FIXME: GCC silently ignores the dependent vector_size attribute, this seems to be a bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703 static_assert(IsSame, u32x4>); static_assert(IsSame, u64x4>); +# endif #endif } diff --git a/AK/StdLibExtraDetails.h b/AK/StdLibExtraDetails.h index 922ba807302..c49c15206c2 100644 --- a/AK/StdLibExtraDetails.h +++ b/AK/StdLibExtraDetails.h @@ -342,6 +342,7 @@ inline constexpr bool __IsIntegral = true; template inline constexpr bool IsIntegral = __IsIntegral>>; +#ifndef KERNEL template inline constexpr bool __IsFloatingPoint = false; template<> @@ -353,6 +354,7 @@ inline constexpr bool __IsFloatingPoint = true; template inline constexpr bool IsFloatingPoint = __IsFloatingPoint>; +#endif template using CopyConst = Conditional, AddConst, RemoveConst>; @@ -369,8 +371,13 @@ inline constexpr bool IsSigned = IsSame>; template inline constexpr bool IsUnsigned = IsSame>; +#ifndef KERNEL template inline constexpr bool IsArithmetic = IsIntegral || IsFloatingPoint; +#else +template +inline constexpr bool IsArithmetic = IsIntegral; +#endif template inline constexpr bool IsFundamental = IsArithmetic || IsVoid || IsNullPointer; @@ -634,7 +641,9 @@ using AK::Detail::IsCopyAssignable; using AK::Detail::IsCopyConstructible; using AK::Detail::IsDestructible; using AK::Detail::IsEnum; +#ifndef KERNEL using AK::Detail::IsFloatingPoint; +#endif using AK::Detail::IsFunction; using AK::Detail::IsFundamental; using AK::Detail::IsHashCompatible;