implement unsigned -> float casts

amd64 lacks an instruction for this so it has to be implemented with
signed -> float casts:
 - Word casting is done by zero-extending the word to a long and then doing
   a regular signed cast.
 - Long casting is done by dividing by two with correct rounding if the
   highest bit is set and casting that to float, then adding
   1 to mantissa with integer addition
This commit is contained in:
Bor Grošelj Simić 2022-01-28 02:06:17 +01:00 committed by Quentin Carbonneaux
parent b0d27d8a01
commit 74d022f975
6 changed files with 107 additions and 5 deletions

View file

@ -698,7 +698,9 @@ or convert a floating point into an integer and vice versa.
* `stosi` -- `I(ss)`
* `dtosi` -- `I(dd)`
* `swtof` -- `F(ww)`
* `uwtof` -- `F(ww)`
* `sltof` -- `F(ll)`
* `ultof` -- `F(ll)`
Extending the precision of a temporary is done using the
`ext` family of instructions. Because QBE types do not
@ -717,9 +719,9 @@ zero.
Converting between signed integers and floating points is
done using `stosi` (single to signed integer), `dtosi`
(double to signed integer), `swtof` (signed word to float),
and `sltof` (signed long to float). These instructions
only handle signed integers, conversion to and from
unsigned types are not yet supported.
`uwtof` (unsigned word to float), `sltof` (signed long
to float) and `ultof` (unsigned long to float). Conversion
from unsigned types is not yet supported.
Because of <@ Subtyping >, there is no need to have an
instruction to lower the precision of an integer temporary.
@ -990,8 +992,10 @@ instructions unless you know exactly what you are doing.
* `extuh`
* `extuw`
* `sltof`
* `ultof`
* `stosi`
* `swtof`
* `uwtof`
* `truncd`
* <@ Cast and Copy > :