mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile,cmd/asm: simplify recording of branch targets, take 2
We currently use two fields to store the targets of branches. Some phases use p.To.Val, some use p.Pcond. Rewrite so that every branch instruction uses p.To.Val. p.From.Val is also used in rare instances. Introduce a Pool link for use by arm/arm64, instead of repurposing Pcond. This is a cleanup CL in preparation for some stack frame CLs. Change-Id: If8239177e4b1ea2bccd0608eb39553d23210d405 Reviewed-on: https://go-review.googlesource.com/c/go/+/251437 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
ba0fab3cb7
commit
9e70564f63
21 changed files with 149 additions and 134 deletions
|
|
@ -227,11 +227,11 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
|
|||
} else {
|
||||
p.Mark |= BRANCH
|
||||
}
|
||||
q1 := p.Pcond
|
||||
q1 := p.To.Target()
|
||||
if q1 != nil {
|
||||
for q1.As == obj.ANOP {
|
||||
q1 = q1.Link
|
||||
p.Pcond = q1
|
||||
p.To.SetTarget(q1)
|
||||
}
|
||||
|
||||
if q1.Mark&LEAF == 0 {
|
||||
|
|
@ -424,8 +424,8 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
|
|||
q = obj.Appendp(q, newprog)
|
||||
|
||||
q.As = obj.ANOP
|
||||
p1.Pcond = q
|
||||
p2.Pcond = q
|
||||
p1.To.SetTarget(q)
|
||||
p2.To.SetTarget(q)
|
||||
}
|
||||
|
||||
case ARET:
|
||||
|
|
@ -778,7 +778,7 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
|
|||
p.To.Type = obj.TYPE_REG
|
||||
p.To.Reg = REG_R3
|
||||
if q != nil {
|
||||
q.Pcond = p
|
||||
q.To.SetTarget(p)
|
||||
p.Mark |= LABEL
|
||||
}
|
||||
|
||||
|
|
@ -805,14 +805,14 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
|
|||
|
||||
p.As = AJMP
|
||||
p.To.Type = obj.TYPE_BRANCH
|
||||
p.Pcond = c.cursym.Func.Text.Link
|
||||
p.To.SetTarget(c.cursym.Func.Text.Link)
|
||||
p.Mark |= BRANCH
|
||||
|
||||
// placeholder for q1's jump target
|
||||
p = obj.Appendp(p, c.newprog)
|
||||
|
||||
p.As = obj.ANOP // zero-width place holder
|
||||
q1.Pcond = p
|
||||
q1.To.SetTarget(p)
|
||||
|
||||
return p
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue