public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Dmitry Selyutin <ghostmansd@gmail.com>
To: Alan Modra <amodra@gmail.com>
Cc: lkcl <luke.leighton@gmail.com>, Binutils <binutils@sourceware.org>
Subject: Re: Teaching expression() to treat some operations specially
Date: Tue, 12 Jul 2022 07:18:11 +0300	[thread overview]
Message-ID: <CAMqzjeu6N-TSnYGTqgAC=a332yAOXfmJ8RmoRyWsNtOq9KbEgQ@mail.gmail.com> (raw)
In-Reply-To: <Ysy0HDc0+LXQjfZa@squeak.grove.modra.org>

On Tue, Jul 12, 2022 at 2:37 AM Alan Modra <amodra@gmail.com> wrote:
>
> You should not call expression like this without some syntactic
> element being consumed.

The expression() is not the culprit, it's the fact that operand() does
not set all the expression fields from the symbol.
The patch below "fixes" it, though I'm quite dubious regarding whether
this is a fix at all.

diff --git a/gas/expr.c b/gas/expr.c
index f4ea24717d..a46e220526 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -1350,8 +1350,7 @@ operand (expressionS *expressionP, enum expr_mode mode)
           }
         else if (mode != expr_defer && segment == reg_section)
           {
-             expressionP->X_op = O_register;
-             expressionP->X_add_number = S_GET_VALUE (symbolP);
+             *expressionP = *symbol_get_value_expression (symbolP);
           }
         else
           {

However, about using expression() in md_operand(), there's another question.
One of particular cases we're interested in is extending operands with
the vector notation.
For example, *%r3 would mean "vector register %r3, same as %r3, but
operating on a vector".
This is the code we're currently using; what'd be the safe way to
replace expression()?

void
md_operand (expressionS *exp)
{
  bool vector = false;

  if (*input_line_pointer == '*')
    {
      ++input_line_pointer;
      vector = true;
    }

  if (!register_name (exp))
    expression (exp);

  if (vector)
    {
      if (exp->X_op == O_register)
        exp->X_op = O_vector_register;
      else if (exp->X_op == O_constant)
        exp->X_op = O_vector_constant;
      else
        exp->X_op = O_absent;
    }
}

-- 
Best regards,
Dmitry Selyutin

  reply	other threads:[~2022-07-12  4:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-09 16:47 Dmitry Selyutin
2022-07-11  1:01 ` Alan Modra
2022-07-11  2:33   ` lkcl
2022-07-11  3:08     ` Alan Modra
2022-07-11 14:28       ` Dmitry Selyutin
2022-07-11 19:13         ` Dmitry Selyutin
2022-07-11 23:37         ` Alan Modra
2022-07-12  4:18           ` Dmitry Selyutin [this message]
2022-07-12  6:25             ` Jan Beulich
2022-07-12  6:47               ` Dmitry Selyutin
2022-07-12  6:57                 ` Jan Beulich
2022-07-12  8:50                   ` Dmitry Selyutin
2022-07-12 10:44                     ` Jan Beulich
2022-07-12 11:17                       ` Dmitry Selyutin
2022-07-12 11:39                         ` Jan Beulich
2022-07-12  9:01                   ` Dmitry Selyutin
2022-07-12  6:58               ` Dmitry Selyutin

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='CAMqzjeu6N-TSnYGTqgAC=a332yAOXfmJ8RmoRyWsNtOq9KbEgQ@mail.gmail.com' \
    --to=ghostmansd@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=luke.leighton@gmail.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).