Description: The LLVM libc project aims to provide a complete, correct, and high-performance C23 standard library. A key differentiator is its focus on correctly rounded math functions for all floating-point types, including float, double, long double, and float128 (IEEE 754 quad precision).
However, not all compilers or architectures support these types natively. For example:
- MSVC on Windows treats long double as 64-bit double and lacks a native
__float128type. - AArch64 targets typically use 128-bit
long double, but lack the 80-bit extended precision format. - Clang on certain non-x86 targets may not enable
__float128by default.
This lack of host compiler support prevents LLVM libc from building and testing its high-precision math routines on these platforms.
The Goal: The goal of this project is to implement standalone C++ classes (e.g., within LIBC_NAMESPACE::fputil) that emulate float80 and float128 semantics in software. These classes should provide the necessary operator overloads and storage (using UInt<128> or similar) to allow the existing templated math implementations to compile and run even when the host compiler does not support the native types.
Proposed Solution:
- Type Abstraction: Create wrapper classes that mimic the behavior of native floating-point types.
- Soft-Float Arithmetic: Implement or connect these classes to soft-float arithmetic routines (
add,sub,mul,div) so that math algorithms (like polynomial evaluation) can be executed. - Integration: Refactor the math function entry points to instantiate templates with these emulated types when native support is missing.
Expected Results:
- A header-only C++ implementation of
float80andfloat128types that can be used where native support is missing. - Basic arithmetic operations (+, -, *, /) implemented for these types.
- Demonstration of LLVM libc math functions compiling and passing tests using these emulated types on a target that lacks native support (e.g., building
float80math on Mac arm64,float128math with MSVC).
Project Size: Medium or Large
Difficulty: Medium
Requirements:
- Basic C++ skills.
- Interest in understanding the intricacies of floating-point formats (IEEE 754 and extended precision).
Mentors: Tue Ly, Nicolas Celik, Krishna Pandey.