From f5632cf71d4dfd2a711b4e8c43f4f0d8c88042da Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 16 May 2023 19:10:03 -0700 Subject: [PATCH] add bfp_CONVERT_FROM_UI32/64 --- openpower/isafunctions/bfp.mdwn | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/openpower/isafunctions/bfp.mdwn b/openpower/isafunctions/bfp.mdwn index 08409e8f..44ac7871 100644 --- a/openpower/isafunctions/bfp.mdwn +++ b/openpower/isafunctions/bfp.mdwn @@ -165,6 +165,60 @@ section 7.6.2.2 result.exponent <- result.exponent - 1 return result + def bfp_CONVERT_FROM_UI32(x): + # x is an integer value represented in unsigned word integer + # format. + + result <- BFPState() + result.sign <- 0 + result.exponent <- 0 + result.significand <- 0 + result.class.SNaN <- 0 + result.class.QNaN <- 0 + result.class.Infinity <- 0 + result.class.Zero <- 0 + result.class.Denormal <- 0 + result.class.Normal <- 0 + + if x = 0x0000_0000 then + result.class.Zero <- 1 + else + result.class.Normal <- 1 + result.sign <- 0 + result.exponent <- 32 + result.significand[0:32] <- 0b0 || x + do while result.significand[0] = 0 + result.significand <- result.significand * 2 + result.exponent <- result.exponent - 1 + return result + + def bfp_CONVERT_FROM_UI64(x): + # x is an integer value represented in unsigned double-word integer + # format. + + result <- BFPState() + result.sign <- 0 + result.exponent <- 0 + result.significand <- 0 + result.class.SNaN <- 0 + result.class.QNaN <- 0 + result.class.Infinity <- 0 + result.class.Zero <- 0 + result.class.Denormal <- 0 + result.class.Normal <- 0 + + if x = 0x0000_0000_0000_0000 then + result.class.Zero <- 1 + else + result.class.Normal <- 1 + result.sign <- 0 + result.exponent <- 64 + result.significand[0:64] <- 0b0 || x + do while result.significand[0] = 0 + result.significand <- result.significand * 2 + result.exponent <- result.exponent - 1 + return result + def bfp_CONVERT_FROM_UI128(x): # x is a 128-bit unsigned integer value. -- 2.30.2