Skip to content

Implement fixed point bitsfx functions in llvm-libc #113359

@PiJoules

Description

@PiJoules

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

Metadata

Metadata

Assignees

Labels

good 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