[dev.regabi] cmd/compile: address some ir TODOs

Previously, ODOTTYPE/ODOTTYPE2 were forced to reuse some available
Node fields for storing pointers to runtime type descriptors. This
resulted in awkward field types for TypeAssertExpr and AddrExpr.

This CL gives TypeAssertExpr proper fields for the runtime type
descriptors, and also tightens the field types as
possible/appropriate.

Passes toolstash -cmp.

Change-Id: I521ee7a1462affc5459de33a0de6c68a7d6416ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/280637
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
Matthew Dempsky 2020-12-28 17:06:43 -08:00
parent 4629f6a51d
commit 6acbae4fcc
5 changed files with 18 additions and 17 deletions

View file

@ -109,7 +109,7 @@ func NewAddStringExpr(pos src.XPos, list []Node) *AddStringExpr {
type AddrExpr struct {
miniExpr
X Node
Alloc Node // preallocated storage if any
Alloc *Name // preallocated storage if any
}
func NewAddrExpr(pos src.XPos, x Node) *AddrExpr {
@ -660,8 +660,13 @@ func (n *StarExpr) SetOTYPE(t *types.Type) {
type TypeAssertExpr struct {
miniExpr
X Node
Ntype Node // TODO: Should be Ntype, but reused as address of type structure
Itab Nodes // Itab[0] is itab
Ntype Ntype
// Runtime type information provided by walkDotType.
// Caution: These aren't always populated; see walkDotType.
SrcType *AddrExpr // *runtime._type for X's type
DstType *AddrExpr // *runtime._type for Type
Itab *AddrExpr // *runtime.itab for Type implementing X's type
}
func NewTypeAssertExpr(pos src.XPos, x Node, typ Ntype) *TypeAssertExpr {