]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: teach rulegen to |-expand multiple |s in a single op
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 10 Mar 2019 18:55:49 +0000 (11:55 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 11 Mar 2019 17:40:52 +0000 (17:40 +0000)
commit48d3c32ba9c2cbe4cfded44a150540f15fdf517c
tree0abd10f3db59d8c01ebcaa5d8e95cc0dc7573c78
parent07b4b4a1a87a74d600d483d155ec1744e08df9c3
cmd/compile: teach rulegen to |-expand multiple |s in a single op

I want to be able to write

MOV(Q|Q|L|L|L|W|W|B)loadidx(1|8|1|4|8|1|2|1)

instead of

MOV(Qloadidx1|Qloadidx8|Lloadidx1|Lloadidx4|Lloadidx8|Wloadidx1|Wloadidx2|Bloadidx1)

in rewrite rules.

Both are fairly cryptic and hard to review, but the former
is at least compact, which helps to not obscure the structure
of the rest of the rule.

Support that by adjusting rulegen's expansion.

Instead of looking for an op that begins with "(", ends with " ",
and has exactly one set of parens in it, look for everything of the
form "(...|...)".

That has false positives: Go code in the && conditions and AuxInt expressions.
Those are easily checked for syntactically: && conditions are between && and ->,
and AuxInt expressions are inside square brackets.
After ruling out those false positives, we can keep everything else,
regardless of where it is.

No change to the generated code for existing rules.

Change-Id: I5b70a190e268989504f53cb2cce2f9a50170d8a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/166737
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/rulegen.go