public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: lkcl <luke.leighton@gmail.com>
To: Alan Modra <amodra@gmail.com>,Dmitry Selyutin <ghostmansd@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: Teaching expression() to treat some operations specially
Date: Mon, 11 Jul 2022 03:33:55 +0100	[thread overview]
Message-ID: <2A99A5EA-C863-465C-A983-244A48D2E3C3@gmail.com> (raw)
In-Reply-To: <Yst2WXcpFZ3udhPx@squeak.grove.modra.org>

alan thank you for the insights. i am using an unusual mailer which only topposts: rather than subject everyone to that i'm trimming all context.

some background on svp64 predication (which is not part of Power ISA): it is the same concept as RVV and NEC SX Aurora (Cray-style) predicate masks except a bit more sophisticated. basic concept of Predicated Cray Vectors: elements may be dynamically skipped at runtime based on VL bits read from the regiater file:

for i in range(VL):
   if get_mask()&(1<<i) == 0: continue
   // do operation

get_mask() above may be one of the following sources:

* all ones (disables predication)
* the contents of r3, r10, r31 or their bit-inverses
* 1<<r3 i.e. one single unary bit
* the concatenation (and inversion) of a selected CR Field
   from CR0, CR1, ..... CRn
   sm=eq means concatenate CR0.eq CR1.eq CR2.eq as the mask

i particularly like 1<<r3 because it is

for i in range(VL):
   if (1<<GPR(r3))&(1<<i) == 0: continue
   GPR(RT+i) = GPR(RA+i) + GPR(RB+i) # vector add

i.e. just

   GPR(RT+GPR(r3)) = GPR(RA+GPR(r3)) + GPR(RB+GPR(r3))


this should help clear up some potential confusion on the meaning of sm=~r3, it is not the inversion of a static constant "3" (to create 0xfff....fffc) but a mnemonic to put a bitpattern into the 24-bit prefix, "at *instruction execute* time please read then use contents of register r3 as the predicate mask, invert all its bits before passing it on".

we could have used "sm=0b0111" or other numeric code and simply dropped that directly into the 24-bit prefix. however this loses the opportunity to perform macro substitution.

another idea we discussed was to move the "~" to the lhs:

    ~sm=r3 / !sm=r3

or

     sm ~= r3

on the basis that only the rhs gets passed to expression().  in english:

      inverted source mask is r3

readability of 1<<r3 is compromised however by trying something aimilar.  we thought perhaps "sm=ur3" or such, for "source mask is unary from r3" but it is pushing things.

adapting 0_constant to recognise 1<<r3 as a special pattern would help preserve readability greatly. i take it you mean that after the lexer has recognised "1" "<<" "r3" that there is a tree-walk done by cr_operand() that *replaces* the patterns?

l.


  reply	other threads:[~2022-07-11  2:34 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 [this message]
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

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=2A99A5EA-C863-465C-A983-244A48D2E3C3@gmail.com \
    --to=luke.leighton@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=ghostmansd@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).