Skip to content

Implement fixed point countls functions in llvm-libc #113357

@PiJoules

Description

@PiJoules

Some fixed point functions from ISO 18037 are implemented in llvm-libc, but not all of them are implemented. The various countlsfx functions 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:headersHeaders provided by Clang, e.g. for intrinsicsgood first issuehttps://github.com/llvm/llvm-project/contributelibc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions