]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: minor simplifications in rulegen
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 23 Sep 2019 22:10:25 +0000 (23:10 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 27 Sep 2019 18:58:08 +0000 (18:58 +0000)
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>

src/cmd/compile/internal/ssa/gen/rulegen.go
src/cmd/compile/internal/ssa/rewriteS390X.go

index 994e5b932f528a0ca4289dfbed80e3b58bbf7b3d..7c02778181726b5ef39f6d0532a68a6fd646a25d 100644 (file)
@@ -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
 
index ac2fbf80b81a047ce69bc552f40963ad39f7c3ae..84fe1473c02e4fcee25c0d554df1f782f804fc81 100644 (file)
@@ -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: