[PATCH 1/3] RISC-V: re-arrange opcode table for consistent alias handling
Andrew Waterman
andrew@sifive.com
Sat Jul 22 16:55:33 GMT 2023
Just as a reminder, the official aliases are not engraved on stone
tablets. I suspect that, as we go through this exercise, we'll find
cases where we really should retain the aliases, in which case we
should just update the official document.
Aside from that comment, this all sounds fine to me (provided, of
course, the assembler will continue to accept these aliases in
perpetuity).
On Sat, Jul 22, 2023 at 8:15 AM Jeff Law via Binutils
<binutils@sourceware.org> wrote:
>
>
>
> On 7/21/23 16:16, Song Fangrui wrote:
> > On Sun, Jul 16, 2023 at 11:50 PM Jan Beulich <jbeulich@suse.com> wrote:
> >>
> >> On 15.07.2023 00:08, Stefan O'Rear wrote:
> >>> On Fri, Jul 14, 2023, at 5:25 PM, Fangrui Song wrote:
> >>>> On Wed, Jul 12, 2023 at 1:15 AM Jan Beulich <jbeulich@suse.com> wrote:
> >>>>> On 11.07.2023 23:02, Fangrui Song wrote:
> >>>>>> I apologize as I haven't read all prior discussions. For many
> >>>>>> instructions, the "i" form is written in the ISA manual and prevalent.
> >>>>>
> >>>>> Why "prevalent"? The "i"-less forms are mentioned there as well, aren't
> >>>>> they? Then why not use them ...
> >>>>
> >>>> I think aliases like "add rd,rs,imm" (without "i") should be treated
> >>>> as deprecated aliases that we keep just for compatibility.
> >>
> >> That's a matter of taste, I'm inclined to say. But see below.
> >>
> >>>> We should not endorse the use cases by making objdump -d "prefer" this form.
> >>>>
> >>>> When I brought up the topic in the #riscv channel on libera.chat, I
> >>>> got a lot of complaints about having these "deprecated" aliases from
> >>>> folks, including courmisch, jrtc27, muurkha, sorear.
> >>>> As I happen to know two folks' email addresses, I have CCed them in this thread.
> >>>>
> >>>>>> I wonder whether we can give these add/and/xor/etc without "i" lower
> >>>>>> priority so that objdump -d will not show them, even without using -M
> >>>>>> no-aliases.
> >>>>>
> >>>>> ... unless use of aliases was suppressed? In other arches' assembly
> >>>>> that I know (to some degree) and which knows the concept of aliases,
> >>>>> aliases are typically the preferred way of disassembling, for
> >>>>> typically producing easier to grok output.
> >>>>
> >>>> AIUI aliases for other architectures are indeeded preferred (use my
> >>>> understanding of llvm-objdump -d output).
> >>>> This RISC-V case is not, though.
> >>>
> >>> The aliases that are documented in [1] are preferred for use in disassembly.
> >>> The other aliases, which gas supports for compatibility with old versions of
> >>> itself but which were never part of any spec, are not preferred.
> >>
> >> This would be a fair policy, as long as there's a not overly troublesome
> >> way of getting further entries on that list (whenever obvious instances
> >> turn up). My main goal, after all, is consistency. What exact policy
> >> underlies this is secondary to me.
> >>
> >> Jan
> >
> > Jan and Nelson, If this is agreed that we should use "addi" instead of
> > the gas alias "add" in situations like addi x0, x0, 1, can either of
> > you make a change to restore the old behavior? Thanks!
> Given the ISA docs use "addi", we should follow that. While GAS does
> provide aliases which allow things like "add" with an immediate operand,
> those are non-standard and should not be preferred.
>
> In an ideal world the output of objdump should be compatible with what
> GAS accepts as well as what the LLVM toolchain accepts -- while we may
> not be there, there's no good reason to introduce additional
> inconsistencies across the tools.
>
> So as Stefan noted, there are a set of aliases defined by the RISC-V
> assembly reference. Those are the only ones that should be preferred.
>
> > https://github.com/riscv-non-isa/riscv-asm-manual/blob/master/riscv-asm.md
>
>
> jeff
>
More information about the Binutils
mailing list