Commit b72636cb authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile/internal/gc: cleanup selecttype

Use namedfield consistently.

Passes toolstash-check.

Change-Id: Ic5a3acb4bfaa1f60dd2eac94612160509e8d7f94
Reviewed-on: https://go-review.googlesource.com/38741
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 3c0072e0
...@@ -254,7 +254,7 @@ func walkselect(sel *Node) { ...@@ -254,7 +254,7 @@ func walkselect(sel *Node) {
// generate sel-struct // generate sel-struct
setlineno(sel) setlineno(sel)
selv = temp(selecttype(int32(sel.Xoffset))) selv = temp(selecttype(sel.Xoffset))
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)
...@@ -327,35 +327,32 @@ out: ...@@ -327,35 +327,32 @@ out:
} }
// Keep in sync with src/runtime/select.go. // Keep in sync with src/runtime/select.go.
func selecttype(size int32) *Type { func selecttype(size int64) *Type {
// TODO(dvyukov): it's possible to generate Scase only once // TODO(dvyukov): it's possible to generate Scase only once
// and then cache; and also cache Select per size. // and then cache; and also cache Select per size.
scase := nod(OTSTRUCT, nil, nil) scase := tostruct([]*Node{
scase.List.Append(namedfield("elem", typPtr(Types[TUINT8]))) namedfield("elem", typPtr(Types[TUINT8])),
scase.List.Append(namedfield("chan", typPtr(Types[TUINT8]))) namedfield("chan", typPtr(Types[TUINT8])),
scase.List.Append(namedfield("pc", Types[TUINTPTR])) namedfield("pc", Types[TUINTPTR]),
scase.List.Append(namedfield("kind", Types[TUINT16])) namedfield("kind", Types[TUINT16]),
scase.List.Append(namedfield("receivedp", typPtr(Types[TUINT8]))) namedfield("receivedp", typPtr(Types[TUINT8])),
scase.List.Append(namedfield("releasetime", Types[TUINT64])) namedfield("releasetime", Types[TUINT64]),
scase = typecheck(scase, Etype) })
scase.Type.SetNoalg(true) scase.SetNoalg(true)
scase.Type.SetLocal(true) scase.SetLocal(true)
sel := nod(OTSTRUCT, nil, nil) sel := tostruct([]*Node{
sel.List.Append(namedfield("tcase", Types[TUINT16])) namedfield("tcase", Types[TUINT16]),
sel.List.Append(namedfield("ncase", Types[TUINT16])) namedfield("ncase", Types[TUINT16]),
sel.List.Append(namedfield("pollorder", typPtr(Types[TUINT8]))) namedfield("pollorder", typPtr(Types[TUINT8])),
sel.List.Append(namedfield("lockorder", typPtr(Types[TUINT8]))) namedfield("lockorder", typPtr(Types[TUINT8])),
arr := nod(OTARRAY, nodintconst(int64(size)), scase) namedfield("scase", typArray(scase, size)),
sel.List.Append(nod(ODCLFIELD, newname(lookup("scase")), arr)) namedfield("lockorderarr", typArray(Types[TUINT16], size)),
arr = nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16])) namedfield("pollorderarr", typArray(Types[TUINT16], size)),
sel.List.Append(nod(ODCLFIELD, newname(lookup("lockorderarr")), arr)) })
arr = nod(OTARRAY, nodintconst(int64(size)), typenod(Types[TUINT16])) sel.SetNoalg(true)
sel.List.Append(nod(ODCLFIELD, newname(lookup("pollorderarr")), arr)) sel.SetLocal(true)
sel = typecheck(sel, Etype)
sel.Type.SetNoalg(true) return sel
sel.Type.SetLocal(true)
return sel.Type
} }
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