aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2021-12-23 22:59:14 +0000
committerSiva Chandra Reddy <sivachandra@google.com>2021-12-23 23:19:42 +0000
commit60509623c46e8d8122dcc1ee62fecae0a6383139 (patch)
tree32f735a088f6d82ebe63487ed5171c7a16894329 /libc
parent[Hexagon] Revamp HVX flag verification in driver (diff)
downloadllvm-project-60509623c46e8d8122dcc1ee62fecae0a6383139.tar.gz
llvm-project-60509623c46e8d8122dcc1ee62fecae0a6383139.tar.bz2
llvm-project-60509623c46e8d8122dcc1ee62fecae0a6383139.zip
[libc][obvious] Fix style of MPFRWrapper.
Diffstat (limited to 'libc')
-rw-r--r--libc/test/src/math/RIntTest.h28
-rw-r--r--libc/test/src/math/RoundToIntegerTest.h18
-rw-r--r--libc/utils/MPFRWrapper/MPFRUtils.cpp392
-rw-r--r--libc/utils/MPFRWrapper/MPFRUtils.h149
4 files changed, 298 insertions, 289 deletions
diff --git a/libc/test/src/math/RIntTest.h b/libc/test/src/math/RIntTest.h
index 7dc677059f19..438a92338dfa 100644
--- a/libc/test/src/math/RIntTest.h
+++ b/libc/test/src/math/RIntTest.h
@@ -70,12 +70,12 @@ public:
for (int mode : ROUNDING_MODES) {
__llvm_libc::fputil::set_round(mode);
mpfr::RoundingMode mpfr_mode = to_mpfr_rounding_mode(mode);
- ASSERT_FP_EQ(func(T(1.0)), mpfr::Round(T(1.0), mpfr_mode));
- ASSERT_FP_EQ(func(T(-1.0)), mpfr::Round(T(-1.0), mpfr_mode));
- ASSERT_FP_EQ(func(T(10.0)), mpfr::Round(T(10.0), mpfr_mode));
- ASSERT_FP_EQ(func(T(-10.0)), mpfr::Round(T(-10.0), mpfr_mode));
- ASSERT_FP_EQ(func(T(1234.0)), mpfr::Round(T(1234.0), mpfr_mode));
- ASSERT_FP_EQ(func(T(-1234.0)), mpfr::Round(T(-1234.0), mpfr_mode));
+ ASSERT_FP_EQ(func(T(1.0)), mpfr::round(T(1.0), mpfr_mode));
+ ASSERT_FP_EQ(func(T(-1.0)), mpfr::round(T(-1.0), mpfr_mode));
+ ASSERT_FP_EQ(func(T(10.0)), mpfr::round(T(10.0), mpfr_mode));
+ ASSERT_FP_EQ(func(T(-10.0)), mpfr::round(T(-10.0), mpfr_mode));
+ ASSERT_FP_EQ(func(T(1234.0)), mpfr::round(T(1234.0), mpfr_mode));
+ ASSERT_FP_EQ(func(T(-1234.0)), mpfr::round(T(-1234.0), mpfr_mode));
}
}
@@ -83,12 +83,12 @@ public:
for (int mode : ROUNDING_MODES) {
__llvm_libc::fputil::set_round(mode);
mpfr::RoundingMode mpfr_mode = to_mpfr_rounding_mode(mode);
- ASSERT_FP_EQ(func(T(0.5)), mpfr::Round(T(0.5), mpfr_mode));
- ASSERT_FP_EQ(func(T(-0.5)), mpfr::Round(T(-0.5), mpfr_mode));
- ASSERT_FP_EQ(func(T(0.115)), mpfr::Round(T(0.115), mpfr_mode));
- ASSERT_FP_EQ(func(T(-0.115)), mpfr::Round(T(-0.115), mpfr_mode));
- ASSERT_FP_EQ(func(T(0.715)), mpfr::Round(T(0.715), mpfr_mode));
- ASSERT_FP_EQ(func(T(-0.715)), mpfr::Round(T(-0.715), mpfr_mode));
+ ASSERT_FP_EQ(func(T(0.5)), mpfr::round(T(0.5), mpfr_mode));
+ ASSERT_FP_EQ(func(T(-0.5)), mpfr::round(T(-0.5), mpfr_mode));
+ ASSERT_FP_EQ(func(T(0.115)), mpfr::round(T(0.115), mpfr_mode));
+ ASSERT_FP_EQ(func(T(-0.115)), mpfr::round(T(-0.115), mpfr_mode));
+ ASSERT_FP_EQ(func(T(0.715)), mpfr::round(T(0.715), mpfr_mode));
+ ASSERT_FP_EQ(func(T(-0.715)), mpfr::round(T(-0.715), mpfr_mode));
}
}
@@ -102,7 +102,7 @@ public:
for (int mode : ROUNDING_MODES) {
__llvm_libc::fputil::set_round(mode);
mpfr::RoundingMode mpfr_mode = to_mpfr_rounding_mode(mode);
- ASSERT_FP_EQ(func(x), mpfr::Round(x, mpfr_mode));
+ ASSERT_FP_EQ(func(x), mpfr::round(x, mpfr_mode));
}
}
}
@@ -121,7 +121,7 @@ public:
for (int mode : ROUNDING_MODES) {
__llvm_libc::fputil::set_round(mode);
mpfr::RoundingMode mpfr_mode = to_mpfr_rounding_mode(mode);
- ASSERT_FP_EQ(func(x), mpfr::Round(x, mpfr_mode));
+ ASSERT_FP_EQ(func(x), mpfr::round(x, mpfr_mode));
}
}
}
diff --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h
index e95f96e92ab0..60647eaadc6b 100644
--- a/libc/test/src/math/RoundToIntegerTest.h
+++ b/libc/test/src/math/RoundToIntegerTest.h
@@ -141,7 +141,7 @@ public:
F x = F(bits);
long mpfr_result;
- bool erangeflag = mpfr::RoundToLong(x, mpfr_result);
+ bool erangeflag = mpfr::round_to_long(x, mpfr_result);
ASSERT_FALSE(erangeflag);
test_one_input(func, x, mpfr_result, false);
}
@@ -163,10 +163,10 @@ public:
long mpfr_long_result;
bool erangeflag;
if (TestModes)
- erangeflag =
- mpfr::RoundToLong(x, to_mpfr_rounding_mode(mode), mpfr_long_result);
+ erangeflag = mpfr::round_to_long(x, to_mpfr_rounding_mode(mode),
+ mpfr_long_result);
else
- erangeflag = mpfr::RoundToLong(x, mpfr_long_result);
+ erangeflag = mpfr::round_to_long(x, mpfr_long_result);
ASSERT_FALSE(erangeflag);
I mpfr_result = mpfr_long_result;
test_one_input(func, x, mpfr_result, false);
@@ -210,13 +210,13 @@ public:
__llvm_libc::fputil::set_round(m);
long mpfr_long_result;
bool erangeflag =
- mpfr::RoundToLong(x, to_mpfr_rounding_mode(m), mpfr_long_result);
+ mpfr::round_to_long(x, to_mpfr_rounding_mode(m), mpfr_long_result);
ASSERT_TRUE(erangeflag);
test_one_input(func, x, INTEGER_MIN, true);
}
} else {
long mpfr_long_result;
- bool erangeflag = mpfr::RoundToLong(x, mpfr_long_result);
+ bool erangeflag = mpfr::round_to_long(x, mpfr_long_result);
ASSERT_TRUE(erangeflag);
test_one_input(func, x, INTEGER_MIN, true);
}
@@ -280,8 +280,8 @@ public:
if (TestModes) {
for (int m : ROUNDING_MODES) {
long mpfr_long_result;
- bool erangeflag =
- mpfr::RoundToLong(x, to_mpfr_rounding_mode(m), mpfr_long_result);
+ bool erangeflag = mpfr::round_to_long(x, to_mpfr_rounding_mode(m),
+ mpfr_long_result);
I mpfr_result = mpfr_long_result;
__llvm_libc::fputil::set_round(m);
if (erangeflag)
@@ -291,7 +291,7 @@ public:
}
} else {
long mpfr_long_result;
- bool erangeflag = mpfr::RoundToLong(x, mpfr_long_result);
+ bool erangeflag = mpfr::round_to_long(x, mpfr_long_result);
I mpfr_result = mpfr_long_result;
if (erangeflag)
test_one_input(func, x, x > 0 ? INTEGER_MAX : INTEGER_MIN, true);
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 7c4f061b47b5..4e25c874d122 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -38,73 +38,77 @@ namespace mpfr {
template <typename T> struct Precision;
template <> struct Precision<float> {
- static constexpr unsigned int value = 24;
+ static constexpr unsigned int VALUE = 24;
};
template <> struct Precision<double> {
- static constexpr unsigned int value = 53;
+ static constexpr unsigned int VALUE = 53;
};
#if !(defined(LLVM_LIBC_ARCH_X86))
template <> struct Precision<long double> {
- static constexpr unsigned int value = 64;
+ static constexpr unsigned int VALUE = 64;
};
#else
template <> struct Precision<long double> {
- static constexpr unsigned int value = 113;
+ static constexpr unsigned int VALUE = 113;
};
#endif
class MPFRNumber {
// A precision value which allows sufficiently large additional
// precision even compared to quad-precision floating point values.
- unsigned int mpfrPrecision;
+ unsigned int mpfr_precision;
mpfr_t value;
public:
- MPFRNumber() : mpfrPrecision(256) { mpfr_init2(value, mpfrPrecision); }
+ MPFRNumber() : mpfr_precision(256) { mpfr_init2(value, mpfr_precision); }
// We use explicit EnableIf specializations to disallow implicit
// conversions. Implicit conversions can potentially lead to loss of
// precision.
template <typename XType,
cpp::EnableIfType<cpp::IsSame<float, XType>::Value, int> = 0>
- explicit MPFRNumber(XType x, int precision = 128) : mpfrPrecision(precision) {
- mpfr_init2(value, mpfrPrecision);
+ explicit MPFRNumber(XType x, int precision = 128)
+ : mpfr_precision(precision) {
+ mpfr_init2(value, mpfr_precision);
mpfr_set_flt(value, x, MPFR_RNDN);
}
template <typename XType,
cpp::EnableIfType<cpp::IsSame<double, XType>::Value, int> = 0>
- explicit MPFRNumber(XType x, int precision = 128) : mpfrPrecision(precision) {
- mpfr_init2(value, mpfrPrecision);
+ explicit MPFRNumber(XType x, int precision = 128)
+ : mpfr_precision(precision) {
+ mpfr_init2(value, mpfr_precision);
mpfr_set_d(value, x, MPFR_RNDN);
}
template <typename XType,
cpp::EnableIfType<cpp::IsSame<long double, XType>::Value, int> = 0>
- explicit MPFRNumber(XType x, int precision = 128) : mpfrPrecision(precision) {
- mpfr_init2(value, mpfrPrecision);
+ explicit MPFRNumber(XType x, int precision = 128)
+ : mpfr_precision(precision) {
+ mpfr_init2(value, mpfr_precision);
mpfr_set_ld(value, x, MPFR_RNDN);
}
template <typename XType,
cpp::EnableIfType<cpp::IsIntegral<XType>::Value, int> = 0>
- explicit MPFRNumber(XType x, int precision = 128) : mpfrPrecision(precision) {
- mpfr_init2(value, mpfrPrecision);
+ explicit MPFRNumber(XType x, int precision = 128)
+ : mpfr_precision(precision) {
+ mpfr_init2(value, mpfr_precision);
mpfr_set_sj(value, x, MPFR_RNDN);
}
- MPFRNumber(const MPFRNumber &other) : mpfrPrecision(other.mpfrPrecision) {
- mpfr_init2(value, mpfrPrecision);
+ MPFRNumber(const MPFRNumber &other) : mpfr_precision(other.mpfr_precision) {
+ mpfr_init2(value, mpfr_precision);
mpfr_set(value, other.value, MPFR_RNDN);
}
~MPFRNumber() { mpfr_clear(value); }
MPFRNumber &operator=(const MPFRNumber &rhs) {
- mpfrPrecision = rhs.mpfrPrecision;
+ mpfr_precision = rhs.mpfr_precision;
mpfr_set(value, rhs.value, MPFR_RNDN);
return *this;
}
@@ -185,7 +189,7 @@ public:
return result;
}
- bool roundToLong(long &result) const {
+ bool roung_to_long(long &result) const {
// We first calculate the rounded value. This way, when converting
// to long using mpfr_get_si, the rounding direction of MPFR_RNDN
// (or any other rounding mode), does not have an influence.
@@ -195,10 +199,10 @@ public:
return mpfr_erangeflag_p();
}
- bool roundToLong(mpfr_rnd_t rnd, long &result) const {
+ bool roung_to_long(mpfr_rnd_t rnd, long &result) const {
MPFRNumber rint_result;
mpfr_rint(rint_result.value, value, rnd);
- return rint_result.roundToLong(result);
+ return rint_result.roung_to_long(result);
}
MPFRNumber rint(mpfr_rnd_t rnd) const {
@@ -374,7 +378,7 @@ namespace internal {
template <typename InputType>
cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
-unaryOperation(Operation op, InputType input) {
+unary_operation(Operation op, InputType input) {
MPFRNumber mpfrInput(input);
switch (op) {
case Operation::Abs:
@@ -416,7 +420,7 @@ unaryOperation(Operation op, InputType input) {
template <typename InputType>
cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
-unaryOperationTwoOutputs(Operation op, InputType input, int &output) {
+unary_operation_two_outputs(Operation op, InputType input, int &output) {
MPFRNumber mpfrInput(input);
switch (op) {
case Operation::Frexp:
@@ -428,7 +432,7 @@ unaryOperationTwoOutputs(Operation op, InputType input, int &output) {
template <typename InputType>
cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
-binaryOperationOneOutput(Operation op, InputType x, InputType y) {
+binary_operation_one_output(Operation op, InputType x, InputType y) {
MPFRNumber inputX(x), inputY(y);
switch (op) {
case Operation::Hypot:
@@ -440,7 +444,8 @@ binaryOperationOneOutput(Operation op, InputType x, InputType y) {
template <typename InputType>
cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
-binaryOperationTwoOutputs(Operation op, InputType x, InputType y, int &output) {
+binary_operation_two_outputs(Operation op, InputType x, InputType y,
+ int &output) {
MPFRNumber inputX(x), inputY(y);
switch (op) {
case Operation::RemQuo:
@@ -452,11 +457,12 @@ binaryOperationTwoOutputs(Operation op, InputType x, InputType y, int &output) {
template <typename InputType>
cpp::EnableIfType<cpp::IsFloatingPointType<InputType>::Value, MPFRNumber>
-ternaryOperationOneOutput(Operation op, InputType x, InputType y, InputType z) {
+ternary_operation_one_output(Operation op, InputType x, InputType y,
+ InputType z) {
// For FMA function, we just need to compare with the mpfr_fma with the same
// precision as InputType. Using higher precision as the intermediate results
// to compare might incorrectly fail due to double-rounding errors.
- constexpr unsigned int prec = Precision<InputType>::value;
+ constexpr unsigned int prec = Precision<InputType>::VALUE;
MPFRNumber inputX(x, prec), inputY(y, prec), inputZ(z, prec);
switch (op) {
case Operation::Fma:
@@ -467,54 +473,55 @@ ternaryOperationOneOutput(Operation op, InputType x, InputType y, InputType z) {
}
template <typename T>
-void explainUnaryOperationSingleOutputError(Operation op, T input, T matchValue,
- testutils::StreamWrapper &OS) {
+void explain_unary_operation_single_output_error(Operation op, T input,
+ T matchValue,
+ testutils::StreamWrapper &OS) {
MPFRNumber mpfrInput(input);
- MPFRNumber mpfrResult = unaryOperation(op, input);
+ MPFRNumber mpfr_result = unary_operation(op, input);
MPFRNumber mpfrMatchValue(matchValue);
FPBits<T> inputBits(input);
FPBits<T> matchBits(matchValue);
- FPBits<T> mpfrResultBits(mpfrResult.as<T>());
+ FPBits<T> mpfr_resultBits(mpfr_result.as<T>());
OS << "Match value not within tolerance value of MPFR result:\n"
<< " Input decimal: " << mpfrInput.str() << '\n';
__llvm_libc::fputil::testing::describeValue(" Input bits: ", input, OS);
OS << '\n' << " Match decimal: " << mpfrMatchValue.str() << '\n';
__llvm_libc::fputil::testing::describeValue(" Match bits: ", matchValue,
OS);
- OS << '\n' << " MPFR result: " << mpfrResult.str() << '\n';
+ OS << '\n' << " MPFR result: " << mpfr_result.str() << '\n';
__llvm_libc::fputil::testing::describeValue(
- " MPFR rounded: ", mpfrResult.as<T>(), OS);
+ " MPFR rounded: ", mpfr_result.as<T>(), OS);
OS << '\n';
- OS << " ULP error: " << std::to_string(mpfrResult.ulp(matchValue))
+ OS << " ULP error: " << std::to_string(mpfr_result.ulp(matchValue))
<< '\n';
}
template void
-explainUnaryOperationSingleOutputError<float>(Operation op, float, float,
- testutils::StreamWrapper &);
-template void
-explainUnaryOperationSingleOutputError<double>(Operation op, double, double,
- testutils::StreamWrapper &);
-template void explainUnaryOperationSingleOutputError<long double>(
+explain_unary_operation_single_output_error<float>(Operation op, float, float,
+ testutils::StreamWrapper &);
+template void explain_unary_operation_single_output_error<double>(
+ Operation op, double, double, testutils::StreamWrapper &);
+template void explain_unary_operation_single_output_error<long double>(
Operation op, long double, long double, testutils::StreamWrapper &);
template <typename T>
-void explainUnaryOperationTwoOutputsError(Operation op, T input,
- const BinaryOutput<T> &libcResult,
- testutils::StreamWrapper &OS) {
+void explain_unary_operation_two_outputs_error(
+ Operation op, T input, const BinaryOutput<T> &libc_result,
+ testutils::StreamWrapper &OS) {
MPFRNumber mpfrInput(input);
FPBits<T> inputBits(input);
int mpfrIntResult;
- MPFRNumber mpfrResult = unaryOperationTwoOutputs(op, input, mpfrIntResult);
+ MPFRNumber mpfr_result =
+ unary_operation_two_outputs(op, input, mpfrIntResult);
- if (mpfrIntResult != libcResult.i) {
+ if (mpfrIntResult != libc_result.i) {
OS << "MPFR integral result: " << mpfrIntResult << '\n'
- << "Libc integral result: " << libcResult.i << '\n';
+ << "Libc integral result: " << libc_result.i << '\n';
} else {
OS << "Integral result from libc matches integral result from MPFR.\n";
}
- MPFRNumber mpfrMatchValue(libcResult.f);
+ MPFRNumber mpfrMatchValue(libc_result.f);
OS << "Libc floating point result is not within tolerance value of the MPFR "
<< "result.\n\n";
@@ -522,74 +529,73 @@ void explainUnaryOperationTwoOutputsError(Operation op, T input,
OS << "Libc floating point value: " << mpfrMatchValue.str() << '\n';
__llvm_libc::fputil::testing::describeValue(
- " Libc floating point bits: ", libcResult.f, OS);
+ " Libc floating point bits: ", libc_result.f, OS);
OS << "\n\n";
- OS << " MPFR result: " << mpfrResult.str() << '\n';
+ OS << " MPFR result: " << mpfr_result.str() << '\n';
__llvm_libc::fputil::testing::describeValue(
- " MPFR rounded: ", mpfrResult.as<T>(), OS);
+ " MPFR rounded: ", mpfr_result.as<T>(), OS);
OS << '\n'
<< " ULP error: "
- << std::to_string(mpfrResult.ulp(libcResult.f)) << '\n';
+ << std::to_string(mpfr_result.ulp(libc_result.f)) << '\n';
}
-template void explainUnaryOperationTwoOutputsError<float>(
+template void explain_unary_operation_two_outputs_error<float>(
Operation, float, const BinaryOutput<float> &, testutils::StreamWrapper &);
template void
-explainUnaryOperationTwoOutputsError<double>(Operation, double,
- const BinaryOutput<double> &,
- testutils::StreamWrapper &);
-template void explainUnaryOperationTwoOutputsError<long double>(
+explain_unary_operation_two_outputs_error<double>(Operation, double,
+ const BinaryOutput<double> &,
+ testutils::StreamWrapper &);
+template void explain_unary_operation_two_outputs_error<long double>(
Operation, long double, const BinaryOutput<long double> &,
testutils::StreamWrapper &);
template <typename T>
-void explainBinaryOperationTwoOutputsError(Operation op,
- const BinaryInput<T> &input,
- const BinaryOutput<T> &libcResult,
- testutils::StreamWrapper &OS) {
+void explain_binary_operation_two_outputs_error(
+ Operation op, const BinaryInput<T> &input,
+ const BinaryOutput<T> &libc_result, testutils::StreamWrapper &OS) {
MPFRNumber mpfrX(input.x);
MPFRNumber mpfrY(input.y);
FPBits<T> xbits(input.x);
FPBits<T> ybits(input.y);
int mpfrIntResult;
- MPFRNumber mpfrResult =
- binaryOperationTwoOutputs(op, input.x, input.y, mpfrIntResult);
- MPFRNumber mpfrMatchValue(libcResult.f);
+ MPFRNumber mpfr_result =
+ binary_operation_two_outputs(op, input.x, input.y, mpfrIntResult);
+ MPFRNumber mpfrMatchValue(libc_result.f);
OS << "Input decimal: x: " << mpfrX.str() << " y: " << mpfrY.str() << '\n'
<< "MPFR integral result: " << mpfrIntResult << '\n'
- << "Libc integral result: " << libcResult.i << '\n'
+ << "Libc integral result: " << libc_result.i << '\n'
<< "Libc floating point result: " << mpfrMatchValue.str() << '\n'
- << " MPFR result: " << mpfrResult.str() << '\n';
+ << " MPFR result: " << mpfr_result.str() << '\n';
__llvm_libc::fputil::testing::describeValue(
- "Libc floating point result bits: ", libcResult.f, OS);
+ "Libc floating point result bits: ", libc_result.f, OS);
__llvm_libc::fputil::testing::describeValue(
- " MPFR rounded bits: ", mpfrResult.as<T>(), OS);
- OS << "ULP error: " << std::to_string(mpfrResult.ulp(libcResult.f)) << '\n';
+ " MPFR rounded bits: ", mpfr_result.as<T>(), OS);
+ OS << "ULP error: " << std::to_string(mpfr_result.ulp(libc_result.f)) << '\n';
}
-template void explainBinaryOperationTwoOutputsError<float>(
+template void explain_binary_operation_two_outputs_error<float>(
Operation, const BinaryInput<float> &, const BinaryOutput<float> &,
testutils::StreamWrapper &);
-template void explainBinaryOperationTwoOutputsError<double>(
+template void explain_binary_operation_two_outputs_error<double>(
Operation, const BinaryInput<double> &, const BinaryOutput<double> &,
testutils::StreamWrapper &);
-template void explainBinaryOperationTwoOutputsError<long double>(
+template void explain_binary_operation_two_outputs_error<long double>(
Operation, const BinaryInput<long double> &,
const BinaryOutput<long double> &, testutils::StreamWrapper &);
template <typename T>
-void explainBinaryOperationOneOutputError(Operation op,
- const BinaryInput<T> &input,
- T libcResult,
- testutils::StreamWrapper &OS) {
+void explain_binary_operation_one_output_error(Operation op,
+ const BinaryInput<T> &input,
+ T libc_result,
+ testutils::StreamWrapper &OS) {
MPFRNumber mpfrX(input.x);
MPFRNumber mpfrY(input.y);
FPBits<T> xbits(input.x);
FPBits<T> ybits(input.y);
- MPFRNumber mpfrResult = binaryOperationOneOutput(op, input.x, input.y);
- MPFRNumber mpfrMatchValue(libcResult);
+ MPFRNumber mpfr_result = binary_operation_one_output(op, input.x, input.y);
+ MPFRNumber mpfrMatchValue(libc_result);
OS << "Input decimal: x: " << mpfrX.str() << " y: " << mpfrY.str() << '\n';
__llvm_libc::fputil::testing::describeValue("First input bits: ", input.x,
@@ -598,36 +604,36 @@ void explainBinaryOperationOneOutputError(Operation op,
OS);
OS << "Libc result: " << mpfrMatchValue.str() << '\n'
- << "MPFR result: " << mpfrResult.str() << '\n';
+ << "MPFR result: " << mpfr_result.str() << '\n';
__llvm_libc::fputil::testing::describeValue(
- "Libc floating point result bits: ", libcResult, OS);
+ "Libc floating point result bits: ", libc_result, OS);
__llvm_libc::fputil::testing::describeValue(
- " MPFR rounded bits: ", mpfrResult.as<T>(), OS);
- OS << "ULP error: " << std::to_string(mpfrResult.ulp(libcResult)) << '\n';
+ " MPFR rounded bits: ", mpfr_result.as<T>(), OS);
+ OS << "ULP error: " << std::to_string(mpfr_result.ulp(libc_result)) << '\n';
}
-template void explainBinaryOperationOneOutputError<float>(
+template void explain_binary_operation_one_output_error<float>(
Operation, const BinaryInput<float> &, float, testutils::StreamWrapper &);
-template void explainBinaryOperationOneOutputError<double>(
+template void explain_binary_operation_one_output_error<double>(
Operation, const BinaryInput<double> &, double, testutils::StreamWrapper &);
-template void explainBinaryOperationOneOutputError<long double>(
+template void explain_binary_operation_one_output_error<long double>(
Operation, const BinaryInput<long double> &, long double,
testutils::StreamWrapper &);
template <typename T>
-void explainTernaryOperationOneOutputError(Operation op,
- const TernaryInput<T> &input,
- T libcResult,
- testutils::StreamWrapper &OS) {
- MPFRNumber mpfrX(input.x, Precision<T>::value);
- MPFRNumber mpfrY(input.y, Precision<T>::value);
- MPFRNumber mpfrZ(input.z, Precision<T>::value);
+void explain_ternary_operation_one_output_error(Operation op,
+ const TernaryInput<T> &input,
+ T libc_result,
+ testutils::StreamWrapper &OS) {
+ MPFRNumber mpfrX(input.x, Precision<T>::VALUE);
+ MPFRNumber mpfrY(input.y, Precision<T>::VALUE);
+ MPFRNumber mpfrZ(input.z, Precision<T>::VALUE);
FPBits<T> xbits(input.x);
FPBits<T> ybits(input.y);
FPBits<T> zbits(input.z);
- MPFRNumber mpfrResult =
- ternaryOperationOneOutput(op, input.x, input.y, input.z);
- MPFRNumber mpfrMatchValue(libcResult);
+ MPFRNumber mpfr_result =
+ ternary_operation_one_output(op, input.x, input.y, input.z);
+ MPFRNumber mpfrMatchValue(libc_result);
OS << "Input decimal: x: " << mpfrX.str() << " y: " << mpfrY.str()
<< " z: " << mpfrZ.str() << '\n';
@@ -639,144 +645,142 @@ void explainTernaryOperationOneOutputError(Operation op,
OS);
OS << "Libc result: " << mpfrMatchValue.str() << '\n'
- << "MPFR result: " << mpfrResult.str() << '\n';
+ << "MPFR result: " << mpfr_result.str() << '\n';
__llvm_libc::fputil::testing::describeValue(
- "Libc floating point result bits: ", libcResult, OS);
+ "Libc floating point result bits: ", libc_result, OS);
__llvm_libc::fputil::testing::describeValue(
- " MPFR rounded bits: ", mpfrResult.as<T>(), OS);
- OS << "ULP error: " << std::to_string(mpfrResult.ulp(libcResult)) << '\n';
+ " MPFR rounded bits: ", mpfr_result.as<T>(), OS);
+ OS << "ULP error: " << std::to_string(mpfr_result.ulp(libc_result)) << '\n';
}
-template void explainTernaryOperationOneOutputError<float>(
+template void explain_ternary_operation_one_output_error<float>(
Operation, const TernaryInput<float> &, float, testutils::StreamWrapper &);
-template void explainTernaryOperationOneOutputError<double>(
+template void explain_ternary_operation_one_output_error<double>(
Operation, const TernaryInput<double> &, double,
testutils::StreamWrapper &);
-template void explainTernaryOperationOneOutputError<long double>(
+template void explain_ternary_operation_one_output_error<long double>(
Operation, const TernaryInput<long double> &, long double,
testutils::StreamWrapper &);
template <typename T>
-bool compareUnaryOperationSingleOutput(Operation op, T input, T libcResult,
- double ulpError) {
+bool compare_unary_operation_single_output(Operation op, T input, T libc_result,
+ double ulp_error) {
// If the ulp error is exactly 0.5 (i.e a tie), we would check that the result
// is rounded to the nearest even.
- MPFRNumber mpfrResult = unaryOperation(op, input);
- double ulp = mpfrResult.ulp(libcResult);
- bool bitsAreEven = ((FPBits<T>(libcResult).uintval() & 1) == 0);
- return (ulp < ulpError) ||
- ((ulp == ulpError) && ((ulp != 0.5) || bitsAreEven));
+ MPFRNumber mpfr_result = unary_operation(op, input);
+ double ulp = mpfr_result.ulp(libc_result);
+ bool bits_are_even = ((FPBits<T>(libc_result).uintval() & 1) == 0);
+ return (ulp < ulp_error) ||
+ ((ulp == ulp_error) && ((ulp != 0.5) || bits_are_even));
}
-template bool compareUnaryOperationSingleOutput<float>(Operation, float, float,
- double);
-template bool compareUnaryOperationSingleOutput<double>(Operation, double,
- double, double);
-template bool compareUnaryOperationSingleOutput<long double>(Operation,
- long double,
- long double,
- double);
+template bool compare_unary_operation_single_output<float>(Operation, float,
+ float, double);
+template bool compare_unary_operation_single_output<double>(Operation, double,
+ double, double);
+template bool compare_unary_operation_single_output<long double>(Operation,
+ long double,
+ long double,
+ double);
template <typename T>
-bool compareUnaryOperationTwoOutputs(Operation op, T input,
- const BinaryOutput<T> &libcResult,
- double ulpError) {
+bool compare_unary_operation_two_outputs(Operation op, T input,
+ const BinaryOutput<T> &libc_result,
+ double ulp_error) {
int mpfrIntResult;
- MPFRNumber mpfrResult = unaryOperationTwoOutputs(op, input, mpfrIntResult);
- double ulp = mpfrResult.ulp(libcResult.f);
+ MPFRNumber mpfr_result =
+ unary_operation_two_outputs(op, input, mpfrIntResult);
+ double ulp = mpfr_result.ulp(libc_result.f);
- if (mpfrIntResult != libcResult.i)
+ if (mpfrIntResult != libc_result.i)
return false;
- bool bitsAreEven = ((FPBits<T>(libcResult.f).uintval() & 1) == 0);
- return (ulp < ulpError) ||
- ((ulp == ulpError) && ((ulp != 0.5) || bitsAreEven));
+ bool bits_are_even = ((FPBits<T>(libc_result.f).uintval() & 1) == 0);
+ return (ulp < ulp_error) ||
+ ((ulp == ulp_error) && ((ulp != 0.5) || bits_are_even));
}
template bool
-compareUnaryOperationTwoOutputs<float>(Operation, float,
- const BinaryOutput<float> &, double);
-template bool
-compareUnaryOperationTwoOutputs<double>(Operation, double,
- const BinaryOutput<double> &, double);
-template bool compareUnaryOperationTwoOutputs<long double>(
+compare_unary_operation_two_outputs<float>(Operation, float,
+ const BinaryOutput<float> &, double);
+template bool compare_unary_operation_two_outputs<double>(
+ Operation, double, const BinaryOutput<double> &, double);
+template bool compare_unary_operation_two_outputs<long double>(
Operation, long double, const BinaryOutput<long double> &, double);
template <typename T>
-bool compareBinaryOperationTwoOutputs(Operation op, const BinaryInput<T> &input,
- const BinaryOutput<T> &libcResult,
- double ulpError) {
+bool compare_binary_operation_two_outputs(Operation op,
+ const BinaryInput<T> &input,
+ const BinaryOutput<T> &libc_result,
+ double ulp_error) {
int mpfrIntResult;
- MPFRNumber mpfrResult =
- binaryOperationTwoOutputs(op, input.x, input.y, mpfrIntResult);
- double ulp = mpfrResult.ulp(libcResult.f);
+ MPFRNumber mpfr_result =
+ binary_operation_two_outputs(op, input.x, input.y, mpfrIntResult);
+ double ulp = mpfr_result.ulp(libc_result.f);
- if (mpfrIntResult != libcResult.i) {
+ if (mpfrIntResult != libc_result.i) {
if (op == Operation::RemQuo) {
- if ((0x7 & mpfrIntResult) != (0x7 & libcResult.i))
+ if ((0x7 & mpfrIntResult) != (0x7 & libc_result.i))
return false;
} else {
return false;
}
}
- bool bitsAreEven = ((FPBits<T>(libcResult.f).uintval() & 1) == 0);
- return (ulp < ulpError) ||
- ((ulp == ulpError) && ((ulp != 0.5) || bitsAreEven));
+ bool bits_are_even = ((FPBits<T>(libc_result.f).uintval() & 1) == 0);
+ return (ulp < ulp_error) ||
+ ((ulp == ulp_error) && ((ulp != 0.5) || bits_are_even));
}
-template bool
-compareBinaryOperationTwoOutputs<float>(Operation, const BinaryInput<float> &,
- const BinaryOutput<float> &, double);
-template bool
-compareBinaryOperationTwoOutputs<double>(Operation, const BinaryInput<double> &,
- const BinaryOutput<double> &, double);
-template bool compareBinaryOperationTwoOutputs<long double>(
+template bool compare_binary_operation_two_outputs<float>(
+ Operation, const BinaryInput<float> &, const BinaryOutput<float> &, double);
+template bool compare_binary_operation_two_outputs<double>(
+ Operation, const BinaryInput<double> &, const BinaryOutput<double> &,
+ double);
+template bool compare_binary_operation_two_outputs<long double>(
Operation, const BinaryInput<long double> &,
const BinaryOutput<long double> &, double);
template <typename T>
-bool compareBinaryOperationOneOutput(Operation op, const BinaryInput<T> &input,
- T libcResult, double ulpError) {
- MPFRNumber mpfrResult = binaryOperationOneOutput(op, input.x, input.y);
- double ulp = mpfrResult.ulp(libcResult);
-
- bool bitsAreEven = ((FPBits<T>(libcResult).uintval() & 1) == 0);
- return (ulp < ulpError) ||
- ((ulp == ulpError) && ((ulp != 0.5) || bitsAreEven));
+bool compare_binary_operation_one_output(Operation op,
+ const BinaryInput<T> &input,
+ T libc_result, double ulp_error) {
+ MPFRNumber mpfr_result = binary_operation_one_output(op, input.x, input.y);
+ double ulp = mpfr_result.ulp(libc_result);
+
+ bool bits_are_even = ((FPBits<T>(libc_result).uintval() & 1) == 0);
+ return (ulp < ulp_error) ||
+ ((ulp == ulp_error) && ((ulp != 0.5) || bits_are_even));
}
-template bool compareBinaryOperationOneOutput<float>(Operation,
- const BinaryInput<float> &,
- float, double);
-template bool
-compareBinaryOperationOneOutput<double>(Operation, const BinaryInput<double> &,
- double, double);
-template bool compareBinaryOperationOneOutput<long double>(
+template bool compare_binary_operation_one_output<float>(
+ Operation, const BinaryInput<float> &, float, double);
+template bool compare_binary_operation_one_output<double>(
+ Operation, const BinaryInput<double> &, double, double);
+template bool compare_binary_operation_one_output<long double>(
Operation, const BinaryInput<long double> &, long double, double);
template <typename T>
-bool compareTernaryOperationOneOutput(Operation op,
- const TernaryInput<T> &input,
- T libcResult, double ulpError) {
- MPFRNumber mpfrResult =
- ternaryOperationOneOutput(op, input.x, input.y, input.z);
- double ulp = mpfrResult.ulp(libcResult);
-
- bool bitsAreEven = ((FPBits<T>(libcResult).uintval() & 1) == 0);
- return (ulp < ulpError) ||
- ((ulp == ulpError) && ((ulp != 0.5) || bitsAreEven));
+bool compare_ternary_operation_one_output(Operation op,
+ const TernaryInput<T> &input,
+ T libc_result, double ulp_error) {
+ MPFRNumber mpfr_result =
+ ternary_operation_one_output(op, input.x, input.y, input.z);
+ double ulp = mpfr_result.ulp(libc_result);
+
+ bool bits_are_even = ((FPBits<T>(libc_result).uintval() & 1) == 0);
+ return (ulp < ulp_error) ||
+ ((ulp == ulp_error) && ((ulp != 0.5) || bits_are_even));
}
-template bool
-compareTernaryOperationOneOutput<float>(Operation, const TernaryInput<float> &,
- float, double);
-template bool compareTernaryOperationOneOutput<double>(
+template bool compare_ternary_operation_one_output<float>(
+ Operation, const TernaryInput<float> &, float, double);
+template bool compare_ternary_operation_one_output<double>(
Operation, const TernaryInput<double> &, double, double);
-template bool compareTernaryOperationOneOutput<long double>(
+template bool compare_ternary_operation_one_output<long double>(
Operation, const TernaryInput<long double> &, long double, double);
-static mpfr_rnd_t getMPFRRoundingMode(RoundingMode mode) {
+static mpfr_rnd_t get_mpfr_rounding_mode(RoundingMode mode) {
switch (mode) {
case RoundingMode::Upward:
return MPFR_RNDU;
@@ -795,33 +799,33 @@ static mpfr_rnd_t getMPFRRoundingMode(RoundingMode mode) {
} // namespace internal
-template <typename T> bool RoundToLong(T x, long &result) {
+template <typename T> bool round_to_long(T x, long &result) {
MPFRNumber mpfr(x);
- return mpfr.roundToLong(result);
+ return mpfr.roung_to_long(result);
}
-template bool RoundToLong<float>(float, long &);
-template bool RoundToLong<double>(double, long &);
-template bool RoundToLong<long double>(long double, long &);
+template bool round_to_long<float>(float, long &);
+template bool round_to_long<double>(double, long &);
+template bool round_to_long<long double>(long double, long &);
-template <typename T> bool RoundToLong(T x, RoundingMode mode, long &result) {
+template <typename T> bool round_to_long(T x, RoundingMode mode, long &result) {
MPFRNumber mpfr(x);
- return mpfr.roundToLong(internal::getMPFRRoundingMode(mode), result);
+ return mpfr.roung_to_long(internal::get_mpfr_rounding_mode(mode), result);
}
-template bool RoundToLong<float>(float, RoundingMode, long &);
-template bool RoundToLong<double>(double, RoundingMode, long &);
-template bool RoundToLong<long double>(long double, RoundingMode, long &);
+template bool round_to_long<float>(float, RoundingMode, long &);
+template bool round_to_long<double>(double, RoundingMode, long &);
+template bool round_to_long<long double>(long double, RoundingMode, long &);
-template <typename T> T Round(T x, RoundingMode mode) {
+template <typename T> T round(T x, RoundingMode mode) {
MPFRNumber mpfr(x);
- MPFRNumber result = mpfr.rint(internal::getMPFRRoundingMode(mode));
+ MPFRNumber result = mpfr.rint(internal::get_mpfr_rounding_mode(mode));
return result.as<T>();
}
-template float Round<float>(float, RoundingMode);
-template double Round<double>(double, RoundingMode);
-template long double Round<long double>(long double, RoundingMode);
+template float round<float>(float, RoundingMode);
+template double round<double>(double, RoundingMode);
+template long double round<long double>(long double, RoundingMode);
} // namespace mpfr
} // namespace testing
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.h b/libc/utils/MPFRWrapper/MPFRUtils.h
index ff35a56231bb..c52f2a76d9c6 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.h
+++ b/libc/utils/MPFRWrapper/MPFRUtils.h
@@ -98,132 +98,137 @@ namespace internal {
template <typename T1, typename T2>
struct AreMatchingBinaryInputAndBinaryOutput {
- static constexpr bool value = false;
+ static constexpr bool VALUE = false;
};
template <typename T>
struct AreMatchingBinaryInputAndBinaryOutput<BinaryInput<T>, BinaryOutput<T>> {
- static constexpr bool value = cpp::IsFloatingPointType<T>::Value;
+ static constexpr bool VALUE = cpp::IsFloatingPointType<T>::Value;
};
template <typename T>
-bool compareUnaryOperationSingleOutput(Operation op, T input, T libcOutput,
- double t);
+bool compare_unary_operation_single_output(Operation op, T input, T libc_output,
+ double t);
template <typename T>
-bool compareUnaryOperationTwoOutputs(Operation op, T input,
- const BinaryOutput<T> &libcOutput,
- double t);
+bool compare_unary_operation_two_outputs(Operation op, T input,
+ const BinaryOutput<T> &libc_output,
+ double t);
template <typename T>
-bool compareBinaryOperationTwoOutputs(Operation op, const BinaryInput<T> &input,
- const BinaryOutput<T> &libcOutput,
- double t);
+bool compare_binary_operation_two_outputs(Operation op,
+ const BinaryInput<T> &input,
+ const BinaryOutput<T> &libc_output,
+ double t);
template <typename T>
-bool compareBinaryOperationOneOutput(Operation op, const BinaryInput<T> &input,
- T libcOutput, double t);
+bool compare_binary_operation_one_output(Operation op,
+ const BinaryInput<T> &input,
+ T libc_output, double t);
template <typename T>
-bool compareTernaryOperationOneOutput(Operation op,
- const TernaryInput<T> &input,
- T libcOutput, double t);
+bool compare_ternary_operation_one_output(Operation op,
+ const TernaryInput<T> &input,
+ T libc_output, double t);
template <typename T>
-void explainUnaryOperationSingleOutputError(Operation op, T input, T matchValue,
- testutils::StreamWrapper &OS);
+void explain_unary_operation_single_output_error(Operation op, T input,
+ T match_value,
+ testutils::StreamWrapper &OS);
template <typename T>
-void explainUnaryOperationTwoOutputsError(Operation op, T input,
- const BinaryOutput<T> &matchValue,
- testutils::StreamWrapper &OS);
+void explain_unary_operation_two_outputs_error(
+ Operation op, T input, const BinaryOutput<T> &match_value,
+ testutils::StreamWrapper &OS);
template <typename T>
-void explainBinaryOperationTwoOutputsError(Operation op,
- const BinaryInput<T> &input,
- const BinaryOutput<T> &matchValue,
- testutils::StreamWrapper &OS);
+void explain_binary_operation_two_outputs_error(
+ Operation op, const BinaryInput<T> &input,
+ const BinaryOutput<T> &match_value, testutils::StreamWrapper &OS);
template <typename T>
-void explainBinaryOperationOneOutputError(Operation op,
- const BinaryInput<T> &input,
- T matchValue,
- testutils::StreamWrapper &OS);
+void explain_binary_operation_one_output_error(Operation op,
+ const BinaryInput<T> &input,
+ T match_value,
+ testutils::StreamWrapper &OS);
template <typename T>
-void explainTernaryOperationOneOutputError(Operation op,
- const TernaryInput<T> &input,
- T matchValue,
- testutils::StreamWrapper &OS);
+void explain_ternary_operation_one_output_error(Operation op,
+ const TernaryInput<T> &input,
+ T match_value,
+ testutils::StreamWrapper &OS);
template <Operation op, typename InputType, typename OutputType>
class MPFRMatcher : public testing::Matcher<OutputType> {
InputType input;
- OutputType matchValue;
- double ulpTolerance;
+ OutputType match_value;
+ double ulp_tolerance;
public:
- MPFRMatcher(InputType testInput, double ulpTolerance)
- : input(testInput), ulpTolerance(ulpTolerance) {}
+ MPFRMatcher(InputType testInput, double ulp_tolerance)
+ : input(testInput), ulp_tolerance(ulp_tolerance) {}
bool match(OutputType libcResult) {
- matchValue = libcResult;
- return match(input, matchValue, ulpTolerance);
+ match_value = libcResult;
+ return match(input, match_value, ulp_tolerance);
}
- void explainError(testutils::StreamWrapper &OS) override {
- explainError(input, matchValue, OS);
+ // This method is marked with NOLINT because it the name `explainError`
+ // does not confirm to the coding style.
+ void explainError(testutils::StreamWrapper &OS) override { // NOLINT
+ explain_error(input, match_value, OS);
}
private:
template <typename T> static bool match(T in, T out, double tolerance) {
- return compareUnaryOperationSingleOutput(op, in, out, tolerance);
+ return compare_unary_operation_single_output(op, in, out, tolerance);
}
template <typename T>
static bool match(T in, const BinaryOutput<T> &out, double tolerance) {
- return compareUnaryOperationTwoOutputs(op, in, out, tolerance);
+ return compare_unary_operation_two_outputs(op, in, out, tolerance);
}
template <typename T>
static bool match(const BinaryInput<T> &in, T out, double tolerance) {
- return compareBinaryOperationOneOutput(op, in, out, tolerance);
+ return compare_binary_operation_one_output(op, in, out, tolerance);
}
template <typename T>
static bool match(BinaryInput<T> in, const BinaryOutput<T> &out,
double tolerance) {
- return compareBinaryOperationTwoOutputs(op, in, out, tolerance);
+ return compare_binary_operation_two_outputs(op, in, out, tolerance);
}
template <typename T>
static bool match(const TernaryInput<T> &in, T out, double tolerance) {
- return compareTernaryOperationOneOutput(op, in, out, tolerance);
+ return compare_ternary_operation_one_output(op, in, out, tolerance);
}
template <typename T>
- static void explainError(T in, T out, testutils::StreamWrapper &OS) {
- explainUnaryOperationSingleOutputError(op, in, out, OS);
+ static void explain_error(T in, T out, testutils::StreamWrapper &OS) {
+ explain_unary_operation_single_output_error(op, in, out, OS);
}
template <typename T>
- static void explainError(T in, const BinaryOutput<T> &out,
- testutils::StreamWrapper &OS) {
- explainUnaryOperationTwoOutputsError(op, in, out, OS);
+ static void explain_error(T in, const BinaryOutput<T> &out,
+ testutils::StreamWrapper &OS) {
+ explain_unary_operation_two_outputs_error(op, in, out, OS);
}
template <typename T>
- static void explainError(const BinaryInput<T> &in, const BinaryOutput<T> &out,
- testutils::StreamWrapper &OS) {
- explainBinaryOperationTwoOutputsError(op, in, out, OS);
+ static void explain_error(const BinaryInput<T> &in,
+ const BinaryOutput<T> &out,
+ testutils::StreamWrapper &OS) {
+ explain_binary_operation_two_outputs_error(op, in, out, OS);
}
template <typename T>
- static void explainError(const BinaryInput<T> &in, T out,
- testutils::StreamWrapper &OS) {
- explainBinaryOperationOneOutputError(op, in, out, OS);
+ static void explain_error(const BinaryInput<T> &in, T out,
+ testutils::StreamWrapper &OS) {
+ explain_binary_operation_one_output_error(op, in, out, OS);
}
template <typename T>
- static void explainError(const TernaryInput<T> &in, T out,
- testutils::StreamWrapper &OS) {
- explainTernaryOperationOneOutputError(op, in, out, OS);
+ static void explain_error(const TernaryInput<T> &in, T out,
+ testutils::StreamWrapper &OS) {
+ explain_ternary_operation_one_output_error(op, in, out, OS);
}
};
@@ -232,7 +237,7 @@ private:
// Return true if the input and ouput types for the operation op are valid
// types.
template <Operation op, typename InputType, typename OutputType>
-constexpr bool isValidOperation() {
+constexpr bool is_valid_operation() {
return (Operation::BeginUnaryOperationsSingleOutput < op &&
op < Operation::EndUnaryOperationsSingleOutput &&
cpp::IsSame<InputType, OutputType>::Value &&
@@ -248,7 +253,7 @@ constexpr bool isValidOperation() {
(Operation::BeginBinaryOperationsTwoOutputs < op &&
op < Operation::EndBinaryOperationsTwoOutputs &&
internal::AreMatchingBinaryInputAndBinaryOutput<InputType,
- OutputType>::value) ||
+ OutputType>::VALUE) ||
(Operation::BeginTernaryOperationsSingleOuput < op &&
op < Operation::EndTernaryOperationsSingleOutput &&
cpp::IsFloatingPointType<OutputType>::Value &&
@@ -257,29 +262,29 @@ constexpr bool isValidOperation() {
template <Operation op, typename InputType, typename OutputType>
__attribute__((no_sanitize("address")))
-cpp::EnableIfType<isValidOperation<op, InputType, OutputType>(),
+cpp::EnableIfType<is_valid_operation<op, InputType, OutputType>(),
internal::MPFRMatcher<op, InputType, OutputType>>
-getMPFRMatcher(InputType input, OutputType outputUnused, double t) {
+get_mpfr_matcher(InputType input, OutputType output_unused, double t) {
return internal::MPFRMatcher<op, InputType, OutputType>(input, t);
}
enum class RoundingMode : uint8_t { Upward, Downward, TowardZero, Nearest };
-template <typename T> T Round(T x, RoundingMode mode);
+template <typename T> T round(T x, RoundingMode mode);
-template <typename T> bool RoundToLong(T x, long &result);
-template <typename T> bool RoundToLong(T x, RoundingMode mode, long &result);
+template <typename T> bool round_to_long(T x, long &result);
+template <typename T> bool round_to_long(T x, RoundingMode mode, long &result);
} // namespace mpfr
} // namespace testing
} // namespace __llvm_libc
-#define EXPECT_MPFR_MATCH(op, input, matchValue, tolerance) \
- EXPECT_THAT(matchValue, __llvm_libc::testing::mpfr::getMPFRMatcher<op>( \
- input, matchValue, tolerance))
+#define EXPECT_MPFR_MATCH(op, input, match_value, tolerance) \
+ EXPECT_THAT(match_value, __llvm_libc::testing::mpfr::get_mpfr_matcher<op>( \
+ input, match_value, tolerance))
-#define ASSERT_MPFR_MATCH(op, input, matchValue, tolerance) \
- ASSERT_THAT(matchValue, __llvm_libc::testing::mpfr::getMPFRMatcher<op>( \
- input, matchValue, tolerance))
+#define ASSERT_MPFR_MATCH(op, input, match_value, tolerance) \
+ ASSERT_THAT(match_value, __llvm_libc::testing::mpfr::get_mpfr_matcher<op>( \
+ input, match_value, tolerance))
#endif // LLVM_LIBC_UTILS_TESTUTILS_MPFRUTILS_H