[dev.regabi] cmd/compile: simplify ir.Func somewhat

Two simplifications:

1. Statements (including ODCLFUNC) don't have types, and the
Func.Nname already has a type. There's no need for a second one.
However, there is a lot of code that expects to be able to call
Func.Type, so leave a forwarding method, like with Sym and Linksym.

2. Inline and remove ir.NewFuncNameAt. It doesn't really save any
code, and it's only used a handful of places.

Passes toolstash -cmp.

Change-Id: I51acaa341897dae0fcdf2fa576a10174a2ae4d1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280648
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
Matthew Dempsky 2020-12-29 03:08:23 -08:00
parent e40cb4d4ae
commit 9ea272e5ec
8 changed files with 18 additions and 32 deletions

View file

@ -49,7 +49,6 @@ import (
// pointer from the Func back to the OCALLPART.
type Func struct {
miniNode
typ *types.Type
Body Nodes
Iota int64
@ -116,9 +115,7 @@ func NewFunc(pos src.XPos) *Func {
func (f *Func) isStmt() {}
func (f *Func) Type() *types.Type { return f.typ }
func (f *Func) SetType(x *types.Type) { f.typ = x }
func (f *Func) Type() *types.Type { return f.Nname.Type() }
func (f *Func) Sym() *types.Sym { return f.Nname.Sym() }
func (f *Func) Linksym() *obj.LSym { return f.Nname.Linksym() }
@ -236,17 +233,6 @@ func FuncSymName(s *types.Sym) string {
return s.Name + "·f"
}
// NewFuncNameAt generates a new name node for a function or method.
func NewFuncNameAt(pos src.XPos, s *types.Sym, fn *Func) *Name {
if fn.Nname != nil {
base.Fatalf("newFuncName - already have name")
}
n := NewNameAt(pos, s)
n.SetFunc(fn)
fn.Nname = n
return n
}
// MarkFunc marks a node as a function.
func MarkFunc(n *Name) {
if n.Op() != ONAME || n.Class_ != Pxxx {