Teaching expression() to treat some operations specially
Dmitry Selyutin
ghostmansd@gmail.com
Sat Jul 9 16:47:26 GMT 2022
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
More information about the Binutils
mailing list