public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jim Wilson <jimw@sifive.com>
To: Jim Wilson <jimw@sifive.com>,
	gdb-patches@sourceware.org,  Monk Chiang <monk@andestech.com>
Subject: Re: [PATCH 06/24] RISC-V: Add fp support.
Date: Wed, 21 Apr 2021 16:34:01 -0700	[thread overview]
Message-ID: <CAFyWVaZqNB-0d=2eoezvEeM4imOL7AE6V3TUw+1eUaOXZqqgPQ@mail.gmail.com> (raw)
In-Reply-To: <YH0CINuYysuX5p86@vapier>

On Sun, Apr 18, 2021 at 9:08 PM Mike Frysinger <vapier@gentoo.org> wrote:

> On 17 Apr 2021 10:58, Jim Wilson wrote:
> > Add F and D instruction support.
>
> substance looks fine, just style nits
>

I fixed the formatting issues.

tests ?
>

These are fairly well tested by the gcc testsuite.  Sim tests would be good
also, but I would prefer to handle that with a follow up patch when I have
time to write the tests, or manage to find someone to write the tests for
me.

> > +      switch (sim_fpu_is (&sfa))
> > +     {
> > +     case SIM_FPU_IS_NINF:
> > +       cpu->regs[rd] = 1;
> > +       break;
> > +     case SIM_FPU_IS_NNUMBER:
> > +       cpu->regs[rd] = 1 << 1;
>
> i'm a little surprised all these bits don't have constants for them.  but i
> guess binutils wouldn't normally have broken out the FPU state into
> headers ?
>

newlib and glibc have macros for them, which of course are named
differently as no one ever thought about that, but we can't easily use
either of those here, and the inconsistent naming could be a problem.
binutils has no need to name these bits.  There is no instruction that
takes these bits as input, so they never appear directly in the assembly
syntax.  Of course, names could potentially be useful for people writing
assembly code, but no one has asked for that yet, or volunteered to write
it yet.  We don't have an assembly language header file for people to
include that could include these constants.  We don't have a proper
assembly language manual either.

> > +    case MATCH_FCVT_L_S:
> > +      TRACE_INSN (cpu, "fcvt.l.s %s, %s",
> > +               rd_name, frs1_name);
> > +      cpu->regs[rd] = (int64_t) cpu->fpregs[rs1].S[0];
> > +      goto done;
> > +    case MATCH_FCVT_LU_S:
> > +      TRACE_INSN (cpu, "fcvt.lu.s %s, %s",
> > +               rd_name, frs1_name);
> > +      cpu->regs[rd] = (uint64_t) cpu->fpregs[rs1].S[0];
> > +      goto done;
> > +    case MATCH_FCVT_S_L:
> > +      TRACE_INSN (cpu, "fcvt.s.l %s, %s",
> > +               frd_name, rs1_name);
> > +      cpu->fpregs[rd].S[0] = (float) ((int64_t) cpu->regs[rs1]);
> > +      goto done;
> > +    case MATCH_FCVT_S_LU:
> > +      TRACE_INSN (cpu, "fcvt.s.lu %s, %s",
> > +               frd_name, rs1_name);
> > +      cpu->fpregs[rd].S[0] = (float) cpu->regs[rs1];
>
> these raw casts all feel ... wrong.  are the semantics guaranteed to match
> between whatever the host CPU is (e.g. x86_64) and the target (e.g. riscv)
> ?
> or it just seems to mostly work so we aren't going to squint too hard at
> it ?
>

Yes, this is probably wrong.  The other FP math is probably also wrong.
RISC-V has canonical NaNs like ARM, but I don't see any obvious canonical
NaN support in common/sim-fpu.c.  I know that qemu handles this correctly.
RISC-V has NaN boxing for FP values smaller than the FP register size, i.e.
the upper bits must all be 1.  I don't see the code doing this, but this
would only matter for broken code so it is less important.  Qemu still got
this wrong last time I looked at it, but it has been a while since I looked
at the qemu code.

Maybe this stuff can be handled with a bug report and follow up patches?

Jim

  reply	other threads:[~2021-04-21 23:34 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-17 17:58 [PATCH 00/24] RISC-V sim: Update from riscv-gnu-toolchain Jim Wilson
2021-04-17 17:58 ` [PATCH 01/24] RISC-V sim: Fix fence.i Jim Wilson
2021-04-17 20:36   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 02/24] RISC-V sim: Fix for jalr Jim Wilson
2021-04-19  3:41   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 03/24] RISC-V sim: Atomic fixes Jim Wilson
2021-04-19  3:56   ` Mike Frysinger
2021-04-21 23:00     ` Jim Wilson
2021-04-22  0:09       ` Mike Frysinger
2021-04-22  3:12         ` Jim Wilson
2021-04-17 17:58 ` [PATCH 04/24] RISC-V sim: More atomic fixes Jim Wilson
2021-04-19  3:57   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 05/24] RISC-V sim: Fix stack pointer alignment Jim Wilson
2021-04-19  3:58   ` Mike Frysinger
2021-04-21 22:39     ` Jim Wilson
2021-04-17 17:58 ` [PATCH 06/24] RISC-V: Add fp support Jim Wilson
2021-04-19  4:08   ` Mike Frysinger
2021-04-21 23:34     ` Jim Wilson [this message]
2021-04-17 17:58 ` [PATCH 07/24] RISC-V sim: Add link syscall support Jim Wilson
2021-04-19  4:09   ` Mike Frysinger
2021-04-21 23:36     ` Jim Wilson
2021-04-17 17:58 ` [PATCH 08/24] RISC-V sim: Add brk syscall Jim Wilson
2021-04-19  5:24   ` Mike Frysinger
2021-04-21 23:51     ` Jim Wilson
2021-04-17 17:58 ` [PATCH 09/24] RISC-V sim: Fix syscall fallback Jim Wilson
2021-04-21 23:38   ` Jim Wilson
2021-04-22  3:23     ` Mike Frysinger
2021-04-23 20:35       ` Jim Wilson
2021-04-17 17:58 ` [PATCH 10/24] RISC-V sim: Fix ebreak Jim Wilson
2021-04-19  4:20   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 11/24] RISC-V sim: Fix ebreak, part 2 Jim Wilson
2021-04-19  4:20   ` Mike Frysinger
2021-04-21 23:41     ` Jim Wilson
2021-04-17 17:58 ` [PATCH 12/24] RISC-V sim: Add compressed support Jim Wilson
2021-04-19  4:13   ` Mike Frysinger
2021-04-21 23:42     ` Jim Wilson
2021-04-17 17:58 ` [PATCH 13/24] RISC-V sim: Add gettimeofday Jim Wilson
2021-04-19  4:19   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 14/24] RISC-V sim: Add csrr*i instructions Jim Wilson
2021-04-19  4:26   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 15/24] RISC-V sim: Improve cycle and instret counts Jim Wilson
2021-04-19  4:25   ` Mike Frysinger
2021-04-22  2:26     ` Jim Wilson
2021-04-17 17:58 ` [PATCH 16/24] RISC-V sim: Check sbrk argument Jim Wilson
2021-04-19  5:33   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 17/24] RISC-V sim: Fix tracing typo Jim Wilson
2021-04-19  4:26   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 18/24] RISC-V sim: Improve branch tracing Jim Wilson
2021-04-19  4:27   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 19/24] RISC-V sim: Improve tracing for slt* instructions Jim Wilson
2021-04-19  4:27   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 20/24] RISC-V sim: Set brk to _end if possible Jim Wilson
2021-04-19  5:41   ` Mike Frysinger
2021-04-22  2:45     ` Jim Wilson
2021-04-17 17:58 ` [PATCH 21/24] RISC-V sim: Fix mingw builds Jim Wilson
2021-04-19  4:12   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 22/24] RISC-V sim: Support compressed FP instructions Jim Wilson
2021-04-19  4:27   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 23/24] RISC-V sim: Add zicsr support Jim Wilson
2021-04-19  5:13   ` Mike Frysinger
2021-04-17 17:58 ` [PATCH 24/24] RISC-V sim: Fix divw and remw Jim Wilson
2021-04-19  5:10   ` Mike Frysinger
2021-04-17 20:38 ` [PATCH 00/24] RISC-V sim: Update from riscv-gnu-toolchain Mike Frysinger
2021-04-19  2:33   ` Jim Wilson
2021-04-19  3:23     ` Mike Frysinger
2021-04-19  4:32       ` Jim Wilson
2021-04-19  3:42 ` Mike Frysinger
2021-04-19  4:37   ` Jim Wilson
2021-04-21 15:47 ` Andrew Burgess
2021-04-21 17:49   ` Andrew Burgess

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='CAFyWVaZqNB-0d=2eoezvEeM4imOL7AE6V3TUw+1eUaOXZqqgPQ@mail.gmail.com' \
    --to=jimw@sifive.com \
    --cc=gdb-patches@sourceware.org \
    --cc=monk@andestech.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).