Skip to content

Commit 92a0168

Browse files
[libc] Enable more entrypoints for riscv (#102055)
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
1 parent bd576fe commit 92a0168

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

libc/config/linux/riscv/entrypoints.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,12 @@ if(LIBC_TYPES_HAS_FLOAT128)
576576
libc.src.math.canonicalizef128
577577
libc.src.math.ceilf128
578578
libc.src.math.copysignf128
579+
libc.src.math.daddf128
580+
libc.src.math.ddivf128
581+
libc.src.math.dfmaf128
579582
libc.src.math.dmulf128
580583
libc.src.math.dsqrtf128
584+
libc.src.math.dsubf128
581585
libc.src.math.fabsf128
582586
libc.src.math.fdimf128
583587
libc.src.math.floorf128
@@ -617,6 +621,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
617621
libc.src.math.roundevenf128
618622
libc.src.math.roundf128
619623
libc.src.math.scalbnf128
624+
libc.src.math.setpayloadf128
620625
libc.src.math.sqrtf128
621626
libc.src.math.totalorderf128
622627
libc.src.math.totalordermagf128

libc/test/src/math/smoke/SetPayloadTest.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ class SetPayloadTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
3333
EXPECT_EQ(1, func(&res, T(-1.0)));
3434
EXPECT_EQ(1, func(&res, T(0x42.1p+0)));
3535
EXPECT_EQ(1, func(&res, T(-0x42.1p+0)));
36-
EXPECT_EQ(1, func(&res, T(StorageType(1) << (FPBits::FRACTION_LEN - 1))));
36+
37+
FPBits nan_payload_bits = FPBits::one();
38+
nan_payload_bits.set_biased_exponent(FPBits::FRACTION_LEN - 1 +
39+
FPBits::EXP_BIAS);
40+
T nan_payload = nan_payload_bits.get_val();
41+
EXPECT_EQ(1, func(&res, nan_payload));
3742
}
3843

3944
void testValidPayloads(SetPayloadFunc func) {
@@ -57,7 +62,15 @@ class SetPayloadTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
5762
EXPECT_EQ(FPBits::quiet_nan(Sign::POS, 0x123).uintval(),
5863
FPBits(res).uintval());
5964

60-
EXPECT_EQ(0, func(&res, T(FPBits::FRACTION_MASK >> 1)));
65+
// The following code is creating a NaN payload manually to prevent a
66+
// conversion from BigInt to float128.
67+
FPBits nan_payload_bits = FPBits::one();
68+
nan_payload_bits.set_biased_exponent(FPBits::SIG_LEN - 2 +
69+
FPBits::EXP_BIAS);
70+
nan_payload_bits.set_mantissa(FPBits::SIG_MASK - 3);
71+
T nan_payload = nan_payload_bits.get_val();
72+
73+
EXPECT_EQ(0, func(&res, nan_payload));
6174
EXPECT_TRUE(FPBits(res).is_quiet_nan());
6275
EXPECT_EQ(
6376
FPBits::quiet_nan(Sign::POS, FPBits::FRACTION_MASK >> 1).uintval(),

0 commit comments

Comments
 (0)