[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:33:52 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 {
----------------
Sh0g0-1758 wrote:

Oh yeah sure. Its obviously better that way and I have actually been meaning to do it for some time now anyways. I decided to name it `complex_basic_ops.h` because its sounds cooler than `complex_utils.h` :)

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


More information about the libc-commits mailing list