Skip to content

[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

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions libc/test/src/math/smoke/SetPayloadTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 nan_payload_bits = FPBits::one();
nan_payload_bits.set_biased_exponent(FPBits::FRACTION_LEN - 1 +
FPBits::EXP_BIAS);
T nan_payload = nan_payload_bits.get_val();
EXPECT_EQ(1, func(&res, nan_payload));
}

void testValidPayloads(SetPayloadFunc func) {
Expand All @@ -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 payload manually to prevent a
// conversion from BigInt to float128.
FPBits nan_payload_bits = FPBits::one();
nan_payload_bits.set_biased_exponent(FPBits::SIG_LEN - 2 +
FPBits::EXP_BIAS);
nan_payload_bits.set_mantissa(FPBits::SIG_MASK - 3);
T nan_payload = nan_payload_bits.get_val();

EXPECT_EQ(0, func(&res, nan_payload));
EXPECT_TRUE(FPBits(res).is_quiet_nan());
EXPECT_EQ(
FPBits::quiet_nan(Sign::POS, FPBits::FRACTION_MASK >> 1).uintval(),
Expand Down
Loading