From 74d022f975f22fda20c0d1fe09a3f6fc7680f64f Mon Sep 17 00:00:00 2001 From: Bor Grošelj Simić Date: Fri, 28 Jan 2022 02:06:17 +0100 Subject: 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 --- doc/il.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/il.txt b/doc/il.txt index 48ecb23..818f0a4 100644 --- a/doc/il.txt +++ b/doc/il.txt @@ -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 > : -- cgit 1.4.1