[libc-commits] [libc] [libc][complex] Testing infra for MPC (PR #121261)
Shourya Goel via libc-commits
libc-commits at lists.llvm.org
Wed Jan 8 12:10:10 PST 2025
================
@@ -0,0 +1,385 @@
+//===-- Utils which wrap MPC ----------------------------------------------===//
+//
+// 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 "MPCUtils.h"
+
+#include "../MPFRWrapper/MPFRUtils.cpp"
+#include "src/__support/CPP/array.h"
+#include "src/__support/CPP/string.h"
+#include "src/__support/CPP/string_view.h"
+#include "src/__support/CPP/stringstream.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/fpbits_str.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+#include <stdint.h>
+
+#include "mpc.h"
+
+template <typename T> using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>;
+
+namespace LIBC_NAMESPACE_DECL {
+namespace testing {
+namespace mpc {
+
+static inline cpp::string str(RoundingMode mode) {
+ switch (mode) {
+ case RoundingMode::Upward:
+ return "MPFR_RNDU";
+ break;
+ case RoundingMode::Downward:
+ return "MPFR_RNDD";
+ break;
+ case RoundingMode::TowardZero:
+ return "MPFR_RNDZ";
+ break;
+ case RoundingMode::Nearest:
+ return "MPFR_RNDN";
+ break;
+ }
+ __builtin_unreachable();
+}
+
+template <typename T> struct MPCComplex {
+ T real;
+ T imag;
+};
+
+class MPCNumber {
+private:
+ unsigned int mpc_real_precision;
+ unsigned int mpc_imag_precision;
+ mpc_t value;
+ mpc_rnd_t mpc_rounding;
+
+public:
+ MPCNumber(unsigned int r_p, unsigned int i_p)
----------------
Sh0g0-1758 wrote:
Indeed. made the changes.
https://github.com/llvm/llvm-project/pull/121261
More information about the libc-commits
mailing list