Skip to content
Permalink
Browse files

cmd/compile: minor simplifications in rulegen

First, be consistent about declaring typ as &b.Func.Config.Types and
not &config.Types. Not particularly better, and it barely changes the
output, but we're more consistent now.

Second, remove a bit of duplication when handling the typ, auxint, and
aux variables.

Third and last, remove a stray canFail assignment; we ended up setting
that in add, not breakf, so it's not necessary to set it manually if we
don't use breakf.

Updates #33644.

Change-Id: I75999cb223a201969266fbfeae043599fa27fac5
Reviewed-on: https://go-review.googlesource.com/c/go/+/196803
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information...
mvdan committed Sep 23, 2019
1 parent 95b8cbf commit bdf0fe54480034cd21e36cfed6e44f10f4cb5c92
Showing with 14 additions and 23 deletions.
  1. +13 −21 src/cmd/compile/internal/ssa/gen/rulegen.go
  2. +1 −2 src/cmd/compile/internal/ssa/rewriteS390X.go
@@ -237,7 +237,7 @@ func genRulesSuffix(arch arch, suff string) {
// so we can make this one function with a switch.
fn = &Func{kind: "Block"}
fn.add(declf("config", "b.Func.Config"))
fn.add(declf("typ", "&config.Types"))
fn.add(declf("typ", "&b.Func.Config.Types"))
fn.add(declf("v", "b.Control"))

sw = &Switch{expr: exprf("b.Kind")}
@@ -851,28 +851,21 @@ func genMatch0(rr *RuleRewrite, arch arch, match, v string) (pos, checkOp string
pos = v + ".Pos"
}

if typ != "" {
if !token.IsIdentifier(typ) || rr.declared(typ) {
// code or variable
rr.add(breakf("%s.Type != %s", v, typ))
} else {
rr.add(declf(typ, "%s.Type", v))
}
}
if auxint != "" {
if !token.IsIdentifier(auxint) || rr.declared(auxint) {
// code or variable
rr.add(breakf("%s.AuxInt != %s", v, auxint))
} else {
rr.add(declf(auxint, "%s.AuxInt", v))
for _, e := range []struct {
name, field string
}{
{typ, "Type"},
{auxint, "AuxInt"},
{aux, "Aux"},
} {
if e.name == "" {
continue
}
}
if aux != "" {
if !token.IsIdentifier(aux) || rr.declared(aux) {
if !token.IsIdentifier(e.name) || rr.declared(e.name) {
// code or variable
rr.add(breakf("%s.Aux != %s", v, aux))
rr.add(breakf("%s.%s != %s", v, e.field, e.name))
} else {
rr.add(declf(aux, "%s.Aux", v))
rr.add(declf(e.name, "%s.%s", v, e.field))
}
}

@@ -921,7 +914,6 @@ func genMatch0(rr *RuleRewrite, arch arch, match, v string) (pos, checkOp string
rr.add(declf(argname, "%s.Args[%d]", v, i))
bexpr := exprf("%s.Op != addLater", argname)
rr.add(&CondBreak{expr: bexpr})
rr.canFail = true // since we're not using breakf
argPos, argCheckOp := genMatch0(rr, arch, arg, argname)
bexpr.(*ast.BinaryExpr).Y.(*ast.Ident).Name = argCheckOp

@@ -36448,8 +36448,7 @@ func rewriteValueS390X_OpZeroExt8to64_0(v *Value) bool {
}
}
func rewriteBlockS390X(b *Block) bool {
config := b.Func.Config
typ := &config.Types
typ := &b.Func.Config.Types
v := b.Control
switch b.Kind {
case BlockS390XBRC:

0 comments on commit bdf0fe5

Please sign in to comment.
You can’t perform that action at this time.