cmd/internal/obj: add Prog.SetFrom3{Reg,Const}

These are the the most common uses, and they reduce line noise.

I don't love adding new deprecated APIs,
but since they're trivial wrappers,
it'll be very easy to update them along with the rest.
No functional changes; passes toolstash-check.

Change-Id: I691a8175cfef9081180e463c63f326376af3f3a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/296009
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2021-01-07 14:01:29 -08:00
parent 5f15af111c
commit a61524d103
8 changed files with 41 additions and 30 deletions

View file

@ -360,6 +360,20 @@ func (p *Prog) SetFrom3(a Addr) {
p.RestArgs = []AddrPos{{a, Source}}
}
// SetFrom3Reg calls p.SetFrom3 with a register Addr containing reg.
//
// Deprecated: for the same reasons as Prog.GetFrom3.
func (p *Prog) SetFrom3Reg(reg int16) {
p.SetFrom3(Addr{Type: TYPE_REG, Reg: reg})
}
// SetFrom3Const calls p.SetFrom3 with a const Addr containing x.
//
// Deprecated: for the same reasons as Prog.GetFrom3.
func (p *Prog) SetFrom3Const(off int64) {
p.SetFrom3(Addr{Type: TYPE_CONST, Offset: off})
}
// SetTo2 assigns []Args{{a, 1}} to p.RestArgs when the second destination
// operand does not fit into prog.RegTo2.
func (p *Prog) SetTo2(a Addr) {