Remove all uses of Node.Val outside of the gc package.
A subsequent, automated commit in the Go 1.6 cycle
will unexport Node.Val.
No functional changes. Passes toolstash -cmp.
Change-Id: Ia92ae6a7766c83ab3e45c69edab24a9581c824f9
Reviewed-on: https://go-review.googlesource.com/9267
Reviewed-by: Russ Cox <rsc@golang.org>
case gc.OLITERAL:
var n1 gc.Node
- gc.Convconst(&n1, n.Type, &n.Val)
+ n.Convconst(&n1, n.Type)
i := n1.Int()
gc.Nodconst(lo, gc.Types[gc.TUINT32], int64(uint32(i)))
i >>= 32
var con gc.Node
switch tt {
default:
- gc.Convconst(&con, t.Type, &f.Val)
+ f.Convconst(&con, t.Type)
case gc.TINT16,
gc.TINT8:
var con gc.Node
- gc.Convconst(&con, gc.Types[gc.TINT32], &f.Val)
+ f.Convconst(&con, gc.Types[gc.TINT32])
var r1 gc.Node
gc.Regalloc(&r1, con.Type, t)
gins(arm.AMOVW, &con, &r1)
case gc.TUINT16,
gc.TUINT8:
var con gc.Node
- gc.Convconst(&con, gc.Types[gc.TUINT32], &f.Val)
+ f.Convconst(&con, gc.Types[gc.TUINT32])
var r1 gc.Node
gc.Regalloc(&r1, con.Type, t)
gins(arm.AMOVW, &con, &r1)
gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 0)
bigi.SetBigInt(&i)
- gc.Convconst(&bigf, gc.Types[gc.TFLOAT64], &bigi.Val)
+ bigi.Convconst(&bigf, gc.Types[gc.TFLOAT64])
}
/*
// convert constant to desired type
if f.Op == gc.OLITERAL {
var con gc.Node
- gc.Convconst(&con, t.Type, &f.Val)
+ f.Convconst(&con, t.Type)
f = &con
ft = tt // so big switch will choose a simple mov
var con gc.Node
switch tt {
default:
- gc.Convconst(&con, t.Type, &f.Val)
+ f.Convconst(&con, t.Type)
case gc.TINT32,
gc.TINT16,
gc.TINT8:
var con gc.Node
- gc.Convconst(&con, gc.Types[gc.TINT64], &f.Val)
+ f.Convconst(&con, gc.Types[gc.TINT64])
var r1 gc.Node
gc.Regalloc(&r1, con.Type, t)
gins(arm64.AMOVD, &con, &r1)
gc.TUINT16,
gc.TUINT8:
var con gc.Node
- gc.Convconst(&con, gc.Types[gc.TUINT64], &f.Val)
+ f.Convconst(&con, gc.Types[gc.TUINT64])
var r1 gc.Node
gc.Regalloc(&r1, con.Type, t)
gins(arm64.AMOVD, &con, &r1)
}
func intLiteral(n *gc.Node) (x int64, ok bool) {
- if n == nil || n.Op != gc.OLITERAL {
+ switch {
+ case n == nil:
return
- }
- switch n.Val.Ctype {
- case gc.CTINT, gc.CTRUNE:
+ case gc.Isconst(n, gc.CTINT):
return n.Int(), true
- case gc.CTBOOL:
- return int64(obj.Bool2int(n.Val.U.Bval)), true
+ case gc.Isconst(n, gc.CTBOOL):
+ return int64(obj.Bool2int(n.Bool())), true
}
return
}
case gc.OLITERAL:
var n1 gc.Node
- gc.Convconst(&n1, n.Type, &n.Val)
+ n.Convconst(&n1, n.Type)
i := n1.Int()
gc.Nodconst(lo, gc.Types[gc.TUINT32], int64(uint32(i)))
i >>= 32
bignodes_did = true
gc.Nodconst(&zerof, gc.Types[gc.TINT64], 0)
- gc.Convconst(&zerof, gc.Types[gc.TFLOAT64], &zerof.Val)
+ zerof.Convconst(&zerof, gc.Types[gc.TFLOAT64])
var i big.Int
i.SetInt64(1)
gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 0)
bigi.SetBigInt(&i)
- gc.Convconst(&two63f, gc.Types[gc.TFLOAT64], &bigi.Val)
+ bigi.Convconst(&two63f, gc.Types[gc.TFLOAT64])
gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 0)
i.Lsh(&i, 1)
bigi.SetBigInt(&i)
- gc.Convconst(&two64f, gc.Types[gc.TFLOAT64], &bigi.Val)
+ bigi.Convconst(&two64f, gc.Types[gc.TFLOAT64])
}
func memname(n *gc.Node, t *gc.Type) {
// convert constant to desired type
if f.Op == gc.OLITERAL {
var con gc.Node
- gc.Convconst(&con, t.Type, &f.Val)
+ f.Convconst(&con, t.Type)
f = &con
ft = gc.Simsimtype(con.Type)
}
// convert constant to desired type
if f.Op == gc.OLITERAL {
var con gc.Node
- gc.Convconst(&con, t.Type, &f.Val)
+ f.Convconst(&con, t.Type)
f = &con
ft = gc.Simsimtype(con.Type)
gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 0)
bigi.SetBigInt(&i)
- gc.Convconst(&bigf, gc.Types[gc.TFLOAT64], &bigi.Val)
+ bigi.Convconst(&bigf, gc.Types[gc.TFLOAT64])
}
/*
var con gc.Node
switch tt {
default:
- gc.Convconst(&con, t.Type, &f.Val)
+ f.Convconst(&con, t.Type)
case gc.TINT32,
gc.TINT16,
gc.TINT8:
var con gc.Node
- gc.Convconst(&con, gc.Types[gc.TINT64], &f.Val)
+ f.Convconst(&con, gc.Types[gc.TINT64])
var r1 gc.Node
gc.Regalloc(&r1, con.Type, t)
gins(ppc64.AMOVD, &con, &r1)
gc.TUINT16,
gc.TUINT8:
var con gc.Node
- gc.Convconst(&con, gc.Types[gc.TUINT64], &f.Val)
+ f.Convconst(&con, gc.Types[gc.TUINT64])
var r1 gc.Node
gc.Regalloc(&r1, con.Type, t)
gins(ppc64.AMOVD, &con, &r1)
}
func intLiteral(n *gc.Node) (x int64, ok bool) {
- if n == nil || n.Op != gc.OLITERAL {
+ switch {
+ case n == nil:
return
- }
- switch n.Val.Ctype {
- case gc.CTINT, gc.CTRUNE:
+ case gc.Isconst(n, gc.CTINT):
return n.Int(), true
- case gc.CTBOOL:
- return int64(obj.Bool2int(n.Val.U.Bval)), true
+ case gc.Isconst(n, gc.CTBOOL):
+ return int64(obj.Bool2int(n.Bool())), true
}
return
}
n.Val.U.Xval.Val.Set(x)
}
+// Bool returns n as an bool.
+// n must be an boolean constant.
+func (n *Node) Bool() bool {
+ if !Isconst(n, CTBOOL) {
+ Fatal("Int(%v)", n)
+ }
+ return n.Val.U.Bval
+}
+
/*
* truncate float literal fv to 32-bit or 64-bit precision
* according to type; return truncated value.
return x
}
-/*
- * convert constant val to type t; leave in con.
- * for back end.
- */
-func Convconst(con *Node, t *Type, val *Val) {
+// Convconst converts constant node n to type t and
+// places the result in con.
+func (n *Node) Convconst(con *Node, t *Type) {
tt := Simsimtype(t)
// copy the constant for conversion
Nodconst(con, Types[TINT8], 0)
con.Type = t
- con.Val = *val
+ con.Val = n.Val
if Isint[tt] {
con.Val.Ctype = CTINT
con.Val.U.Xval = new(Mpint)
var i int64
- switch val.Ctype {
+ switch n.Val.Ctype {
default:
- Fatal("convconst ctype=%d %v", val.Ctype, Tconv(t, obj.FmtLong))
+ Fatal("convconst ctype=%d %v", n.Val.Ctype, Tconv(t, obj.FmtLong))
case CTINT, CTRUNE:
- i = Mpgetfix(val.U.Xval)
+ i = Mpgetfix(n.Val.U.Xval)
case CTBOOL:
- i = int64(obj.Bool2int(val.U.Bval))
+ i = int64(obj.Bool2int(n.Val.U.Bval))
case CTNIL:
i = 0
con.Val.U.Cval.Real = *truncfltlit(&con.Val.U.Cval.Real, Types[TFLOAT32])
con.Val.U.Cval.Imag = *truncfltlit(&con.Val.U.Cval.Imag, Types[TFLOAT32])
}
-
return
}