cmd/compile: abstract type type+value obtained from types2

In preparation for encoding it in a more efficient way.

Change-Id: I299dd2befc3d07107a1b7b49225bbb9f2e48a343
Reviewed-on: https://go-review.googlesource.com/c/go/+/432896
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Keith Randall 2022-09-02 13:50:10 -07:00
parent dcb90152a4
commit b52783c1e9
4 changed files with 52 additions and 50 deletions

View file

@ -27,10 +27,7 @@ func (g *irgen) expr(expr syntax.Expr) ir.Node {
return ir.BlankNode
}
tv, ok := g.info.Types[expr]
if !ok {
base.FatalfAt(g.pos(expr), "missing type for %v (%T)", expr, expr)
}
tv := g.typeAndValue(expr)
switch {
case tv.IsBuiltin():
// Qualified builtins, such as unsafe.Add and unsafe.Slice.
@ -105,8 +102,7 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
case *syntax.IndexExpr:
args := unpackListExpr(expr.Index)
if len(args) == 1 {
tv, ok := g.info.Types[args[0]]
assert(ok)
tv := g.typeAndValue(args[0])
if tv.IsValue() {
// This is just a normal index expression
n := Index(pos, g.typ(typ), g.expr(expr.X), g.expr(args[0]))