1
0
mirror of https://github.com/golang/go synced 2024-09-23 17:10:13 -06:00

[dev.regabi] cmd/compile: setup to move Addrconst, Patch into cmd/internal/obj

Deleting the Pc assignment from Patch is safe because the actual PCs
are not assigned until well after the compiler is done patching jumps.
And it proves that replacing uses of Patch with SetTarget will be safe later.

Change-Id: Iffcbe03f0b5949ccd4c91e79c1272cd06be0f434
Reviewed-on: https://go-review.googlesource.com/c/go/+/279296
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Russ Cox 2020-12-21 01:14:36 -05:00
parent 0bb0baf683
commit 2153a99914
2 changed files with 7 additions and 7 deletions

View File

@ -321,15 +321,9 @@ func ggloblsym(s *obj.LSym, width int32, flags int16) {
}
func Addrconst(a *obj.Addr, v int64) {
a.Sym = nil
a.Type = obj.TYPE_CONST
a.Offset = v
a.SetConst(v)
}
func Patch(p *obj.Prog, to *obj.Prog) {
if p.To.Type != obj.TYPE_BRANCH {
base.Fatalf("patch: not a branch")
}
p.To.SetTarget(to)
p.To.Offset = to.Pc
}

View File

@ -250,6 +250,12 @@ func (a *Addr) SetTarget(t *Prog) {
a.Val = t
}
func (a *Addr) SetConst(v int64) {
a.Sym = nil
a.Type = TYPE_CONST
a.Offset = v
}
// Prog describes a single machine instruction.
//
// The general instruction form is: