Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org>
To: Dragan Mladjenovic <Dragan.Mladjenovic@syrmia.com>
Cc: Chao-ying Fu <cfu@wavecomp.com>,
	Faraz Shahbazker <fshahbazker@wavecomp.com>,
	gdb-patches@sourceware.org,
	"Maciej W . Rozycki" <macro@orcam.me.uk>
Subject: Re: [PATCH v3 3/4] sim: Add partial support for IEEE 754-2008
Date: Wed, 12 Jan 2022 05:47:55 -0500	[thread overview]
Message-ID: <Yd6x2x3qkLADEsuj@vapier> (raw)
In-Reply-To: <20220111212406.32312-4-Dragan.Mladjenovic@syrmia.com>

[-- Attachment #1: Type: text/plain, Size: 2235 bytes --]

On 11 Jan 2022 22:24, Dragan Mladjenovic wrote:
> --- a/sim/common/sim-fpu.c
> +++ b/sim/common/sim-fpu.c
>  
> +INLINE_SIM_FPU (int)
> +sim_fpu_is_un (const sim_fpu *l,
> +    const sim_fpu *r)

the arguments fit on one line

> +INLINE_SIM_FPU (int)
> +sim_fpu_is_or (const sim_fpu *l,
> +    const sim_fpu *r)

same here

> +INLINE_SIM_FPU (int)
> +sim_fpu_un (int *is, const sim_fpu *l, const sim_fpu *r)
> 
> +INLINE_SIM_FPU (int)
> +sim_fpu_or (int *is, const sim_fpu *l, const sim_fpu *r)

sorry, but what are these functions supposed to be doing ?

the sim_fpu_{lt,le,eq,ne,...} binary operations are all fairly obvious in
that they map directly to < <= == != ...

but what do un & or map to ?  they clearly aren't "Specific comparison
operators" like the others as they aren't actually testing the value of
the operands other than whether they're NaN's.

> +  if (sim_fpu_is_nan (l) || sim_fpu_is_nan (r))
> +  {
> +    *is = 1;
> +    return 0;
> +  }

the {} section should be indented one more level

> +INLINE_SIM_FPU(int)
> +sim_fpu_classify (const sim_fpu *f)
> +{
> +  switch (f->class)
> +    {
> +    case sim_fpu_class_snan: return SIM_FPU_IS_SNAN;
> +    case sim_fpu_class_qnan: return SIM_FPU_IS_QNAN;
> +    case sim_fpu_class_infinity:
> +      if (!f->sign)
> +	return SIM_FPU_IS_PINF;
> +      else
> +	return SIM_FPU_IS_NINF;
> +    case sim_fpu_class_zero:
> +      if (!f->sign)
> +	return SIM_FPU_IS_PZERO;
> +      else
> +	return SIM_FPU_IS_NZERO;
> +    case sim_fpu_class_number:
> +      if (!f->sign)
> +	return SIM_FPU_IS_PNUMBER;
> +      else
> +	return SIM_FPU_IS_NNUMBER;
> +    case sim_fpu_class_denorm:
> +      if (!f->sign)
> +	return SIM_FPU_IS_PDENORM;
> +      else
> +	return SIM_FPU_IS_NDENORM;

i think these would be a bit more succinct written as:
      return f->sign ? SIM_FPU_IS_NINF : SIM_FPU_IS_PINF;

>  /* A number of useful constants */
>  
>  #if EXTERN_SIM_FPU_P
> +static sim_fpu_mode sim_fpu_current_mode = sim_fpu_ieee754_1985;

this isn't a constant.  please don't use global variables to hold state.  same
as the earlier patch, this should go into the (new) sim_fpu_state structure.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-01-12 10:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11 21:24 [PATCH v3 0/4] sim: Add support for MIPS32/64 revision 6 Dragan Mladjenovic
2022-01-11 21:24 ` [PATCH v3 1/4] sim: Allow toggling of quiet NaN-bit semantics Dragan Mladjenovic
2022-01-12 10:06   ` Mike Frysinger via Gdb-patches
2022-01-12 10:44     ` Mike Frysinger via Gdb-patches
2022-01-11 21:24 ` [PATCH v3 2/4] sim: Factor out NaN handling in floating point operations Dragan Mladjenovic
2022-01-12 10:22   ` Mike Frysinger via Gdb-patches
2022-01-11 21:24 ` [PATCH v3 3/4] sim: Add partial support for IEEE 754-2008 Dragan Mladjenovic
2022-01-12 10:47   ` Mike Frysinger via Gdb-patches [this message]
2022-01-11 21:24 ` [PATCH v3 4/4] sim: mips: Add simulator support for mips32r6/mips64r6 Dragan Mladjenovic
2022-01-12 10:57   ` Mike Frysinger via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yd6x2x3qkLADEsuj@vapier \
    --to=gdb-patches@sourceware.org \
    --cc=Dragan.Mladjenovic@syrmia.com \
    --cc=cfu@wavecomp.com \
    --cc=fshahbazker@wavecomp.com \
    --cc=macro@orcam.me.uk \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox