Skip to content

Commit

Permalink
cmd/{5,6,8,9}g, cmd/internal/gc: use bools for is* and okfor*
Browse files Browse the repository at this point in the history
No functional changes.

This diff was generated as follows:

* Manually edit cmd/internal/gc/go.go to update types and group variables.
* Manually edit initialization in cmd/internal/gc/align.go--localized s/1/true.
* Manually fix the handling of sign in cmd/internal/gc/walk.go in func bounded (near line 4000).
* Manually update go.y and regenerate y.go.
* Run gofmt -r many times to do the rest, using https://gist.github.com/josharian/0f61dbb2dff81f938e70.

toolstash -cmp on the stdlib comes back green.

Change-Id: I19766ed551714e51b325133e7138818d117b3a9a
Reviewed-on: https://go-review.googlesource.com/6530
Reviewed-by: Russ Cox <rsc@golang.org>
  • Loading branch information
josharian committed Mar 3, 2015
1 parent 85c6f71 commit 25da594
Show file tree
Hide file tree
Showing 32 changed files with 294 additions and 304 deletions.
20 changes: 10 additions & 10 deletions src/cmd/5g/cgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func cgen(n *gc.Node, res *gc.Node) {

// if both are addressable, move
if n.Addable != 0 && res.Addable != 0 {
if gc.Is64(n.Type) || gc.Is64(res.Type) || n.Op == gc.OREGISTER || res.Op == gc.OREGISTER || gc.Iscomplex[n.Type.Etype] != 0 || gc.Iscomplex[res.Type.Etype] != 0 {
if gc.Is64(n.Type) || gc.Is64(res.Type) || n.Op == gc.OREGISTER || res.Op == gc.OREGISTER || gc.Iscomplex[n.Type.Etype] || gc.Iscomplex[res.Type.Etype] {
gmove(n, res)
} else {
var n1 gc.Node
Expand Down Expand Up @@ -148,7 +148,7 @@ func cgen(n *gc.Node, res *gc.Node) {
}

// if n is sudoaddable generate addr and move
if !gc.Is64(n.Type) && !gc.Is64(res.Type) && gc.Iscomplex[n.Type.Etype] == 0 && gc.Iscomplex[res.Type.Etype] == 0 {
if !gc.Is64(n.Type) && !gc.Is64(res.Type) && !gc.Iscomplex[n.Type.Etype] && !gc.Iscomplex[res.Type.Etype] {
a := optoas(gc.OAS, n.Type)
var w int
var addr obj.Addr
Expand Down Expand Up @@ -220,7 +220,7 @@ func cgen(n *gc.Node, res *gc.Node) {
var f0 gc.Node
var n1 gc.Node
var n2 gc.Node
if nl != nil && gc.Isfloat[n.Type.Etype] != 0 && gc.Isfloat[nl.Type.Etype] != 0 {
if nl != nil && gc.Isfloat[n.Type.Etype] && gc.Isfloat[nl.Type.Etype] {
// floating-point.
regalloc(&f0, nl.Type, res)

Expand Down Expand Up @@ -338,7 +338,7 @@ func cgen(n *gc.Node, res *gc.Node) {
regalloc(&n1, nl.Type, res)
gmove(nl, &n1)
} else {
if n.Type.Width > int64(gc.Widthptr) || gc.Is64(nl.Type) || gc.Isfloat[nl.Type.Etype] != 0 {
if n.Type.Width > int64(gc.Widthptr) || gc.Is64(nl.Type) || gc.Isfloat[nl.Type.Etype] {
gc.Tempname(&n1, nl.Type)
} else {
regalloc(&n1, nl.Type, res)
Expand All @@ -347,7 +347,7 @@ func cgen(n *gc.Node, res *gc.Node) {
}

var n2 gc.Node
if n.Type.Width > int64(gc.Widthptr) || gc.Is64(n.Type) || gc.Isfloat[n.Type.Etype] != 0 {
if n.Type.Width > int64(gc.Widthptr) || gc.Is64(n.Type) || gc.Isfloat[n.Type.Etype] {
gc.Tempname(&n2, n.Type)
} else {
regalloc(&n2, n.Type, nil)
Expand Down Expand Up @@ -1269,7 +1269,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
gc.OGE:
a := int(n.Op)
if !true_ {
if gc.Isfloat[nl.Type.Etype] != 0 {
if gc.Isfloat[nl.Type.Etype] {
// brcom is not valid on floats when NaN is involved.
p1 := gc.Gbranch(arm.AB, nil, 0)

Expand Down Expand Up @@ -1328,7 +1328,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
break
}

if gc.Iscomplex[nl.Type.Etype] != 0 {
if gc.Iscomplex[nl.Type.Etype] {
gc.Complexbool(a, nl, nr, true_, likely, to)
break
}
Expand Down Expand Up @@ -1408,7 +1408,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
gmove(&tmp, &n2)

gcmp(optoas(gc.OCMP, nr.Type), &n1, &n2)
if gc.Isfloat[nl.Type.Etype] != 0 {
if gc.Isfloat[nl.Type.Etype] {
if n.Op == gc.ONE {
p1 := gc.Gbranch(arm.ABVS, nr.Type, likely)
gc.Patch(gc.Gbranch(a, nr.Type, likely), to)
Expand Down Expand Up @@ -1441,7 +1441,7 @@ func stkof(n *gc.Node) int32 {

case gc.ODOT:
t := n.Left.Type
if gc.Isptr[t.Etype] != 0 {
if gc.Isptr[t.Etype] {
break
}
off := stkof(n.Left)
Expand All @@ -1468,7 +1468,7 @@ func stkof(n *gc.Node) int32 {
gc.OCALLINTER,
gc.OCALLFUNC:
t := n.Left.Type
if gc.Isptr[t.Etype] != 0 {
if gc.Isptr[t.Etype] {
t = t.Type
}

Expand Down
10 changes: 5 additions & 5 deletions src/cmd/5g/ggen.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func cgen_callret(n *gc.Node, res *gc.Node) {
*/
func cgen_aret(n *gc.Node, res *gc.Node) {
t := n.Left.Type
if gc.Isptr[t.Etype] != 0 {
if gc.Isptr[t.Etype] {
t = t.Type
}

Expand Down Expand Up @@ -466,7 +466,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
case gc.TINT32,
gc.TUINT32:
var p *obj.Prog
if gc.Issigned[t.Etype] != 0 {
if gc.Issigned[t.Etype] {
p = gins(arm.AMULL, &n2, nil)
} else {
p = gins(arm.AMULLU, &n2, nil)
Expand Down Expand Up @@ -532,13 +532,13 @@ func cgen_shift(op int, bounded bool, nl *gc.Node, nr *gc.Node, res *gc.Node) {
if sc == 0 {
} else // nothing to do
if sc >= uint64(nl.Type.Width*8) {
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] != 0 {
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
gshift(arm.AMOVW, &n1, arm.SHIFT_AR, int32(w), &n1)
} else {
gins(arm.AEOR, &n1, &n1)
}
} else {
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] != 0 {
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
gshift(arm.AMOVW, &n1, arm.SHIFT_AR, int32(sc), &n1)
} else if op == gc.ORSH {
gshift(arm.AMOVW, &n1, arm.SHIFT_LR, int32(sc), &n1) // OLSH
Expand Down Expand Up @@ -617,7 +617,7 @@ func cgen_shift(op int, bounded bool, nl *gc.Node, nr *gc.Node, res *gc.Node) {
if op == gc.ORSH {
var p1 *obj.Prog
var p2 *obj.Prog
if gc.Issigned[nl.Type.Etype] != 0 {
if gc.Issigned[nl.Type.Etype] {
p1 = gshift(arm.AMOVW, &n2, arm.SHIFT_AR, int32(w)-1, &n2)
p2 = gregshift(arm.AMOVW, &n2, arm.SHIFT_AR, &n1, &n2)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/5g/gsubr.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func gmove(f *gc.Node, t *gc.Node) {
tt := gc.Simsimtype(t.Type)
cvt := t.Type

if gc.Iscomplex[ft] != 0 || gc.Iscomplex[tt] != 0 {
if gc.Iscomplex[ft] || gc.Iscomplex[tt] {
gc.Complexmove(f, t)
return
}
Expand Down
26 changes: 13 additions & 13 deletions src/cmd/6g/cgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func cgen(n *gc.Node, res *gc.Node) {
f = 0
}

if gc.Iscomplex[n.Type.Etype] == 0 {
if !gc.Iscomplex[n.Type.Etype] {
a := optoas(gc.OAS, res.Type)
var addr obj.Addr
if sudoaddable(a, res, &addr) {
Expand Down Expand Up @@ -202,7 +202,7 @@ func cgen(n *gc.Node, res *gc.Node) {
}
}

if gc.Iscomplex[n.Type.Etype] == 0 {
if !gc.Iscomplex[n.Type.Etype] {
a := optoas(gc.OAS, n.Type)
var addr obj.Addr
if sudoaddable(a, n, &addr) {
Expand Down Expand Up @@ -269,7 +269,7 @@ func cgen(n *gc.Node, res *gc.Node) {
return

case gc.OMINUS:
if gc.Isfloat[nl.Type.Etype] != 0 {
if gc.Isfloat[nl.Type.Etype] {
nr = gc.Nodintconst(-1)
gc.Convlit(&nr, n.Type)
a = optoas(gc.OMUL, nl.Type)
Expand Down Expand Up @@ -489,7 +489,7 @@ func cgen(n *gc.Node, res *gc.Node) {

case gc.OMOD,
gc.ODIV:
if gc.Isfloat[n.Type.Etype] != 0 {
if gc.Isfloat[n.Type.Etype] {
a = optoas(int(n.Op), nl.Type)
goto abop
}
Expand Down Expand Up @@ -777,7 +777,7 @@ func agenr(n *gc.Node, a *gc.Node, res *gc.Node) {
// type of the index
t := gc.Types[gc.TUINT64]

if gc.Issigned[n1.Type.Etype] != 0 {
if gc.Issigned[n1.Type.Etype] {
t = gc.Types[gc.TINT64]
}

Expand Down Expand Up @@ -1053,10 +1053,10 @@ func igen(n *gc.Node, a *gc.Node, res *gc.Node) {
// Could do the same for slice except that we need
// to use the real index for the bounds checking.
case gc.OINDEX:
if gc.Isfixedarray(n.Left.Type) || (gc.Isptr[n.Left.Type.Etype] != 0 && gc.Isfixedarray(n.Left.Left.Type)) {
if gc.Isfixedarray(n.Left.Type) || (gc.Isptr[n.Left.Type.Etype] && gc.Isfixedarray(n.Left.Left.Type)) {
if gc.Isconst(n.Right, gc.CTINT) {
// Compute &a.
if gc.Isptr[n.Left.Type.Etype] == 0 {
if !gc.Isptr[n.Left.Type.Etype] {
igen(n.Left, a, res)
} else {
var n1 gc.Node
Expand Down Expand Up @@ -1200,7 +1200,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
gc.OGE:
a := int(n.Op)
if !true_ {
if gc.Isfloat[nr.Type.Etype] != 0 {
if gc.Isfloat[nr.Type.Etype] {
// brcom is not valid on floats when NaN is involved.
p1 := gc.Gbranch(obj.AJMP, nil, 0)

Expand Down Expand Up @@ -1266,7 +1266,7 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
break
}

if gc.Iscomplex[nl.Type.Etype] != 0 {
if gc.Iscomplex[nl.Type.Etype] {
gc.Complexbool(a, nl, nr, true_, likely, to)
break
}
Expand Down Expand Up @@ -1309,15 +1309,15 @@ func bgen(n *gc.Node, true_ bool, likely int, to *obj.Prog) {
l := &n1

r := &n2
if gc.Isfloat[nl.Type.Etype] != 0 && (a == gc.OGT || a == gc.OGE) {
if gc.Isfloat[nl.Type.Etype] && (a == gc.OGT || a == gc.OGE) {
l = &n2
r = &n1
a = gc.Brrev(a)
}

gins(optoas(gc.OCMP, nr.Type), l, r)

if gc.Isfloat[nr.Type.Etype] != 0 && (n.Op == gc.OEQ || n.Op == gc.ONE) {
if gc.Isfloat[nr.Type.Etype] && (n.Op == gc.OEQ || n.Op == gc.ONE) {
if n.Op == gc.OEQ {
// neither NE nor P
p1 := gc.Gbranch(x86.AJNE, nil, -likely)
Expand Down Expand Up @@ -1369,7 +1369,7 @@ func stkof(n *gc.Node) int64 {

case gc.ODOT:
t := n.Left.Type
if gc.Isptr[t.Etype] != 0 {
if gc.Isptr[t.Etype] {
break
}
off := stkof(n.Left)
Expand All @@ -1396,7 +1396,7 @@ func stkof(n *gc.Node) int64 {
gc.OCALLINTER,
gc.OCALLFUNC:
t := n.Left.Type
if gc.Isptr[t.Etype] != 0 {
if gc.Isptr[t.Etype] {
t = t.Type
}

Expand Down
12 changes: 6 additions & 6 deletions src/cmd/6g/ggen.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func cgen_callret(n *gc.Node, res *gc.Node) {
*/
func cgen_aret(n *gc.Node, res *gc.Node) {
t := n.Left.Type
if gc.Isptr[t.Etype] != 0 {
if gc.Isptr[t.Etype] {
t = t.Type
}

Expand Down Expand Up @@ -456,7 +456,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {

t0 := t
check := 0
if gc.Issigned[t.Etype] != 0 {
if gc.Issigned[t.Etype] {
check = 1
if gc.Isconst(nl, gc.CTINT) && gc.Mpgetfix(nl.Val.U.Xval) != -(1<<uint64(t.Width*8-1)) {
check = 0
Expand All @@ -466,7 +466,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
}

if t.Width < 4 {
if gc.Issigned[t.Etype] != 0 {
if gc.Issigned[t.Etype] {
t = gc.Types[gc.TINT32]
} else {
t = gc.Types[gc.TUINT32]
Expand Down Expand Up @@ -543,7 +543,7 @@ func dodiv(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
var olddx gc.Node
var dx gc.Node
savex(x86.REG_DX, &dx, &olddx, res, t)
if gc.Issigned[t.Etype] == 0 {
if !gc.Issigned[t.Etype] {
gc.Nodconst(&n4, t, 0)
gmove(&n4, &dx)
} else {
Expand Down Expand Up @@ -873,7 +873,7 @@ func cgen_shift(op int, bounded bool, nl *gc.Node, nr *gc.Node, res *gc.Node) {
gc.Nodconst(&n3, tcount, nl.Type.Width*8)
gins(optoas(gc.OCMP, tcount), &n1, &n3)
p1 := gc.Gbranch(optoas(gc.OLT, tcount), nil, +1)
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] != 0 {
if op == gc.ORSH && gc.Issigned[nl.Type.Etype] {
gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
gins(a, &n3, &n2)
} else {
Expand Down Expand Up @@ -924,7 +924,7 @@ func cgen_bmul(op int, nl *gc.Node, nr *gc.Node, res *gc.Node) {
// perform full-width multiplication.
t := gc.Types[gc.TUINT64]

if gc.Issigned[nl.Type.Etype] != 0 {
if gc.Issigned[nl.Type.Etype] {
t = gc.Types[gc.TINT64]
}
var n1 gc.Node
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/6g/gsubr.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func gmove(f *gc.Node, t *gc.Node) {
tt := gc.Simsimtype(t.Type)
cvt := t.Type

if gc.Iscomplex[ft] != 0 || gc.Iscomplex[tt] != 0 {
if gc.Iscomplex[ft] || gc.Iscomplex[tt] {
gc.Complexmove(f, t)
return
}
Expand All @@ -330,13 +330,13 @@ func gmove(f *gc.Node, t *gc.Node) {
// some constants can't move directly to memory.
if gc.Ismem(t) {
// float constants come from memory.
if gc.Isfloat[tt] != 0 {
if gc.Isfloat[tt] {
goto hard
}

// 64-bit immediates are really 32-bit sign-extended
// unless moving into a register.
if gc.Isint[tt] != 0 {
if gc.Isint[tt] {
if gc.Mpcmpfixfix(con.Val.U.Xval, gc.Minintval[gc.TINT32]) < 0 {
goto hard
}
Expand Down
Loading

0 comments on commit 25da594

Please sign in to comment.