<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113357>113357</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement fixed point countlsfx 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 `countls` should also be added. Copying from the extension:
```
4.1.7.3 The fixed-point bit countls functions
The bit count functions countlsfx, 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 result type is int.
The integer return value of the above functions is defined as follows:
- if the value of the fixed-point argument is non-zero, the return value is the largest integer k for
which the expression a<<k does not overflow;
- if the value of the fixed-point argument is zero, an integer value is returned that is at least as large as N, where N is the total number of value bits of the fixed-point type of the argument.
```
This effectively returns the number of leading sign bits. These can first be implemented as `__builtin_*` functions in clang then llvm-libc can provide the `countlsfx` wrappers for each of the builtin functions.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE-vozYQ_zTmMnoIDAnhwKEvq0jbw7bS9v5k8ABujI38J8nrp69sCOFVe6oUTeJoPL8_nhlmrRgUYkMO7-TwLWHejdo0f4rftZdok1bzz-annhB68UAOsxbKQe9V54RWFnqjJ_j-8w_IT1lRATMIYpolTqgcchAKpLxNb1K0HaFnaL0DpR0wKUH34Eac_nsnhb9GhBszQnsL5Jh12isnLTlmYEftJQcmrYYWgXEe8s96_hRqWLi4EQEfDpUVWpHiN5J9I9kzHrP1E49lmqdVWkS8qO5tUdcKByvoS-m-TriwJe3MWC_1jyD1PqJB6B9gHVPcQq8NaIVB9mhCQgwyxvEaYgwyRr-k-CUuSX7J8lfQBvyS59gVY9U9f_c5IzAz-GAoEHrqtDFoZ614s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