public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Teaching expression() to treat some operations specially
@ 2022-07-09 16:47 Dmitry Selyutin
  2022-07-11  1:01 ` Alan Modra
  0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Selyutin @ 2022-07-09 16:47 UTC (permalink / raw)
  To: Binutils; +Cc: Luke Kenneth Casson Leighton, Alan Modra

Hi folks, I'm still working on SVP64 extension support[0]. I'm now
checking the SVP64 predicates[1].
Recently I stumbled upon the need to be able to resolve some complex
expressions as a single entity.
Here's the exhaustive list we're going to support: 1<<r3, r3, ~r3,
r10, ~r10, r30, ~r30, lt, nl, ge, gt, ng, le, eq, ne, so, un, ns, nu.
All of these can be represented as macros. For example, let's consider
the instruction `sv.setb/dm=~r3/sm=1<<r3 5, 31`.
When SVP64 parsing code sees dm= or sm=, it simply iterates over the
possible arguments[2].
However, we'd also like to have macros support here, like:

    .set DM, ~r3
    .set SM, 1<<r3
    sv.setb/dm=DM/sm=SM 5, 31

The obvious candidate was expression() routine, which I already
re-used for a simpler case when the value is always a constant[3].
However, things like 1<<r3 and ~r3 are more tricky, and I'm not sure
how to handle these.
expression() would, as it seems, defer the calculation, since r3 is a symbol.
Instead, I'd like to teach expression() the knowledge that 1<<r3
combination is special.

Two places I've been thinking of are ppc_parse_name() and register_name().
The first one "hooks" the name lookup algorithm, but it unsurprizingly
only gets "r3" from "1<<r3".
The second one seems like a minor hack, substituting expression()
logic (in fact, expression() is a fallback for it).

To be honest, I'm not sure how to achieve the goal. In fact, I must
teach expression() to treat some operations specially in some
contexts.
Could you, please, recommend me options to achieve the goal? I want to
keep the logic clear to anyone potentially reading this code later.

Thank you!

[0] https://libre-soc.org/
[1] https://libre-soc.org/openpower/sv/svp64/appendix/
[2] https://git.libre-soc.org/?p=binutils-gdb.git;a=blob;f=gas/config/tc-ppc-svp64.c;h=9dfafa20347f5085653439f7bd4d70c1710a205d;hb=refs/heads/svp64-ng#l144
[3] https://git.libre-soc.org/?p=binutils-gdb.git;a=blob;f=gas/config/tc-ppc-svp64.c;h=9dfafa20347f5085653439f7bd4d70c1710a205d;hb=refs/heads/svp64-ng#l349

--
Best regards,
Dmitry Selyutin

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-07-12 11:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-09 16:47 Teaching expression() to treat some operations specially 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
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

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).