public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Waterman <andrew@sifive.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
	Jim Wilson <jim.wilson.gcc@gmail.com>,
	Nelson Chu <nelson.chu@sifive.com>,
	Binutils <binutils@sourceware.org>
Subject: Re: RISC-V: observations / questions
Date: Sun, 27 Feb 2022 19:20:48 -0800	[thread overview]
Message-ID: <CA++6G0AA-NJoAowcOMj7uCSoPf_7vNfj2sOd-Vdx8YD02rhJMA@mail.gmail.com> (raw)
In-Reply-To: <eb192f05-c3cd-d3da-6ec8-d57627bc129f@suse.com>

On Fri, Feb 25, 2022 at 6:59 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> Hello,
>
> besides the two relatively simple patches that I have sent earlier
> today, I do have a few more questions:
>
> 1) Many insn encodings using x0 as the destination are marked as hint
> encodings. Wouldn't things like "add x0, x1, x2" therefore better be
> at least warned about?

Encodings like that should not issue warnings, for a few reasons:
- It's always functionally correct to include stray HINTs in programs,
since by definition they don't affect architectural state.
- This style provides a clean way to encode hints before they've been
added to binutils.
- This style facilitates writing test programs.

>
> 2) Insns like "beq x0, x0, ." (perhaps not very useful outside of
> assembler / disassembler test suites) result in odd ".L0 " labels in
> the object's symbol table. My best guess so far was that this may be
> a result of "#define tc_fix_adjustable(fixp) 0". As these labels are
> somewhat confusing - would there be a way to suppress their emission?
>
> 3) When the assembler can determine a branch's destination, e.g. in
> "beq x0, x0, .+1", wouldn't it be useful to warn about the non-even
> destination address? And with the C extension disabled even about
> any one not evenly divisible by 4?

(Only in response to the second question:)  It's legal to include
branches to addresses that aren't divisible by 4 (but are divisible by
2) when C is disabled; the trap only occurs if the branch is taken.
Prohibiting these branches' inclusion would make it harder to write
test programs.

>
> 4) A number of CSRs are valid in RV32 mode only. Shouldn't their use
> be diagnosed when assembling 64-bit code? (I thought I had seen a
> patch to this effect, but not overly old gas still happily accepts
> them.)
>
> 5) While possibly not too interesting for RV32, in RV64 auipc and
> lui have immediate operands which are sign-extended. Yet gas chokes
> on any of
>
>         auipc   x31, -0x100
>         lui     x31, -0x100
>         c.lui   x31, -0x20
>
> Shouldn't signed operands be permitted (if not required) there, and
> then ideally permitted (but not required) also on RV32?

IMO, changing the set of immediates that these instructions can accept
risks causing more confusion than it resolves.  Part of the reason is
they already accept large unsigned immediates (e.g., lui t0, 0xfffff),
which is an odd holdover from the MIPS assembler, but one we can't
change for backwards-compatibility reasons.  IMO, it seems a bit funky
to accept both [-0x80000, -1] and [0x80000, 0xfffff] to refer to the
same set of numbers.

>
> Thanks for any helpful insight,
> Jan
>

      reply	other threads:[~2022-02-28  3:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 14:59 Jan Beulich
2022-02-28  3:20 ` Andrew Waterman [this message]

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=CA++6G0AA-NJoAowcOMj7uCSoPf_7vNfj2sOd-Vdx8YD02rhJMA@mail.gmail.com \
    --to=andrew@sifive.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=jim.wilson.gcc@gmail.com \
    --cc=nelson.chu@sifive.com \
    --cc=palmer@dabbelt.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).