[libc-commits] [libc] [libc][stdfix] Add integer square root with fixed point output functions. (PR #83959)
via libc-commits
libc-commits at lists.llvm.org
Tue Mar 5 12:01:58 PST 2024
================
@@ -0,0 +1,66 @@
+//===-- Utility class to test integer sqrt ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+#include "src/__support/CPP/bit.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/fixed_point/fx_rep.h"
+#include "src/__support/fixed_point/sqrt.h"
+
+template <typename T> class ISqrtTest : public LIBC_NAMESPACE::testing::Test {
+
+ using OutType =
+ typename LIBC_NAMESPACE::fixed_point::internal::SqrtConfig<T>::OutType;
+ using FXRep = LIBC_NAMESPACE::fixed_point::FXRep<OutType>;
+ static constexpr OutType zero = FXRep::ZERO();
+ static constexpr OutType one = static_cast<OutType>(1);
+ static constexpr OutType eps = FXRep::EPS();
+
+public:
+ typedef OutType (*SqrtFunc)(T);
----------------
lntue wrote:
Yes, the fast math implementations are explicitly added in `uhksqrtus_test.cpp` and `uksqrtui_test.cpp`.
https://github.com/llvm/llvm-project/pull/83959
More information about the libc-commits
mailing list