[dev.typeparams] cmd/compile: implement generic type switches

Add a new dynamicType node, which is used as a case entry when
the type being switched to is generic.

Change-Id: Ice77c6f224b8fdd3ff574fdf4a8ea5f6c7ddbe75
Reviewed-on: https://go-review.googlesource.com/c/go/+/339429
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
Keith Randall 2021-08-03 08:10:17 -07:00
parent 57668b84ff
commit ca3c6985cd
21 changed files with 342 additions and 18 deletions

View file

@ -107,6 +107,10 @@ type gfInfo struct {
// Nodes in generic functions that are a conversion from a typeparam/derived
// type to a specific interface.
itabConvs []ir.Node
// For type switches on nonempty interfaces, a map from OTYPE entries of
// HasTParam type, to the interface type we're switching from.
// TODO: what if the type we're switching from is a shape type?
type2switchType map[ir.Node]*types.Type
}
// instInfo is information gathered on an gcshape (or fully concrete)