Remove all uses of Mp* outside of the gc package.
A subsequent, automated commit in the Go 1.6
cycle will unexport all Mp* functions and types.
No functional changes. Passes toolstash -cmp.
Change-Id: Ie1604cb5b84ffb30b47f4777d4235570f2c62709
Reviewed-on: https://go-review.googlesource.com/9263
Reviewed-by: Russ Cox <rsc@golang.org>
// shld hi:lo, c
// shld lo:t, c
case gc.OLROT:
- v := uint64(gc.Mpgetfix(r.Val.U.Xval))
+ v := uint64(r.Int())
var bl gc.Node
gc.Regalloc(&bl, lo1.Type, nil)
var p4 *obj.Prog
var p5 *obj.Prog
if r.Op == gc.OLITERAL {
- v := uint64(gc.Mpgetfix(r.Val.U.Xval))
+ v := uint64(r.Int())
if v >= 64 {
// TODO(kaib): replace with gins(AMOVW, nodintconst(0), &al)
// here and below (verify it optimizes to EOR)
var creg gc.Node
var p3 *obj.Prog
if r.Op == gc.OLITERAL {
- v := uint64(gc.Mpgetfix(r.Val.U.Xval))
+ v := uint64(r.Int())
if v >= 64 {
if bh.Type.Etype == gc.TINT32 {
// MOVW bh->31, al
w := int(nl.Type.Width * 8)
if op == gc.OLROT {
- v := int(gc.Mpgetfix(nr.Val.U.Xval))
+ v := nr.Int()
var n1 gc.Node
gc.Regalloc(&n1, nl.Type, res)
if w == 32 {
var n1 gc.Node
gc.Regalloc(&n1, nl.Type, res)
gc.Cgen(nl, &n1)
- sc := uint64(gc.Mpgetfix(nr.Val.U.Xval))
+ sc := uint64(nr.Int())
if sc == 0 {
} else // nothing to do
if sc >= uint64(nl.Type.Width*8) {
}
func ginscmp(op int, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
- if gc.Isint[t.Etype] && n1.Op == gc.OLITERAL && gc.Mpgetfix(n1.Val.U.Xval) == 0 && n2.Op != gc.OLITERAL {
+ if gc.Isint[t.Etype] && n1.Op == gc.OLITERAL && n1.Int() == 0 && n2.Op != gc.OLITERAL {
op = gc.Brrev(op)
n1, n2 = n2, n1
}
gc.Regalloc(&g1, n1.Type, &r1)
gc.Cgen(n1, &g1)
gmove(&g1, &r1)
- if gc.Isint[t.Etype] && n2.Op == gc.OLITERAL && gc.Mpgetfix(n2.Val.U.Xval) == 0 {
+ if gc.Isint[t.Etype] && n2.Op == gc.OLITERAL && n2.Int() == 0 {
gins(arm.ACMP, &r1, n2)
} else {
gc.Regalloc(&r2, t, n2)
if ncon_n.Type == nil {
gc.Nodconst(&ncon_n, gc.Types[gc.TUINT32], 0)
}
- gc.Mpmovecfix(ncon_n.Val.U.Xval, int64(i))
+ ncon_n.SetInt(int64(i))
return &ncon_n
}
case gc.OLITERAL:
var n1 gc.Node
gc.Convconst(&n1, n.Type, &n.Val)
- i := gc.Mpgetfix(n1.Val.U.Xval)
+ i := n1.Int()
gc.Nodconst(lo, gc.Types[gc.TUINT32], int64(uint32(i)))
i >>= 32
if n.Type.Etype == gc.TINT64 {
if !gc.Isconst(n, gc.CTINT) {
break
}
- v := gc.Mpgetfix(n.Val.U.Xval)
+ v := n.Int()
if v >= 32000 || v <= -32000 {
break
}
check := 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)) {
+ if gc.Isconst(nl, gc.CTINT) && nl.Int() != -(1<<uint64(t.Width*8-1)) {
check = 0
- } else if gc.Isconst(nr, gc.CTINT) && gc.Mpgetfix(nr.Val.U.Xval) != -1 {
+ } else if gc.Isconst(nr, gc.CTINT) && nr.Int() != -1 {
check = 0
}
}
var n1 gc.Node
gc.Regalloc(&n1, nl.Type, res)
gc.Cgen(nl, &n1)
- sc := uint64(gc.Mpgetfix(nr.Val.U.Xval))
+ sc := uint64(nr.Int())
if sc >= uint64(nl.Type.Width*8) {
// large shift gets 2 shifts by width-1
var n3 gc.Node
import (
"cmd/internal/gc"
+ "cmd/internal/gc/big"
"cmd/internal/obj"
"cmd/internal/obj/x86"
"fmt"
gins(jmptoset(a), nil, n)
}
-/*
- * set up nodes representing 2^63
- */
-var bigi gc.Node
-
-var bigf gc.Node
-
-var bignodes_did int
+// set up nodes representing 2^63
+var (
+ bigi gc.Node
+ bigf gc.Node
+ bignodes_did bool
+)
func bignodes() {
- if bignodes_did != 0 {
+ if bignodes_did {
return
}
- bignodes_did = 1
+ bignodes_did = true
+
+ var i big.Int
+ i.SetInt64(1)
+ i.Lsh(&i, 63)
- gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 1)
- gc.Mpshiftfix(bigi.Val.U.Xval, 63)
+ gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 0)
+ bigi.SetBigInt(&i)
- bigf = bigi
- bigf.Type = gc.Types[gc.TFLOAT64]
- bigf.Val.Ctype = gc.CTFLT
- bigf.Val.U.Fval = new(gc.Mpflt)
- gc.Mpmovefixflt(bigf.Val.U.Fval, bigi.Val.U.Xval)
+ gc.Convconst(&bigf, gc.Types[gc.TFLOAT64], &bigi.Val)
}
/*
// 64-bit immediates are really 32-bit sign-extended
// unless moving into a register.
if gc.Isint[tt] {
- if gc.Mpcmpfixfix(con.Val.U.Xval, gc.Minintval[gc.TINT32]) < 0 {
- goto hard
- }
- if gc.Mpcmpfixfix(con.Val.U.Xval, gc.Maxintval[gc.TINT32]) > 0 {
+ if i := con.Int(); int64(int32(i)) != i {
goto hard
}
}
if !gc.Isconst(n, gc.CTINT) {
break
}
- v := gc.Mpgetfix(n.Val.U.Xval)
+ v := n.Int()
if v >= 32000 || v <= -32000 {
break
}
check := 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)) {
+ if gc.Isconst(nl, gc.CTINT) && nl.Int() != -(1<<uint64(t.Width*8-1)) {
check = 0
- } else if gc.Isconst(nr, gc.CTINT) && gc.Mpgetfix(nr.Val.U.Xval) != -1 {
+ } else if gc.Isconst(nr, gc.CTINT) && nr.Int() != -1 {
check = 0
}
}
var n1 gc.Node
gc.Regalloc(&n1, nl.Type, res)
gc.Cgen(nl, &n1)
- sc := uint64(uint64(gc.Mpgetfix(nr.Val.U.Xval)))
+ sc := uint64(nr.Int())
if sc >= uint64(nl.Type.Width*8) {
// large shift gets 2 shifts by width-1
var n3 gc.Node
gc.Cgen(n1, &g1)
gmove(&g1, &r1)
if gc.Isint[t.Etype] && gc.Isconst(n2, gc.CTINT) {
- ginscon2(optoas(gc.OCMP, t), &r1, gc.Mpgetfix(n2.Val.U.Xval))
+ ginscon2(optoas(gc.OCMP, t), &r1, n2.Int())
} else {
gc.Regalloc(&r2, t, n2)
gc.Regalloc(&g2, n1.Type, &r2)
}
switch n.Val.Ctype {
case gc.CTINT, gc.CTRUNE:
- return gc.Mpgetfix(n.Val.U.Xval), true
+ return n.Int(), true
case gc.CTBOOL:
return int64(obj.Bool2int(n.Val.U.Bval)), true
}
// shld hi:lo, c
// shld lo:t, c
case gc.OLROT:
- v := uint64(gc.Mpgetfix(r.Val.U.Xval))
+ v := uint64(r.Int())
if v >= 32 {
// reverse during load to do the first 32 bits of rotate
case gc.OLSH:
if r.Op == gc.OLITERAL {
- v := uint64(gc.Mpgetfix(r.Val.U.Xval))
+ v := uint64(r.Int())
if v >= 64 {
if gc.Is64(r.Type) {
splitclean()
case gc.ORSH:
if r.Op == gc.OLITERAL {
- v := uint64(gc.Mpgetfix(r.Val.U.Xval))
+ v := uint64(r.Int())
if v >= 64 {
if gc.Is64(r.Type) {
splitclean()
if lo2.Op == gc.OLITERAL {
// special cases for constants.
- lv := uint32(gc.Mpgetfix(lo2.Val.U.Xval))
-
- hv := uint32(gc.Mpgetfix(hi2.Val.U.Xval))
+ lv := uint32(lo2.Int())
+ hv := uint32(hi2.Int())
splitclean() // right side
split64(res, &lo2, &hi2)
switch n.Op {
check := 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) {
+ if gc.Isconst(nl, gc.CTINT) && nl.Int() != -1<<uint64(t.Width*8-1) {
check = 0
- } else if gc.Isconst(nr, gc.CTINT) && gc.Mpgetfix(nr.Val.U.Xval) != -1 {
+ } else if gc.Isconst(nr, gc.CTINT) && nr.Int() != -1 {
check = 0
}
}
var n1 gc.Node
gc.Regalloc(&n1, nl.Type, res)
gmove(&n2, &n1)
- sc := uint64(gc.Mpgetfix(nr.Val.U.Xval))
+ sc := uint64(nr.Int())
if sc >= uint64(nl.Type.Width*8) {
// large shift gets 2 shifts by width-1
gins(a, ncon(uint32(w)-1), &n1)
import (
"cmd/internal/gc"
+ "cmd/internal/gc/big"
"cmd/internal/obj"
"cmd/internal/obj/x86"
"fmt"
if ncon_n.Type == nil {
gc.Nodconst(&ncon_n, gc.Types[gc.TUINT32], 0)
}
- gc.Mpmovecfix(ncon_n.Val.U.Xval, int64(i))
+ ncon_n.SetInt(int64(i))
return &ncon_n
}
case gc.OLITERAL:
var n1 gc.Node
gc.Convconst(&n1, n.Type, &n.Val)
- i := gc.Mpgetfix(n1.Val.U.Xval)
+ i := n1.Int()
gc.Nodconst(lo, gc.Types[gc.TUINT32], int64(uint32(i)))
i >>= 32
if n.Type.Etype == gc.TINT64 {
}
}
-/*
- * set up nodes representing fp constants
- */
-var zerof gc.Node
-
-var two64f gc.Node
-
-var two63f gc.Node
-
-var bignodes_did int
+// set up nodes representing fp constants
+var (
+ zerof gc.Node
+ two63f gc.Node
+ two64f gc.Node
+ bignodes_did bool
+)
func bignodes() {
- if bignodes_did != 0 {
+ if bignodes_did {
return
}
- bignodes_did = 1
+ bignodes_did = true
+
+ gc.Nodconst(&zerof, gc.Types[gc.TINT64], 0)
+ gc.Convconst(&zerof, gc.Types[gc.TFLOAT64], &zerof.Val)
- two64f = *ncon(0)
- two64f.Type = gc.Types[gc.TFLOAT64]
- two64f.Val.Ctype = gc.CTFLT
- two64f.Val.U.Fval = new(gc.Mpflt)
- gc.Mpmovecflt(two64f.Val.U.Fval, 18446744073709551616.)
+ var i big.Int
+ i.SetInt64(1)
+ i.Lsh(&i, 63)
+ var bigi gc.Node
- two63f = two64f
- two63f.Val.U.Fval = new(gc.Mpflt)
- gc.Mpmovecflt(two63f.Val.U.Fval, 9223372036854775808.)
+ gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 0)
+ bigi.SetBigInt(&i)
+ gc.Convconst(&two63f, gc.Types[gc.TFLOAT64], &bigi.Val)
- zerof = two64f
- zerof.Val.U.Fval = new(gc.Mpflt)
- gc.Mpmovecflt(zerof.Val.U.Fval, 0)
+ gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 0)
+ i.Lsh(&i, 1)
+ bigi.SetBigInt(&i)
+ gc.Convconst(&two64f, gc.Types[gc.TFLOAT64], &bigi.Val)
}
func memname(n *gc.Node, t *gc.Type) {
check := 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)) {
+ if gc.Isconst(nl, gc.CTINT) && nl.Int() != -(1<<uint64(t.Width*8-1)) {
check = 0
- } else if gc.Isconst(nr, gc.CTINT) && gc.Mpgetfix(nr.Val.U.Xval) != -1 {
+ } else if gc.Isconst(nr, gc.CTINT) && nr.Int() != -1 {
check = 0
}
}
var n1 gc.Node
gc.Regalloc(&n1, nl.Type, res)
gc.Cgen(nl, &n1)
- sc := uint64(uint64(gc.Mpgetfix(nr.Val.U.Xval)))
+ sc := uint64(nr.Int())
if sc >= uint64(nl.Type.Width*8) {
// large shift gets 2 shifts by width-1
var n3 gc.Node
import (
"cmd/internal/gc"
+ "cmd/internal/gc/big"
"cmd/internal/obj"
"cmd/internal/obj/ppc64"
"fmt"
gc.Cgen(n1, &g1)
gmove(&g1, &r1)
if gc.Isint[t.Etype] && gc.Isconst(n2, gc.CTINT) {
- ginscon2(optoas(gc.OCMP, t), &r1, gc.Mpgetfix(n2.Val.U.Xval))
+ ginscon2(optoas(gc.OCMP, t), &r1, n2.Int())
} else {
gc.Regalloc(&r2, t, n2)
gc.Regalloc(&g2, n1.Type, &r2)
return gc.Gbranch(optoas(op, t), nil, likely)
}
-/*
- * set up nodes representing 2^63
- */
-var bigi gc.Node
-
-var bigf gc.Node
-
-var bignodes_did int
+// set up nodes representing 2^63
+var (
+ bigi gc.Node
+ bigf gc.Node
+ bignodes_did bool
+)
func bignodes() {
- if bignodes_did != 0 {
+ if bignodes_did {
return
}
- bignodes_did = 1
+ bignodes_did = true
+
+ var i big.Int
+ i.SetInt64(1)
+ i.Lsh(&i, 63)
- gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 1)
- gc.Mpshiftfix(bigi.Val.U.Xval, 63)
+ gc.Nodconst(&bigi, gc.Types[gc.TUINT64], 0)
+ bigi.SetBigInt(&i)
- bigf = bigi
- bigf.Type = gc.Types[gc.TFLOAT64]
- bigf.Val.Ctype = gc.CTFLT
- bigf.Val.U.Fval = new(gc.Mpflt)
- gc.Mpmovefixflt(bigf.Val.U.Fval, bigi.Val.U.Xval)
+ gc.Convconst(&bigf, gc.Types[gc.TFLOAT64], &bigi.Val)
}
/*
}
switch n.Val.Ctype {
case gc.CTINT, gc.CTRUNE:
- return gc.Mpgetfix(n.Val.U.Xval), true
+ return n.Int(), true
case gc.CTBOOL:
return int64(obj.Bool2int(n.Val.U.Bval)), true
}
package gc
import (
+ "cmd/internal/gc/big"
"cmd/internal/obj"
"strings"
)
+// Int returns n as an int.
+// n must be an integer constant.
+func (n *Node) Int() int64 {
+ if !Isconst(n, CTINT) {
+ Fatal("Int(%v)", n)
+ }
+ return Mpgetfix(n.Val.U.Xval)
+}
+
+// SetInt sets n's value to i.
+// n must be an integer constant.
+func (n *Node) SetInt(i int64) {
+ if !Isconst(n, CTINT) {
+ Fatal("SetInt(%v)", n)
+ }
+ Mpmovecfix(n.Val.U.Xval, i)
+}
+
+// SetBigInt sets n's value to x.
+// n must be an integer constant.
+func (n *Node) SetBigInt(x *big.Int) {
+ if !Isconst(n, CTINT) {
+ Fatal("SetBigInt(%v)", n)
+ }
+ n.Val.U.Xval.Val.Set(x)
+}
+
/*
* truncate float literal fv to 32-bit or 64-bit precision
* according to type; return truncated value.