From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBsVG-0007dW-BD for qemu-devel@nongnu.org; Wed, 23 Dec 2015 18:07:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBsVD-0005um-5b for qemu-devel@nongnu.org; Wed, 23 Dec 2015 18:07:30 -0500 Received: from mail-qk0-x233.google.com ([2607:f8b0:400d:c09::233]:34659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBsVD-0005ui-0k for qemu-devel@nongnu.org; Wed, 23 Dec 2015 18:07:27 -0500 Received: by mail-qk0-x233.google.com with SMTP id p187so165198148qkd.1 for ; Wed, 23 Dec 2015 15:07:27 -0800 (PST) Sender: Richard Henderson References: <1450907315-10135-1-git-send-email-chengang@emindsoft.com.cn> <1450907315-10135-3-git-send-email-chengang@emindsoft.com.cn> From: Richard Henderson Message-ID: <567B292B.6070207@twiddle.net> Date: Wed, 23 Dec 2015 15:07:23 -0800 MIME-Version: 1.0 In-Reply-To: <1450907315-10135-3-git-send-email-chengang@emindsoft.com.cn> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 2/4] target-tilegx: Add single floating point implementation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: chengang@emindsoft.com.cn, peter.maydell@linaro.org, cmetcalf@ezchip.com Cc: qemu-devel@nongnu.org, Chen Gang On 12/23/2015 01:48 PM, chengang@emindsoft.com.cn wrote: > +static float32 sfmt_to_float32(uint64_t sfmt) > +{ > + uint32_t sign = get_fsingle_sign(sfmt); > + uint32_t man = get_fsingle_man(sfmt); > + uint32_t exp = get_fsingle_exp(sfmt); > + float32 f; > + > + if (get_fsingle_calc(sfmt) == TILEGX_F_CALC_CVT) { > + if (sign) { > + f = int32_to_float32(0 - man, &fp_status); > + } else { > + f = uint32_to_float32(man, &fp_status); > + } > + exp += get_f32_exp(f) - 0x9e; > + if ((int32_t) exp < 0) { > + return float32_infinity | float32_set_sign(float32_zero, sign); > + } else if (exp >= 0xff) { > + return float32_zero | float32_set_sign(float32_zero, sign); > + } else { > + set_f32_exp(&f, exp); > + } What in the world are you attempting to do here? This is not normalization. This is not even remotely correct with respect to zero or infinity. Moreover, I thought we agreed to do away with that CALC bit. r~ > + } else { > + f = create_f32_man(man >> 8); > + set_f32_exp(&f, exp); > + } > + > + f = float32_set_sign(f, sign); > + return f; > +} > + > +uint64_t helper_fsingle_pack2(uint64_t srca) > +{ > + return float32_val(sfmt_to_float32(srca)); > +} > + > +static uint64_t main_calc(float32 fsrca, float32 fsrcb, > + float32 (*calc)(float32, float32, float_status *)) > +{ > + uint64_t sfmt = float32_to_sfmt(calc(fsrca, fsrcb, &fp_status)); > + > + if (float32_eq(fsrca, fsrcb, &fp_status)) { > + sfmt |= create_fsfd_flag_eq(); > + } else { > + sfmt |= create_fsfd_flag_ne(); > + } > + > + if (float32_lt(fsrca, fsrcb, &fp_status)) { > + sfmt |= create_fsfd_flag_lt(); > + } > + if (float32_le(fsrca, fsrcb, &fp_status)) { > + sfmt |= create_fsfd_flag_le(); > + } > + > + if (float32_lt(fsrcb, fsrca, &fp_status)) { > + sfmt |= create_fsfd_flag_gt(); > + } > + if (float32_le(fsrcb, fsrca, &fp_status)) { > + sfmt |= create_fsfd_flag_ge(); > + } > + > + if (float32_unordered(fsrca, fsrcb, &fp_status)) { > + sfmt |= create_fsfd_flag_un(); > + } > + > + set_fsingle_calc(&sfmt, TILEGX_F_CALC_NCVT); > + return sfmt; > +} > + > +uint64_t helper_fsingle_add1(uint64_t srca, uint64_t srcb) > +{ > + return main_calc(make_float32(srca), make_float32(srcb), float32_add); > +} > + > +uint64_t helper_fsingle_sub1(uint64_t srca, uint64_t srcb) > +{ > + return main_calc(make_float32(srca), make_float32(srcb), float32_sub); > +} > + > +uint64_t helper_fsingle_mul1(uint64_t srca, uint64_t srcb) > +{ > + return main_calc(make_float32(srca), make_float32(srcb), float32_mul); > +} >