1
0
mirror of https://github.com/golang/go synced 2024-11-20 10:34:42 -07:00

[dev.cc] cmd/internal/obj, cmd/new9a: use ctxt.NewProg

cmd/internal/obj reconverted using rsc.io/c2go rev 40275b8.

All Prog*s need Ctxt field set so that the printer can tell
which architecture the Prog belongs to.
Use ctxt.NewProg consistently for this.

Change-Id: Ic981b3d68f24931ffae74a772e83a3dc2fdf518a
Reviewed-on: https://go-review.googlesource.com/3152
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Russ Cox 2015-01-21 21:45:29 -05:00
parent ebaf8db4f6
commit 67e7ded029
10 changed files with 43 additions and 49 deletions

View File

@ -463,7 +463,7 @@ func asmoutnacl(ctxt *obj.Link, origPC int32, p *obj.Prog, o *Optab, out []uint3
// split it into two instructions:
// ADD $-100004, R13
// MOVW R14, 0(R13)
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
p.Scond &^= C_WBIT
*q = *p
@ -546,7 +546,7 @@ func asmoutnacl(ctxt *obj.Link, origPC int32, p *obj.Prog, o *Optab, out []uint3
ctxt.Diag("unsupported instruction (.P/.W): %v", p)
}
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
*q = *p
if p.To.Type == D_OREG {
a2 = &q.To
@ -894,7 +894,7 @@ func flushpool(ctxt *obj.Link, p *obj.Prog, skip int, force int) int {
if false && skip == 1 {
fmt.Printf("note: flush literal pool at %x: len=%d ref=%x\n", uint64(p.Pc+4), pool.size, pool.start)
}
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = AB
q.To.Type = D_BRANCH
q.Pcond = p.Link
@ -906,7 +906,7 @@ func flushpool(ctxt *obj.Link, p *obj.Prog, skip int, force int) int {
}
if ctxt.Headtype == obj.Hnacl && pool.size%16 != 0 {
// if pool is not multiple of 16 bytes, add an alignment marker
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = ADATABUNDLEEND
ctxt.Elitrl.Link = q
@ -983,7 +983,7 @@ func addpool(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
if ctxt.Headtype == obj.Hnacl && pool.size%16 == 0 {
// start a new data bundle
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
*q = zprg
q.As = ADATABUNDLE
@ -1000,7 +1000,7 @@ func addpool(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
ctxt.Elitrl = q
}
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
*q = t
q.Pc = int64(pool.size)

View File

@ -219,11 +219,8 @@ func progedit(ctxt *obj.Link, p *obj.Prog) {
}
func prg() *obj.Prog {
var p *obj.Prog
p = new(obj.Prog)
*p = zprg5
return p
p := zprg
return &p
}
// Prog.mark
@ -789,7 +786,7 @@ func softfloat(ctxt *obj.Link, cursym *obj.LSym) {
soft:
if !(wasfloat != 0) || (p.Mark&LABEL != 0) {
next = ctxt.Arch.Prg()
next = ctxt.NewProg()
*next = *p
// BL _sfloat(SB)
@ -954,7 +951,7 @@ func follow(ctxt *obj.Link, s *obj.LSym) {
ctxt.Cursym = s
firstp = ctxt.Arch.Prg()
firstp = ctxt.NewProg()
lastp = firstp
xfol(ctxt, s.Text, &lastp)
lastp.Link = nil
@ -1048,7 +1045,7 @@ loop:
copy:
for {
r = ctxt.Arch.Prg()
r = ctxt.NewProg()
*r = *p
if !(r.Mark&FOLL != 0) {
fmt.Printf("can't happen 1\n")
@ -1083,7 +1080,7 @@ loop:
}
a = AB
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = int16(a)
q.Lineno = p.Lineno
q.To.Type = D_BRANCH

View File

@ -287,11 +287,8 @@ func progedit(ctxt *obj.Link, p *obj.Prog) {
}
func prg() *obj.Prog {
var p *obj.Prog
p = new(obj.Prog)
*p = zprg
return p
p := zprg
return &p
}
func addstacksplit(ctxt *obj.Link, cursym *obj.LSym) {
@ -726,7 +723,7 @@ func follow(ctxt *obj.Link, s *obj.LSym) {
ctxt.Cursym = s
firstp = ctxt.Arch.Prg()
firstp = ctxt.NewProg()
lastp = firstp
xfol(ctxt, s.Text, &lastp)
lastp.Link = nil
@ -882,7 +879,7 @@ loop:
/* */
}
}
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = AJMP
q.Lineno = p.Lineno
q.To.Type = D_BRANCH

View File

@ -144,7 +144,7 @@ func mkfwd(sym *LSym) {
func Copyp(ctxt *Link, q *Prog) *Prog {
var p *Prog
p = ctxt.Arch.Prg()
p = ctxt.NewProg()
*p = *q
return p
}
@ -152,7 +152,7 @@ func Copyp(ctxt *Link, q *Prog) *Prog {
func Appendp(ctxt *Link, q *Prog) *Prog {
var p *Prog
p = ctxt.Arch.Prg()
p = ctxt.NewProg()
p.Link = q.Link
q.Link = p
p.Lineno = q.Lineno

View File

@ -49,7 +49,7 @@ type Addr struct {
Class int8
Etype uint8
Offset2 int32
Node *struct{}
Node interface{}
Width int64
}

View File

@ -475,14 +475,14 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) {
otxt = p.Pcond.Pc - c
if otxt < -(1<<15)+10 || otxt >= (1<<15)-10 {
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.Link = p.Link
p.Link = q
q.As = ABR
q.To.Type = D_BRANCH
q.Pcond = p.Pcond
p.Pcond = q
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.Link = p.Link
p.Link = q
q.As = ABR

View File

@ -599,7 +599,7 @@ func addstacksplit(ctxt *obj.Link, cursym *obj.LSym) {
p.To.Reg = REGSP
p.Spadj = -autosize
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = ABR
q.Lineno = p.Lineno
q.To.Type = D_SPR
@ -619,7 +619,7 @@ func addstacksplit(ctxt *obj.Link, cursym *obj.LSym) {
p.To.Type = D_REG
p.To.Reg = REGTMP
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = AMOVD
q.Lineno = p.Lineno
q.From.Type = D_REG
@ -633,7 +633,7 @@ func addstacksplit(ctxt *obj.Link, cursym *obj.LSym) {
if false {
// Debug bad returns
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = AMOVD
q.Lineno = p.Lineno
@ -649,7 +649,7 @@ func addstacksplit(ctxt *obj.Link, cursym *obj.LSym) {
}
if autosize != 0 {
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = AADD
q.Lineno = p.Lineno
q.From.Type = D_CONST
@ -662,7 +662,7 @@ func addstacksplit(ctxt *obj.Link, cursym *obj.LSym) {
p.Link = q
}
q1 = ctxt.Arch.Prg()
q1 = ctxt.NewProg()
q1.As = ABR
q1.Lineno = p.Lineno
q1.To.Type = D_SPR
@ -888,7 +888,7 @@ func follow(ctxt *obj.Link, s *obj.LSym) {
ctxt.Cursym = s
firstp = ctxt.Arch.Prg()
firstp = ctxt.NewProg()
lastp = firstp
xfol(ctxt, s.Text, &lastp)
lastp.Link = nil
@ -984,7 +984,7 @@ loop:
copy:
for {
r = ctxt.Arch.Prg()
r = ctxt.NewProg()
*r = *p
if !(r.Mark&FOLL != 0) {
fmt.Printf("cant happen 1\n")
@ -1016,7 +1016,7 @@ loop:
}
a = ABR
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = int16(a)
q.Lineno = p.Lineno
q.To.Type = D_BRANCH
@ -1053,11 +1053,8 @@ loop:
}
func prg() *obj.Prog {
var p *obj.Prog
p = new(obj.Prog)
*p = zprg
return p
p := zprg
return &p
}
var Linkppc64 = obj.LinkArch{

View File

@ -117,3 +117,9 @@ func (p *Prog) String() string {
}
return p.Ctxt.Arch.Pconv(p)
}
func (ctxt *Link) NewProg() *Prog {
p := ctxt.Arch.Prg() // should be the only call to this; all others should use ctxt.NewProg
p.Ctxt = ctxt
return p
}

View File

@ -887,7 +887,7 @@ func follow(ctxt *obj.Link, s *obj.LSym) {
ctxt.Cursym = s
firstp = ctxt.Arch.Prg()
firstp = ctxt.NewProg()
lastp = firstp
xfol(ctxt, s.Text, &lastp)
lastp.Link = nil
@ -1051,7 +1051,7 @@ loop:
/* */
}
}
q = ctxt.Arch.Prg()
q = ctxt.NewProg()
q.As = AJMP
q.Lineno = p.Lineno
q.To.Type = D_BRANCH
@ -1124,11 +1124,8 @@ loop:
}
func prg() *obj.Prog {
var p *obj.Prog
p = new(obj.Prog)
*p = zprg
return p
p := zprg
return &p
}
var Linkamd64 = obj.LinkArch{

View File

@ -498,7 +498,7 @@ func outcode(a int, g1 *obj.Addr, reg int, g2 *obj.Addr) {
reg = int(g2.Scale)
}
p = asm.Ctxt.Arch.Prg()
p = asm.Ctxt.NewProg()
p.As = int16(a)
p.Lineno = asm.Lineno
if nosched != 0 {
@ -531,7 +531,7 @@ func outgcode(a int, g1 *obj.Addr, reg int, g2, g3 *obj.Addr) {
goto out
}
p = asm.Ctxt.Arch.Prg()
p = asm.Ctxt.NewProg()
p.As = int16(a)
p.Lineno = asm.Lineno
if nosched != 0 {