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
|
|
@ -237,6 +237,19 @@ const (
|
|||
TYPE_REGLIST
|
||||
)
|
||||
|
||||
func (a *Addr) Target() *Prog {
|
||||
if a.Type == TYPE_BRANCH && a.Val != nil {
|
||||
return a.Val.(*Prog)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (a *Addr) SetTarget(t *Prog) {
|
||||
if a.Type != TYPE_BRANCH {
|
||||
panic("setting branch target when type is not TYPE_BRANCH")
|
||||
}
|
||||
a.Val = t
|
||||
}
|
||||
|
||||
// Prog describes a single machine instruction.
|
||||
//
|
||||
// The general instruction form is:
|
||||
|
|
@ -255,7 +268,7 @@ const (
|
|||
// to avoid too much changes in a single swing.
|
||||
// (1) scheme is enough to express any kind of operand combination.
|
||||
//
|
||||
// Jump instructions use the Pcond field to point to the target instruction,
|
||||
// Jump instructions use the To.Val field to point to the target *Prog,
|
||||
// which must be in the same linked list as the jump instruction.
|
||||
//
|
||||
// The Progs for a given function are arranged in a list linked through the Link field.
|
||||
|
|
@ -274,7 +287,7 @@ type Prog struct {
|
|||
From Addr // first source operand
|
||||
RestArgs []Addr // can pack any operands that not fit into {Prog.From, Prog.To}
|
||||
To Addr // destination operand (second is RegTo2 below)
|
||||
Pcond *Prog // target of conditional jump
|
||||
Pool *Prog // constant pool entry, for arm,arm64 back ends
|
||||
Forwd *Prog // for x86 back end
|
||||
Rel *Prog // for x86, arm back ends
|
||||
Pc int64 // for back ends or assembler: virtual or actual program counter, depending on phase
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue