Commit 2805d206 authored by Martin Möhrmann's avatar Martin Möhrmann Committed by Josh Bleecher Snyder

cmd/compile: replace all uses of ptrto by typPtr

This makes the overall naming and use of the functions
to create a Type more consistent.

Passes toolstash -cmp.

Change-Id: Ie0d40b42cc32b5ecf5f20502675a225038ea40e4
Reviewed-on: https://go-review.googlesource.com/38354Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 00f4cacb
...@@ -198,7 +198,7 @@ func genhash(sym *Sym, t *Type) { ...@@ -198,7 +198,7 @@ func genhash(sym *Sym, t *Type) {
tfn := nod(OTFUNC, nil, nil) tfn := nod(OTFUNC, nil, nil)
fn.Func.Nname.Name.Param.Ntype = tfn fn.Func.Nname.Name.Param.Ntype = tfn
n := nod(ODCLFIELD, newname(lookup("p")), typenod(ptrto(t))) n := nod(ODCLFIELD, newname(lookup("p")), typenod(typPtr(t)))
tfn.List.Append(n) tfn.List.Append(n)
np := n.Left np := n.Left
n = nod(ODCLFIELD, newname(lookup("h")), typenod(Types[TUINTPTR])) n = nod(ODCLFIELD, newname(lookup("h")), typenod(Types[TUINTPTR]))
...@@ -349,7 +349,7 @@ func hashfor(t *Type) *Node { ...@@ -349,7 +349,7 @@ func hashfor(t *Type) *Node {
n := newname(sym) n := newname(sym)
n.Class = PFUNC n.Class = PFUNC
tfn := nod(OTFUNC, nil, nil) tfn := nod(OTFUNC, nil, nil)
tfn.List.Append(nod(ODCLFIELD, nil, typenod(ptrto(t)))) tfn.List.Append(nod(ODCLFIELD, nil, typenod(typPtr(t))))
tfn.List.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.List.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
tfn.Rlist.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.Rlist.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
tfn = typecheck(tfn, Etype) tfn = typecheck(tfn, Etype)
...@@ -376,10 +376,10 @@ func geneq(sym *Sym, t *Type) { ...@@ -376,10 +376,10 @@ func geneq(sym *Sym, t *Type) {
tfn := nod(OTFUNC, nil, nil) tfn := nod(OTFUNC, nil, nil)
fn.Func.Nname.Name.Param.Ntype = tfn fn.Func.Nname.Name.Param.Ntype = tfn
n := nod(ODCLFIELD, newname(lookup("p")), typenod(ptrto(t))) n := nod(ODCLFIELD, newname(lookup("p")), typenod(typPtr(t)))
tfn.List.Append(n) tfn.List.Append(n)
np := n.Left np := n.Left
n = nod(ODCLFIELD, newname(lookup("q")), typenod(ptrto(t))) n = nod(ODCLFIELD, newname(lookup("q")), typenod(typPtr(t)))
tfn.List.Append(n) tfn.List.Append(n)
nq := n.Left nq := n.Left
n = nod(ODCLFIELD, nil, typenod(Types[TBOOL])) n = nod(ODCLFIELD, nil, typenod(Types[TBOOL]))
......
...@@ -343,7 +343,7 @@ func transformclosure(xfunc *Node) { ...@@ -343,7 +343,7 @@ func transformclosure(xfunc *Node) {
// and v remains PAUTOHEAP with &v heapaddr // and v remains PAUTOHEAP with &v heapaddr
// (accesses will implicitly deref &v). // (accesses will implicitly deref &v).
addr := newname(lookupf("&%s", v.Sym.Name)) addr := newname(lookupf("&%s", v.Sym.Name))
addr.Type = ptrto(v.Type) addr.Type = typPtr(v.Type)
addr.Class = PPARAM addr.Class = PPARAM
v.Name.Param.Heapaddr = addr v.Name.Param.Heapaddr = addr
fld.Nname = addr fld.Nname = addr
...@@ -382,7 +382,7 @@ func transformclosure(xfunc *Node) { ...@@ -382,7 +382,7 @@ func transformclosure(xfunc *Node) {
cv.Type = v.Type cv.Type = v.Type
if !v.Name.Byval() { if !v.Name.Byval() {
cv.Type = ptrto(v.Type) cv.Type = typPtr(v.Type)
} }
offset = Rnd(offset, int64(cv.Type.Align)) offset = Rnd(offset, int64(cv.Type.Align))
cv.Xoffset = offset cv.Xoffset = offset
...@@ -634,7 +634,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node { ...@@ -634,7 +634,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
ptr.Name.Param.Ntype = typenod(rcvrtype) ptr.Name.Param.Ntype = typenod(rcvrtype)
body = append(body, nod(OAS, ptr, cv)) body = append(body, nod(OAS, ptr, cv))
} else { } else {
ptr.Name.Param.Ntype = typenod(ptrto(rcvrtype)) ptr.Name.Param.Ntype = typenod(typPtr(rcvrtype))
body = append(body, nod(OAS, ptr, nod(OADDR, cv, nil))) body = append(body, nod(OAS, ptr, nod(OADDR, cv, nil)))
} }
......
...@@ -937,14 +937,14 @@ var thisT *Type ...@@ -937,14 +937,14 @@ var thisT *Type
func fakethis() *Node { func fakethis() *Node {
if thisT == nil { if thisT == nil {
thisT = ptrto(typ(TSTRUCT)) thisT = typPtr(typ(TSTRUCT))
} }
return nod(ODCLFIELD, nil, typenod(thisT)) return nod(ODCLFIELD, nil, typenod(thisT))
} }
func fakethisfield() *Field { func fakethisfield() *Field {
if thisT == nil { if thisT == nil {
thisT = ptrto(typ(TSTRUCT)) thisT = typPtr(typ(TSTRUCT))
} }
f := newField() f := newField()
f.Type = thisT f.Type = thisT
...@@ -1046,7 +1046,7 @@ func methodsym(nsym *Sym, t0 *Type, iface int) *Sym { ...@@ -1046,7 +1046,7 @@ func methodsym(nsym *Sym, t0 *Type, iface int) *Sym {
// if t0 == *t and t0 has a sym, // if t0 == *t and t0 has a sym,
// we want to see *t, not t0, in the method name. // we want to see *t, not t0, in the method name.
if t != t0 && t0.Sym != nil { if t != t0 && t0.Sym != nil {
t0 = ptrto(t) t0 = typPtr(t)
} }
suffix = "" suffix = ""
......
...@@ -1154,7 +1154,7 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) { ...@@ -1154,7 +1154,7 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) {
a := nod(OADDR, src, nil) a := nod(OADDR, src, nil)
a.Pos = src.Pos a.Pos = src.Pos
e.nodeEscState(a).Loopdepth = e.nodeEscState(src).Loopdepth e.nodeEscState(a).Loopdepth = e.nodeEscState(src).Loopdepth
a.Type = ptrto(src.Type) a.Type = typPtr(src.Type)
e.escflows(dst, a, e.stepAssign(nil, originalDst, src, dstwhy)) e.escflows(dst, a, e.stepAssign(nil, originalDst, src, dstwhy))
// Flowing multiple returns to a single dst happens when // Flowing multiple returns to a single dst happens when
...@@ -1552,7 +1552,7 @@ func (e *EscState) esccall(call *Node, parent *Node) { ...@@ -1552,7 +1552,7 @@ func (e *EscState) esccall(call *Node, parent *Node) {
// Introduce ODDDARG node to represent ... allocation. // Introduce ODDDARG node to represent ... allocation.
arg = nod(ODDDARG, nil, nil) arg = nod(ODDDARG, nil, nil)
arr := typArray(n.Type.Elem(), int64(len(args))) arr := typArray(n.Type.Elem(), int64(len(args)))
arg.Type = ptrto(arr) // make pointer so it will be tracked arg.Type = typPtr(arr) // make pointer so it will be tracked
arg.Pos = call.Pos arg.Pos = call.Pos
e.track(arg) e.track(arg)
call.Right = arg call.Right = arg
...@@ -1616,7 +1616,7 @@ func (e *EscState) esccall(call *Node, parent *Node) { ...@@ -1616,7 +1616,7 @@ func (e *EscState) esccall(call *Node, parent *Node) {
arg = nod(ODDDARG, nil, nil) arg = nod(ODDDARG, nil, nil)
arg.Pos = call.Pos arg.Pos = call.Pos
arr := typArray(param.Type.Elem(), int64(len(args)-i)) arr := typArray(param.Type.Elem(), int64(len(args)-i))
arg.Type = ptrto(arr) // make pointer so it will be tracked arg.Type = typPtr(arr) // make pointer so it will be tracked
e.track(arg) e.track(arg)
call.Right = arg call.Right = arg
} }
......
...@@ -112,7 +112,7 @@ func moveToHeap(n *Node) { ...@@ -112,7 +112,7 @@ func moveToHeap(n *Node) {
// Allocate a local stack variable to hold the pointer to the heap copy. // Allocate a local stack variable to hold the pointer to the heap copy.
// temp will add it to the function declaration list automatically. // temp will add it to the function declaration list automatically.
heapaddr := temp(ptrto(n.Type)) heapaddr := temp(typPtr(n.Type))
heapaddr.Sym = lookup("&" + n.Sym.Name) heapaddr.Sym = lookup("&" + n.Sym.Name)
heapaddr.Orig.Sym = heapaddr.Sym heapaddr.Orig.Sym = heapaddr.Sym
......
...@@ -216,7 +216,7 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) { ...@@ -216,7 +216,7 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
instrumentnode(&n.Left, init, 0, 0) instrumentnode(&n.Left, init, 0, 0)
if n.Left.Type.IsMap() { if n.Left.Type.IsMap() {
n1 := nod(OCONVNOP, n.Left, nil) n1 := nod(OCONVNOP, n.Left, nil)
n1.Type = ptrto(Types[TUINT8]) n1.Type = typPtr(Types[TUINT8])
n1 = nod(OIND, n1, nil) n1 = nod(OIND, n1, nil)
n1 = typecheck(n1, Erv) n1 = typecheck(n1, Erv)
callinstr(&n1, init, 0, skip) callinstr(&n1, init, 0, skip)
...@@ -568,7 +568,7 @@ func uintptraddr(n *Node) *Node { ...@@ -568,7 +568,7 @@ func uintptraddr(n *Node) *Node {
func detachexpr(n *Node, init *Nodes) *Node { func detachexpr(n *Node, init *Nodes) *Node {
addr := nod(OADDR, n, nil) addr := nod(OADDR, n, nil)
l := temp(ptrto(n.Type)) l := temp(typPtr(n.Type))
as := nod(OAS, l, addr) as := nod(OAS, l, addr)
as = typecheck(as, Etop) as = typecheck(as, Etop)
as = walkexpr(as, init) as = walkexpr(as, init)
......
...@@ -195,7 +195,7 @@ func walkrange(n *Node) *Node { ...@@ -195,7 +195,7 @@ func walkrange(n *Node) *Node {
init = append(init, nod(OAS, hn, nod(OLEN, ha, nil))) init = append(init, nod(OAS, hn, nod(OLEN, ha, nil)))
if v2 != nil { if v2 != nil {
hp = temp(ptrto(n.Type.Elem())) hp = temp(typPtr(n.Type.Elem()))
tmp := nod(OINDEX, ha, nodintconst(0)) tmp := nod(OINDEX, ha, nodintconst(0))
tmp.SetBounded(true) tmp.SetBounded(true)
init = append(init, nod(OAS, hp, nod(OADDR, tmp, nil))) init = append(init, nod(OAS, hp, nod(OADDR, tmp, nil)))
......
...@@ -111,10 +111,10 @@ func mapbucket(t *Type) *Type { ...@@ -111,10 +111,10 @@ func mapbucket(t *Type) *Type {
dowidth(keytype) dowidth(keytype)
dowidth(valtype) dowidth(valtype)
if keytype.Width > MAXKEYSIZE { if keytype.Width > MAXKEYSIZE {
keytype = ptrto(keytype) keytype = typPtr(keytype)
} }
if valtype.Width > MAXVALSIZE { if valtype.Width > MAXVALSIZE {
valtype = ptrto(valtype) valtype = typPtr(valtype)
} }
field := make([]*Field, 0, 5) field := make([]*Field, 0, 5)
...@@ -158,7 +158,7 @@ func mapbucket(t *Type) *Type { ...@@ -158,7 +158,7 @@ func mapbucket(t *Type) *Type {
// Arrange for the bucket to have no pointers by changing // Arrange for the bucket to have no pointers by changing
// the type of the overflow field to uintptr in this case. // the type of the overflow field to uintptr in this case.
// See comment on hmap.overflow in ../../../../runtime/hashmap.go. // See comment on hmap.overflow in ../../../../runtime/hashmap.go.
otyp := ptrto(bucket) otyp := typPtr(bucket)
if !haspointers(t.Val()) && !haspointers(t.Key()) && t.Val().Width <= MAXVALSIZE && t.Key().Width <= MAXKEYSIZE { if !haspointers(t.Val()) && !haspointers(t.Key()) && t.Val().Width <= MAXVALSIZE && t.Key().Width <= MAXKEYSIZE {
otyp = Types[TUINTPTR] otyp = Types[TUINTPTR]
} }
...@@ -197,8 +197,8 @@ func hmap(t *Type) *Type { ...@@ -197,8 +197,8 @@ func hmap(t *Type) *Type {
makefield("B", Types[TUINT8]), makefield("B", Types[TUINT8]),
makefield("noverflow", Types[TUINT16]), makefield("noverflow", Types[TUINT16]),
makefield("hash0", Types[TUINT32]), makefield("hash0", Types[TUINT32]),
makefield("buckets", ptrto(bucket)), makefield("buckets", typPtr(bucket)),
makefield("oldbuckets", ptrto(bucket)), makefield("oldbuckets", typPtr(bucket)),
makefield("nevacuate", Types[TUINTPTR]), makefield("nevacuate", Types[TUINTPTR]),
makefield("overflow", Types[TUNSAFEPTR]), makefield("overflow", Types[TUNSAFEPTR]),
} }
...@@ -235,12 +235,12 @@ func hiter(t *Type) *Type { ...@@ -235,12 +235,12 @@ func hiter(t *Type) *Type {
// } // }
// must match ../../../../runtime/hashmap.go:hiter. // must match ../../../../runtime/hashmap.go:hiter.
var field [12]*Field var field [12]*Field
field[0] = makefield("key", ptrto(t.Key())) field[0] = makefield("key", typPtr(t.Key()))
field[1] = makefield("val", ptrto(t.Val())) field[1] = makefield("val", typPtr(t.Val()))
field[2] = makefield("t", ptrto(Types[TUINT8])) field[2] = makefield("t", typPtr(Types[TUINT8]))
field[3] = makefield("h", ptrto(hmap(t))) field[3] = makefield("h", typPtr(hmap(t)))
field[4] = makefield("buckets", ptrto(mapbucket(t))) field[4] = makefield("buckets", typPtr(mapbucket(t)))
field[5] = makefield("bptr", ptrto(mapbucket(t))) field[5] = makefield("bptr", typPtr(mapbucket(t)))
field[6] = makefield("overflow0", Types[TUNSAFEPTR]) field[6] = makefield("overflow0", Types[TUNSAFEPTR])
field[7] = makefield("overflow1", Types[TUNSAFEPTR]) field[7] = makefield("overflow1", Types[TUNSAFEPTR])
field[8] = makefield("startBucket", Types[TUINTPTR]) field[8] = makefield("startBucket", Types[TUINTPTR])
...@@ -310,7 +310,7 @@ func methods(t *Type) []*Sig { ...@@ -310,7 +310,7 @@ func methods(t *Type) []*Sig {
it := t it := t
if !isdirectiface(it) { if !isdirectiface(it) {
it = ptrto(t) it = typPtr(t)
} }
// make list of methods for t, // make list of methods for t,
...@@ -845,7 +845,7 @@ func dcommontype(s *Sym, ot int, t *Type) int { ...@@ -845,7 +845,7 @@ func dcommontype(s *Sym, ot int, t *Type) int {
sptrWeak := true sptrWeak := true
var sptr *Sym var sptr *Sym
if !t.IsPtr() || t.ptrTo != nil { if !t.IsPtr() || t.ptrTo != nil {
tptr := ptrto(t) tptr := typPtr(t)
if t.Sym != nil || methods(tptr) != nil { if t.Sym != nil || methods(tptr) != nil {
sptrWeak = false sptrWeak = false
} }
...@@ -994,7 +994,7 @@ func typenamesym(t *Type) *Sym { ...@@ -994,7 +994,7 @@ func typenamesym(t *Type) *Sym {
func typename(t *Type) *Node { func typename(t *Type) *Node {
s := typenamesym(t) s := typenamesym(t)
n := nod(OADDR, s.Def, nil) n := nod(OADDR, s.Def, nil)
n.Type = ptrto(s.Def.Type) n.Type = typPtr(s.Def.Type)
n.SetAddable(true) n.SetAddable(true)
n.Typecheck = 1 n.Typecheck = 1
return n return n
...@@ -1016,7 +1016,7 @@ func itabname(t, itype *Type) *Node { ...@@ -1016,7 +1016,7 @@ func itabname(t, itype *Type) *Node {
} }
n := nod(OADDR, s.Def, nil) n := nod(OADDR, s.Def, nil)
n.Type = ptrto(s.Def.Type) n.Type = typPtr(s.Def.Type)
n.SetAddable(true) n.SetAddable(true)
n.Typecheck = 1 n.Typecheck = 1
return n return n
...@@ -1473,7 +1473,7 @@ func dumptypestructs() { ...@@ -1473,7 +1473,7 @@ func dumptypestructs() {
t := signatlist[i] t := signatlist[i]
dtypesym(t) dtypesym(t)
if t.Sym != nil { if t.Sym != nil {
dtypesym(ptrto(t)) dtypesym(typPtr(t))
} }
} }
...@@ -1550,14 +1550,14 @@ func dumptypestructs() { ...@@ -1550,14 +1550,14 @@ func dumptypestructs() {
// but using runtime means fewer copies in .6 files. // but using runtime means fewer copies in .6 files.
if myimportpath == "runtime" { if myimportpath == "runtime" {
for i := EType(1); i <= TBOOL; i++ { for i := EType(1); i <= TBOOL; i++ {
dtypesym(ptrto(Types[i])) dtypesym(typPtr(Types[i]))
} }
dtypesym(ptrto(Types[TSTRING])) dtypesym(typPtr(Types[TSTRING]))
dtypesym(ptrto(Types[TUNSAFEPTR])) dtypesym(typPtr(Types[TUNSAFEPTR]))
// emit type structs for error and func(error) string. // emit type structs for error and func(error) string.
// The latter is the type of an auto-generated wrapper. // The latter is the type of an auto-generated wrapper.
dtypesym(ptrto(errortype)) dtypesym(typPtr(errortype))
dtypesym(functype(nil, []*Node{nod(ODCLFIELD, nil, typenod(errortype))}, []*Node{nod(ODCLFIELD, nil, typenod(Types[TSTRING]))})) dtypesym(functype(nil, []*Node{nod(ODCLFIELD, nil, typenod(errortype))}, []*Node{nod(ODCLFIELD, nil, typenod(Types[TSTRING]))}))
...@@ -1861,7 +1861,7 @@ func zeroaddr(size int64) *Node { ...@@ -1861,7 +1861,7 @@ func zeroaddr(size int64) *Node {
s.Def = x s.Def = x
} }
z := nod(OADDR, s.Def, nil) z := nod(OADDR, s.Def, nil)
z.Type = ptrto(Types[TUINT8]) z.Type = typPtr(Types[TUINT8])
z.SetAddable(true) z.SetAddable(true)
z.Typecheck = 1 z.Typecheck = 1
return z return z
......
...@@ -258,7 +258,7 @@ func walkselect(sel *Node) { ...@@ -258,7 +258,7 @@ func walkselect(sel *Node) {
r = nod(OAS, selv, nil) r = nod(OAS, selv, nil)
r = typecheck(r, Etop) r = typecheck(r, Etop)
init = append(init, r) init = append(init, r)
var_ = conv(conv(nod(OADDR, selv, nil), Types[TUNSAFEPTR]), ptrto(Types[TUINT8])) var_ = conv(conv(nod(OADDR, selv, nil), Types[TUNSAFEPTR]), typPtr(Types[TUINT8]))
r = mkcall("newselect", nil, nil, var_, nodintconst(selv.Type.Width), nodintconst(sel.Xoffset)) r = mkcall("newselect", nil, nil, var_, nodintconst(selv.Type.Width), nodintconst(sel.Xoffset))
r = typecheck(r, Etop) r = typecheck(r, Etop)
init = append(init, r) init = append(init, r)
...@@ -332,11 +332,11 @@ func selecttype(size int32) *Type { ...@@ -332,11 +332,11 @@ func selecttype(size int32) *Type {
// and then cache; and also cache Select per size. // and then cache; and also cache Select per size.
scase := nod(OTSTRUCT, nil, nil) scase := nod(OTSTRUCT, nil, nil)
scase.List.Append(nod(ODCLFIELD, newname(lookup("elem")), typenod(ptrto(Types[TUINT8])))) scase.List.Append(nod(ODCLFIELD, newname(lookup("elem")), typenod(typPtr(Types[TUINT8]))))
scase.List.Append(nod(ODCLFIELD, newname(lookup("chan")), typenod(ptrto(Types[TUINT8])))) scase.List.Append(nod(ODCLFIELD, newname(lookup("chan")), typenod(typPtr(Types[TUINT8]))))
scase.List.Append(nod(ODCLFIELD, newname(lookup("pc")), typenod(Types[TUINTPTR]))) scase.List.Append(nod(ODCLFIELD, newname(lookup("pc")), typenod(Types[TUINTPTR])))
scase.List.Append(nod(ODCLFIELD, newname(lookup("kind")), typenod(Types[TUINT16]))) scase.List.Append(nod(ODCLFIELD, newname(lookup("kind")), typenod(Types[TUINT16])))
scase.List.Append(nod(ODCLFIELD, newname(lookup("receivedp")), typenod(ptrto(Types[TUINT8])))) scase.List.Append(nod(ODCLFIELD, newname(lookup("receivedp")), typenod(typPtr(Types[TUINT8]))))
scase.List.Append(nod(ODCLFIELD, newname(lookup("releasetime")), typenod(Types[TUINT64]))) scase.List.Append(nod(ODCLFIELD, newname(lookup("releasetime")), typenod(Types[TUINT64])))
scase = typecheck(scase, Etype) scase = typecheck(scase, Etype)
scase.Type.SetNoalg(true) scase.Type.SetNoalg(true)
...@@ -345,8 +345,8 @@ func selecttype(size int32) *Type { ...@@ -345,8 +345,8 @@ func selecttype(size int32) *Type {
sel := nod(OTSTRUCT, nil, nil) sel := nod(OTSTRUCT, nil, nil)
sel.List.Append(nod(ODCLFIELD, newname(lookup("tcase")), typenod(Types[TUINT16]))) sel.List.Append(nod(ODCLFIELD, newname(lookup("tcase")), typenod(Types[TUINT16])))
sel.List.Append(nod(ODCLFIELD, newname(lookup("ncase")), typenod(Types[TUINT16]))) sel.List.Append(nod(ODCLFIELD, newname(lookup("ncase")), typenod(Types[TUINT16])))
sel.List.Append(nod(ODCLFIELD, newname(lookup("pollorder")), typenod(ptrto(Types[TUINT8])))) sel.List.Append(nod(ODCLFIELD, newname(lookup("pollorder")), typenod(typPtr(Types[TUINT8]))))
sel.List.Append(nod(ODCLFIELD, newname(lookup("lockorder")), typenod(ptrto(Types[TUINT8])))) sel.List.Append(nod(ODCLFIELD, newname(lookup("lockorder")), typenod(typPtr(Types[TUINT8]))))
arr := nod(OTARRAY, nodintconst(int64(size)), scase) arr := nod(OTARRAY, nodintconst(int64(size)), scase)
sel.List.Append(nod(ODCLFIELD, newname(lookup("scase")), arr)) sel.List.Append(nod(ODCLFIELD, newname(lookup("scase")), arr))
arr = nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16])) arr = nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16]))
......
...@@ -535,7 +535,7 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool { ...@@ -535,7 +535,7 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
*out = append(*out, nod(OAS, a, val)) *out = append(*out, nod(OAS, a, val))
} }
ptr := nod(OADDR, a, nil) ptr := nod(OADDR, a, nil)
n.Type = ptrto(val.Type) n.Type = typPtr(val.Type)
gdata(&n, ptr, Widthptr) gdata(&n, ptr, Widthptr)
} }
...@@ -828,7 +828,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) { ...@@ -828,7 +828,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
} }
// make new auto *array (3 declare) // make new auto *array (3 declare)
vauto := temp(ptrto(t)) vauto := temp(typPtr(t))
// set auto to point at new temp or heap (3 assign) // set auto to point at new temp or heap (3 assign)
var a *Node var a *Node
......
...@@ -37,14 +37,14 @@ func initssaconfig() { ...@@ -37,14 +37,14 @@ func initssaconfig() {
Int: Types[TINT], Int: Types[TINT],
Uintptr: Types[TUINTPTR], Uintptr: Types[TUINTPTR],
String: Types[TSTRING], String: Types[TSTRING],
BytePtr: ptrto(Types[TUINT8]), BytePtr: typPtr(Types[TUINT8]),
Int32Ptr: ptrto(Types[TINT32]), Int32Ptr: typPtr(Types[TINT32]),
UInt32Ptr: ptrto(Types[TUINT32]), UInt32Ptr: typPtr(Types[TUINT32]),
IntPtr: ptrto(Types[TINT]), IntPtr: typPtr(Types[TINT]),
UintptrPtr: ptrto(Types[TUINTPTR]), UintptrPtr: typPtr(Types[TUINTPTR]),
Float32Ptr: ptrto(Types[TFLOAT32]), Float32Ptr: typPtr(Types[TFLOAT32]),
Float64Ptr: ptrto(Types[TFLOAT64]), Float64Ptr: typPtr(Types[TFLOAT64]),
BytePtrPtr: ptrto(ptrto(Types[TUINT8])), BytePtrPtr: typPtr(typPtr(Types[TUINT8])),
} }
ssaConfig = ssa.NewConfig(thearch.LinkArch.Name, types, Ctxt, Debug['N'] == 0) ssaConfig = ssa.NewConfig(thearch.LinkArch.Name, types, Ctxt, Debug['N'] == 0)
if thearch.LinkArch.Name == "386" { if thearch.LinkArch.Name == "386" {
...@@ -126,7 +126,7 @@ func buildssa(fn *Node) *ssa.Func { ...@@ -126,7 +126,7 @@ func buildssa(fn *Node) *ssa.Func {
switch n.Class { switch n.Class {
case PPARAM, PPARAMOUT: case PPARAM, PPARAMOUT:
aux := s.lookupSymbol(n, &ssa.ArgSymbol{Typ: n.Type, Node: n}) aux := s.lookupSymbol(n, &ssa.ArgSymbol{Typ: n.Type, Node: n})
s.decladdrs[n] = s.entryNewValue1A(ssa.OpAddr, ptrto(n.Type), aux, s.sp) s.decladdrs[n] = s.entryNewValue1A(ssa.OpAddr, typPtr(n.Type), aux, s.sp)
if n.Class == PPARAMOUT && s.canSSA(n) { if n.Class == PPARAMOUT && s.canSSA(n) {
// Save ssa-able PPARAMOUT variables so we can // Save ssa-able PPARAMOUT variables so we can
// store them back to the stack at the end of // store them back to the stack at the end of
...@@ -1367,7 +1367,7 @@ func (s *state) expr(n *Node) *ssa.Value { ...@@ -1367,7 +1367,7 @@ func (s *state) expr(n *Node) *ssa.Value {
// "value" of a function is the address of the function's closure // "value" of a function is the address of the function's closure
sym := Linksym(funcsym(n.Sym)) sym := Linksym(funcsym(n.Sym))
aux := &ssa.ExternSymbol{Typ: n.Type, Sym: sym} aux := &ssa.ExternSymbol{Typ: n.Type, Sym: sym}
return s.entryNewValue1A(ssa.OpAddr, ptrto(n.Type), aux, s.sb) return s.entryNewValue1A(ssa.OpAddr, typPtr(n.Type), aux, s.sb)
} }
if s.canSSA(n) { if s.canSSA(n) {
return s.variable(n, n.Type) return s.variable(n, n.Type)
...@@ -1875,7 +1875,7 @@ func (s *state) expr(n *Node) *ssa.Value { ...@@ -1875,7 +1875,7 @@ func (s *state) expr(n *Node) *ssa.Value {
return s.addr(n.Left, n.Bounded()) return s.addr(n.Left, n.Bounded())
case OINDREGSP: case OINDREGSP:
addr := s.constOffPtrSP(ptrto(n.Type), n.Xoffset) addr := s.constOffPtrSP(typPtr(n.Type), n.Xoffset)
return s.newValue2(ssa.OpLoad, n.Type, addr, s.mem()) return s.newValue2(ssa.OpLoad, n.Type, addr, s.mem())
case OIND: case OIND:
...@@ -1902,7 +1902,7 @@ func (s *state) expr(n *Node) *ssa.Value { ...@@ -1902,7 +1902,7 @@ func (s *state) expr(n *Node) *ssa.Value {
case ODOTPTR: case ODOTPTR:
p := s.exprPtr(n.Left, false, n.Pos) p := s.exprPtr(n.Left, false, n.Pos)
p = s.newValue1I(ssa.OpOffPtr, ptrto(n.Type), n.Xoffset, p) p = s.newValue1I(ssa.OpOffPtr, typPtr(n.Type), n.Xoffset, p)
return s.newValue2(ssa.OpLoad, n.Type, p, s.mem()) return s.newValue2(ssa.OpLoad, n.Type, p, s.mem())
case OINDEX: case OINDEX:
...@@ -2094,7 +2094,7 @@ func (s *state) append(n *Node, inplace bool) *ssa.Value { ...@@ -2094,7 +2094,7 @@ func (s *state) append(n *Node, inplace bool) *ssa.Value {
// *(ptr+len+2) = e3 // *(ptr+len+2) = e3
et := n.Type.Elem() et := n.Type.Elem()
pt := ptrto(et) pt := typPtr(et)
// Evaluate slice // Evaluate slice
sn := n.List.First() // the slice node is the first in the list sn := n.List.First() // the slice node is the first in the list
...@@ -3083,7 +3083,7 @@ func (s *state) call(n *Node, k callKind) *ssa.Value { ...@@ -3083,7 +3083,7 @@ func (s *state) call(n *Node, k callKind) *ssa.Value {
return nil return nil
} }
fp := res.Field(0) fp := res.Field(0)
return s.constOffPtrSP(ptrto(fp.Type), fp.Offset+Ctxt.FixedFrameSize()) return s.constOffPtrSP(typPtr(fp.Type), fp.Offset+Ctxt.FixedFrameSize())
} }
// etypesign returns the signed-ness of e, for integer/pointer etypes. // etypesign returns the signed-ness of e, for integer/pointer etypes.
...@@ -3122,7 +3122,7 @@ func (s *state) lookupSymbol(n *Node, sym interface{}) interface{} { ...@@ -3122,7 +3122,7 @@ func (s *state) lookupSymbol(n *Node, sym interface{}) interface{} {
// If bounded is true then this address does not require a nil check for its operand // If bounded is true then this address does not require a nil check for its operand
// even if that would otherwise be implied. // even if that would otherwise be implied.
func (s *state) addr(n *Node, bounded bool) *ssa.Value { func (s *state) addr(n *Node, bounded bool) *ssa.Value {
t := ptrto(n.Type) t := typPtr(n.Type)
switch n.Op { switch n.Op {
case ONAME: case ONAME:
switch n.Class { switch n.Class {
...@@ -3183,7 +3183,7 @@ func (s *state) addr(n *Node, bounded bool) *ssa.Value { ...@@ -3183,7 +3183,7 @@ func (s *state) addr(n *Node, bounded bool) *ssa.Value {
if !n.Bounded() { if !n.Bounded() {
s.boundsCheck(i, len) s.boundsCheck(i, len)
} }
return s.newValue2(ssa.OpPtrIndex, ptrto(n.Left.Type.Elem()), a, i) return s.newValue2(ssa.OpPtrIndex, typPtr(n.Left.Type.Elem()), a, i)
} }
case OIND: case OIND:
return s.exprPtr(n.Left, bounded, n.Pos) return s.exprPtr(n.Left, bounded, n.Pos)
...@@ -3429,7 +3429,7 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*Type, args ...*ssa ...@@ -3429,7 +3429,7 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*Type, args ...*ssa
res := make([]*ssa.Value, len(results)) res := make([]*ssa.Value, len(results))
for i, t := range results { for i, t := range results {
off = Rnd(off, t.Alignment()) off = Rnd(off, t.Alignment())
ptr := s.constOffPtrSP(ptrto(t), off) ptr := s.constOffPtrSP(typPtr(t), off)
res[i] = s.newValue2(ssa.OpLoad, t, ptr, s.mem()) res[i] = s.newValue2(ssa.OpLoad, t, ptr, s.mem())
off += t.Size() off += t.Size()
} }
...@@ -3555,13 +3555,13 @@ func (s *state) slice(t *Type, v, i, j, k *ssa.Value) (p, l, c *ssa.Value) { ...@@ -3555,13 +3555,13 @@ func (s *state) slice(t *Type, v, i, j, k *ssa.Value) (p, l, c *ssa.Value) {
switch { switch {
case t.IsSlice(): case t.IsSlice():
elemtype = t.Elem() elemtype = t.Elem()
ptrtype = ptrto(elemtype) ptrtype = typPtr(elemtype)
ptr = s.newValue1(ssa.OpSlicePtr, ptrtype, v) ptr = s.newValue1(ssa.OpSlicePtr, ptrtype, v)
len = s.newValue1(ssa.OpSliceLen, Types[TINT], v) len = s.newValue1(ssa.OpSliceLen, Types[TINT], v)
cap = s.newValue1(ssa.OpSliceCap, Types[TINT], v) cap = s.newValue1(ssa.OpSliceCap, Types[TINT], v)
case t.IsString(): case t.IsString():
elemtype = Types[TUINT8] elemtype = Types[TUINT8]
ptrtype = ptrto(elemtype) ptrtype = typPtr(elemtype)
ptr = s.newValue1(ssa.OpStringPtr, ptrtype, v) ptr = s.newValue1(ssa.OpStringPtr, ptrtype, v)
len = s.newValue1(ssa.OpStringLen, Types[TINT], v) len = s.newValue1(ssa.OpStringLen, Types[TINT], v)
cap = len cap = len
...@@ -3570,7 +3570,7 @@ func (s *state) slice(t *Type, v, i, j, k *ssa.Value) (p, l, c *ssa.Value) { ...@@ -3570,7 +3570,7 @@ func (s *state) slice(t *Type, v, i, j, k *ssa.Value) (p, l, c *ssa.Value) {
s.Fatalf("bad ptr to array in slice %v\n", t) s.Fatalf("bad ptr to array in slice %v\n", t)
} }
elemtype = t.Elem().Elem() elemtype = t.Elem().Elem()
ptrtype = ptrto(elemtype) ptrtype = typPtr(elemtype)
s.nilCheck(v) s.nilCheck(v)
ptr = v ptr = v
len = s.constInt(Types[TINT], t.Elem().NumElem()) len = s.constInt(Types[TINT], t.Elem().NumElem())
...@@ -4100,7 +4100,7 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) { ...@@ -4100,7 +4100,7 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) {
if direct { if direct {
return s.newValue1(ssa.OpIData, n.Type, iface), nil return s.newValue1(ssa.OpIData, n.Type, iface), nil
} }
p := s.newValue1(ssa.OpIData, ptrto(n.Type), iface) p := s.newValue1(ssa.OpIData, typPtr(n.Type), iface)
return s.newValue2(ssa.OpLoad, n.Type, p, s.mem()), nil return s.newValue2(ssa.OpLoad, n.Type, p, s.mem()), nil
} }
...@@ -4117,11 +4117,11 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) { ...@@ -4117,11 +4117,11 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) {
if direct { if direct {
s.vars[valVar] = s.newValue1(ssa.OpIData, n.Type, iface) s.vars[valVar] = s.newValue1(ssa.OpIData, n.Type, iface)
} else { } else {
p := s.newValue1(ssa.OpIData, ptrto(n.Type), iface) p := s.newValue1(ssa.OpIData, typPtr(n.Type), iface)
s.vars[valVar] = s.newValue2(ssa.OpLoad, n.Type, p, s.mem()) s.vars[valVar] = s.newValue2(ssa.OpLoad, n.Type, p, s.mem())
} }
} else { } else {
p := s.newValue1(ssa.OpIData, ptrto(n.Type), iface) p := s.newValue1(ssa.OpIData, typPtr(n.Type), iface)
store := s.newValue3I(ssa.OpMove, ssa.TypeMem, n.Type.Size(), addr, p, s.mem()) store := s.newValue3I(ssa.OpMove, ssa.TypeMem, n.Type.Size(), addr, p, s.mem())
store.Aux = n.Type store.Aux = n.Type
s.vars[&memVar] = store s.vars[&memVar] = store
...@@ -4712,7 +4712,7 @@ func (e *ssafn) Auto(t ssa.Type) ssa.GCNode { ...@@ -4712,7 +4712,7 @@ func (e *ssafn) Auto(t ssa.Type) ssa.GCNode {
func (e *ssafn) SplitString(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot) { func (e *ssafn) SplitString(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot) {
n := name.N.(*Node) n := name.N.(*Node)
ptrType := ptrto(Types[TUINT8]) ptrType := typPtr(Types[TUINT8])
lenType := Types[TINT] lenType := Types[TINT]
if n.Class == PAUTO && !n.Addrtaken() { if n.Class == PAUTO && !n.Addrtaken() {
// Split this string up into two separate variables. // Split this string up into two separate variables.
...@@ -4726,7 +4726,7 @@ func (e *ssafn) SplitString(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot) { ...@@ -4726,7 +4726,7 @@ func (e *ssafn) SplitString(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot) {
func (e *ssafn) SplitInterface(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot) { func (e *ssafn) SplitInterface(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot) {
n := name.N.(*Node) n := name.N.(*Node)
t := ptrto(Types[TUINT8]) t := typPtr(Types[TUINT8])
if n.Class == PAUTO && !n.Addrtaken() { if n.Class == PAUTO && !n.Addrtaken() {
// Split this interface up into two separate variables. // Split this interface up into two separate variables.
f := ".itab" f := ".itab"
...@@ -4743,7 +4743,7 @@ func (e *ssafn) SplitInterface(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot ...@@ -4743,7 +4743,7 @@ func (e *ssafn) SplitInterface(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot
func (e *ssafn) SplitSlice(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot, ssa.LocalSlot) { func (e *ssafn) SplitSlice(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot, ssa.LocalSlot) {
n := name.N.(*Node) n := name.N.(*Node)
ptrType := ptrto(name.Type.ElemType().(*Type)) ptrType := typPtr(name.Type.ElemType().(*Type))
lenType := Types[TINT] lenType := Types[TINT]
if n.Class == PAUTO && !n.Addrtaken() { if n.Class == PAUTO && !n.Addrtaken() {
// Split this slice up into three separate variables. // Split this slice up into three separate variables.
......
...@@ -1112,18 +1112,6 @@ func typehash(t *Type) uint32 { ...@@ -1112,18 +1112,6 @@ func typehash(t *Type) uint32 {
return binary.LittleEndian.Uint32(h[:4]) return binary.LittleEndian.Uint32(h[:4])
} }
// ptrto returns the Type *t.
// The returned struct must not be modified.
func ptrto(t *Type) *Type {
if Tptr == 0 {
Fatalf("ptrto: no tptr")
}
if t == nil {
Fatalf("ptrto: nil ptr")
}
return typPtr(t)
}
func frame(context int) { func frame(context int) {
if context != 0 { if context != 0 {
fmt.Printf("--- external frame ---\n") fmt.Printf("--- external frame ---\n")
...@@ -1826,7 +1814,7 @@ func hashmem(t *Type) *Node { ...@@ -1826,7 +1814,7 @@ func hashmem(t *Type) *Node {
n := newname(sym) n := newname(sym)
n.Class = PFUNC n.Class = PFUNC
tfn := nod(OTFUNC, nil, nil) tfn := nod(OTFUNC, nil, nil)
tfn.List.Append(nod(ODCLFIELD, nil, typenod(ptrto(t)))) tfn.List.Append(nod(ODCLFIELD, nil, typenod(typPtr(t))))
tfn.List.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.List.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
tfn.List.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.List.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
tfn.Rlist.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.Rlist.Append(nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
...@@ -2123,7 +2111,7 @@ func isdirectiface(t *Type) bool { ...@@ -2123,7 +2111,7 @@ func isdirectiface(t *Type) bool {
// itabType loads the _type field from a runtime.itab struct. // itabType loads the _type field from a runtime.itab struct.
func itabType(itab *Node) *Node { func itabType(itab *Node) *Node {
typ := nodSym(ODOTPTR, itab, nil) typ := nodSym(ODOTPTR, itab, nil)
typ.Type = ptrto(Types[TUINT8]) typ.Type = typPtr(Types[TUINT8])
typ.Typecheck = 1 typ.Typecheck = 1
typ.Xoffset = int64(Widthptr) // offset of _type in runtime.itab typ.Xoffset = int64(Widthptr) // offset of _type in runtime.itab
typ.SetBounded(true) // guaranteed not to fault typ.SetBounded(true) // guaranteed not to fault
...@@ -2140,7 +2128,7 @@ func ifaceData(n *Node, t *Type) *Node { ...@@ -2140,7 +2128,7 @@ func ifaceData(n *Node, t *Type) *Node {
ptr.Typecheck = 1 ptr.Typecheck = 1
return ptr return ptr
} }
ptr.Type = ptrto(t) ptr.Type = typPtr(t)
ptr.SetBounded(true) ptr.SetBounded(true)
ptr.Typecheck = 1 ptr.Typecheck = 1
ind := nod(OIND, ptr, nil) ind := nod(OIND, ptr, nil)
......
...@@ -494,13 +494,21 @@ func typMap(k, v *Type) *Type { ...@@ -494,13 +494,21 @@ func typMap(k, v *Type) *Type {
// typPtr returns the pointer type pointing to t. // typPtr returns the pointer type pointing to t.
func typPtr(elem *Type) *Type { func typPtr(elem *Type) *Type {
if elem == nil {
Fatalf("typPtr: pointer to elem Type is nil")
}
if t := elem.ptrTo; t != nil { if t := elem.ptrTo; t != nil {
if t.Elem() != elem { if t.Elem() != elem {
Fatalf("elem mismatch") Fatalf("typPtr: elem mismatch")
} }
return t return t
} }
if Tptr == 0 {
Fatalf("typPtr: Tptr not intialized")
}
t := typ(Tptr) t := typ(Tptr)
t.Extra = PtrType{Elem: elem} t.Extra = PtrType{Elem: elem}
t.Width = int64(Widthptr) t.Width = int64(Widthptr)
...@@ -1217,7 +1225,7 @@ func (t *Type) ElemType() ssa.Type { ...@@ -1217,7 +1225,7 @@ func (t *Type) ElemType() ssa.Type {
return t.Elem() return t.Elem()
} }
func (t *Type) PtrTo() ssa.Type { func (t *Type) PtrTo() ssa.Type {
return ptrto(t) return typPtr(t)
} }
func (t *Type) NumFields() int { func (t *Type) NumFields() int {
......
...@@ -492,7 +492,7 @@ OpSwitch: ...@@ -492,7 +492,7 @@ OpSwitch:
if l.Op == OTYPE { if l.Op == OTYPE {
ok |= Etype ok |= Etype
n.Op = OTYPE n.Op = OTYPE
n.Type = ptrto(l.Type) n.Type = typPtr(l.Type)
n.Left = nil n.Left = nil
break OpSwitch break OpSwitch
} }
...@@ -823,7 +823,7 @@ OpSwitch: ...@@ -823,7 +823,7 @@ OpSwitch:
n.Type = nil n.Type = nil
return n return n
} }
n.Type = ptrto(t) n.Type = typPtr(t)
break OpSwitch break OpSwitch
case OCOMPLIT: case OCOMPLIT:
...@@ -1871,7 +1871,7 @@ OpSwitch: ...@@ -1871,7 +1871,7 @@ OpSwitch:
} }
n.Left = l n.Left = l
n.Type = ptrto(t) n.Type = typPtr(t)
break OpSwitch break OpSwitch
case OPRINT, OPRINTN: case OPRINT, OPRINTN:
...@@ -1933,7 +1933,7 @@ OpSwitch: ...@@ -1933,7 +1933,7 @@ OpSwitch:
if !t.IsInterface() { if !t.IsInterface() {
Fatalf("OITAB of %v", t) Fatalf("OITAB of %v", t)
} }
n.Type = ptrto(Types[TUINTPTR]) n.Type = typPtr(Types[TUINTPTR])
break OpSwitch break OpSwitch
case OIDATA: case OIDATA:
...@@ -1954,9 +1954,9 @@ OpSwitch: ...@@ -1954,9 +1954,9 @@ OpSwitch:
Fatalf("OSPTR of %v", t) Fatalf("OSPTR of %v", t)
} }
if t.IsString() { if t.IsString() {
n.Type = ptrto(Types[TUINT8]) n.Type = typPtr(Types[TUINT8])
} else { } else {
n.Type = ptrto(t.Elem()) n.Type = typPtr(t.Elem())
} }
break OpSwitch break OpSwitch
......
...@@ -843,7 +843,7 @@ opswitch: ...@@ -843,7 +843,7 @@ opswitch:
// don't generate a = *var if a is _ // don't generate a = *var if a is _
if !isblank(a) { if !isblank(a) {
var_ := temp(ptrto(t.Val())) var_ := temp(typPtr(t.Val()))
var_.Typecheck = 1 var_.Typecheck = 1
var_.SetNonNil(true) // mapaccess always returns a non-nil pointer var_.SetNonNil(true) // mapaccess always returns a non-nil pointer
n.List.SetFirst(var_) n.List.SetFirst(var_)
...@@ -954,7 +954,7 @@ opswitch: ...@@ -954,7 +954,7 @@ opswitch:
init.Append(nod(OAS, c, n.Left)) init.Append(nod(OAS, c, n.Left))
// Get the itab out of the interface. // Get the itab out of the interface.
tmp := temp(ptrto(Types[TUINT8])) tmp := temp(typPtr(Types[TUINT8]))
init.Append(nod(OAS, tmp, typecheck(nod(OITAB, c, nil), Erv))) init.Append(nod(OAS, tmp, typecheck(nod(OITAB, c, nil), Erv)))
// Get the type out of the itab. // Get the type out of the itab.
...@@ -963,7 +963,7 @@ opswitch: ...@@ -963,7 +963,7 @@ opswitch:
init.Append(nif) init.Append(nif)
// Build the result. // Build the result.
e := nod(OEFACE, tmp, ifaceData(c, ptrto(Types[TUINT8]))) e := nod(OEFACE, tmp, ifaceData(c, typPtr(Types[TUINT8])))
e.Type = n.Type // assign type manually, typecheck doesn't understand OEFACE. e.Type = n.Type // assign type manually, typecheck doesn't understand OEFACE.
e.Typecheck = 1 e.Typecheck = 1
n = e n = e
...@@ -1203,14 +1203,14 @@ opswitch: ...@@ -1203,14 +1203,14 @@ opswitch:
} }
if w := t.Val().Width; w <= 1024 { // 1024 must match ../../../../runtime/hashmap.go:maxZero if w := t.Val().Width; w <= 1024 { // 1024 must match ../../../../runtime/hashmap.go:maxZero
n = mkcall1(mapfn(p, t), ptrto(t.Val()), init, typename(t), map_, key) n = mkcall1(mapfn(p, t), typPtr(t.Val()), init, typename(t), map_, key)
} else { } else {
p = "mapaccess1_fat" p = "mapaccess1_fat"
z := zeroaddr(w) z := zeroaddr(w)
n = mkcall1(mapfn(p, t), ptrto(t.Val()), init, typename(t), map_, key, z) n = mkcall1(mapfn(p, t), typPtr(t.Val()), init, typename(t), map_, key, z)
} }
} }
n.Type = ptrto(t.Val()) n.Type = typPtr(t.Val())
n.SetNonNil(true) // mapaccess1* and mapassign always return non-nil pointers. n.SetNonNil(true) // mapaccess1* and mapassign always return non-nil pointers.
n = nod(OIND, n, nil) n = nod(OIND, n, nil)
n.Type = t.Val() n.Type = t.Val()
...@@ -1975,7 +1975,7 @@ func callnew(t *Type) *Node { ...@@ -1975,7 +1975,7 @@ func callnew(t *Type) *Node {
dowidth(t) dowidth(t)
fn := syslook("newobject") fn := syslook("newobject")
fn = substArgTypes(fn, t) fn = substArgTypes(fn, t)
v := mkcall1(fn, ptrto(t), nil, typename(t)) v := mkcall1(fn, typPtr(t), nil, typename(t))
v.SetNonNil(true) v.SetNonNil(true)
return v return v
} }
...@@ -3025,8 +3025,8 @@ func eqfor(t *Type, needsize *int) *Node { ...@@ -3025,8 +3025,8 @@ func eqfor(t *Type, needsize *int) *Node {
n := newname(sym) n := newname(sym)
n.Class = PFUNC n.Class = PFUNC
ntype := nod(OTFUNC, nil, nil) ntype := nod(OTFUNC, nil, nil)
ntype.List.Append(nod(ODCLFIELD, nil, typenod(ptrto(t)))) ntype.List.Append(nod(ODCLFIELD, nil, typenod(typPtr(t))))
ntype.List.Append(nod(ODCLFIELD, nil, typenod(ptrto(t)))) ntype.List.Append(nod(ODCLFIELD, nil, typenod(typPtr(t))))
ntype.Rlist.Append(nod(ODCLFIELD, nil, typenod(Types[TBOOL]))) ntype.Rlist.Append(nod(ODCLFIELD, nil, typenod(Types[TBOOL])))
ntype = typecheck(ntype, Etype) ntype = typecheck(ntype, Etype)
n.Type = ntype.Type n.Type = ntype.Type
...@@ -3071,7 +3071,7 @@ func walkcompare(n *Node, init *Nodes) *Node { ...@@ -3071,7 +3071,7 @@ func walkcompare(n *Node, init *Nodes) *Node {
tab := nod(OITAB, l, nil) tab := nod(OITAB, l, nil)
rtyp := typename(r.Type) rtyp := typename(r.Type)
if l.Type.IsEmptyInterface() { if l.Type.IsEmptyInterface() {
tab.Type = ptrto(Types[TUINT8]) tab.Type = typPtr(Types[TUINT8])
tab.Typecheck = 1 tab.Typecheck = 1
eqtype = nod(eq, tab, rtyp) eqtype = nod(eq, tab, rtyp)
} else { } else {
...@@ -3128,13 +3128,13 @@ func walkcompare(n *Node, init *Nodes) *Node { ...@@ -3128,13 +3128,13 @@ func walkcompare(n *Node, init *Nodes) *Node {
} }
// eq algs take pointers // eq algs take pointers
pl := temp(ptrto(t)) pl := temp(typPtr(t))
al := nod(OAS, pl, nod(OADDR, cmpl, nil)) al := nod(OAS, pl, nod(OADDR, cmpl, nil))
al.Right.Etype = 1 // addr does not escape al.Right.Etype = 1 // addr does not escape
al = typecheck(al, Etop) al = typecheck(al, Etop)
init.Append(al) init.Append(al)
pr := temp(ptrto(t)) pr := temp(typPtr(t))
ar := nod(OAS, pr, nod(OADDR, cmpr, nil)) ar := nod(OAS, pr, nod(OADDR, cmpr, nil))
ar.Right.Etype = 1 // addr does not escape ar.Right.Etype = 1 // addr does not escape
ar = typecheck(ar, Etop) ar = typecheck(ar, Etop)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment