1
0
mirror of https://github.com/golang/go synced 2024-11-18 03:54:50 -07:00

cmd/compile: eliminate Gins and Naddr

Preparation for eliminating Prog-related globals.

Passes toolstash-check -all.

Updates #15756

Change-Id: Ia199fcb282cc3a84903a6e92a3ce342c5faba79c
Reviewed-on: https://go-review.googlesource.com/38409
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Josh Bleecher Snyder 2017-03-22 11:31:56 -07:00
parent c644a76e1f
commit 352e19c92c
3 changed files with 10 additions and 63 deletions

View File

@ -653,7 +653,6 @@ var knownFormats = map[string]string{
"cmd/compile/internal/syntax.token %d": "",
"cmd/compile/internal/syntax.token %q": "",
"cmd/compile/internal/syntax.token %s": "",
"cmd/internal/obj.As %v": "",
"cmd/internal/src.Pos %s": "",
"cmd/internal/src.Pos %v": "",
"error %v": "",

View File

@ -109,44 +109,6 @@ func isfat(t *Type) bool {
return false
}
// Naddr rewrites a to refer to n.
// It assumes that a is zeroed on entry.
func Naddr(a *obj.Addr, n *Node) {
if n == nil {
return
}
if n.Op != ONAME {
Debug['h'] = 1
Dump("naddr", n)
Fatalf("naddr: bad %v %v", n.Op, Ctxt.Dconv(a))
}
a.Offset = n.Xoffset
s := n.Sym
if s == nil {
Fatalf("naddr: nil sym %v", n)
}
a.Type = obj.TYPE_MEM
switch n.Class {
default:
Fatalf("naddr: ONAME class %v %d\n", n.Sym, n.Class)
case PEXTERN, PFUNC:
a.Name = obj.NAME_EXTERN
case PAUTO:
a.Name = obj.NAME_AUTO
case PPARAM, PPARAMOUT:
a.Name = obj.NAME_PARAM
}
a.Sym = Linksym(s)
}
func Addrconst(a *obj.Addr, v int64) {
a.Sym = nil
a.Type = obj.TYPE_CONST
@ -277,17 +239,3 @@ func Patch(p *obj.Prog, to *obj.Prog) {
p.To.Val = to
p.To.Offset = to.Pc
}
// Gins inserts instruction as. f is from, t is to.
func Gins(as obj.As, f, t *Node) *obj.Prog {
switch as {
case obj.ATEXT, obj.AFUNCDATA:
default:
Fatalf("unhandled gins op %v", as)
}
p := Prog(as)
Naddr(&p.From, f)
Naddr(&p.To, t)
return p
}

View File

@ -316,12 +316,15 @@ func compile(fn *Node) {
setlineno(fn)
nam := fn.Func.Nname
if isblank(nam) {
nam = nil
ptxt := Prog(obj.ATEXT)
if nam := fn.Func.Nname; !isblank(nam) {
ptxt.From.Type = obj.TYPE_MEM
ptxt.From.Name = obj.NAME_EXTERN
ptxt.From.Sym = Linksym(nam.Sym)
if fn.Func.Pragma&Systemstack != 0 {
ptxt.From.Sym.Set(obj.AttrCFunc, true)
}
}
ptxt := Gins(obj.ATEXT, nam, nil)
fnsym := ptxt.From.Sym
ptxt.From3 = new(obj.Addr)
if fn.Func.Dupok() {
@ -342,9 +345,6 @@ func compile(fn *Node) {
if fn.Func.ReflectMethod() {
ptxt.From3.Offset |= obj.REFLECTMETHOD
}
if fn.Func.Pragma&Systemstack != 0 {
ptxt.From.Sym.Set(obj.AttrCFunc, true)
}
// Clumsy but important.
// See test/recover.go for test cases and src/reflect/value.go
@ -357,10 +357,10 @@ func compile(fn *Node) {
genssa(ssafn, ptxt)
fieldtrack(ptxt.From.Sym, fn.Func.FieldTrack)
obj.Flushplist(Ctxt, plist) // convert from Prog list to machine code
ptxt = nil // nil to prevent misuse; Prog may have been freed by Flushplist
fieldtrack(fnsym, fn.Func.FieldTrack)
}
func debuginfo(fnsym *obj.LSym) []*dwarf.Var {