From: Rich Felker <dalias@libc.org>
To: "Alex Rønne Petersen" <alex@alexrp.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] riscv: Fix setjmp assembly when compiling for ilp32f/lp64f.
Date: Tue, 23 Jul 2024 18:58:54 -0400 [thread overview]
Message-ID: <20240723225853.GV10433@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAH9TF6OXdGZAQ5qsLceAvJzOxdGiFd5Q3XK5yRJJFaWsaw9vTg@mail.gmail.com>
On Wed, Jul 24, 2024 at 12:47:14AM +0200, Alex Rønne Petersen wrote:
> On Tue, Jul 23, 2024 at 11:22 PM Szabolcs Nagy <nsz@port70.net> wrote:
> >
> > * Alex Rønne Petersen <alex@alexrp.com> [2024-06-29 04:04:34 +0200]:
> > > To keep things simple, I just changed the instruction mnemonics appropriately,
> > > rather than adding complexity by changing the buffer size/offsets based on ABI.
> > >
> > > Signed-off-by: Alex Rønne Petersen <alex@alexrp.com>
> >
> > fwiw this looks good to me.
> >
> > the only weirdness is that the math code uses __riscv_flen
> > and this code __riscv_float_abi*. i don't know if there
> > is semantic difference.
>
> `__riscv_flen` tells you the width of the FP registers on the target
> CPU. This is semantically distinct from `__riscv_float_abi`. For
> example, while it would probably be a bit silly, there's no particular
> reason why I couldn't target the LP64F ABI on an RV64IMAFDC machine.
> In that case, no code needs to concern itself with the upper bits of
> the FP registers.
>
> I took a quick peek at some of the `__riscv_flen` checks in musl. They
> look ok. They're checking the capabilities of the machine for the
> purposes of performing a computation; they're not making ABI
> decisions. In my silly example above, if I tell the compiler to do so
> with `-march=rv64...d`, it would theoretically be fine for the
> compiler to generate double-precision float instructions for
> computations as long as values are passed/returned according to LP64F
> rules.
If you're building code for -sf or -sp ABI, but could run on a machine
with larger floating point register file, it's possible that the user
could have libc built not to use fp registers at all or only 32-bit
registers (respectively), but the calling application could be built
for and running on a machine with 64-bit registers. In this case we
need to understand what the ABI says. Are the 64-bit register, if
present, call-saved in lower ABI levels where they don't participate
in the calling convention? If so, no #ifdef is sufficient and there
must be a runtime hwcap check here to determine which form of
save/restore to do, like on arm and powerpc.
Rich
next prev parent reply other threads:[~2024-07-23 22:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-29 2:04 Alex Rønne Petersen
2024-07-23 19:48 ` [musl] " Alex Rønne Petersen
2024-07-23 21:22 ` [musl] " Szabolcs Nagy
2024-07-23 22:47 ` Alex Rønne Petersen
2024-07-23 22:58 ` Rich Felker [this message]
2024-07-23 23:12 ` Alex Rønne Petersen
2024-07-23 23:22 ` Rich Felker
2024-07-24 0:09 ` Alex Rønne Petersen
2024-07-24 0:13 ` Rich Felker
2024-08-03 2:02 ` Alex Rønne Petersen
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=20240723225853.GV10433@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=alex@alexrp.com \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).