[libc-commits] [libc] [libc][stdfix] Implement fxdivi functions (rdivi) (PR #154914)

Shreeyash Pandey via libc-commits libc-commits at lists.llvm.org
Tue Aug 26 05:52:15 PDT 2025


================
@@ -0,0 +1,49 @@
+//===-- Utility class to test fxdivi functions ------------------*- 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/Test.h"
+
+#include "src/__support/fixed_point/fx_rep.h"
+#include "src/__support/macros/sanitizer.h"
+
+#include "hdr/signal_macros.h"
+
+template <typename XType>
+class DivITest : public LIBC_NAMESPACE::testing::Test {
+  using FXRep = LIBC_NAMESPACE::fixed_point::FXRep<int>;
+
+public:
+  typedef XType (*DivIFunc)(int, int);
+
+  void testBasic(DivIFunc func) {
+    auto c1 = func(2, 3);
+    auto e1 = 0.666666;
+    EXPECT_EQ(static_cast<XType>(c1), static_cast<XType>(e1));
+
+    c1 = func(3, 4);
+    e1 = 0.75;
+    EXPECT_EQ(static_cast<XType>(c1), static_cast<XType>(e1));
+
+    c1 = func(1043, 2764);
+    e1 = 0.37735;
+    EXPECT_EQ(static_cast<XType>(c1), static_cast<XType>(e1));
+
+    c1 = func(60000, 720293);
+    e1 = 0.083299;
+    EXPECT_EQ(static_cast<XType>(c1), static_cast<XType>(e1));
+
+    c1 = func(7, 3);
+    e1 = 2.33333;
----------------
bojle wrote:

removed it

https://github.com/llvm/llvm-project/pull/154914


More information about the libc-commits mailing list