Update the utility functions for checking exceptional values of math
functions to use cpp::optional return values.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libc/src/__support/FPUtil/except_value_utils.h | ||
---|---|---|
44 | I want to suggest a rearrangement: template <typename T, size_t N> struct ExceptValues { static_assert(cpp::is_floating_point_v<T>, "..."); using UIntType = typename FPBits<T>::UIntType; struct Mapping { // This is the same as ExceptValueOutput from above with an additional field UIntType input; UIntType rnd_towardzero_result; ... }; Mapping values[N]; // You can choose to prevent implicit type promotions and convertions using enable_if constexpr cpp::optional<T> lookup(UIntType bits) const { ... } constexpr cpp::optional<T> lookup(T x) const { // Implement this method if required } constexpr cpp::optional<T> lookup_odd(UIntType bits) const { ... } constexpr cpp::optional<T> lookup_odd(T x) const ( // Implement this method if required. } }; | |
libc/src/math/generic/cosf.cpp | ||
114 | Patterns like this should get simplified to: if (auto r = COSF_EXCEPTS.lookup(x_abs); unlikely(r)) return r; |
libc/src/math/generic/cosf.cpp | ||
---|---|---|
114 | I tried it but our current implementation of cpp::optional has no implicit conversion to T and the conversion to bool is explicit. |
libc/src/math/generic/cosf.cpp | ||
---|---|---|
114 | Ah yes! We should do *r but thats a nitty nit at this point. |
I want to suggest a rearrangement: