Commit bdd7c01b authored by fanzha02's avatar fanzha02 Committed by Cherry Zhang

cmd/internal/obj/arm64: fix assemble movk bug

The current code gets shift arguments value from prog.From3.Offset.
But prog.From3.Offset is not assigned the shift arguments value in
instructions assemble process.

The fix calls movcon() function to get the correct value.

Uncomment the movk/movkw  cases.

Fixes #21398
Change-Id: I78d40c33c24bd4e3688a04622e4af7ddb5333fa6
Reviewed-on: https://go-review.googlesource.com/54990
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent 33484a6a
...@@ -242,9 +242,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$-8 ...@@ -242,9 +242,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$-8
ORRW $16252928, ZR, R21 // f5130d32 ORRW $16252928, ZR, R21 // f5130d32
MOVD $-4260607558625, R11 // eb6b16b2 MOVD $-4260607558625, R11 // eb6b16b2
MOVD R30, R7 // e7031eaa MOVD R30, R7 // e7031eaa
// MOVKW $(3905<<0), R21 // MOVKW $3905, R21 // 35e88172 MOVKW $(3905<<0), R21 // MOVKW $3905, R21 // 35e88172
// MOVKW $(3905<<16), R21 // MOVKW $255918080, R21 // 35e8a172 MOVKW $(3905<<16), R21 // MOVKW $255918080, R21 // 35e8a172
// MOVK $(3905<<32), R21 // MOVK $16771847290880, R21 // 35e8c1f2 MOVK $(3905<<32), R21 // MOVK $16771847290880, R21 // 35e8c1f2
MOVD $0, R5 // 050080d2 MOVD $0, R5 // 050080d2
// MRS $4567, R16 // f03a32d5 // MRS $4567, R16 // f03a32d5
// MRS $32345, R6 // 26cb3fd5 // MRS $32345, R6 // 26cb3fd5
......
...@@ -2597,22 +2597,19 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) { ...@@ -2597,22 +2597,19 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
o1 = c.opirr(p, p.As) o1 = c.opirr(p, p.As)
d := p.From.Offset d := p.From.Offset
if (d >> 16) != 0 { s := movcon(d)
c.ctxt.Diag("requires uimm16\n%v", p) if s < 0 || s >= 4 {
c.ctxt.Diag("bad constant for MOVK: %#x\n%v", uint64(d), p)
} }
s := 0 if (o1&S64) == 0 && s >= 2 {
if p.From3Type() != obj.TYPE_NONE { c.ctxt.Diag("illegal bit position\n%v", p)
if p.From3.Type != obj.TYPE_CONST { }
c.ctxt.Diag("missing bit position\n%v", p) if ((d >> uint(s*16)) >> 16) != 0 {
} c.ctxt.Diag("requires uimm16\n%v",p)
s = int(p.From3.Offset / 16)
if (s*16&0xF) != 0 || s >= 4 || (o1&S64) == 0 && s >= 2 {
c.ctxt.Diag("illegal bit position\n%v", p)
}
} }
rt := int(p.To.Reg) rt := int(p.To.Reg)
o1 |= uint32(((d & 0xFFFF) << 5) | int64((uint32(s)&3)<<21) | int64(rt&31))
o1 |= uint32((((d >> uint(s*16)) & 0xFFFF) << 5) | int64((uint32(s)&3)<<21) | int64(rt&31))
case 34: /* mov $lacon,R */ case 34: /* mov $lacon,R */
o1 = c.omovlit(AMOVD, p, &p.From, REGTMP) o1 = c.omovlit(AMOVD, p, &p.From, REGTMP)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment