<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/114503>114503</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libc] [stdfix] Implement fixed-point `mulifx` functions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          duncpro
      </td>
    </tr>
</table>

<pre>
    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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVV1v6jgQ_TXmZdQocQiEhzzclovE011t7ztykgnM1rGRP2jZX7-yEyAsS7VSm2B75syZkxmPsJb2CrFixSsr1jPh3UGbqvWqORo9q3V7rn4fEDr6wvblqEk5YIu095K6L7ZIoRM9yTPoDjqvGkdaWeiM7oEVr9v3X5CVab5kxZrx8uDc0bL8B-MbxjfWCdUK09qErE602TO-Iec6xjd_-FpSI88_ToKkqCW-X2wZ3zRpkWV8sdu-_9ptf77tfv-5izF2PE3L5G86Mr4CYRCUdkAKp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