-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] Enable more entrypoints for riscv #102055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-libc Author: Mikhail R. Gadelha (mikhailramalho) ChangesThis patch enables more entrypoints for riscv. The changes to the test cases are introduced to support rv32 which has long double but doesn't have int128 Full diff: https://github.com/llvm/llvm-project/pull/102055.diff 2 Files Affected:
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 15a6827c040c7..51fe6f3522d72 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -576,8 +576,12 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.canonicalizef128
libc.src.math.ceilf128
libc.src.math.copysignf128
+ libc.src.math.daddf128
+ libc.src.math.ddivf128
+ libc.src.math.dfmaf128
libc.src.math.dmulf128
libc.src.math.dsqrtf128
+ libc.src.math.dsubf128
libc.src.math.fabsf128
libc.src.math.fdimf128
libc.src.math.floorf128
@@ -617,6 +621,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.roundevenf128
libc.src.math.roundf128
libc.src.math.scalbnf128
+ libc.src.math.setpayloadf128
libc.src.math.sqrtf128
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
diff --git a/libc/test/src/math/smoke/SetPayloadTest.h b/libc/test/src/math/smoke/SetPayloadTest.h
index 4b0dacf3e1544..b72128e1d4c5f 100644
--- a/libc/test/src/math/smoke/SetPayloadTest.h
+++ b/libc/test/src/math/smoke/SetPayloadTest.h
@@ -33,7 +33,12 @@ class SetPayloadTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_EQ(1, func(&res, T(-1.0)));
EXPECT_EQ(1, func(&res, T(0x42.1p+0)));
EXPECT_EQ(1, func(&res, T(-0x42.1p+0)));
- EXPECT_EQ(1, func(&res, T(StorageType(1) << (FPBits::FRACTION_LEN - 1))));
+
+ FPBits default_snan_payload_bits = FPBits::one();
+ default_snan_payload_bits.set_biased_exponent(FPBits::FRACTION_LEN - 1 +
+ FPBits::EXP_BIAS);
+ T default_snan_payload = default_snan_payload_bits.get_val();
+ EXPECT_EQ(1, func(&res, default_snan_payload));
}
void testValidPayloads(SetPayloadFunc func) {
@@ -57,7 +62,15 @@ class SetPayloadTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_EQ(FPBits::quiet_nan(Sign::POS, 0x123).uintval(),
FPBits(res).uintval());
- EXPECT_EQ(0, func(&res, T(FPBits::FRACTION_MASK >> 1)));
+ // The following code is creating a NaN manually to prevent a conversion
+ // from BigInt to long double.
+ FPBits default_snan_payload_bits = FPBits::one();
+ default_snan_payload_bits.set_biased_exponent(FPBits::SIG_LEN - 2 +
+ FPBits::EXP_BIAS);
+ default_snan_payload_bits.set_mantissa(FPBits::SIG_MASK - 3);
+ T default_snan_payload = default_snan_payload_bits.get_val();
+
+ EXPECT_EQ(0, func(&res, default_snan_payload));
EXPECT_TRUE(FPBits(res).is_quiet_nan());
EXPECT_EQ(
FPBits::quiet_nan(Sign::POS, FPBits::FRACTION_MASK >> 1).uintval(),
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default_snan_payload
and default_snan_payload_bits
are incorrect/misleading variable names in this context.
This patch enables more entrypoints for riscv. The changes to the test cases are introduced to support rv32 which has long double but doesn't have int128
Signed-off-by: Mikhail R. Gadelha <[email protected]>
cacb126
to
ca1ea2a
Compare
This patch enables more entrypoints for riscv. The changes to the test cases are introduced to support rv32 which has long double but doesn't have int128