]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/gc: make Addrtaken a bool
authorDave Cheney <dave@cheney.net>
Thu, 5 Mar 2015 07:20:54 +0000 (18:20 +1100)
committerDave Cheney <dave@cheney.net>
Fri, 6 Mar 2015 07:03:53 +0000 (07:03 +0000)
Node.Addrtaken is treated as a bool, so make it a bool.

I'll start to batch these changes if they are simple.

Change-Id: I02a3d1131efc4e12b78b83372c1b50f8b160c194
Reviewed-on: https://go-review.googlesource.com/6911
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/internal/gc/closure.go
src/cmd/internal/gc/fmt.go
src/cmd/internal/gc/plive.go
src/cmd/internal/gc/reg.go
src/cmd/internal/gc/subr.go
src/cmd/internal/gc/syntax.go
src/cmd/internal/gc/typecheck.go
src/cmd/internal/gc/walk.go

index d6f657f1253a404ac5230f299a82aeeeb50b1188..1f47547a7de68df603ddc61fad8515262f1c0d47 100644 (file)
@@ -254,10 +254,10 @@ func capturevars(xfunc *Node) {
                v.Outerexpr = nil
 
                // out parameters will be assigned to implicitly upon return.
-               if outer.Class != PPARAMOUT && v.Closure.Addrtaken == 0 && v.Closure.Assigned == 0 && v.Type.Width <= 128 {
+               if outer.Class != PPARAMOUT && !v.Closure.Addrtaken && v.Closure.Assigned == 0 && v.Type.Width <= 128 {
                        v.Byval = 1
                } else {
-                       v.Closure.Addrtaken = 1
+                       v.Closure.Addrtaken = true
                        outer = Nod(OADDR, outer, nil)
                }
 
index 46b02f7b1f3412c72d4aa2efc792c4c8449f9c48..6124ae5096cc530494064a65ebf6c40e785bf347 100644 (file)
@@ -281,7 +281,7 @@ func Jconv(n *Node, flag int) string {
                fp += fmt.Sprintf(" embedded(%d)", n.Embedded)
        }
 
-       if n.Addrtaken != 0 {
+       if n.Addrtaken {
                fp += " addrtaken"
        }
 
index 97e870b57a81410a0ce91a9dc733fcdb87c6de79..27ea38d95ca95efdc3948f3895cc5cf86a3f6ff3 100644 (file)
@@ -587,7 +587,7 @@ func progeffects(prog *obj.Prog, vars []*Node, uevar Bvec, varkill Bvec, avarini
                        // non-tail-call return instructions; see note above
                        // the for loop for details.
                        case PPARAMOUT:
-                               if node.Addrtaken == 0 && prog.To.Type == obj.TYPE_NONE {
+                               if !node.Addrtaken && prog.To.Type == obj.TYPE_NONE {
                                        bvset(uevar, int32(i))
                                }
                        }
@@ -602,7 +602,7 @@ func progeffects(prog *obj.Prog, vars []*Node, uevar Bvec, varkill Bvec, avarini
                for i, node := range vars {
                        switch node.Class &^ PHEAP {
                        case PPARAM:
-                               if node.Addrtaken != 0 {
+                               if node.Addrtaken {
                                        bvset(avarinit, int32(i))
                                }
                                bvset(varkill, int32(i))
@@ -626,7 +626,7 @@ func progeffects(prog *obj.Prog, vars []*Node, uevar Bvec, varkill Bvec, avarini
                                if pos >= int32(len(vars)) || vars[pos] != from.Node {
                                        Fatal("bad bookkeeping in liveness %v %d", Nconv(from.Node.(*Node), 0), pos)
                                }
-                               if ((from.Node).(*Node)).Addrtaken != 0 {
+                               if ((from.Node).(*Node)).Addrtaken {
                                        bvset(avarinit, pos)
                                } else {
                                        if info.Flags&(LeftRead|LeftAddr) != 0 {
@@ -657,7 +657,7 @@ Next:
                                if pos >= int32(len(vars)) || vars[pos] != to.Node {
                                        Fatal("bad bookkeeping in liveness %v %d", Nconv(to.Node.(*Node), 0), pos)
                                }
-                               if ((to.Node).(*Node)).Addrtaken != 0 {
+                               if ((to.Node).(*Node)).Addrtaken {
                                        if prog.As != obj.AVARKILL {
                                                bvset(avarinit, pos)
                                        }
@@ -742,7 +742,7 @@ func printnode(node *Node) {
                p = "^"
        }
        a := ""
-       if node.Addrtaken != 0 {
+       if node.Addrtaken {
                a = "@"
        }
        fmt.Printf(" %v%s%s", Nconv(node, 0), p, a)
index 9b4645223c55adce01a7f4f86855a5371565c922..41200bac6ff0d834a3029f3c8f7beb82b74efab5 100644 (file)
@@ -371,7 +371,7 @@ func mkvar(f *Flow, a *obj.Addr) Bits {
        // If we were better about _ elision, _ = &x would suffice too.
        // The broader := in a closure problem is mentioned in a comment in
        // closure.c:/^typecheckclosure and dcl.c:/^oldname.
-       if node.Addrtaken != 0 {
+       if node.Addrtaken {
                v.addr = 1
        }
 
index a6e9bf3ad8ffd00cb345f7fc3671173216ef3af3..ef043a78199e4b996fa232c56739fe319769a95d 100644 (file)
@@ -1994,7 +1994,7 @@ func cheapexpr(n *Node, init **NodeList) *Node {
  * assignment to it.
  */
 func localexpr(n *Node, t *Type, init **NodeList) *Node {
-       if n.Op == ONAME && (n.Addrtaken == 0 || strings.HasPrefix(n.Sym.Name, "autotmp_")) && (n.Class == PAUTO || n.Class == PPARAM || n.Class == PPARAMOUT) && convertop(n.Type, t, nil) == OCONVNOP {
+       if n.Op == ONAME && (!n.Addrtaken || strings.HasPrefix(n.Sym.Name, "autotmp_")) && (n.Class == PAUTO || n.Class == PPARAM || n.Class == PPARAMOUT) && convertop(n.Type, t, nil) == OCONVNOP {
                return n
        }
 
index 6303502af009d214b14d53680a1bef097f0063c2..a81f8420cf00491af0d94c00155aad24310ec0c5 100644 (file)
@@ -47,7 +47,7 @@ type Node struct {
        Isddd          uint8
        Readonly       bool
        Implicit       uint8
-       Addrtaken      uint8 // address taken, even if not moved to heap
+       Addrtaken      bool  // address taken, even if not moved to heap
        Assigned       uint8 // is the variable ever assigned to
        Captured       uint8 // is the variable captured by a closure
        Byval          uint8 // is the variable captured by value or by reference
index 764b3339802de90a93b4d4f3f6d451d7dd090fe9..f6d51d641830869e6361e1c4338d31a874b9c682 100644 (file)
@@ -825,18 +825,18 @@ OpSwitch:
                r := outervalue(n.Left)
                var l *Node
                for l = n.Left; l != r; l = l.Left {
-                       l.Addrtaken = 1
+                       l.Addrtaken = true
                        if l.Closure != nil {
-                               l.Closure.Addrtaken = 1
+                               l.Closure.Addrtaken = true
                        }
                }
 
                if l.Orig != l && l.Op == ONAME {
                        Fatal("found non-orig name node %v", Nconv(l, 0))
                }
-               l.Addrtaken = 1
+               l.Addrtaken = true
                if l.Closure != nil {
-                       l.Closure.Addrtaken = 1
+                       l.Closure.Addrtaken = true
                }
                defaultlit(&n.Left, nil)
                l = n.Left
index a96ce07905951f038a5f37b6f6cb28b9780436ec..7ba66b044f30ab70fddfcd4d75a94690cca87492 100644 (file)
@@ -96,7 +96,7 @@ func paramoutheap(fn *Node) int {
                switch l.N.Class {
                case PPARAMOUT,
                        PPARAMOUT | PHEAP:
-                       return int(l.N.Addrtaken)
+                       return bool2int(l.N.Addrtaken)
 
                        // stop early - parameters are over
                case PAUTO,
@@ -2516,7 +2516,7 @@ func aliased(n *Node, all *NodeList, stop *NodeList) bool {
                case PAUTO,
                        PPARAM,
                        PPARAMOUT:
-                       if n.Addrtaken != 0 {
+                       if n.Addrtaken {
                                varwrite = 1
                                continue
                        }
@@ -2568,7 +2568,7 @@ func varexpr(n *Node) bool {
                case PAUTO,
                        PPARAM,
                        PPARAMOUT:
-                       if n.Addrtaken == 0 {
+                       if !n.Addrtaken {
                                return true
                        }
                }