[libc] [llvm] [libc][complex] Testing infra for MPC (PR #121261)
Nick Desaulniers via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 09:53:35 PST 2025
================
@@ -0,0 +1,356 @@
+//===-- 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 "src/__support/CPP/array.h"
+#include "src/__support/CPP/stringstream.h"
+#include "utils/MPFRWrapper/MPCommon.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";
+ case RoundingMode::Downward:
+ return "MPFR_RNDD";
+ case RoundingMode::TowardZero:
+ return "MPFR_RNDZ";
+ case RoundingMode::Nearest:
+ return "MPFR_RNDN";
+ }
+}
+
+class MPCNumber {
----------------
nickdesaulniers wrote:
Consider moving this to its own header, MPCNumber.h. A common pattern throughout LLVM is to have one header per class. Or a class defined in one header.
https://github.com/llvm/llvm-project/pull/121261
More information about the llvm-commits
mailing list