public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@dabbelt.com>
To: jbeulich@suse.com
Cc: Andrew Waterman <andrew@sifive.com>,
	Jim Wilson <jim.wilson.gcc@gmail.com>,
	nelson@rivosinc.com, Nick Clifton <nickc@redhat.com>,
	binutils@sourceware.org
Subject: Re: [PATCH] gas/RISC-V: adjust assembler for opcode table re-ordering
Date: Mon, 09 Jan 2023 11:07:03 -0800 (PST)	[thread overview]
Message-ID: <mhng-da78c63b-1a53-4a49-8adc-e0e97b9c9259@palmer-ri-x1c9a> (raw)
In-Reply-To: <cc82cc48-0363-71ee-ac17-76619953b5e8@suse.com>

On Mon, 09 Jan 2023 09:07:06 PST (-0800), jbeulich@suse.com wrote:
> On 08.01.2023 00:29, Aurelien Jarno wrote:
>> On 2023-01-06 13:34, Jan Beulich via Binutils wrote:
>>> PR gas/29940
>>>
>>> With the single-operand JAL entry now sitting ahead of the two-operand
>>> one, the parsing of a two-operand insn would first try to parse an 'a'-
>>> style operand, resulting in the insertion of bogus (and otherwise
>>> unused) undefined symbols in the symbol table, having register names.
>>> Since 'a' is used as 1st operand only with J and JAL, and since JAL is
>>> the only insn _also_ allowing for a register as 1st operand (and then
>>> there being a 2nd one), special case this parsing aspect right there.
>>> ---
>>> This, of course, is fragile, but I guess such workarounds are
>>> unavoidable with the chosen approach of (recurring) parsing, and with
>>> register names being special only in certain contexts.
>>>
>>> A more generic approach, then possibly also helping performance, might
>>> be to count the number of operands first, and do full parsing only when
>>> the count matches that in the operand specifier string (at least when
>>> there are multiple insn forms).
>>>
>>> The similar workaround in my_getSmallExpression() actually looks
>>> suspicious to me: I expect that it would get in the way of using equates
>>> "shadowing" names of GPRs.
>>>
>>> --- a/gas/config/tc-riscv.c
>>> +++ b/gas/config/tc-riscv.c
>>> @@ -3266,6 +3266,17 @@ riscv_ip (char *str, struct riscv_cl_ins
>>>  	      continue;
>>>
>>>  	    case 'a': /* 20-bit PC-relative offset.  */
>>> +	      /* Like in my_getSmallExpression() we need to avoid emitting
>>> +		 a stray undefined symbol if the 1st JAL entry doesn't match,
>>> +		 but the 2nd (with 2 operands) might.  */
>>> +	      if (oparg == insn->args)
>>> +		{
>>> +		  asargStart = asarg;
>>> +		  if (reg_lookup (&asarg, RCLASS_GPR, NULL)
>>> +		      && (*asarg == ',' || (ISSPACE (*asarg) && asarg[1] == ',')))
>>> +		    break;
>>> +		  asarg = asargStart;
>>> +		}
>>>  	    jump:
>>>  	      my_getExpression (imm_expr, asarg);
>>>  	      asarg = expr_end;
>>
>> Thanks for the patch. I have tested it and confirmed it fix the problem
>> I reported.
>
> With 2.40 scheduled to be cut in less than a week, may I ask for an arch
> maintainer's view here?

Thanks for fixing this.  I don't have any issues with what's there, but 
looks like I'm also getting some failures (glibc/multilib errno related 
stuff).  I'm trying to bisect those so I can't really get a proper test 
up now, I'll try to do so ASAP as it's really late to have stuff broken.

> Nick, to save a round trip, could you confirm (or otherwise) that this
> fix is then also fine to go on the branch (after having gone into master)?
>
> Thanks, Jan

  reply	other threads:[~2023-01-09 19:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 12:34 Jan Beulich
2023-01-07 23:29 ` Aurelien Jarno
2023-01-09 17:07   ` Jan Beulich
2023-01-09 19:07     ` Palmer Dabbelt [this message]
2023-01-09 21:59       ` Maciej W. Rozycki
2023-01-10  9:25         ` Jan Beulich
2023-01-10 22:58           ` Maciej W. Rozycki
2023-01-11  9:28             ` Jan Beulich
2023-01-12  1:28               ` Maciej W. Rozycki
2023-01-12  8:26                 ` Jan Beulich
2023-01-12  8:40                   ` Andrew Waterman
2023-01-10 12:31     ` Nick Clifton
2023-01-10 20:14       ` Palmer Dabbelt

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=mhng-da78c63b-1a53-4a49-8adc-e0e97b9c9259@palmer-ri-x1c9a \
    --to=palmer@dabbelt.com \
    --cc=andrew@sifive.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=jim.wilson.gcc@gmail.com \
    --cc=nelson@rivosinc.com \
    --cc=nickc@redhat.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).