Received: from [140.186.70.92] (port=43613 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4UrG-0005U6-Dy for qemu-devel@nongnu.org; Tue, 29 Mar 2011 05:05:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4UrF-0004AQ-38 for qemu-devel@nongnu.org; Tue, 29 Mar 2011 05:05:02 -0400 Received: from cantor.suse.de ([195.135.220.2]:38446 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4UrE-0004A1-Qc for qemu-devel@nongnu.org; Tue, 29 Mar 2011 05:05:01 -0400 Subject: Re: [Qemu-devel] [PATCH 14/17] s390x: Implement opcode helpers Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: Date: Tue, 29 Mar 2011 11:04:57 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1300982333-12802-1-git-send-email-agraf@suse.de> <1300982333-12802-15-git-send-email-agraf@suse.de> <4D90C428.2030101@suse.de> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU-devel Developers , Aurelien Jarno , Richard Henderson On 28.03.2011, at 19:55, Peter Maydell wrote: > On 28 March 2011 18:23, Alexander Graf wrote: >> On 03/24/2011 06:29 PM, Peter Maydell wrote: >>>> +/* condition codes for binary FP ops */ >>>> +static uint32_t set_cc_f32(float32 v1, float32 v2) >>>> +{ >>>> + if (float32_is_any_nan(v1) || float32_is_any_nan(v2)) { >>>> + return 3; >>>> + } else if (float32_eq(v1, v2,&env->fpu_status)) { >>>> + return 0; >>>> + } else if (float32_lt(v1, v2,&env->fpu_status)) { >>>> + return 1; >>>> + } else { >>>> + return 2; >>>> + } >>>> +} >>>=20 >>> Can you not use float32_compare_quiet() (returns a value >>> telling you if it's less/equal/greater/unordered)? >>> If not, needs a comment saying why you need to do it the hard way. >>=20 >> I just checked the macros there and it looks like = float32_compare_quiet >> returns eq when both numbers are NaN. >=20 > Hmm? >=20 > if (( ( extractFloat ## s ## Exp( a ) =3D=3D nan_exp ) && = \ > extractFloat ## s ## Frac( a ) ) || = \ > ( ( extractFloat ## s ## Exp( b ) =3D=3D nan_exp ) && = \ > extractFloat ## s ## Frac( b ) )) { = \ > if (!is_quiet || = \ > float ## s ## _is_signaling_nan( a ) || = \ > float ## s ## _is_signaling_nan( b ) ) { = \ > float_raise( float_flag_invalid STATUS_VAR); = \ > } = \ > return float_relation_unordered; = \ > } = \ >=20 > If A is a NaN (ie its exponent is nan_exp and the frac bits aren't = zero) > or B is a NaN then we return float_relation_unordered. >=20 >> We would still have to convert from >> the return value from that over to a CC value. I honestly don't see = any >> benefit - the code doesn't become cleaner or smaller. >=20 > So you get > static uint32_t set_cc_f32(float32 v1, float32 v2) > { > switch (float32_compare_quiet(v1, v2, &env->fpu_status)) { > case float_relation_unordered: > return 3; > case float_relation_equal: > return 0; > case float_relation_less: > return 1; > case float_relation_greater: > return 2; > case float_relation_unordered: > return 3; > } > } >=20 > (and you probably want to put the conversion switch into a function > since you'll be using it several times.) >=20 > Which I think is pretty straightforward, cleaner because we only > call one softfloat function rather than several, and should be > faster too (we get to avoid repeating a pile of tedious bit = manipulation > in the eq and lt functions). Alrighty, changed the code :). >=20 >>>> +/* load 128-bit FP zero */ >>>> +void HELPER(lzxr)(uint32_t f1) >>>> +{ >>>> + CPU_QuadU x; >>>> + x.q =3D float64_to_float128(float64_zero,&env->fpu_status); >>>=20 >>> Yuck. Just define a float128_zero if we need one. >>=20 >> Good point. Mind to do so? I find myself struggling with the code = there. >=20 > We could just follow the pattern of float128_default_nan_{low,high} > in softfloat.h: >=20 > #define float128_zero_low LIT64(0) > #define float128_zero_high LIT64(0) >=20 > then your function has: > x.q.high =3D float128_zero_high; > x.q.low =3D float128_zero_low; >=20 > Or we could do something with an expression that returns a > struct type; that would be cleaner. I think the default nan > code is assuming it might have to be compiled with something > other than gcc. However I forget the C syntax and have to go > home now :-) I'll just leave it to you for a follow-up patch :). The less I have to = touch in softfpu code, the better :) Alex