<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113359>113359</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement fixed point bitsfx functions in llvm-libc
</td>
</tr>
<tr>
<th>Labels</th>
<td>
good first issue,
clang,
libc
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PiJoules
</td>
</tr>
</table>
<pre>
Some fixed point functions from ISO 18037 are implemented in llvm-libc, but not all of them are implemented. The various bits`fx` functions should also be added. Copying from the extension:
```
4.1.7.4 The bitwise fixed-point to integer conversion functions
The bitwise fixed-point to integer conversion functions bitsfx, where fx stands for one of hr, r, lr, hk, k, lk, uhr, ur, ulr, uhk, uk or ulk, take one fixed-point type argument (corresponding to fx); the type of the function is an implementation-defined integer type int_fx_t (for signed fixed-point types) or uint_fx_t (for unsigned fixed-point types), defined in the <stdfix.h> headerfile, that is large enough to hold all the bits in the fixed-point type.
The bitwise fixed-point to integer conversion functions return an integer value equal to the fixedpoint value of the argument multiplied by 2^F, where F is the number of fractional bits in the fixed point type. The result type is an integer type big enough to hold all valid result values for the given fixed-point argument type. For example, if the fract type has 15 fractional bits, then after the declaration
fract a = 0.5;
the value of bitsr(a) is 0.5 * 2^15 = 0x4000.
```
These can first be implemented as `__builtin_*` functions in clang then llvm-libc can provide the wrappers for each of the builtin functions.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU1v4zYQ_TX0ZRBBpiR_HHTYTdbA9tIC23swEkcSG4pU-eE4_74gqdhOdtFDUSCYQNbMm3lvnkh0To6aqGXNV9Y8bTD4ydj2D_mbCYrcpjPirf1hZoJBXkjAYqT2MATde2m0g8GaGb7_-B22h7LaA1oCOS-KZtKeBEgNSp3nByW7nvFH6IIHbTygUmAG8BPNn2sK-HMiOKOVJjjopHdsVw4Xtivhrq-bTFACUDkDHQEKESsfzfIm9Zin8hMBXTxpJ41m1R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