| Issue |
114503
|
| Summary |
[libc] [stdfix] Implement fixed-point `mulifx` functions
|
| Labels |
libc
|
| Assignees |
|
| Reporter |
duncpro
|
The fixed-point `mulifx` family of functions from [ISO 18037](https://standards.iso.org/ittf/PubliclyAvailableStandards/c051126_ISO_IEC_TR_18037_2008.zip) are not in llvm-libc yet.
> The muli functions multiply an integer operand by a fixed-point operand and return an integer value.
> ...
> If an integer result of one of these functions overflows, the behavior is undefined.
>
> \- ISO 18037
# Definitions
```
int mulir(int, fract);
long int mulilr(long int, long fract);
int mulik(int, accum);
long int mulilk(long int, long accum);
unsigned int muliur(unsigned int, unsigned fract);
unsigned long int muliulr(unsigned long int, unsigned long fract);
unsigned int muliuk(unsigned int, unsigned accum);
unsigned long int muliulk(unsigned long int, unsigned long accum);
```
# Implementation
For `accum` types this could be implemented by converting the integer operand into an `accum` with no fractional value, and then using the multiplication operator on the two `accum`s. Then truncating the result's fractional value, and finally bitcasting to the integer type.
For `fract` types we could convert the `fract` into an `accum` with no integral value, and then use the same routine above.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs