cmd/compile: merge Node.Opt and Node.Val behind access methods
$ sizeof -p cmd/compile/internal/gc Node
Node 144
$
Change-Id: I688e3790964fe42f48c19f697ec38094a92fe1c1
Reviewed-on: https://go-review.googlesource.com/10531
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index 7af0e7e..c0fbc75 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -363,7 +363,7 @@
}
t := n.Type
- return Smallintconst(l) && Smallintconst(r) && (t.Type.Width == 0 || Mpgetfix(r.Val.U.(*Mpint)) < (1<<16)/t.Type.Width)
+ return Smallintconst(l) && Smallintconst(r) && (t.Type.Width == 0 || Mpgetfix(r.Val().U.(*Mpint)) < (1<<16)/t.Type.Width)
}
/*
@@ -1220,7 +1220,7 @@
Yyerror("index out of bounds")
}
} else if Isconst(n.Left, CTSTR) {
- n.Bounded = bounded(r, int64(len(n.Left.Val.U.(string))))
+ n.Bounded = bounded(r, int64(len(n.Left.Val().U.(string))))
if Debug['m'] != 0 && n.Bounded && !Isconst(n.Right, CTINT) {
Warn("index bounds check elided")
}
@@ -1231,16 +1231,16 @@
// replace "abc"[1] with 'b'.
// delayed until now because "abc"[1] is not
// an ideal constant.
- v := Mpgetfix(n.Right.Val.U.(*Mpint))
+ v := Mpgetfix(n.Right.Val().U.(*Mpint))
- Nodconst(n, n.Type, int64(n.Left.Val.U.(string)[v]))
+ Nodconst(n, n.Type, int64(n.Left.Val().U.(string)[v]))
n.Typecheck = 1
}
}
}
if Isconst(n.Right, CTINT) {
- if Mpcmpfixfix(n.Right.Val.U.(*Mpint), &mpzero) < 0 || Mpcmpfixfix(n.Right.Val.U.(*Mpint), Maxintval[TINT]) > 0 {
+ if Mpcmpfixfix(n.Right.Val().U.(*Mpint), &mpzero) < 0 || Mpcmpfixfix(n.Right.Val().U.(*Mpint), Maxintval[TINT]) > 0 {
Yyerror("index out of bounds")
}
}
@@ -1355,7 +1355,7 @@
// comparing the lengths instead will yield the same result
// without the function call.
case OCMPSTR:
- if (Isconst(n.Left, CTSTR) && len(n.Left.Val.U.(string)) == 0) || (Isconst(n.Right, CTSTR) && len(n.Right.Val.U.(string)) == 0) {
+ if (Isconst(n.Left, CTSTR) && len(n.Left.Val().U.(string)) == 0) || (Isconst(n.Right, CTSTR) && len(n.Right.Val().U.(string)) == 0) {
r := Nod(int(n.Etype), Nod(OLEN, n.Left, nil), Nod(OLEN, n.Right, nil))
typecheck(&r, Erv)
walkexpr(&r, init)
@@ -2027,7 +2027,7 @@
n = l.N
if n.Op == OLITERAL {
- switch n.Val.Ctype() {
+ switch n.Val().Ctype() {
case CTRUNE:
defaultlit(&n, runetype)
@@ -2828,7 +2828,7 @@
sz := int64(0)
for l := n.List; l != nil; l = l.Next {
if n.Op == OLITERAL {
- sz += int64(len(n.Val.U.(string)))
+ sz += int64(len(n.Val().U.(string)))
}
}
@@ -3383,7 +3383,7 @@
case OINDEX:
ar = a.Right
br = b.Right
- if !Isconst(ar, CTINT) || !Isconst(br, CTINT) || Mpcmpfixfix(ar.Val.U.(*Mpint), br.Val.U.(*Mpint)) != 0 {
+ if !Isconst(ar, CTINT) || !Isconst(br, CTINT) || Mpcmpfixfix(ar.Val().U.(*Mpint), br.Val().U.(*Mpint)) != 0 {
return false
}
}
@@ -3419,9 +3419,9 @@
w := int(l.Type.Width * 8)
if Smallintconst(l.Right) && Smallintconst(r.Right) {
- sl := int(Mpgetfix(l.Right.Val.U.(*Mpint)))
+ sl := int(Mpgetfix(l.Right.Val().U.(*Mpint)))
if sl >= 0 {
- sr := int(Mpgetfix(r.Right.Val.U.(*Mpint)))
+ sr := int(Mpgetfix(r.Right.Val().U.(*Mpint)))
if sr >= 0 && sl+sr == w {
// Rewrite left shift half to left rotate.
if l.Op == OLSH {
@@ -3432,7 +3432,7 @@
n.Op = OLROT
// Remove rotate 0 and rotate w.
- s := int(Mpgetfix(n.Right.Val.U.(*Mpint)))
+ s := int(Mpgetfix(n.Right.Val().U.(*Mpint)))
if s == 0 || s == w {
n = n.Left
@@ -3475,7 +3475,7 @@
// x*0 is 0 (and side effects of x).
var pow int
var w int
- if Mpgetfix(nr.Val.U.(*Mpint)) == 0 {
+ if Mpgetfix(nr.Val().U.(*Mpint)) == 0 {
cheapexpr(nl, init)
Nodconst(n, n.Type, 0)
goto ret
@@ -3568,10 +3568,10 @@
m.W = w
if Issigned[nl.Type.Etype] {
- m.Sd = Mpgetfix(nr.Val.U.(*Mpint))
+ m.Sd = Mpgetfix(nr.Val().U.(*Mpint))
Smagic(&m)
} else {
- m.Ud = uint64(Mpgetfix(nr.Val.U.(*Mpint)))
+ m.Ud = uint64(Mpgetfix(nr.Val().U.(*Mpint)))
Umagic(&m)
}
@@ -3765,7 +3765,7 @@
// n = nl & (nr-1)
n.Op = OAND
- Nodconst(nc, nl.Type, Mpgetfix(nr.Val.U.(*Mpint))-1)
+ Nodconst(nc, nl.Type, Mpgetfix(nr.Val().U.(*Mpint))-1)
} else {
// n = nl >> pow
n.Op = ORSH
@@ -3795,7 +3795,7 @@
bits := int32(8 * n.Type.Width)
if Smallintconst(n) {
- v := Mpgetfix(n.Val.U.(*Mpint))
+ v := Mpgetfix(n.Val().U.(*Mpint))
return 0 <= v && v < max
}
@@ -3803,9 +3803,9 @@
case OAND:
v := int64(-1)
if Smallintconst(n.Left) {
- v = Mpgetfix(n.Left.Val.U.(*Mpint))
+ v = Mpgetfix(n.Left.Val().U.(*Mpint))
} else if Smallintconst(n.Right) {
- v = Mpgetfix(n.Right.Val.U.(*Mpint))
+ v = Mpgetfix(n.Right.Val().U.(*Mpint))
}
if 0 <= v && v < max {
@@ -3814,7 +3814,7 @@
case OMOD:
if !sign && Smallintconst(n.Right) {
- v := Mpgetfix(n.Right.Val.U.(*Mpint))
+ v := Mpgetfix(n.Right.Val().U.(*Mpint))
if 0 <= v && v <= max {
return true
}
@@ -3822,7 +3822,7 @@
case ODIV:
if !sign && Smallintconst(n.Right) {
- v := Mpgetfix(n.Right.Val.U.(*Mpint))
+ v := Mpgetfix(n.Right.Val().U.(*Mpint))
for bits > 0 && v >= 2 {
bits--
v >>= 1
@@ -3831,7 +3831,7 @@
case ORSH:
if !sign && Smallintconst(n.Right) {
- v := Mpgetfix(n.Right.Val.U.(*Mpint))
+ v := Mpgetfix(n.Right.Val().U.(*Mpint))
if v > int64(bits) {
return true
}
@@ -3965,17 +3965,17 @@
// Discardable as long as we know it's not division by zero.
case ODIV, OMOD:
- if Isconst(n.Right, CTINT) && mpcmpfixc(n.Right.Val.U.(*Mpint), 0) != 0 {
+ if Isconst(n.Right, CTINT) && mpcmpfixc(n.Right.Val().U.(*Mpint), 0) != 0 {
break
}
- if Isconst(n.Right, CTFLT) && mpcmpfltc(n.Right.Val.U.(*Mpflt), 0) != 0 {
+ if Isconst(n.Right, CTFLT) && mpcmpfltc(n.Right.Val().U.(*Mpflt), 0) != 0 {
break
}
return false
// Discardable as long as we know it won't fail because of a bad size.
case OMAKECHAN, OMAKEMAP:
- if Isconst(n.Left, CTINT) && mpcmpfixc(n.Left.Val.U.(*Mpint), 0) == 0 {
+ if Isconst(n.Left, CTINT) && mpcmpfixc(n.Left.Val().U.(*Mpint), 0) == 0 {
break
}
return false