mirror of
https://github.com/golang/go
synced 2024-11-23 20:40:07 -07:00
cmd/internal/obj/arm64: use more appropriate types for olsr12u
This allows for a large number of casts to be removed at call sites. Change-Id: Id929f6c7155b0b59a2bcdf43144de95a007b8a48 Reviewed-on: https://go-review.googlesource.com/c/go/+/461139 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Eric Fang <eric.fang@arm.com>
This commit is contained in:
parent
ecff9c9335
commit
f07fafacef
@ -3710,31 +3710,31 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
v := int32(c.regoff(&p.To))
|
||||
sz := int32(1 << uint(movesize(p.As)))
|
||||
|
||||
r := int(p.To.Reg)
|
||||
r := p.To.Reg
|
||||
if r == obj.REG_NONE {
|
||||
r = int(o.param)
|
||||
r = o.param
|
||||
}
|
||||
if v < 0 || v%sz != 0 { /* unscaled 9-bit signed */
|
||||
o1 = c.olsr9s(p, int32(c.opstr(p, p.As)), v, r, int(p.From.Reg))
|
||||
o1 = c.olsr9s(p, int32(c.opstr(p, p.As)), v, int(r), int(p.From.Reg))
|
||||
} else {
|
||||
v = int32(c.offsetshift(p, int64(v), int(o.a4)))
|
||||
o1 = c.olsr12u(p, int32(c.opstr(p, p.As)), v, r, int(p.From.Reg))
|
||||
o1 = c.olsr12u(p, c.opstr(p, p.As), v, r, p.From.Reg)
|
||||
}
|
||||
|
||||
case 21: /* movT O(R),R -> ldrT */
|
||||
v := int32(c.regoff(&p.From))
|
||||
sz := int32(1 << uint(movesize(p.As)))
|
||||
|
||||
r := int(p.From.Reg)
|
||||
r := p.From.Reg
|
||||
if r == obj.REG_NONE {
|
||||
r = int(o.param)
|
||||
r = o.param
|
||||
}
|
||||
if v < 0 || v%sz != 0 { /* unscaled 9-bit signed */
|
||||
o1 = c.olsr9s(p, int32(c.opldr(p, p.As)), v, r, int(p.To.Reg))
|
||||
o1 = c.olsr9s(p, int32(c.opldr(p, p.As)), v, int(r), int(p.To.Reg))
|
||||
} else {
|
||||
v = int32(c.offsetshift(p, int64(v), int(o.a1)))
|
||||
//print("offset=%lld v=%ld a1=%d\n", instoffset, v, o->a1);
|
||||
o1 = c.olsr12u(p, int32(c.opldr(p, p.As)), v, r, int(p.To.Reg))
|
||||
o1 = c.olsr12u(p, c.opldr(p, p.As), v, r, p.To.Reg)
|
||||
}
|
||||
|
||||
case 22: /* movT (R)O!,R; movT O(R)!, R -> ldrT */
|
||||
@ -3913,7 +3913,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
}
|
||||
|
||||
o1 = c.oaddi(p, int32(c.opirr(p, AADD)), hi, r, REGTMP)
|
||||
o2 = c.olsr12u(p, int32(c.opstr(p, p.As)), ((v-hi)>>uint(s))&0xFFF, REGTMP, int(p.From.Reg))
|
||||
o2 = c.olsr12u(p, c.opstr(p, p.As), ((v-hi)>>uint(s))&0xFFF, REGTMP, p.From.Reg)
|
||||
break
|
||||
|
||||
storeusepool:
|
||||
@ -3957,7 +3957,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
}
|
||||
|
||||
o1 = c.oaddi(p, int32(c.opirr(p, AADD)), hi, r, REGTMP)
|
||||
o2 = c.olsr12u(p, int32(c.opldr(p, p.As)), ((v-hi)>>uint(s))&0xFFF, REGTMP, int(p.To.Reg))
|
||||
o2 = c.olsr12u(p, c.opldr(p, p.As), ((v-hi)>>uint(s))&0xFFF, REGTMP, p.To.Reg)
|
||||
break
|
||||
|
||||
loadusepool:
|
||||
@ -4472,11 +4472,11 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
// For unaligned access, fall back to adrp + add + movT R, (REGTMP).
|
||||
if o.size(c.ctxt, p) != 8 {
|
||||
o2 = c.opirr(p, AADD) | REGTMP&31<<5 | REGTMP&31
|
||||
o3 = c.olsr12u(p, int32(c.opstr(p, p.As)), 0, REGTMP, int(p.From.Reg))
|
||||
o3 = c.olsr12u(p, c.opstr(p, p.As), 0, REGTMP, p.From.Reg)
|
||||
rel.Type = objabi.R_ADDRARM64
|
||||
break
|
||||
}
|
||||
o2 = c.olsr12u(p, int32(c.opstr(p, p.As)), 0, REGTMP, int(p.From.Reg))
|
||||
o2 = c.olsr12u(p, c.opstr(p, p.As), 0, REGTMP, p.From.Reg)
|
||||
rel.Type = c.addrRelocType(p)
|
||||
|
||||
case 65: /* movT addr,R -> adrp + movT (REGTMP), R */
|
||||
@ -4489,11 +4489,11 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
// For unaligned access, fall back to adrp + add + movT (REGTMP), R.
|
||||
if o.size(c.ctxt, p) != 8 {
|
||||
o2 = c.opirr(p, AADD) | REGTMP&31<<5 | REGTMP&31
|
||||
o3 = c.olsr12u(p, int32(c.opldr(p, p.As)), 0, REGTMP, int(p.To.Reg))
|
||||
o3 = c.olsr12u(p, c.opldr(p, p.As), 0, REGTMP, p.To.Reg)
|
||||
rel.Type = objabi.R_ADDRARM64
|
||||
break
|
||||
}
|
||||
o2 = c.olsr12u(p, int32(c.opldr(p, p.As)), 0, REGTMP, int(p.To.Reg))
|
||||
o2 = c.olsr12u(p, c.opldr(p, p.As), 0, REGTMP, p.To.Reg)
|
||||
rel.Type = c.addrRelocType(p)
|
||||
|
||||
case 66: /* ldp O(R)!, (r1, r2); ldp (R)O!, (r1, r2) */
|
||||
@ -4547,7 +4547,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
|
||||
case 70: /* IE model movd $tlsvar, reg -> adrp REGTMP, 0; ldr reg, [REGTMP, #0] + relocs */
|
||||
o1 = ADR(1, 0, REGTMP)
|
||||
o2 = c.olsr12u(p, int32(c.opldr(p, AMOVD)), 0, REGTMP, int(p.To.Reg))
|
||||
o2 = c.olsr12u(p, c.opldr(p, AMOVD), 0, REGTMP, p.To.Reg)
|
||||
rel := obj.Addrel(c.cursym)
|
||||
rel.Off = int32(c.pc)
|
||||
rel.Siz = 8
|
||||
@ -4560,7 +4560,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
|
||||
case 71: /* movd sym@GOT, reg -> adrp REGTMP, #0; ldr reg, [REGTMP, #0] + relocs */
|
||||
o1 = ADR(1, 0, REGTMP)
|
||||
o2 = c.olsr12u(p, int32(c.opldr(p, AMOVD)), 0, REGTMP, int(p.To.Reg))
|
||||
o2 = c.olsr12u(p, c.opldr(p, AMOVD), 0, REGTMP, p.To.Reg)
|
||||
rel := obj.Addrel(c.cursym)
|
||||
rel.Off = int32(c.pc)
|
||||
rel.Siz = 8
|
||||
@ -6984,15 +6984,15 @@ func (c *ctxt7) opstore(p *obj.Prog, a obj.As) uint32 {
|
||||
* load/store register (scaled 12-bit unsigned immediate) C3.3.13
|
||||
* these produce 64-bit values (when there's an option)
|
||||
*/
|
||||
func (c *ctxt7) olsr12u(p *obj.Prog, o int32, v int32, b int, r int) uint32 {
|
||||
func (c *ctxt7) olsr12u(p *obj.Prog, o uint32, v int32, b, r int16) uint32 {
|
||||
if v < 0 || v >= (1<<12) {
|
||||
c.ctxt.Diag("offset out of range: %d\n%v", v, p)
|
||||
}
|
||||
o |= (v & 0xFFF) << 10
|
||||
o |= int32(b&31) << 5
|
||||
o |= int32(r & 31)
|
||||
o |= uint32(v&0xFFF) << 10
|
||||
o |= uint32(b&31) << 5
|
||||
o |= uint32(r & 31)
|
||||
o |= 1 << 24
|
||||
return uint32(o)
|
||||
return o
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user