aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2016-03-20 19:41:43 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2016-03-21 04:11:11 +0000
commita4dce128035ebeb61cc3db11bf99d7884839935f (patch)
tree660d18a255ce855f60de53f9b562c8a37550ff7e /src
parent39af1eb96f37edc96e2bde24fdd877e49223f751 (diff)
downloadgo-a4dce128035ebeb61cc3db11bf99d7884839935f.tar.xz
cmd/compile: unexport convlit
Add a special helper for its one external use. This is in preparation for an upcoming CL. Passes toolstash -cmp / buildall. Change-Id: I9d3463792afe220cc4bc89269bdecf0279abd281 Reviewed-on: https://go-review.googlesource.com/20933 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/cgen.go4
-rw-r--r--src/cmd/compile/internal/gc/const.go53
-rw-r--r--src/cmd/compile/internal/gc/export.go2
-rw-r--r--src/cmd/compile/internal/gc/typecheck.go2
-rw-r--r--src/cmd/compile/internal/x86/ggen.go3
5 files changed, 35 insertions, 29 deletions
diff --git a/src/cmd/compile/internal/gc/cgen.go b/src/cmd/compile/internal/gc/cgen.go
index b1e152b814..552b951546 100644
--- a/src/cmd/compile/internal/gc/cgen.go
+++ b/src/cmd/compile/internal/gc/cgen.go
@@ -391,7 +391,7 @@ func cgen_wb(n, res *Node, wb bool) {
case OMINUS:
if Isfloat[nl.Type.Etype] {
nr = Nodintconst(-1)
- Convlit(&nr, n.Type)
+ convlit(&nr, n.Type)
a = Thearch.Optoas(OMUL, nl.Type)
goto sbop
}
@@ -1784,7 +1784,7 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) {
Genlist(n.Ninit)
if n.Type == nil {
- Convlit(&n, Types[TBOOL])
+ convlit(&n, Types[TBOOL])
if n.Type == nil {
return
}
diff --git a/src/cmd/compile/internal/gc/const.go b/src/cmd/compile/internal/gc/const.go
index 0edcc61b97..3fb07d0b8d 100644
--- a/src/cmd/compile/internal/gc/const.go
+++ b/src/cmd/compile/internal/gc/const.go
@@ -88,9 +88,16 @@ func truncfltlit(oldv *Mpflt, t *Type) *Mpflt {
return fv
}
+// NegOne returns a Node of type t with value -1.
+func NegOne(t *Type) *Node {
+ n := Nodintconst(-1)
+ convlit(&n, t)
+ return n
+}
+
// convert n, if literal, to type t.
// implicit conversion.
-func Convlit(np **Node, t *Type) {
+func convlit(np **Node, t *Type) {
convlit1(np, t, false)
}
@@ -124,8 +131,8 @@ func convlit1(np **Node, t *Type, explicit bool) {
}
if n.Type.Etype == TIDEAL {
- Convlit(&n.Left, t)
- Convlit(&n.Right, t)
+ convlit(&n.Left, t)
+ convlit(&n.Right, t)
n.Type = t
}
@@ -166,13 +173,13 @@ func convlit1(np **Node, t *Type, explicit bool) {
case TCOMPLEX128:
n.Type = t
- Convlit(&n.Left, Types[TFLOAT64])
- Convlit(&n.Right, Types[TFLOAT64])
+ convlit(&n.Left, Types[TFLOAT64])
+ convlit(&n.Right, Types[TFLOAT64])
case TCOMPLEX64:
n.Type = t
- Convlit(&n.Left, Types[TFLOAT32])
- Convlit(&n.Right, Types[TFLOAT32])
+ convlit(&n.Left, Types[TFLOAT32])
+ convlit(&n.Right, Types[TFLOAT32])
}
}
@@ -1256,7 +1263,7 @@ func defaultlit(np **Node, t *Type) {
switch ctype {
default:
if t != nil {
- Convlit(np, t)
+ convlit(np, t)
return
}
@@ -1273,7 +1280,7 @@ func defaultlit(np **Node, t *Type) {
if n.Val().Ctype() == CTSTR {
t1 := Types[TSTRING]
- Convlit(np, t1)
+ convlit(np, t1)
break
}
@@ -1287,7 +1294,7 @@ func defaultlit(np **Node, t *Type) {
if t != nil && t.Etype == TBOOL {
t1 = t
}
- Convlit(np, t1)
+ convlit(np, t1)
case CTINT:
t1 = Types[TINT]
@@ -1332,7 +1339,7 @@ num:
if n.Val().Ctype() != CTxxx {
overflow(n.Val(), t1)
}
- Convlit(np, t1)
+ convlit(np, t1)
lineno = lno
return
}
@@ -1348,12 +1355,12 @@ func defaultlit2(lp **Node, rp **Node, force bool) {
return
}
if !isideal(l.Type) {
- Convlit(rp, l.Type)
+ convlit(rp, l.Type)
return
}
if !isideal(r.Type) {
- Convlit(lp, r.Type)
+ convlit(lp, r.Type)
return
}
@@ -1362,32 +1369,32 @@ func defaultlit2(lp **Node, rp **Node, force bool) {
}
if l.Type.Etype == TBOOL {
- Convlit(lp, Types[TBOOL])
- Convlit(rp, Types[TBOOL])
+ convlit(lp, Types[TBOOL])
+ convlit(rp, Types[TBOOL])
}
lkind := idealkind(l)
rkind := idealkind(r)
if lkind == CTCPLX || rkind == CTCPLX {
- Convlit(lp, Types[TCOMPLEX128])
- Convlit(rp, Types[TCOMPLEX128])
+ convlit(lp, Types[TCOMPLEX128])
+ convlit(rp, Types[TCOMPLEX128])
return
}
if lkind == CTFLT || rkind == CTFLT {
- Convlit(lp, Types[TFLOAT64])
- Convlit(rp, Types[TFLOAT64])
+ convlit(lp, Types[TFLOAT64])
+ convlit(rp, Types[TFLOAT64])
return
}
if lkind == CTRUNE || rkind == CTRUNE {
- Convlit(lp, runetype)
- Convlit(rp, runetype)
+ convlit(lp, runetype)
+ convlit(rp, runetype)
return
}
- Convlit(lp, Types[TINT])
- Convlit(rp, Types[TINT])
+ convlit(lp, Types[TINT])
+ convlit(rp, Types[TINT])
}
// strlit returns the value of a literal string Node as a string.
diff --git a/src/cmd/compile/internal/gc/export.go b/src/cmd/compile/internal/gc/export.go
index 751ad57174..db46d6b6ce 100644
--- a/src/cmd/compile/internal/gc/export.go
+++ b/src/cmd/compile/internal/gc/export.go
@@ -511,7 +511,7 @@ func importimport(s *Sym, path string) {
func importconst(s *Sym, t *Type, n *Node) {
importsym(s, OLITERAL)
- Convlit(&n, t)
+ convlit(&n, t)
if s.Def != nil { // TODO: check if already the same.
return
diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go
index 2de8947dfc..1803cd700a 100644
--- a/src/cmd/compile/internal/gc/typecheck.go
+++ b/src/cmd/compile/internal/gc/typecheck.go
@@ -3707,7 +3707,7 @@ func typecheckdef(n *Node) *Node {
goto ret
}
- Convlit(&e, t)
+ convlit(&e, t)
}
n.SetVal(e.Val())
diff --git a/src/cmd/compile/internal/x86/ggen.go b/src/cmd/compile/internal/x86/ggen.go
index c65a217a78..4dcd912e18 100644
--- a/src/cmd/compile/internal/x86/ggen.go
+++ b/src/cmd/compile/internal/x86/ggen.go
@@ -666,8 +666,7 @@ func cgen_floatsse(n *gc.Node, res *gc.Node) {
case gc.OMINUS,
gc.OCOM:
- nr = gc.Nodintconst(-1)
- gc.Convlit(&nr, n.Type)
+ nr = gc.NegOne(n.Type)
a = foptoas(gc.OMUL, nl.Type, 0)
goto sbop