public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: jacob navia <jacob@jacob.remcomp.fr>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
	binutils@sourceware.org, Paul Koning <paulkoning@comcast.net>
Subject: Re: P.S. Follow up to my last post
Date: Mon, 28 Aug 2023 08:17:47 +0200	[thread overview]
Message-ID: <3a591c4f-806b-4c40-f127-46bd9a065206@suse.com> (raw)
In-Reply-To: <44B3B136-BE36-4D9C-AF87-B39228860B27@jacob.remcomp.fr>

On 25.08.2023 21:44, jacob navia wrote:
> I am just invoking the assembler with its default settings:
> 
> ~/star64 $ as -o test.o test.s
> 
> The assembler is testing the default architecture here:
> Function: riscv_ip
> 
> 	for (; insn && insn->name && strcmp(insn->name,str) == 0; insn++) {
> #if 0
> 		if ((insn->xlen_requirement != 0) && (xlen != insn->xlen_requirement))
> 			continue;
> 
> 		if (!riscv_multi_subset_supports(&riscv_rps_as,insn->insn_class)) {
> 			error.missing_ext = riscv_multi_subset_supports_ext(&riscv_rps_as,
> 							    insn->insn_class);
> 			continue;
> 		}
> #endif
> 
> The #if 0/#endif were added by me. I think those tests do not belong here. The assembler should assemble and not test if the instruction is legal. If the instruction is illegal the program will crash at run-time, something not that unusual if you are programming in assembler!

Having a program crash at runtime when this can be avoided at build time is
deemed undesirable by many people, including me. I did point out before that
there are two approaches for assemblers - default-enabling everything and
default-disabling everything except the base architecture insns. To a large
part this is a decision to be taken by the people writing an assembler. But
there are technical constraints as well: As soon as you have two conflicting
extensions (which RISC-V was always allowing for, and which it now actively
has), the former model won't work very well anymore.

Of course you're free to propose a patch allowing the alternative model (via
command line option and/or directive). Obviously whether that'll be approved
is unknown up front.

> And if you are assembling compiler output, it is up to the compiler to furnish the correct instructions.

Yes. Plus, with an assembler following the former model, the necessary
directives. (As an aside, compilers aren't bug-free, and hence the assembler
still applying some sanity checks makes some sense.)

> Tiny-asm doesn’t test any instruction compliance and that is why it works out of the box!

As said, which model to use is up to the writers of any particular assembler.

Jan

  reply	other threads:[~2023-08-28  6:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AEF14E89-14CF-4474-8822-B0139F3F740B@jacob.remcomp.fr>
2023-08-25 15:32 ` Palmer Dabbelt
2023-08-25 16:10   ` jacob navia
2023-08-25 17:03     ` Paul Koning
2023-08-25 19:44       ` jacob navia
2023-08-28  6:17         ` Jan Beulich [this message]
2023-08-28  7:04           ` jacob navia
2023-08-25 11:52 jacob navia
2023-08-25 12:00 ` Jan Beulich
2023-08-25 13:07   ` jacob navia
2023-08-25 13:30     ` Jan Beulich
2023-08-25 13:40       ` Paul Koning

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=3a591c4f-806b-4c40-f127-46bd9a065206@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=jacob@jacob.remcomp.fr \
    --cc=palmer@dabbelt.com \
    --cc=paulkoning@comcast.net \
    /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).