Commit 7e817859 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/internal/obj: eliminate Curp

Remove the global obj.Link.Curp.

In asmz.go, replace the only use by passing it as an argument.
In asm0.go and asm9.go, it was written but never read.
In asm5.go and asm7.go, thread it through as an argument.

Passes toolstash-check -all.

Updates #15756

Change-Id: I1a0faa89e768820f35d73a8b37ec8088d78d15f7
Reviewed-on: https://go-review.googlesource.com/38715
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 1acba7d4
...@@ -583,7 +583,6 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -583,7 +583,6 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) {
break break
} }
ctxt.Curp = p
p.Pc = int64(c) p.Pc = int64(c)
o = oplook(ctxt, p) o = oplook(ctxt, p)
if ctxt.Headtype != obj.Hnacl { if ctxt.Headtype != obj.Hnacl {
...@@ -653,7 +652,6 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -653,7 +652,6 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) {
times++ times++
cursym.Text.Pc = 0 // force re-layout the code. cursym.Text.Pc = 0 // force re-layout the code.
for p = cursym.Text; p != nil; p = p.Link { for p = cursym.Text; p != nil; p = p.Link {
ctxt.Curp = p
o = oplook(ctxt, p) o = oplook(ctxt, p)
if int64(c) > p.Pc { if int64(c) > p.Pc {
p.Pc = int64(c) p.Pc = int64(c)
...@@ -742,7 +740,6 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -742,7 +740,6 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) {
var v int var v int
for p = p.Link; p != nil; p = p.Link { for p = p.Link; p != nil; p = p.Link {
ctxt.Pc = p.Pc ctxt.Pc = p.Pc
ctxt.Curp = p
o = oplook(ctxt, p) o = oplook(ctxt, p)
opc = int32(p.Pc) opc = int32(p.Pc)
if ctxt.Headtype != obj.Hnacl { if ctxt.Headtype != obj.Hnacl {
...@@ -1488,7 +1485,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1488,7 +1485,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
case 1: /* op R,[R],R */ case 1: /* op R,[R],R */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
rf := int(p.From.Reg) rf := int(p.From.Reg)
rt := int(p.To.Reg) rt := int(p.To.Reg)
...@@ -1506,7 +1503,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1506,7 +1503,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
case 2: /* movbu $I,[R],R */ case 2: /* movbu $I,[R],R */
aclass(ctxt, &p.From) aclass(ctxt, &p.From)
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= uint32(immrot(uint32(ctxt.Instoffset))) o1 |= uint32(immrot(uint32(ctxt.Instoffset)))
rt := int(p.To.Reg) rt := int(p.To.Reg)
r := int(p.Reg) r := int(p.Reg)
...@@ -1526,10 +1523,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1526,10 +1523,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
case 4: /* MOVW $off(R), R -> add $off,[R],R */ case 4: /* MOVW $off(R), R -> add $off,[R],R */
aclass(ctxt, &p.From) aclass(ctxt, &p.From)
if ctxt.Instoffset < 0 { if ctxt.Instoffset < 0 {
o1 = oprrr(ctxt, ASUB, int(p.Scond)) o1 = oprrr(ctxt, p, ASUB, int(p.Scond))
o1 |= uint32(immrot(uint32(-ctxt.Instoffset))) o1 |= uint32(immrot(uint32(-ctxt.Instoffset)))
} else { } else {
o1 = oprrr(ctxt, AADD, int(p.Scond)) o1 = oprrr(ctxt, p, AADD, int(p.Scond))
o1 |= uint32(immrot(uint32(ctxt.Instoffset))) o1 |= uint32(immrot(uint32(ctxt.Instoffset)))
} }
r := int(p.From.Reg) r := int(p.From.Reg)
...@@ -1562,7 +1559,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1562,7 +1559,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
case 6: /* b ,O(R) -> add $O,R,PC */ case 6: /* b ,O(R) -> add $O,R,PC */
aclass(ctxt, &p.To) aclass(ctxt, &p.To)
o1 = oprrr(ctxt, AADD, int(p.Scond)) o1 = oprrr(ctxt, p, AADD, int(p.Scond))
o1 |= uint32(immrot(uint32(ctxt.Instoffset))) o1 |= uint32(immrot(uint32(ctxt.Instoffset)))
o1 |= (uint32(p.To.Reg) & 15) << 16 o1 |= (uint32(p.To.Reg) & 15) << 16
o1 |= (REGPC & 15) << 12 o1 |= (REGPC & 15) << 12
...@@ -1573,7 +1570,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1573,7 +1570,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if ctxt.Instoffset != 0 { if ctxt.Instoffset != 0 {
ctxt.Diag("%v: doesn't support BL offset(REG) with non-zero offset %d", p, ctxt.Instoffset) ctxt.Diag("%v: doesn't support BL offset(REG) with non-zero offset %d", p, ctxt.Instoffset)
} }
o1 = oprrr(ctxt, ABL, int(p.Scond)) o1 = oprrr(ctxt, p, ABL, int(p.Scond))
o1 |= (uint32(p.To.Reg) & 15) << 0 o1 |= (uint32(p.To.Reg) & 15) << 0
rel := obj.Addrel(ctxt.Cursym) rel := obj.Addrel(ctxt.Cursym)
rel.Off = int32(ctxt.Pc) rel.Off = int32(ctxt.Pc)
...@@ -1583,7 +1580,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1583,7 +1580,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
case 8: /* sll $c,[R],R -> mov (R<<$c),R */ case 8: /* sll $c,[R],R -> mov (R<<$c),R */
aclass(ctxt, &p.From) aclass(ctxt, &p.From)
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
r := int(p.Reg) r := int(p.Reg)
if r == 0 { if r == 0 {
r = int(p.To.Reg) r = int(p.To.Reg)
...@@ -1593,7 +1590,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1593,7 +1590,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(p.To.Reg) & 15) << 12 o1 |= (uint32(p.To.Reg) & 15) << 12
case 9: /* sll R,[R],R -> mov (R<<R),R */ case 9: /* sll R,[R],R -> mov (R<<R),R */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
r := int(p.Reg) r := int(p.Reg)
if r == 0 { if r == 0 {
...@@ -1604,7 +1601,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1604,7 +1601,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(p.To.Reg) & 15) << 12 o1 |= (uint32(p.To.Reg) & 15) << 12
case 10: /* swi [$con] */ case 10: /* swi [$con] */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
if p.To.Type != obj.TYPE_NONE { if p.To.Type != obj.TYPE_NONE {
aclass(ctxt, &p.To) aclass(ctxt, &p.To)
...@@ -1642,7 +1639,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1642,7 +1639,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 = omvl(ctxt, p, &p.From, int(p.To.Reg)) o1 = omvl(ctxt, p, &p.From, int(p.To.Reg))
if o.flag&LPCREL != 0 { if o.flag&LPCREL != 0 {
o2 = oprrr(ctxt, AADD, int(p.Scond)) | (uint32(p.To.Reg)&15)<<0 | (REGPC&15)<<16 | (uint32(p.To.Reg)&15)<<12 o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | (uint32(p.To.Reg)&15)<<0 | (REGPC&15)<<16 | (uint32(p.To.Reg)&15)<<12
} }
case 13: /* op $lcon, [R], R */ case 13: /* op $lcon, [R], R */
...@@ -1651,7 +1648,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1651,7 +1648,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if o1 == 0 { if o1 == 0 {
break break
} }
o2 = oprrr(ctxt, p.As, int(p.Scond)) o2 = oprrr(ctxt, p, p.As, int(p.Scond))
o2 |= REGTMP & 15 o2 |= REGTMP & 15
r := int(p.Reg) r := int(p.Reg)
if p.As == AMOVW || p.As == AMVN { if p.As == AMOVW || p.As == AMVN {
...@@ -1665,12 +1662,12 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1665,12 +1662,12 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
case 14: /* movb/movbu/movh/movhu R,R */ case 14: /* movb/movbu/movh/movhu R,R */
o1 = oprrr(ctxt, ASLL, int(p.Scond)) o1 = oprrr(ctxt, p, ASLL, int(p.Scond))
if p.As == AMOVBU || p.As == AMOVHU { if p.As == AMOVBU || p.As == AMOVHU {
o2 = oprrr(ctxt, ASRL, int(p.Scond)) o2 = oprrr(ctxt, p, ASRL, int(p.Scond))
} else { } else {
o2 = oprrr(ctxt, ASRA, int(p.Scond)) o2 = oprrr(ctxt, p, ASRA, int(p.Scond))
} }
r := int(p.To.Reg) r := int(p.To.Reg)
...@@ -1685,7 +1682,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1685,7 +1682,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
case 15: /* mul r,[r,]r */ case 15: /* mul r,[r,]r */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
rf := int(p.From.Reg) rf := int(p.From.Reg)
rt := int(p.To.Reg) rt := int(p.To.Reg)
...@@ -1712,7 +1709,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1712,7 +1709,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o2 = 0 o2 = 0
case 17: case 17:
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
rf := int(p.From.Reg) rf := int(p.From.Reg)
rt := int(p.To.Reg) rt := int(p.To.Reg)
rt2 := int(p.To.Offset) rt2 := int(p.To.Offset)
...@@ -1777,7 +1774,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1777,7 +1774,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
break break
} }
o2 = oprrr(ctxt, AADD, int(p.Scond)) o2 = oprrr(ctxt, p, AADD, int(p.Scond))
o2 |= REGTMP & 15 o2 |= REGTMP & 15
r := int(p.From.Reg) r := int(p.From.Reg)
if r == 0 { if r == 0 {
...@@ -1897,7 +1894,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1897,7 +1894,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if r == 0 { if r == 0 {
r = int(o.param) r = int(o.param)
} }
o2 = oprrr(ctxt, AADD, int(p.Scond)) | (REGTMP&15)<<12 | (REGTMP&15)<<16 | (uint32(r)&15)<<0 o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | (REGTMP&15)<<12 | (REGTMP&15)<<16 | (uint32(r)&15)<<0
o3 = ofsr(ctxt, p.As, int(p.From.Reg), 0, REGTMP, int(p.Scond), p) o3 = ofsr(ctxt, p.As, int(p.From.Reg), 0, REGTMP, int(p.Scond), p)
case 53: /* floating point load, int32 offset UGLY */ case 53: /* floating point load, int32 offset UGLY */
...@@ -1910,11 +1907,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1910,11 +1907,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if r == 0 { if r == 0 {
r = int(o.param) r = int(o.param)
} }
o2 = oprrr(ctxt, AADD, int(p.Scond)) | (REGTMP&15)<<12 | (REGTMP&15)<<16 | (uint32(r)&15)<<0 o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | (REGTMP&15)<<12 | (REGTMP&15)<<16 | (uint32(r)&15)<<0
o3 = ofsr(ctxt, p.As, int(p.To.Reg), 0, (REGTMP&15), int(p.Scond), p) | 1<<20 o3 = ofsr(ctxt, p.As, int(p.To.Reg), 0, (REGTMP&15), int(p.Scond), p) | 1<<20
case 54: /* floating point arith */ case 54: /* floating point arith */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
rf := int(p.From.Reg) rf := int(p.From.Reg)
rt := int(p.To.Reg) rt := int(p.To.Reg)
...@@ -1939,7 +1936,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1939,7 +1936,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= ((uint32(p.From.Reg)&1)+1)<<21 | (uint32(p.To.Reg)&15)<<12 | 1<<20 o1 |= ((uint32(p.From.Reg)&1)+1)<<21 | (uint32(p.To.Reg)&15)<<12 | 1<<20
case 58: /* movbu R,R */ case 58: /* movbu R,R */
o1 = oprrr(ctxt, AAND, int(p.Scond)) o1 = oprrr(ctxt, p, AAND, int(p.Scond))
o1 |= uint32(immrot(0xff)) o1 |= uint32(immrot(0xff))
rt := int(p.To.Reg) rt := int(p.To.Reg)
...@@ -2001,7 +1998,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2001,7 +1998,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o2 = osr(ctxt, p.As, int(p.From.Reg), 0, REGTMP, int(p.Scond)) o2 = osr(ctxt, p.As, int(p.From.Reg), 0, REGTMP, int(p.Scond))
if o.flag&LPCREL != 0 { if o.flag&LPCREL != 0 {
o3 = o2 o3 = o2
o2 = oprrr(ctxt, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12 o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12
} }
case 65: /* mov/movbu addr,R */ case 65: /* mov/movbu addr,R */
...@@ -2016,7 +2013,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2016,7 +2013,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
if o.flag&LPCREL != 0 { if o.flag&LPCREL != 0 {
o3 = o2 o3 = o2
o2 = oprrr(ctxt, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12 o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12
} }
case 101: /* movw tlsvar,R, local exec*/ case 101: /* movw tlsvar,R, local exec*/
...@@ -2072,7 +2069,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2072,7 +2069,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o2 = ofsr(ctxt, p.As, int(p.From.Reg), 0, REGTMP, int(p.Scond), p) o2 = ofsr(ctxt, p.As, int(p.From.Reg), 0, REGTMP, int(p.Scond), p)
if o.flag&LPCREL != 0 { if o.flag&LPCREL != 0 {
o3 = o2 o3 = o2
o2 = oprrr(ctxt, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12 o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12
} }
case 69: /* floating point load <- ADDR */ case 69: /* floating point load <- ADDR */
...@@ -2084,7 +2081,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2084,7 +2081,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o2 = ofsr(ctxt, p.As, int(p.To.Reg), 0, (REGTMP&15), int(p.Scond), p) | 1<<20 o2 = ofsr(ctxt, p.As, int(p.To.Reg), 0, (REGTMP&15), int(p.Scond), p) | 1<<20
if o.flag&LPCREL != 0 { if o.flag&LPCREL != 0 {
o3 = o2 o3 = o2
o2 = oprrr(ctxt, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12 o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12
} }
/* ArmV4 ops: */ /* ArmV4 ops: */
...@@ -2151,17 +2148,17 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2151,17 +2148,17 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
/* /*
o1 = oprrr(ctxt, AADD, p->scond) | immrot(0) | ((REGPC&15)<<16) | ((REGLINK&15)<<12); // mov PC, LR o1 = oprrr(ctxt, p, AADD, p->scond) | immrot(0) | ((REGPC&15)<<16) | ((REGLINK&15)<<12); // mov PC, LR
o2 = (((p->scond&C_SCOND) ^ C_SCOND_XOR)<<28) | (0x12fff<<8) | (1<<4) | ((p->to.reg&15) << 0); // BX R o2 = (((p->scond&C_SCOND) ^ C_SCOND_XOR)<<28) | (0x12fff<<8) | (1<<4) | ((p->to.reg&15) << 0); // BX R
*/ */
// p->to.reg may be REGLINK // p->to.reg may be REGLINK
o1 = oprrr(ctxt, AADD, int(p.Scond)) o1 = oprrr(ctxt, p, AADD, int(p.Scond))
o1 |= uint32(immrot(uint32(ctxt.Instoffset))) o1 |= uint32(immrot(uint32(ctxt.Instoffset)))
o1 |= (uint32(p.To.Reg) & 15) << 16 o1 |= (uint32(p.To.Reg) & 15) << 16
o1 |= (REGTMP & 15) << 12 o1 |= (REGTMP & 15) << 12
o2 = oprrr(ctxt, AADD, int(p.Scond)) | uint32(immrot(0)) | (REGPC&15)<<16 | (REGLINK&15)<<12 // mov PC, LR o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | uint32(immrot(0)) | (REGPC&15)<<16 | (REGLINK&15)<<12 // mov PC, LR
o3 = ((uint32(p.Scond)&C_SCOND)^C_SCOND_XOR)<<28 | 0x12fff<<8 | 1<<4 | REGTMP&15 // BX Rtmp o3 = ((uint32(p.Scond)&C_SCOND)^C_SCOND_XOR)<<28 | 0x12fff<<8 | 1<<4 | REGTMP&15 // BX Rtmp
case 76: /* bx O(R) when returning from fn*/ case 76: /* bx O(R) when returning from fn*/
ctxt.Diag("ABXRET") ctxt.Diag("ABXRET")
...@@ -2192,10 +2189,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2192,10 +2189,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
case 80: /* fmov zfcon,freg */ case 80: /* fmov zfcon,freg */
if p.As == AMOVD { if p.As == AMOVD {
o1 = 0xeeb00b00 // VMOV imm 64 o1 = 0xeeb00b00 // VMOV imm 64
o2 = oprrr(ctxt, ASUBD, int(p.Scond)) o2 = oprrr(ctxt, p, ASUBD, int(p.Scond))
} else { } else {
o1 = 0x0eb00a00 // VMOV imm 32 o1 = 0x0eb00a00 // VMOV imm 32
o2 = oprrr(ctxt, ASUBF, int(p.Scond)) o2 = oprrr(ctxt, p, ASUBF, int(p.Scond))
} }
v := int32(0x70) // 1.0 v := int32(0x70) // 1.0
...@@ -2223,59 +2220,59 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2223,59 +2220,59 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(v) & 0xf0) << 12 o1 |= (uint32(v) & 0xf0) << 12
case 82: /* fcmp freg,freg, */ case 82: /* fcmp freg,freg, */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= (uint32(p.Reg)&15)<<12 | (uint32(p.From.Reg)&15)<<0 o1 |= (uint32(p.Reg)&15)<<12 | (uint32(p.From.Reg)&15)<<0
o2 = 0x0ef1fa10 // VMRS R15 o2 = 0x0ef1fa10 // VMRS R15
o2 |= ((uint32(p.Scond) & C_SCOND) ^ C_SCOND_XOR) << 28 o2 |= ((uint32(p.Scond) & C_SCOND) ^ C_SCOND_XOR) << 28
case 83: /* fcmp freg,, */ case 83: /* fcmp freg,, */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= (uint32(p.From.Reg)&15)<<12 | 1<<16 o1 |= (uint32(p.From.Reg)&15)<<12 | 1<<16
o2 = 0x0ef1fa10 // VMRS R15 o2 = 0x0ef1fa10 // VMRS R15
o2 |= ((uint32(p.Scond) & C_SCOND) ^ C_SCOND_XOR) << 28 o2 |= ((uint32(p.Scond) & C_SCOND) ^ C_SCOND_XOR) << 28
case 84: /* movfw freg,freg - truncate float-to-fix */ case 84: /* movfw freg,freg - truncate float-to-fix */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= (uint32(p.From.Reg) & 15) << 0 o1 |= (uint32(p.From.Reg) & 15) << 0
o1 |= (uint32(p.To.Reg) & 15) << 12 o1 |= (uint32(p.To.Reg) & 15) << 12
case 85: /* movwf freg,freg - fix-to-float */ case 85: /* movwf freg,freg - fix-to-float */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= (uint32(p.From.Reg) & 15) << 0 o1 |= (uint32(p.From.Reg) & 15) << 0
o1 |= (uint32(p.To.Reg) & 15) << 12 o1 |= (uint32(p.To.Reg) & 15) << 12
// macro for movfw freg,FTMP; movw FTMP,reg // macro for movfw freg,FTMP; movw FTMP,reg
case 86: /* movfw freg,reg - truncate float-to-fix */ case 86: /* movfw freg,reg - truncate float-to-fix */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= (uint32(p.From.Reg) & 15) << 0 o1 |= (uint32(p.From.Reg) & 15) << 0
o1 |= (FREGTMP & 15) << 12 o1 |= (FREGTMP & 15) << 12
o2 = oprrr(ctxt, -AMOVFW, int(p.Scond)) o2 = oprrr(ctxt, p, -AMOVFW, int(p.Scond))
o2 |= (FREGTMP & 15) << 16 o2 |= (FREGTMP & 15) << 16
o2 |= (uint32(p.To.Reg) & 15) << 12 o2 |= (uint32(p.To.Reg) & 15) << 12
// macro for movw reg,FTMP; movwf FTMP,freg // macro for movw reg,FTMP; movwf FTMP,freg
case 87: /* movwf reg,freg - fix-to-float */ case 87: /* movwf reg,freg - fix-to-float */
o1 = oprrr(ctxt, -AMOVWF, int(p.Scond)) o1 = oprrr(ctxt, p, -AMOVWF, int(p.Scond))
o1 |= (uint32(p.From.Reg) & 15) << 12 o1 |= (uint32(p.From.Reg) & 15) << 12
o1 |= (FREGTMP & 15) << 16 o1 |= (FREGTMP & 15) << 16
o2 = oprrr(ctxt, p.As, int(p.Scond)) o2 = oprrr(ctxt, p, p.As, int(p.Scond))
o2 |= (FREGTMP & 15) << 0 o2 |= (FREGTMP & 15) << 0
o2 |= (uint32(p.To.Reg) & 15) << 12 o2 |= (uint32(p.To.Reg) & 15) << 12
case 88: /* movw reg,freg */ case 88: /* movw reg,freg */
o1 = oprrr(ctxt, -AMOVWF, int(p.Scond)) o1 = oprrr(ctxt, p, -AMOVWF, int(p.Scond))
o1 |= (uint32(p.From.Reg) & 15) << 12 o1 |= (uint32(p.From.Reg) & 15) << 12
o1 |= (uint32(p.To.Reg) & 15) << 16 o1 |= (uint32(p.To.Reg) & 15) << 16
case 89: /* movw freg,reg */ case 89: /* movw freg,reg */
o1 = oprrr(ctxt, -AMOVFW, int(p.Scond)) o1 = oprrr(ctxt, p, -AMOVFW, int(p.Scond))
o1 |= (uint32(p.From.Reg) & 15) << 16 o1 |= (uint32(p.From.Reg) & 15) << 16
o1 |= (uint32(p.To.Reg) & 15) << 12 o1 |= (uint32(p.To.Reg) & 15) << 12
...@@ -2317,7 +2314,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2317,7 +2314,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
if o.flag&LPCREL != 0 { if o.flag&LPCREL != 0 {
o3 = o2 o3 = o2
o2 = oprrr(ctxt, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12 o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12
} }
case 94: /* movh/movhu R,addr -> strh */ case 94: /* movh/movhu R,addr -> strh */
...@@ -2329,7 +2326,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2329,7 +2326,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o2 = oshr(ctxt, int(p.From.Reg), 0, REGTMP, int(p.Scond)) o2 = oshr(ctxt, int(p.From.Reg), 0, REGTMP, int(p.Scond))
if o.flag&LPCREL != 0 { if o.flag&LPCREL != 0 {
o3 = o2 o3 = o2
o2 = oprrr(ctxt, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12 o2 = oprrr(ctxt, p, AADD, int(p.Scond)) | REGTMP&15 | (REGPC&15)<<16 | (REGTMP&15)<<12
} }
case 95: /* PLD off(reg) */ case 95: /* PLD off(reg) */
...@@ -2352,20 +2349,20 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2352,20 +2349,20 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 = 0xf7fabcfd o1 = 0xf7fabcfd
case 97: /* CLZ Rm, Rd */ case 97: /* CLZ Rm, Rd */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= (uint32(p.To.Reg) & 15) << 12 o1 |= (uint32(p.To.Reg) & 15) << 12
o1 |= (uint32(p.From.Reg) & 15) << 0 o1 |= (uint32(p.From.Reg) & 15) << 0
case 98: /* MULW{T,B} Rs, Rm, Rd */ case 98: /* MULW{T,B} Rs, Rm, Rd */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= (uint32(p.To.Reg) & 15) << 16 o1 |= (uint32(p.To.Reg) & 15) << 16
o1 |= (uint32(p.From.Reg) & 15) << 8 o1 |= (uint32(p.From.Reg) & 15) << 8
o1 |= (uint32(p.Reg) & 15) << 0 o1 |= (uint32(p.Reg) & 15) << 0
case 99: /* MULAW{T,B} Rs, Rm, Rn, Rd */ case 99: /* MULAW{T,B} Rs, Rm, Rn, Rd */
o1 = oprrr(ctxt, p.As, int(p.Scond)) o1 = oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= (uint32(p.To.Reg) & 15) << 12 o1 |= (uint32(p.To.Reg) & 15) << 12
o1 |= (uint32(p.From.Reg) & 15) << 8 o1 |= (uint32(p.From.Reg) & 15) << 8
...@@ -2391,7 +2388,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2391,7 +2388,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
func mov(ctxt *obj.Link, p *obj.Prog) uint32 { func mov(ctxt *obj.Link, p *obj.Prog) uint32 {
aclass(ctxt, &p.From) aclass(ctxt, &p.From)
o1 := oprrr(ctxt, p.As, int(p.Scond)) o1 := oprrr(ctxt, p, p.As, int(p.Scond))
o1 |= uint32(p.From.Offset) o1 |= uint32(p.From.Offset)
rt := int(p.To.Reg) rt := int(p.To.Reg)
if p.To.Type == obj.TYPE_NONE { if p.To.Type == obj.TYPE_NONE {
...@@ -2407,7 +2404,7 @@ func mov(ctxt *obj.Link, p *obj.Prog) uint32 { ...@@ -2407,7 +2404,7 @@ func mov(ctxt *obj.Link, p *obj.Prog) uint32 {
return o1 return o1
} }
func oprrr(ctxt *obj.Link, a obj.As, sc int) uint32 { func oprrr(ctxt *obj.Link, p *obj.Prog, a obj.As, sc int) uint32 {
o := ((uint32(sc) & C_SCOND) ^ C_SCOND_XOR) << 28 o := ((uint32(sc) & C_SCOND) ^ C_SCOND_XOR) << 28
if sc&C_SBIT != 0 { if sc&C_SBIT != 0 {
o |= 1 << 20 o |= 1 << 20
...@@ -2566,7 +2563,7 @@ func oprrr(ctxt *obj.Link, a obj.As, sc int) uint32 { ...@@ -2566,7 +2563,7 @@ func oprrr(ctxt *obj.Link, a obj.As, sc int) uint32 {
return o&(0xf<<28) | 0x12fff3<<4 return o&(0xf<<28) | 0x12fff3<<4
} }
ctxt.Diag("%v: bad rrr %d", ctxt.Curp, a) ctxt.Diag("%v: bad rrr %d", p, a)
return 0 return 0
} }
...@@ -2619,7 +2616,7 @@ func opbra(ctxt *obj.Link, p *obj.Prog, a obj.As, sc int) uint32 { ...@@ -2619,7 +2616,7 @@ func opbra(ctxt *obj.Link, p *obj.Prog, a obj.As, sc int) uint32 {
return 0xe<<28 | 0x5<<25 return 0xe<<28 | 0x5<<25
} }
ctxt.Diag("%v: bad bra %v", ctxt.Curp, a) ctxt.Diag("%v: bad bra %v", p, a)
return 0 return 0
} }
...@@ -2762,7 +2759,7 @@ func omvl(ctxt *obj.Link, p *obj.Prog, a *obj.Addr, dr int) uint32 { ...@@ -2762,7 +2759,7 @@ func omvl(ctxt *obj.Link, p *obj.Prog, a *obj.Addr, dr int) uint32 {
return 0 return 0
} }
o1 = oprrr(ctxt, AMVN, int(p.Scond)&C_SCOND) o1 = oprrr(ctxt, p, AMVN, int(p.Scond)&C_SCOND)
o1 |= uint32(v) o1 |= uint32(v)
o1 |= (uint32(dr) & 15) << 12 o1 |= (uint32(dr) & 15) << 12
} else { } else {
......
...@@ -542,7 +542,6 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -542,7 +542,6 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
var m int var m int
var o *Optab var o *Optab
for p = p.Link; p != nil; p = p.Link { for p = p.Link; p != nil; p = p.Link {
ctxt.Curp = p
if p.As == ADWORD && (c&7) != 0 { if p.As == ADWORD && (c&7) != 0 {
c += 4 c += 4
} }
...@@ -641,7 +640,6 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -641,7 +640,6 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
var out [6]uint32 var out [6]uint32
for p := cursym.Text.Link; p != nil; p = p.Link { for p := cursym.Text.Link; p != nil; p = p.Link {
ctxt.Pc = p.Pc ctxt.Pc = p.Pc
ctxt.Curp = p
o = oplook(ctxt, p) o = oplook(ctxt, p)
// need to align DWORDs on 8-byte boundary. The ISA doesn't // need to align DWORDs on 8-byte boundary. The ISA doesn't
...@@ -1014,7 +1012,7 @@ func oregclass(l int64) int { ...@@ -1014,7 +1012,7 @@ func oregclass(l int64) int {
* return the offset value to use in the instruction, * return the offset value to use in the instruction,
* scaled if necessary * scaled if necessary
*/ */
func offsetshift(ctxt *obj.Link, v int64, c int) int64 { func offsetshift(ctxt *obj.Link, p *obj.Prog, v int64, c int) int64 {
s := 0 s := 0
if c >= C_SEXT1 && c <= C_SEXT16 { if c >= C_SEXT1 && c <= C_SEXT16 {
s = c - C_SEXT1 s = c - C_SEXT1
...@@ -1025,7 +1023,7 @@ func offsetshift(ctxt *obj.Link, v int64, c int) int64 { ...@@ -1025,7 +1023,7 @@ func offsetshift(ctxt *obj.Link, v int64, c int) int64 {
} }
vs := v >> uint(s) vs := v >> uint(s)
if vs<<uint(s) != v { if vs<<uint(s) != v {
ctxt.Diag("odd offset: %d\n%v", v, ctxt.Curp) ctxt.Diag("odd offset: %d\n%v", v, p)
} }
return vs return vs
} }
...@@ -1935,7 +1933,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1935,7 +1933,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
break break
case 1: /* op Rm,[Rn],Rd; default Rn=Rd -> op Rm<<0,[Rn,]Rd (shifted register) */ case 1: /* op Rm,[Rn],Rd; default Rn=Rd -> op Rm<<0,[Rn,]Rd (shifted register) */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
rf := int(p.From.Reg) rf := int(p.From.Reg)
rt := int(p.To.Reg) rt := int(p.To.Reg)
...@@ -1949,7 +1947,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1949,7 +1947,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(rf&31) << 16) | (uint32(r&31) << 5) | uint32(rt&31) o1 |= (uint32(rf&31) << 16) | (uint32(r&31) << 5) | uint32(rt&31)
case 2: /* add/sub $(uimm12|uimm24)[,R],R; cmp $(uimm12|uimm24),R */ case 2: /* add/sub $(uimm12|uimm24)[,R],R; cmp $(uimm12|uimm24),R */
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
rt := int(p.To.Reg) rt := int(p.To.Reg)
if p.To.Type == obj.TYPE_NONE { if p.To.Type == obj.TYPE_NONE {
...@@ -1964,10 +1962,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1964,10 +1962,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
r = rt r = rt
} }
v := int32(regoff(ctxt, &p.From)) v := int32(regoff(ctxt, &p.From))
o1 = oaddi(ctxt, int32(o1), v, r, rt) o1 = oaddi(ctxt, p, int32(o1), v, r, rt)
case 3: /* op R<<n[,R],R (shifted register) */ case 3: /* op R<<n[,R],R (shifted register) */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
o1 |= uint32(p.From.Offset) /* includes reg, op, etc */ o1 |= uint32(p.From.Offset) /* includes reg, op, etc */
rt := int(p.To.Reg) rt := int(p.To.Reg)
...@@ -1983,7 +1981,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1983,7 +1981,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(r&31) << 5) | uint32(rt&31) o1 |= (uint32(r&31) << 5) | uint32(rt&31)
case 4: /* mov $addcon, R; mov $recon, R; mov $racon, R */ case 4: /* mov $addcon, R; mov $recon, R; mov $racon, R */
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
rt := int(p.To.Reg) rt := int(p.To.Reg)
r := int(o.param) r := int(o.param)
...@@ -2004,7 +2002,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2004,7 +2002,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= ((uint32(v) & 0xFFF) << 10) | (uint32(r&31) << 5) | uint32(rt&31) o1 |= ((uint32(v) & 0xFFF) << 10) | (uint32(r&31) << 5) | uint32(rt&31)
case 5: /* b s; bl s */ case 5: /* b s; bl s */
o1 = opbra(ctxt, p.As) o1 = opbra(ctxt, p, p.As)
if p.To.Sym == nil { if p.To.Sym == nil {
o1 |= uint32(brdist(ctxt, p, 0, 26, 2)) o1 |= uint32(brdist(ctxt, p, 0, 26, 2))
...@@ -2019,7 +2017,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2019,7 +2017,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
rel.Type = obj.R_CALLARM64 rel.Type = obj.R_CALLARM64
case 6: /* b ,O(R); bl ,O(R) */ case 6: /* b ,O(R); bl ,O(R) */
o1 = opbrr(ctxt, p.As) o1 = opbrr(ctxt, p, p.As)
o1 |= uint32(p.To.Reg&31) << 5 o1 |= uint32(p.To.Reg&31) << 5
rel := obj.Addrel(ctxt.Cursym) rel := obj.Addrel(ctxt.Cursym)
...@@ -2028,7 +2026,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2028,7 +2026,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
rel.Type = obj.R_CALLIND rel.Type = obj.R_CALLIND
case 7: /* beq s */ case 7: /* beq s */
o1 = opbra(ctxt, p.As) o1 = opbra(ctxt, p, p.As)
o1 |= uint32(brdist(ctxt, p, 0, 19, 2) << 5) o1 |= uint32(brdist(ctxt, p, 0, 19, 2) << 5)
...@@ -2042,36 +2040,36 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2042,36 +2040,36 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
v := int32(p.From.Offset) v := int32(p.From.Offset)
switch p.As { switch p.As {
case AASR: case AASR:
o1 = opbfm(ctxt, ASBFM, int(v), 63, rf, rt) o1 = opbfm(ctxt, p, ASBFM, int(v), 63, rf, rt)
case AASRW: case AASRW:
o1 = opbfm(ctxt, ASBFMW, int(v), 31, rf, rt) o1 = opbfm(ctxt, p, ASBFMW, int(v), 31, rf, rt)
case ALSL: case ALSL:
o1 = opbfm(ctxt, AUBFM, int((64-v)&63), int(63-v), rf, rt) o1 = opbfm(ctxt, p, AUBFM, int((64-v)&63), int(63-v), rf, rt)
case ALSLW: case ALSLW:
o1 = opbfm(ctxt, AUBFMW, int((32-v)&31), int(31-v), rf, rt) o1 = opbfm(ctxt, p, AUBFMW, int((32-v)&31), int(31-v), rf, rt)
case ALSR: case ALSR:
o1 = opbfm(ctxt, AUBFM, int(v), 63, rf, rt) o1 = opbfm(ctxt, p, AUBFM, int(v), 63, rf, rt)
case ALSRW: case ALSRW:
o1 = opbfm(ctxt, AUBFMW, int(v), 31, rf, rt) o1 = opbfm(ctxt, p, AUBFMW, int(v), 31, rf, rt)
case AROR: case AROR:
o1 = opextr(ctxt, AEXTR, v, rf, rf, rt) o1 = opextr(ctxt, p, AEXTR, v, rf, rf, rt)
case ARORW: case ARORW:
o1 = opextr(ctxt, AEXTRW, v, rf, rf, rt) o1 = opextr(ctxt, p, AEXTRW, v, rf, rf, rt)
default: default:
ctxt.Diag("bad shift $con\n%v", ctxt.Curp) ctxt.Diag("bad shift $con\n%v", p)
break break
} }
case 9: /* lsl Rm,[Rn],Rd -> lslv Rm, Rn, Rd */ case 9: /* lsl Rm,[Rn],Rd -> lslv Rm, Rn, Rd */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
r := int(p.Reg) r := int(p.Reg)
if r == 0 { if r == 0 {
...@@ -2080,7 +2078,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2080,7 +2078,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(p.From.Reg&31) << 16) | (uint32(r&31) << 5) | uint32(p.To.Reg&31) o1 |= (uint32(p.From.Reg&31) << 16) | (uint32(r&31) << 5) | uint32(p.To.Reg&31)
case 10: /* brk/hvc/.../svc [$con] */ case 10: /* brk/hvc/.../svc [$con] */
o1 = opimm(ctxt, p.As) o1 = opimm(ctxt, p, p.As)
if p.To.Type != obj.TYPE_NONE { if p.To.Type != obj.TYPE_NONE {
o1 |= uint32((p.To.Offset & 0xffff) << 5) o1 |= uint32((p.To.Offset & 0xffff) << 5)
...@@ -2120,11 +2118,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2120,11 +2118,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
r = rt r = rt
} }
if p.To.Type != obj.TYPE_NONE && (p.To.Reg == REGSP || r == REGSP) { if p.To.Type != obj.TYPE_NONE && (p.To.Reg == REGSP || r == REGSP) {
o2 = opxrrr(ctxt, p.As) o2 = opxrrr(ctxt, p, p.As)
o2 |= REGTMP & 31 << 16 o2 |= REGTMP & 31 << 16
o2 |= LSL0_64 o2 |= LSL0_64
} else { } else {
o2 = oprrr(ctxt, p.As) o2 = oprrr(ctxt, p, p.As)
o2 |= REGTMP & 31 << 16 /* shift is 0 */ o2 |= REGTMP & 31 << 16 /* shift is 0 */
} }
...@@ -2150,7 +2148,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2150,7 +2148,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
case 15: /* mul/mneg/umulh/umull r,[r,]r; madd/msub Rm,Rn,Ra,Rd */ case 15: /* mul/mneg/umulh/umull r,[r,]r; madd/msub Rm,Rn,Ra,Rd */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
rf := int(p.From.Reg) rf := int(p.From.Reg)
rt := int(p.To.Reg) rt := int(p.To.Reg)
...@@ -2173,7 +2171,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2173,7 +2171,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(rf&31) << 16) | (uint32(ra&31) << 10) | (uint32(r&31) << 5) | uint32(rt&31) o1 |= (uint32(rf&31) << 16) | (uint32(ra&31) << 10) | (uint32(r&31) << 5) | uint32(rt&31)
case 16: /* XremY R[,R],R -> XdivY; XmsubY */ case 16: /* XremY R[,R],R -> XdivY; XmsubY */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
rf := int(p.From.Reg) rf := int(p.From.Reg)
rt := int(p.To.Reg) rt := int(p.To.Reg)
...@@ -2182,12 +2180,12 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2182,12 +2180,12 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
r = rt r = rt
} }
o1 |= (uint32(rf&31) << 16) | (uint32(r&31) << 5) | REGTMP&31 o1 |= (uint32(rf&31) << 16) | (uint32(r&31) << 5) | REGTMP&31
o2 = oprrr(ctxt, AMSUBW) o2 = oprrr(ctxt, p, AMSUBW)
o2 |= o1 & (1 << 31) /* same size */ o2 |= o1 & (1 << 31) /* same size */
o2 |= (uint32(rf&31) << 16) | (uint32(r&31) << 10) | (REGTMP & 31 << 5) | uint32(rt&31) o2 |= (uint32(rf&31) << 16) | (uint32(r&31) << 10) | (REGTMP & 31 << 5) | uint32(rt&31)
case 17: /* op Rm,[Rn],Rd; default Rn=ZR */ case 17: /* op Rm,[Rn],Rd; default Rn=ZR */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
rf := int(p.From.Reg) rf := int(p.From.Reg)
rt := int(p.To.Reg) rt := int(p.To.Reg)
...@@ -2201,7 +2199,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2201,7 +2199,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(rf&31) << 16) | (uint32(r&31) << 5) | uint32(rt&31) o1 |= (uint32(rf&31) << 16) | (uint32(r&31) << 5) | uint32(rt&31)
case 18: /* csel cond,Rn,Rm,Rd; cinc/cinv/cneg cond,Rn,Rd; cset cond,Rd */ case 18: /* csel cond,Rn,Rm,Rd; cinc/cinv/cneg cond,Rn,Rd; cset cond,Rd */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
cond := int(p.From.Reg) cond := int(p.From.Reg)
r := int(p.Reg) r := int(p.Reg)
...@@ -2234,10 +2232,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2234,10 +2232,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
cond := int(p.From.Reg) cond := int(p.From.Reg)
var rf int var rf int
if p.From3.Type == obj.TYPE_REG { if p.From3.Type == obj.TYPE_REG {
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
rf = int(p.From3.Reg) /* Rm */ rf = int(p.From3.Reg) /* Rm */
} else { } else {
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
rf = int(p.From3.Offset & 0x1F) rf = int(p.From3.Offset & 0x1F)
} }
...@@ -2252,10 +2250,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2252,10 +2250,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
r = int(o.param) r = int(o.param)
} }
if v < 0 || v%sz != 0 { /* unscaled 9-bit signed */ if v < 0 || v%sz != 0 { /* unscaled 9-bit signed */
o1 = olsr9s(ctxt, int32(opstr9(ctxt, p.As)), v, r, int(p.From.Reg)) o1 = olsr9s(ctxt, p, int32(opstr9(ctxt, p, p.As)), v, r, int(p.From.Reg))
} else { } else {
v = int32(offsetshift(ctxt, int64(v), int(o.a3))) v = int32(offsetshift(ctxt, p, int64(v), int(o.a3)))
o1 = olsr12u(ctxt, int32(opstr12(ctxt, p.As)), v, r, int(p.From.Reg)) o1 = olsr12u(ctxt, p, int32(opstr12(ctxt, p, p.As)), v, r, int(p.From.Reg))
} }
case 21: /* movT O(R),R -> ldrT */ case 21: /* movT O(R),R -> ldrT */
...@@ -2267,11 +2265,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2267,11 +2265,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
r = int(o.param) r = int(o.param)
} }
if v < 0 || v%sz != 0 { /* unscaled 9-bit signed */ if v < 0 || v%sz != 0 { /* unscaled 9-bit signed */
o1 = olsr9s(ctxt, int32(opldr9(ctxt, p.As)), v, r, int(p.To.Reg)) o1 = olsr9s(ctxt, p, int32(opldr9(ctxt, p, p.As)), v, r, int(p.To.Reg))
} else { } else {
v = int32(offsetshift(ctxt, int64(v), int(o.a1))) v = int32(offsetshift(ctxt, p, int64(v), int(o.a1)))
//print("offset=%lld v=%ld a1=%d\n", instoffset, v, o->a1); //print("offset=%lld v=%ld a1=%d\n", instoffset, v, o->a1);
o1 = olsr12u(ctxt, int32(opldr12(ctxt, p.As)), v, r, int(p.To.Reg)) o1 = olsr12u(ctxt, p, int32(opldr12(ctxt, p, p.As)), v, r, int(p.To.Reg))
} }
case 22: /* movT (R)O!,R; movT O(R)!, R -> ldrT */ case 22: /* movT (R)O!,R; movT O(R)!, R -> ldrT */
...@@ -2280,7 +2278,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2280,7 +2278,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if v < -256 || v > 255 { if v < -256 || v > 255 {
ctxt.Diag("offset out of range\n%v", p) ctxt.Diag("offset out of range\n%v", p)
} }
o1 = opldrpp(ctxt, p.As) o1 = opldrpp(ctxt, p, p.As)
if o.scond == C_XPOST { if o.scond == C_XPOST {
o1 |= 1 << 10 o1 |= 1 << 10
} else { } else {
...@@ -2294,7 +2292,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2294,7 +2292,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if v < -256 || v > 255 { if v < -256 || v > 255 {
ctxt.Diag("offset out of range\n%v", p) ctxt.Diag("offset out of range\n%v", p)
} }
o1 = LD2STR(opldrpp(ctxt, p.As)) o1 = LD2STR(opldrpp(ctxt, p, p.As))
if o.scond == C_XPOST { if o.scond == C_XPOST {
o1 |= 1 << 10 o1 |= 1 << 10
} else { } else {
...@@ -2310,18 +2308,18 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2310,18 +2308,18 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if s { if s {
ctxt.Diag("illegal SP reference\n%v", p) ctxt.Diag("illegal SP reference\n%v", p)
} }
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
o1 |= (uint32(rf&31) << 16) | (REGZERO & 31 << 5) | uint32(rt&31) o1 |= (uint32(rf&31) << 16) | (REGZERO & 31 << 5) | uint32(rt&31)
} else if s { } else if s {
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
o1 |= (uint32(rf&31) << 5) | uint32(rt&31) o1 |= (uint32(rf&31) << 5) | uint32(rt&31)
} else { } else {
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
o1 |= (uint32(rf&31) << 16) | (REGZERO & 31 << 5) | uint32(rt&31) o1 |= (uint32(rf&31) << 16) | (REGZERO & 31 << 5) | uint32(rt&31)
} }
case 25: /* negX Rs, Rd -> subX Rs<<0, ZR, Rd */ case 25: /* negX Rs, Rd -> subX Rs<<0, ZR, Rd */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
rf := int(p.From.Reg) rf := int(p.From.Reg)
if rf == C_NONE { if rf == C_NONE {
...@@ -2331,14 +2329,14 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2331,14 +2329,14 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(rf&31) << 16) | (REGZERO & 31 << 5) | uint32(rt&31) o1 |= (uint32(rf&31) << 16) | (REGZERO & 31 << 5) | uint32(rt&31)
case 26: /* negX Rm<<s, Rd -> subX Rm<<s, ZR, Rd */ case 26: /* negX Rm<<s, Rd -> subX Rm<<s, ZR, Rd */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
o1 |= uint32(p.From.Offset) /* includes reg, op, etc */ o1 |= uint32(p.From.Offset) /* includes reg, op, etc */
rt := int(p.To.Reg) rt := int(p.To.Reg)
o1 |= (REGZERO & 31 << 5) | uint32(rt&31) o1 |= (REGZERO & 31 << 5) | uint32(rt&31)
case 27: /* op Rm<<n[,Rn],Rd (extended register) */ case 27: /* op Rm<<n[,Rn],Rd (extended register) */
o1 = opxrrr(ctxt, p.As) o1 = opxrrr(ctxt, p, p.As)
if (p.From.Reg-obj.RBaseARM64)&REG_EXT != 0 { if (p.From.Reg-obj.RBaseARM64)&REG_EXT != 0 {
ctxt.Diag("extended register not implemented\n%v", p) ctxt.Diag("extended register not implemented\n%v", p)
...@@ -2366,7 +2364,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2366,7 +2364,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if r == 0 { if r == 0 {
r = int(p.To.Reg) r = int(p.To.Reg)
} }
o2 = oprrr(ctxt, p.As) o2 = oprrr(ctxt, p, p.As)
o2 |= REGTMP & 31 << 16 /* shift is 0 */ o2 |= REGTMP & 31 << 16 /* shift is 0 */
o2 |= uint32(r&31) << 5 o2 |= uint32(r&31) << 5
o2 |= uint32(p.To.Reg & 31) o2 |= uint32(p.To.Reg & 31)
...@@ -2384,7 +2382,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2384,7 +2382,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= 1 << 16 // FMOV Rx, Fy o1 |= 1 << 16 // FMOV Rx, Fy
} }
} else { } else {
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
} }
o1 |= uint32(p.From.Reg&31)<<5 | uint32(p.To.Reg&31) o1 |= uint32(p.From.Reg&31)<<5 | uint32(p.To.Reg&31)
...@@ -2412,8 +2410,8 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2412,8 +2410,8 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if r == 0 { if r == 0 {
r = int(o.param) r = int(o.param)
} }
o1 = oaddi(ctxt, int32(opirr(ctxt, AADD)), hi, r, REGTMP) o1 = oaddi(ctxt, p, int32(opirr(ctxt, p, AADD)), hi, r, REGTMP)
o2 = olsr12u(ctxt, int32(opstr12(ctxt, p.As)), ((v-hi)>>uint(s))&0xFFF, REGTMP, int(p.From.Reg)) o2 = olsr12u(ctxt, p, int32(opstr12(ctxt, p, p.As)), ((v-hi)>>uint(s))&0xFFF, REGTMP, int(p.From.Reg))
case 31: /* movT L(R), R -> ldrT */ case 31: /* movT L(R), R -> ldrT */
s := movesize(o.as) s := movesize(o.as)
...@@ -2439,14 +2437,14 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2439,14 +2437,14 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if r == 0 { if r == 0 {
r = int(o.param) r = int(o.param)
} }
o1 = oaddi(ctxt, int32(opirr(ctxt, AADD)), hi, r, REGTMP) o1 = oaddi(ctxt, p, int32(opirr(ctxt, p, AADD)), hi, r, REGTMP)
o2 = olsr12u(ctxt, int32(opldr12(ctxt, p.As)), ((v-hi)>>uint(s))&0xFFF, REGTMP, int(p.To.Reg)) o2 = olsr12u(ctxt, p, int32(opldr12(ctxt, p, p.As)), ((v-hi)>>uint(s))&0xFFF, REGTMP, int(p.To.Reg))
case 32: /* mov $con, R -> movz/movn */ case 32: /* mov $con, R -> movz/movn */
o1 = omovconst(ctxt, p.As, p, &p.From, int(p.To.Reg)) o1 = omovconst(ctxt, p.As, p, &p.From, int(p.To.Reg))
case 33: /* movk $uimm16 << pos */ case 33: /* movk $uimm16 << pos */
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
d := p.From.Offset d := p.From.Offset
if (d >> 16) != 0 { if (d >> 16) != 0 {
...@@ -2472,7 +2470,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2472,7 +2470,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if !(o1 != 0) { if !(o1 != 0) {
break break
} }
o2 = opxrrr(ctxt, AADD) o2 = opxrrr(ctxt, p, AADD)
o2 |= REGTMP & 31 << 16 o2 |= REGTMP & 31 << 16
o2 |= LSL0_64 o2 |= LSL0_64
r := int(p.From.Reg) r := int(p.From.Reg)
...@@ -2483,7 +2481,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2483,7 +2481,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o2 |= uint32(p.To.Reg & 31) o2 |= uint32(p.To.Reg & 31)
case 35: /* mov SPR,R -> mrs */ case 35: /* mov SPR,R -> mrs */
o1 = oprrr(ctxt, AMRS) o1 = oprrr(ctxt, p, AMRS)
v := int32(p.From.Offset) v := int32(p.From.Offset)
if (o1 & uint32(v&^(3<<19))) != 0 { if (o1 & uint32(v&^(3<<19))) != 0 {
...@@ -2493,7 +2491,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2493,7 +2491,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= uint32(p.To.Reg & 31) o1 |= uint32(p.To.Reg & 31)
case 36: /* mov R,SPR */ case 36: /* mov R,SPR */
o1 = oprrr(ctxt, AMSR) o1 = oprrr(ctxt, p, AMSR)
v := int32(p.To.Offset) v := int32(p.To.Offset)
if (o1 & uint32(v&^(3<<19))) != 0 { if (o1 & uint32(v&^(3<<19))) != 0 {
...@@ -2506,7 +2504,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2506,7 +2504,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if (uint64(p.From.Offset) &^ uint64(0xF)) != 0 { if (uint64(p.From.Offset) &^ uint64(0xF)) != 0 {
ctxt.Diag("illegal immediate for PSTATE field\n%v", p) ctxt.Diag("illegal immediate for PSTATE field\n%v", p)
} }
o1 = opirr(ctxt, AMSR) o1 = opirr(ctxt, p, AMSR)
o1 |= uint32((p.From.Offset & 0xF) << 8) /* Crm */ o1 |= uint32((p.From.Offset & 0xF) << 8) /* Crm */
v := int32(0) v := int32(0)
for i := 0; i < len(pstatefield); i++ { for i := 0; i < len(pstatefield); i++ {
...@@ -2522,7 +2520,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2522,7 +2520,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= uint32(v) o1 |= uint32(v)
case 38: /* clrex [$imm] */ case 38: /* clrex [$imm] */
o1 = opimm(ctxt, p.As) o1 = opimm(ctxt, p, p.As)
if p.To.Type == obj.TYPE_NONE { if p.To.Type == obj.TYPE_NONE {
o1 |= 0xF << 8 o1 |= 0xF << 8
...@@ -2531,13 +2529,13 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2531,13 +2529,13 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
case 39: /* cbz R, rel */ case 39: /* cbz R, rel */
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
o1 |= uint32(p.From.Reg & 31) o1 |= uint32(p.From.Reg & 31)
o1 |= uint32(brdist(ctxt, p, 0, 19, 2) << 5) o1 |= uint32(brdist(ctxt, p, 0, 19, 2) << 5)
case 40: /* tbz */ case 40: /* tbz */
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
v := int32(p.From.Offset) v := int32(p.From.Offset)
if v < 0 || v > 63 { if v < 0 || v > 63 {
...@@ -2548,10 +2546,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2548,10 +2546,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= uint32(p.Reg) o1 |= uint32(p.Reg)
case 41: /* eret, nop, others with no operands */ case 41: /* eret, nop, others with no operands */
o1 = op0(ctxt, p.As) o1 = op0(ctxt, p, p.As)
case 42: /* bfm R,r,s,R */ case 42: /* bfm R,r,s,R */
o1 = opbfm(ctxt, p.As, int(p.From.Offset), int(p.From3.Offset), int(p.Reg), int(p.To.Reg)) o1 = opbfm(ctxt, p, p.As, int(p.From.Offset), int(p.From3.Offset), int(p.Reg), int(p.To.Reg))
case 43: /* bfm aliases */ case 43: /* bfm aliases */
r := int(p.From.Offset) r := int(p.From.Offset)
...@@ -2564,48 +2562,48 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2564,48 +2562,48 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
switch p.As { switch p.As {
case ABFI: case ABFI:
o1 = opbfm(ctxt, ABFM, 64-r, s-1, rf, rt) o1 = opbfm(ctxt, p, ABFM, 64-r, s-1, rf, rt)
case ABFIW: case ABFIW:
o1 = opbfm(ctxt, ABFMW, 32-r, s-1, rf, rt) o1 = opbfm(ctxt, p, ABFMW, 32-r, s-1, rf, rt)
case ABFXIL: case ABFXIL:
o1 = opbfm(ctxt, ABFM, r, r+s-1, rf, rt) o1 = opbfm(ctxt, p, ABFM, r, r+s-1, rf, rt)
case ABFXILW: case ABFXILW:
o1 = opbfm(ctxt, ABFMW, r, r+s-1, rf, rt) o1 = opbfm(ctxt, p, ABFMW, r, r+s-1, rf, rt)
case ASBFIZ: case ASBFIZ:
o1 = opbfm(ctxt, ASBFM, 64-r, s-1, rf, rt) o1 = opbfm(ctxt, p, ASBFM, 64-r, s-1, rf, rt)
case ASBFIZW: case ASBFIZW:
o1 = opbfm(ctxt, ASBFMW, 32-r, s-1, rf, rt) o1 = opbfm(ctxt, p, ASBFMW, 32-r, s-1, rf, rt)
case ASBFX: case ASBFX:
o1 = opbfm(ctxt, ASBFM, r, r+s-1, rf, rt) o1 = opbfm(ctxt, p, ASBFM, r, r+s-1, rf, rt)
case ASBFXW: case ASBFXW:
o1 = opbfm(ctxt, ASBFMW, r, r+s-1, rf, rt) o1 = opbfm(ctxt, p, ASBFMW, r, r+s-1, rf, rt)
case AUBFIZ: case AUBFIZ:
o1 = opbfm(ctxt, AUBFM, 64-r, s-1, rf, rt) o1 = opbfm(ctxt, p, AUBFM, 64-r, s-1, rf, rt)
case AUBFIZW: case AUBFIZW:
o1 = opbfm(ctxt, AUBFMW, 32-r, s-1, rf, rt) o1 = opbfm(ctxt, p, AUBFMW, 32-r, s-1, rf, rt)
case AUBFX: case AUBFX:
o1 = opbfm(ctxt, AUBFM, r, r+s-1, rf, rt) o1 = opbfm(ctxt, p, AUBFM, r, r+s-1, rf, rt)
case AUBFXW: case AUBFXW:
o1 = opbfm(ctxt, AUBFMW, r, r+s-1, rf, rt) o1 = opbfm(ctxt, p, AUBFMW, r, r+s-1, rf, rt)
default: default:
ctxt.Diag("bad bfm alias\n%v", ctxt.Curp) ctxt.Diag("bad bfm alias\n%v", p)
break break
} }
case 44: /* extr $b, Rn, Rm, Rd */ case 44: /* extr $b, Rn, Rm, Rd */
o1 = opextr(ctxt, p.As, int32(p.From.Offset), int(p.From3.Reg), int(p.Reg), int(p.To.Reg)) o1 = opextr(ctxt, p, p.As, int32(p.From.Offset), int(p.From3.Reg), int(p.Reg), int(p.To.Reg))
case 45: /* sxt/uxt[bhw] R,R; movT R,R -> sxtT R,R */ case 45: /* sxt/uxt[bhw] R,R; movT R,R -> sxtT R,R */
rf := int(p.From.Reg) rf := int(p.From.Reg)
...@@ -2617,37 +2615,37 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2617,37 +2615,37 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
switch as { switch as {
case AMOVB, ASXTB: case AMOVB, ASXTB:
o1 = opbfm(ctxt, ASBFM, 0, 7, rf, rt) o1 = opbfm(ctxt, p, ASBFM, 0, 7, rf, rt)
case AMOVH, ASXTH: case AMOVH, ASXTH:
o1 = opbfm(ctxt, ASBFM, 0, 15, rf, rt) o1 = opbfm(ctxt, p, ASBFM, 0, 15, rf, rt)
case AMOVW, ASXTW: case AMOVW, ASXTW:
o1 = opbfm(ctxt, ASBFM, 0, 31, rf, rt) o1 = opbfm(ctxt, p, ASBFM, 0, 31, rf, rt)
case AMOVBU, AUXTB: case AMOVBU, AUXTB:
o1 = opbfm(ctxt, AUBFM, 0, 7, rf, rt) o1 = opbfm(ctxt, p, AUBFM, 0, 7, rf, rt)
case AMOVHU, AUXTH: case AMOVHU, AUXTH:
o1 = opbfm(ctxt, AUBFM, 0, 15, rf, rt) o1 = opbfm(ctxt, p, AUBFM, 0, 15, rf, rt)
case AMOVWU: case AMOVWU:
o1 = oprrr(ctxt, as) | (uint32(rf&31) << 16) | (REGZERO & 31 << 5) | uint32(rt&31) o1 = oprrr(ctxt, p, as) | (uint32(rf&31) << 16) | (REGZERO & 31 << 5) | uint32(rt&31)
case AUXTW: case AUXTW:
o1 = opbfm(ctxt, AUBFM, 0, 31, rf, rt) o1 = opbfm(ctxt, p, AUBFM, 0, 31, rf, rt)
case ASXTBW: case ASXTBW:
o1 = opbfm(ctxt, ASBFMW, 0, 7, rf, rt) o1 = opbfm(ctxt, p, ASBFMW, 0, 7, rf, rt)
case ASXTHW: case ASXTHW:
o1 = opbfm(ctxt, ASBFMW, 0, 15, rf, rt) o1 = opbfm(ctxt, p, ASBFMW, 0, 15, rf, rt)
case AUXTBW: case AUXTBW:
o1 = opbfm(ctxt, AUBFMW, 0, 7, rf, rt) o1 = opbfm(ctxt, p, AUBFMW, 0, 7, rf, rt)
case AUXTHW: case AUXTHW:
o1 = opbfm(ctxt, AUBFMW, 0, 15, rf, rt) o1 = opbfm(ctxt, p, AUBFMW, 0, 15, rf, rt)
default: default:
ctxt.Diag("bad sxt %v", as) ctxt.Diag("bad sxt %v", as)
...@@ -2655,7 +2653,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2655,7 +2653,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
case 46: /* cls */ case 46: /* cls */
o1 = opbit(ctxt, p.As) o1 = opbit(ctxt, p, p.As)
o1 |= uint32(p.From.Reg&31) << 5 o1 |= uint32(p.From.Reg&31) << 5
o1 |= uint32(p.To.Reg & 31) o1 |= uint32(p.To.Reg & 31)
...@@ -2670,7 +2668,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2670,7 +2668,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if r == 0 { if r == 0 {
r = int(o.param) r = int(o.param)
} }
o2 = olsxrr(ctxt, p.As, REGTMP, r, int(p.From.Reg)) o2 = olsxrr(ctxt, p, p.As, REGTMP, r, int(p.From.Reg))
case 48: /* movT V(R), R -> ldrT (huge offset) */ case 48: /* movT V(R), R -> ldrT (huge offset) */
o1 = omovlit(ctxt, AMOVW, p, &p.From, REGTMP) o1 = omovlit(ctxt, AMOVW, p, &p.From, REGTMP)
...@@ -2682,10 +2680,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2682,10 +2680,10 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if r == 0 { if r == 0 {
r = int(o.param) r = int(o.param)
} }
o2 = olsxrr(ctxt, p.As, REGTMP, r, int(p.To.Reg)) o2 = olsxrr(ctxt, p, p.As, REGTMP, r, int(p.To.Reg))
case 50: /* sys/sysl */ case 50: /* sys/sysl */
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
if (p.From.Offset &^ int64(SYSARG4(0x7, 0xF, 0xF, 0x7))) != 0 { if (p.From.Offset &^ int64(SYSARG4(0x7, 0xF, 0xF, 0x7))) != 0 {
ctxt.Diag("illegal SYS argument\n%v", p) ctxt.Diag("illegal SYS argument\n%v", p)
...@@ -2700,14 +2698,14 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2700,14 +2698,14 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
case 51: /* dmb */ case 51: /* dmb */
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
if p.From.Type == obj.TYPE_CONST { if p.From.Type == obj.TYPE_CONST {
o1 |= uint32((p.From.Offset & 0xF) << 8) o1 |= uint32((p.From.Offset & 0xF) << 8)
} }
case 52: /* hint */ case 52: /* hint */
o1 = opirr(ctxt, p.As) o1 = opirr(ctxt, p, p.As)
o1 |= uint32((p.From.Offset & 0x7F) << 5) o1 |= uint32((p.From.Offset & 0x7F) << 5)
...@@ -2729,11 +2727,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2729,11 +2727,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
v = ^v v = ^v
mode = 32 mode = 32
} }
o1 = opirr(ctxt, a) o1 = opirr(ctxt, p, a)
o1 |= bitconEncode(v, mode) | uint32(r&31)<<5 | uint32(rt&31) o1 |= bitconEncode(v, mode) | uint32(r&31)<<5 | uint32(rt&31)
case 54: /* floating point arith */ case 54: /* floating point arith */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
var rf int var rf int
if p.From.Type == obj.TYPE_CONST { if p.From.Type == obj.TYPE_CONST {
...@@ -2758,7 +2756,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2758,7 +2756,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(rf&31) << 16) | (uint32(r&31) << 5) | uint32(rt&31) o1 |= (uint32(rf&31) << 16) | (uint32(r&31) << 5) | uint32(rt&31)
case 56: /* floating point compare */ case 56: /* floating point compare */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
var rf int var rf int
if p.From.Type == obj.TYPE_CONST { if p.From.Type == obj.TYPE_CONST {
...@@ -2771,7 +2769,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2771,7 +2769,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= uint32(rf&31)<<16 | uint32(rt&31)<<5 o1 |= uint32(rf&31)<<16 | uint32(rt&31)<<5
case 57: /* floating point conditional compare */ case 57: /* floating point conditional compare */
o1 = oprrr(ctxt, p.As) o1 = oprrr(ctxt, p, p.As)
cond := int(p.From.Reg) cond := int(p.From.Reg)
nzcv := int(p.To.Offset) nzcv := int(p.To.Offset)
...@@ -2787,7 +2785,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2787,7 +2785,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= uint32(rf&31)<<16 | uint32(cond)<<12 | uint32(rt&31)<<5 | uint32(nzcv) o1 |= uint32(rf&31)<<16 | uint32(cond)<<12 | uint32(rt&31)<<5 | uint32(nzcv)
case 58: /* ldar/ldxr/ldaxr */ case 58: /* ldar/ldxr/ldaxr */
o1 = opload(ctxt, p.As) o1 = opload(ctxt, p, p.As)
o1 |= 0x1F << 16 o1 |= 0x1F << 16
o1 |= uint32(p.From.Reg) << 5 o1 |= uint32(p.From.Reg) << 5
...@@ -2799,7 +2797,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2799,7 +2797,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= uint32(p.To.Reg & 31) o1 |= uint32(p.To.Reg & 31)
case 59: /* stxr/stlxr */ case 59: /* stxr/stlxr */
o1 = opstore(ctxt, p.As) o1 = opstore(ctxt, p, p.As)
if p.RegTo2 != obj.REG_NONE { if p.RegTo2 != obj.REG_NONE {
o1 |= uint32(p.RegTo2&31) << 16 o1 |= uint32(p.RegTo2&31) << 16
...@@ -2837,11 +2835,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2837,11 +2835,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
r = rt r = rt
} }
if p.To.Type != obj.TYPE_NONE && (p.To.Reg == REGSP || r == REGSP) { if p.To.Type != obj.TYPE_NONE && (p.To.Reg == REGSP || r == REGSP) {
o2 = opxrrr(ctxt, p.As) o2 = opxrrr(ctxt, p, p.As)
o2 |= REGTMP & 31 << 16 o2 |= REGTMP & 31 << 16
o2 |= LSL0_64 o2 |= LSL0_64
} else { } else {
o2 = oprrr(ctxt, p.As) o2 = oprrr(ctxt, p, p.As)
o2 |= REGTMP & 31 << 16 /* shift is 0 */ o2 |= REGTMP & 31 << 16 /* shift is 0 */
} }
o2 |= uint32(r&31) << 5 o2 |= uint32(r&31) << 5
...@@ -2850,25 +2848,25 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2850,25 +2848,25 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
/* reloc ops */ /* reloc ops */
case 64: /* movT R,addr -> adrp + add + movT R, (REGTMP) */ case 64: /* movT R,addr -> adrp + add + movT R, (REGTMP) */
o1 = ADR(1, 0, REGTMP) o1 = ADR(1, 0, REGTMP)
o2 = opirr(ctxt, AADD) | REGTMP&31<<5 | REGTMP&31 o2 = opirr(ctxt, p, AADD) | REGTMP&31<<5 | REGTMP&31
rel := obj.Addrel(ctxt.Cursym) rel := obj.Addrel(ctxt.Cursym)
rel.Off = int32(ctxt.Pc) rel.Off = int32(ctxt.Pc)
rel.Siz = 8 rel.Siz = 8
rel.Sym = p.To.Sym rel.Sym = p.To.Sym
rel.Add = p.To.Offset rel.Add = p.To.Offset
rel.Type = obj.R_ADDRARM64 rel.Type = obj.R_ADDRARM64
o3 = olsr12u(ctxt, int32(opstr12(ctxt, p.As)), 0, REGTMP, int(p.From.Reg)) o3 = olsr12u(ctxt, p, int32(opstr12(ctxt, p, p.As)), 0, REGTMP, int(p.From.Reg))
case 65: /* movT addr,R -> adrp + add + movT (REGTMP), R */ case 65: /* movT addr,R -> adrp + add + movT (REGTMP), R */
o1 = ADR(1, 0, REGTMP) o1 = ADR(1, 0, REGTMP)
o2 = opirr(ctxt, AADD) | REGTMP&31<<5 | REGTMP&31 o2 = opirr(ctxt, p, AADD) | REGTMP&31<<5 | REGTMP&31
rel := obj.Addrel(ctxt.Cursym) rel := obj.Addrel(ctxt.Cursym)
rel.Off = int32(ctxt.Pc) rel.Off = int32(ctxt.Pc)
rel.Siz = 8 rel.Siz = 8
rel.Sym = p.From.Sym rel.Sym = p.From.Sym
rel.Add = p.From.Offset rel.Add = p.From.Offset
rel.Type = obj.R_ADDRARM64 rel.Type = obj.R_ADDRARM64
o3 = olsr12u(ctxt, int32(opldr12(ctxt, p.As)), 0, REGTMP, int(p.To.Reg)) o3 = olsr12u(ctxt, p, int32(opldr12(ctxt, p, p.As)), 0, REGTMP, int(p.To.Reg))
case 66: /* ldp O(R)!, (r1, r2); ldp (R)O!, (r1, r2) */ case 66: /* ldp O(R)!, (r1, r2); ldp (R)O!, (r1, r2) */
v := int32(p.From.Offset) v := int32(p.From.Offset)
...@@ -2902,7 +2900,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2902,7 +2900,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
ctxt.Diag("invalid load of 32-bit address: %v", p) ctxt.Diag("invalid load of 32-bit address: %v", p)
} }
o1 = ADR(1, 0, uint32(p.To.Reg)) o1 = ADR(1, 0, uint32(p.To.Reg))
o2 = opirr(ctxt, AADD) | uint32(p.To.Reg&31)<<5 | uint32(p.To.Reg&31) o2 = opirr(ctxt, p, AADD) | uint32(p.To.Reg&31)<<5 | uint32(p.To.Reg&31)
rel := obj.Addrel(ctxt.Cursym) rel := obj.Addrel(ctxt.Cursym)
rel.Off = int32(ctxt.Pc) rel.Off = int32(ctxt.Pc)
rel.Siz = 8 rel.Siz = 8
...@@ -2911,7 +2909,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2911,7 +2909,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
rel.Type = obj.R_ADDRARM64 rel.Type = obj.R_ADDRARM64
case 69: /* LE model movd $tlsvar, reg -> movz reg, 0 + reloc */ case 69: /* LE model movd $tlsvar, reg -> movz reg, 0 + reloc */
o1 = opirr(ctxt, AMOVZ) o1 = opirr(ctxt, p, AMOVZ)
o1 |= uint32(p.To.Reg & 31) o1 |= uint32(p.To.Reg & 31)
rel := obj.Addrel(ctxt.Cursym) rel := obj.Addrel(ctxt.Cursym)
rel.Off = int32(ctxt.Pc) rel.Off = int32(ctxt.Pc)
...@@ -2924,7 +2922,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2924,7 +2922,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
case 70: /* IE model movd $tlsvar, reg -> adrp REGTMP, 0; ldr reg, [REGTMP, #0] + relocs */ case 70: /* IE model movd $tlsvar, reg -> adrp REGTMP, 0; ldr reg, [REGTMP, #0] + relocs */
o1 = ADR(1, 0, REGTMP) o1 = ADR(1, 0, REGTMP)
o2 = olsr12u(ctxt, int32(opldr12(ctxt, AMOVD)), 0, REGTMP, int(p.To.Reg)) o2 = olsr12u(ctxt, p, int32(opldr12(ctxt, p, AMOVD)), 0, REGTMP, int(p.To.Reg))
rel := obj.Addrel(ctxt.Cursym) rel := obj.Addrel(ctxt.Cursym)
rel.Off = int32(ctxt.Pc) rel.Off = int32(ctxt.Pc)
rel.Siz = 8 rel.Siz = 8
...@@ -2937,7 +2935,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2937,7 +2935,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
case 71: /* movd sym@GOT, reg -> adrp REGTMP, #0; ldr reg, [REGTMP, #0] + relocs */ case 71: /* movd sym@GOT, reg -> adrp REGTMP, #0; ldr reg, [REGTMP, #0] + relocs */
o1 = ADR(1, 0, REGTMP) o1 = ADR(1, 0, REGTMP)
o2 = olsr12u(ctxt, int32(opldr12(ctxt, AMOVD)), 0, REGTMP, int(p.To.Reg)) o2 = olsr12u(ctxt, p, int32(opldr12(ctxt, p, AMOVD)), 0, REGTMP, int(p.To.Reg))
rel := obj.Addrel(ctxt.Cursym) rel := obj.Addrel(ctxt.Cursym)
rel.Off = int32(ctxt.Pc) rel.Off = int32(ctxt.Pc)
rel.Siz = 8 rel.Siz = 8
...@@ -2969,7 +2967,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2969,7 +2967,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
* also op Rn -> Rt * also op Rn -> Rt
* also Rm*Rn op Ra -> Rd * also Rm*Rn op Ra -> Rd
*/ */
func oprrr(ctxt *obj.Link, a obj.As) uint32 { func oprrr(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case AADC: case AADC:
return S64 | 0<<30 | 0<<29 | 0xd0<<21 | 0<<10 return S64 | 0<<30 | 0<<29 | 0xd0<<21 | 0<<10
...@@ -3483,7 +3481,7 @@ func oprrr(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3483,7 +3481,7 @@ func oprrr(ctxt *obj.Link, a obj.As) uint32 {
return FPOP1S(0, 0, 3, 5) return FPOP1S(0, 0, 3, 5)
} }
ctxt.Diag("%v: bad rrr %d %v", ctxt.Curp, a, a) ctxt.Diag("%v: bad rrr %d %v", p, a, a)
return 0 return 0
} }
...@@ -3491,7 +3489,7 @@ func oprrr(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3491,7 +3489,7 @@ func oprrr(ctxt *obj.Link, a obj.As) uint32 {
* imm -> Rd * imm -> Rd
* imm op Rn -> Rd * imm op Rn -> Rd
*/ */
func opirr(ctxt *obj.Link, a obj.As) uint32 { func opirr(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
/* op $addcon, Rn, Rd */ /* op $addcon, Rn, Rd */
case AMOVD, AADD: case AMOVD, AADD:
...@@ -3669,11 +3667,11 @@ func opirr(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3669,11 +3667,11 @@ func opirr(ctxt *obj.Link, a obj.As) uint32 {
return SYSOP(0, 0, 3, 2, 0, 0, 0x1F) return SYSOP(0, 0, 3, 2, 0, 0, 0x1F)
} }
ctxt.Diag("%v: bad irr %v", ctxt.Curp, a) ctxt.Diag("%v: bad irr %v", p, a)
return 0 return 0
} }
func opbit(ctxt *obj.Link, a obj.As) uint32 { func opbit(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case ACLS: case ACLS:
return S64 | OPBIT(5) return S64 | OPBIT(5)
...@@ -3709,7 +3707,7 @@ func opbit(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3709,7 +3707,7 @@ func opbit(ctxt *obj.Link, a obj.As) uint32 {
return S64 | OPBIT(2) return S64 | OPBIT(2)
default: default:
ctxt.Diag("bad bit op\n%v", ctxt.Curp) ctxt.Diag("bad bit op\n%v", p)
return 0 return 0
} }
} }
...@@ -3717,7 +3715,7 @@ func opbit(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3717,7 +3715,7 @@ func opbit(ctxt *obj.Link, a obj.As) uint32 {
/* /*
* add/subtract extended register * add/subtract extended register
*/ */
func opxrrr(ctxt *obj.Link, a obj.As) uint32 { func opxrrr(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case AADD: case AADD:
return S64 | 0<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_64 return S64 | 0<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_64
...@@ -3744,11 +3742,11 @@ func opxrrr(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3744,11 +3742,11 @@ func opxrrr(ctxt *obj.Link, a obj.As) uint32 {
return S32 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32 return S32 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32
} }
ctxt.Diag("bad opxrrr %v\n%v", a, ctxt.Curp) ctxt.Diag("bad opxrrr %v\n%v", a, p)
return 0 return 0
} }
func opimm(ctxt *obj.Link, a obj.As) uint32 { func opimm(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case ASVC: case ASVC:
return 0xD4<<24 | 0<<21 | 1 /* imm16<<5 */ return 0xD4<<24 | 0<<21 | 1 /* imm16<<5 */
...@@ -3778,7 +3776,7 @@ func opimm(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3778,7 +3776,7 @@ func opimm(ctxt *obj.Link, a obj.As) uint32 {
return SYSOP(0, 0, 3, 3, 0, 2, 0x1F) return SYSOP(0, 0, 3, 3, 0, 2, 0x1F)
} }
ctxt.Diag("%v: bad imm %v", ctxt.Curp, a) ctxt.Diag("%v: bad imm %v", p, a)
return 0 return 0
} }
...@@ -3804,7 +3802,7 @@ func brdist(ctxt *obj.Link, p *obj.Prog, preshift int, flen int, shift int) int6 ...@@ -3804,7 +3802,7 @@ func brdist(ctxt *obj.Link, p *obj.Prog, preshift int, flen int, shift int) int6
/* /*
* pc-relative branches * pc-relative branches
*/ */
func opbra(ctxt *obj.Link, a obj.As) uint32 { func opbra(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case ABEQ: case ABEQ:
return OPBcc(0x0) return OPBcc(0x0)
...@@ -3861,11 +3859,11 @@ func opbra(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3861,11 +3859,11 @@ func opbra(ctxt *obj.Link, a obj.As) uint32 {
return 1<<31 | 5<<26 return 1<<31 | 5<<26
} }
ctxt.Diag("%v: bad bra %v", ctxt.Curp, a) ctxt.Diag("%v: bad bra %v", p, a)
return 0 return 0
} }
func opbrr(ctxt *obj.Link, a obj.As) uint32 { func opbrr(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case ABL: case ABL:
return OPBLR(1) /* BLR */ return OPBLR(1) /* BLR */
...@@ -3877,11 +3875,11 @@ func opbrr(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3877,11 +3875,11 @@ func opbrr(ctxt *obj.Link, a obj.As) uint32 {
return OPBLR(2) /* RET */ return OPBLR(2) /* RET */
} }
ctxt.Diag("%v: bad brr %v", ctxt.Curp, a) ctxt.Diag("%v: bad brr %v", p, a)
return 0 return 0
} }
func op0(ctxt *obj.Link, a obj.As) uint32 { func op0(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case ADRPS: case ADRPS:
return 0x6B<<25 | 5<<21 | 0x1F<<16 | 0x1F<<5 return 0x6B<<25 | 5<<21 | 0x1F<<16 | 0x1F<<5
...@@ -3908,14 +3906,14 @@ func op0(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3908,14 +3906,14 @@ func op0(ctxt *obj.Link, a obj.As) uint32 {
return SYSHINT(5) return SYSHINT(5)
} }
ctxt.Diag("%v: bad op0 %v", ctxt.Curp, a) ctxt.Diag("%v: bad op0 %v", p, a)
return 0 return 0
} }
/* /*
* register offset * register offset
*/ */
func opload(ctxt *obj.Link, a obj.As) uint32 { func opload(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case ALDAR: case ALDAR:
return LDSTX(3, 1, 1, 0, 1) | 0x1F<<10 return LDSTX(3, 1, 1, 0, 1) | 0x1F<<10
...@@ -3972,11 +3970,11 @@ func opload(ctxt *obj.Link, a obj.As) uint32 { ...@@ -3972,11 +3970,11 @@ func opload(ctxt *obj.Link, a obj.As) uint32 {
return S32 | 0<<30 | 5<<27 | 0<<26 | 0<<23 | 1<<22 return S32 | 0<<30 | 5<<27 | 0<<26 | 0<<23 | 1<<22
} }
ctxt.Diag("bad opload %v\n%v", a, ctxt.Curp) ctxt.Diag("bad opload %v\n%v", a, p)
return 0 return 0
} }
func opstore(ctxt *obj.Link, a obj.As) uint32 { func opstore(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case ASTLR: case ASTLR:
return LDSTX(3, 1, 0, 0, 1) | 0x1F<<10 return LDSTX(3, 1, 0, 0, 1) | 0x1F<<10
...@@ -4039,7 +4037,7 @@ func opstore(ctxt *obj.Link, a obj.As) uint32 { ...@@ -4039,7 +4037,7 @@ func opstore(ctxt *obj.Link, a obj.As) uint32 {
return S32 | 0<<30 | 5<<27 | 0<<26 | 0<<23 | 1<<22 return S32 | 0<<30 | 5<<27 | 0<<26 | 0<<23 | 1<<22
} }
ctxt.Diag("bad opstore %v\n%v", a, ctxt.Curp) ctxt.Diag("bad opstore %v\n%v", a, p)
return 0 return 0
} }
...@@ -4047,9 +4045,9 @@ func opstore(ctxt *obj.Link, a obj.As) uint32 { ...@@ -4047,9 +4045,9 @@ func opstore(ctxt *obj.Link, a obj.As) uint32 {
* load/store register (unsigned immediate) C3.3.13 * load/store register (unsigned immediate) C3.3.13
* these produce 64-bit values (when there's an option) * these produce 64-bit values (when there's an option)
*/ */
func olsr12u(ctxt *obj.Link, o int32, v int32, b int, r int) uint32 { func olsr12u(ctxt *obj.Link, p *obj.Prog, o int32, v int32, b int, r int) uint32 {
if v < 0 || v >= (1<<12) { if v < 0 || v >= (1<<12) {
ctxt.Diag("offset out of range: %d\n%v", v, ctxt.Curp) ctxt.Diag("offset out of range: %d\n%v", v, p)
} }
o |= (v & 0xFFF) << 10 o |= (v & 0xFFF) << 10
o |= int32(b&31) << 5 o |= int32(b&31) << 5
...@@ -4057,7 +4055,7 @@ func olsr12u(ctxt *obj.Link, o int32, v int32, b int, r int) uint32 { ...@@ -4057,7 +4055,7 @@ func olsr12u(ctxt *obj.Link, o int32, v int32, b int, r int) uint32 {
return uint32(o) return uint32(o)
} }
func opldr12(ctxt *obj.Link, a obj.As) uint32 { func opldr12(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case AMOVD: case AMOVD:
return LDSTR12U(3, 0, 1) /* imm12<<10 | Rn<<5 | Rt */ return LDSTR12U(3, 0, 1) /* imm12<<10 | Rn<<5 | Rt */
...@@ -4087,20 +4085,20 @@ func opldr12(ctxt *obj.Link, a obj.As) uint32 { ...@@ -4087,20 +4085,20 @@ func opldr12(ctxt *obj.Link, a obj.As) uint32 {
return LDSTR12U(3, 1, 1) return LDSTR12U(3, 1, 1)
} }
ctxt.Diag("bad opldr12 %v\n%v", a, ctxt.Curp) ctxt.Diag("bad opldr12 %v\n%v", a, p)
return 0 return 0
} }
func opstr12(ctxt *obj.Link, a obj.As) uint32 { func opstr12(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
return LD2STR(opldr12(ctxt, a)) return LD2STR(opldr12(ctxt, p, a))
} }
/* /*
* load/store register (unscaled immediate) C3.3.12 * load/store register (unscaled immediate) C3.3.12
*/ */
func olsr9s(ctxt *obj.Link, o int32, v int32, b int, r int) uint32 { func olsr9s(ctxt *obj.Link, p *obj.Prog, o int32, v int32, b int, r int) uint32 {
if v < -256 || v > 255 { if v < -256 || v > 255 {
ctxt.Diag("offset out of range: %d\n%v", v, ctxt.Curp) ctxt.Diag("offset out of range: %d\n%v", v, p)
} }
o |= (v & 0x1FF) << 12 o |= (v & 0x1FF) << 12
o |= int32(b&31) << 5 o |= int32(b&31) << 5
...@@ -4108,7 +4106,7 @@ func olsr9s(ctxt *obj.Link, o int32, v int32, b int, r int) uint32 { ...@@ -4108,7 +4106,7 @@ func olsr9s(ctxt *obj.Link, o int32, v int32, b int, r int) uint32 {
return uint32(o) return uint32(o)
} }
func opldr9(ctxt *obj.Link, a obj.As) uint32 { func opldr9(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case AMOVD: case AMOVD:
return LDSTR9S(3, 0, 1) /* simm9<<12 | Rn<<5 | Rt */ return LDSTR9S(3, 0, 1) /* simm9<<12 | Rn<<5 | Rt */
...@@ -4138,15 +4136,15 @@ func opldr9(ctxt *obj.Link, a obj.As) uint32 { ...@@ -4138,15 +4136,15 @@ func opldr9(ctxt *obj.Link, a obj.As) uint32 {
return LDSTR9S(3, 1, 1) return LDSTR9S(3, 1, 1)
} }
ctxt.Diag("bad opldr9 %v\n%v", a, ctxt.Curp) ctxt.Diag("bad opldr9 %v\n%v", a, p)
return 0 return 0
} }
func opstr9(ctxt *obj.Link, a obj.As) uint32 { func opstr9(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
return LD2STR(opldr9(ctxt, a)) return LD2STR(opldr9(ctxt, p, a))
} }
func opldrpp(ctxt *obj.Link, a obj.As) uint32 { func opldrpp(ctxt *obj.Link, p *obj.Prog, a obj.As) uint32 {
switch a { switch a {
case AMOVD: case AMOVD:
return 3<<30 | 7<<27 | 0<<26 | 0<<24 | 1<<22 /* simm9<<12 | Rn<<5 | Rt */ return 3<<30 | 7<<27 | 0<<26 | 0<<24 | 1<<22 /* simm9<<12 | Rn<<5 | Rt */
...@@ -4170,22 +4168,22 @@ func opldrpp(ctxt *obj.Link, a obj.As) uint32 { ...@@ -4170,22 +4168,22 @@ func opldrpp(ctxt *obj.Link, a obj.As) uint32 {
return 0<<30 | 7<<27 | 0<<26 | 0<<24 | 1<<22 return 0<<30 | 7<<27 | 0<<26 | 0<<24 | 1<<22
} }
ctxt.Diag("bad opldr %v\n%v", a, ctxt.Curp) ctxt.Diag("bad opldr %v\n%v", a, p)
return 0 return 0
} }
/* /*
* load/store register (extended register) * load/store register (extended register)
*/ */
func olsxrr(ctxt *obj.Link, as obj.As, rt int, r1 int, r2 int) uint32 { func olsxrr(ctxt *obj.Link, p *obj.Prog, as obj.As, rt int, r1 int, r2 int) uint32 {
ctxt.Diag("need load/store extended register\n%v", ctxt.Curp) ctxt.Diag("need load/store extended register\n%v", p)
return 0xffffffff return 0xffffffff
} }
func oaddi(ctxt *obj.Link, o1 int32, v int32, r int, rt int) uint32 { func oaddi(ctxt *obj.Link, p *obj.Prog, o1 int32, v int32, r int, rt int) uint32 {
if (v & 0xFFF000) != 0 { if (v & 0xFFF000) != 0 {
if v&0xFFF != 0 { if v&0xFFF != 0 {
ctxt.Diag("%v misuses oaddi", ctxt.Curp) ctxt.Diag("%v misuses oaddi", p)
} }
v >>= 12 v >>= 12
o1 |= 1 << 22 o1 |= 1 << 22
...@@ -4205,7 +4203,7 @@ func omovlit(ctxt *obj.Link, as obj.As, p *obj.Prog, a *obj.Addr, dr int) uint32 ...@@ -4205,7 +4203,7 @@ func omovlit(ctxt *obj.Link, as obj.As, p *obj.Prog, a *obj.Addr, dr int) uint32
ctxt.Logf("omovlit add %d (%#x)\n", ctxt.Instoffset, uint64(ctxt.Instoffset)) ctxt.Logf("omovlit add %d (%#x)\n", ctxt.Instoffset, uint64(ctxt.Instoffset))
/* TODO: could be clever, and use general constant builder */ /* TODO: could be clever, and use general constant builder */
o1 = int32(opirr(ctxt, AADD)) o1 = int32(opirr(ctxt, p, AADD))
v := int32(ctxt.Instoffset) v := int32(ctxt.Instoffset)
if v != 0 && (v&0xFFF) == 0 { if v != 0 && (v&0xFFF) == 0 {
...@@ -4259,7 +4257,7 @@ func omovconst(ctxt *obj.Link, as obj.As, p *obj.Prog, a *obj.Addr, rt int) (o1 ...@@ -4259,7 +4257,7 @@ func omovconst(ctxt *obj.Link, as obj.As, p *obj.Prog, a *obj.Addr, rt int) (o1
case AMOVD: case AMOVD:
as1 = AORR as1 = AORR
} }
o1 = opirr(ctxt, as1) o1 = opirr(ctxt, p, as1)
o1 |= bitconEncode(uint64(a.Offset), mode) | uint32(REGZERO&31)<<5 | uint32(rt&31) o1 |= bitconEncode(uint64(a.Offset), mode) | uint32(REGZERO&31)<<5 | uint32(rt&31)
return o1 return o1
} }
...@@ -4277,51 +4275,51 @@ func omovconst(ctxt *obj.Link, as obj.As, p *obj.Prog, a *obj.Addr, rt int) (o1 ...@@ -4277,51 +4275,51 @@ func omovconst(ctxt *obj.Link, as obj.As, p *obj.Prog, a *obj.Addr, rt int) (o1
ctxt.Diag("impossible move wide: %#x\n%v", uint64(a.Offset), p) ctxt.Diag("impossible move wide: %#x\n%v", uint64(a.Offset), p)
} }
if as == AMOVD { if as == AMOVD {
o1 = opirr(ctxt, AMOVN) o1 = opirr(ctxt, p, AMOVN)
} else { } else {
o1 = opirr(ctxt, AMOVNW) o1 = opirr(ctxt, p, AMOVNW)
} }
} else { } else {
if as == AMOVD { if as == AMOVD {
o1 = opirr(ctxt, AMOVZ) o1 = opirr(ctxt, p, AMOVZ)
} else { } else {
o1 = opirr(ctxt, AMOVZW) o1 = opirr(ctxt, p, AMOVZW)
} }
} }
o1 |= uint32((((d >> uint(s*16)) & 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))
return o1 return o1
} }
func opbfm(ctxt *obj.Link, a obj.As, r int, s int, rf int, rt int) uint32 { func opbfm(ctxt *obj.Link, p *obj.Prog, a obj.As, r int, s int, rf int, rt int) uint32 {
var c uint32 var c uint32
o := opirr(ctxt, a) o := opirr(ctxt, p, a)
if (o & (1 << 31)) == 0 { if (o & (1 << 31)) == 0 {
c = 32 c = 32
} else { } else {
c = 64 c = 64
} }
if r < 0 || uint32(r) >= c { if r < 0 || uint32(r) >= c {
ctxt.Diag("illegal bit number\n%v", ctxt.Curp) ctxt.Diag("illegal bit number\n%v", p)
} }
o |= (uint32(r) & 0x3F) << 16 o |= (uint32(r) & 0x3F) << 16
if s < 0 || uint32(s) >= c { if s < 0 || uint32(s) >= c {
ctxt.Diag("illegal bit number\n%v", ctxt.Curp) ctxt.Diag("illegal bit number\n%v", p)
} }
o |= (uint32(s) & 0x3F) << 10 o |= (uint32(s) & 0x3F) << 10
o |= (uint32(rf&31) << 5) | uint32(rt&31) o |= (uint32(rf&31) << 5) | uint32(rt&31)
return o return o
} }
func opextr(ctxt *obj.Link, a obj.As, v int32, rn int, rm int, rt int) uint32 { func opextr(ctxt *obj.Link, p *obj.Prog, a obj.As, v int32, rn int, rm int, rt int) uint32 {
var c uint32 var c uint32
o := opirr(ctxt, a) o := opirr(ctxt, p, a)
if (o & (1 << 31)) != 0 { if (o & (1 << 31)) != 0 {
c = 63 c = 63
} else { } else {
c = 31 c = 31
} }
if v < 0 || uint32(v) > c { if v < 0 || uint32(v) > c {
ctxt.Diag("illegal bit number\n%v", ctxt.Curp) ctxt.Diag("illegal bit number\n%v", p)
} }
o |= uint32(v) << 10 o |= uint32(v) << 10
o |= uint32(rn&31) << 5 o |= uint32(rn&31) << 5
......
...@@ -730,7 +730,6 @@ type Link struct { ...@@ -730,7 +730,6 @@ type Link struct {
Sym_mod *LSym Sym_mod *LSym
Sym_modu *LSym Sym_modu *LSym
Plan9privates *LSym Plan9privates *LSym
Curp *Prog
Printp *Prog Printp *Prog
Blitrl *Prog Blitrl *Prog
Elitrl *Prog Elitrl *Prog
......
...@@ -391,7 +391,6 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -391,7 +391,6 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) {
var m int var m int
var o *Optab var o *Optab
for p = p.Link; p != nil; p = p.Link { for p = p.Link; p != nil; p = p.Link {
ctxt.Curp = p
p.Pc = c p.Pc = c
o = oplook(ctxt, p) o = oplook(ctxt, p)
m = int(o.size) m = int(o.size)
...@@ -482,7 +481,6 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -482,7 +481,6 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) {
var out [4]uint32 var out [4]uint32
for p := cursym.Text.Link; p != nil; p = p.Link { for p := cursym.Text.Link; p != nil; p = p.Link {
ctxt.Pc = p.Pc ctxt.Pc = p.Pc
ctxt.Curp = p
o = oplook(ctxt, p) o = oplook(ctxt, p)
if int(o.size) > 4*len(out) { if int(o.size) > 4*len(out) {
log.Fatalf("out array in span0 is too small, need at least %d for %v", o.size/4, p) log.Fatalf("out array in span0 is too small, need at least %d for %v", o.size/4, p)
......
...@@ -136,7 +136,6 @@ func flushplist(ctxt *Link, plist *Plist, freeProgs bool) { ...@@ -136,7 +136,6 @@ func flushplist(ctxt *Link, plist *Plist, freeProgs bool) {
// Add to running list in ctxt. // Add to running list in ctxt.
ctxt.Text = append(ctxt.Text, text...) ctxt.Text = append(ctxt.Text, text...)
ctxt.Curp = nil
if freeProgs { if freeProgs {
ctxt.freeProgs() ctxt.freeProgs()
} }
......
...@@ -570,7 +570,6 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -570,7 +570,6 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) {
var m int var m int
var o *Optab var o *Optab
for p = p.Link; p != nil; p = p.Link { for p = p.Link; p != nil; p = p.Link {
ctxt.Curp = p
p.Pc = c p.Pc = c
o = oplook(ctxt, p) o = oplook(ctxt, p)
m = int(o.size) m = int(o.size)
...@@ -658,7 +657,6 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -658,7 +657,6 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) {
var out [6]uint32 var out [6]uint32
for p := cursym.Text.Link; p != nil; p = p.Link { for p := cursym.Text.Link; p != nil; p = p.Link {
ctxt.Pc = p.Pc ctxt.Pc = p.Pc
ctxt.Curp = p
o = oplook(ctxt, p) o = oplook(ctxt, p)
if int(o.size) > 4*len(out) { if int(o.size) > 4*len(out) {
log.Fatalf("out array in span9 is too small, need at least %d for %v", o.size/4, p) log.Fatalf("out array in span9 is too small, need at least %d for %v", o.size/4, p)
......
...@@ -415,8 +415,7 @@ func spanz(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -415,8 +415,7 @@ func spanz(ctxt *obj.Link, cursym *obj.LSym) {
} }
p.Pc = pc p.Pc = pc
ctxt.Pc = p.Pc ctxt.Pc = p.Pc
ctxt.Curp = p asmout(ctxt, p, &buffer)
asmout(ctxt, &buffer)
if pc == int64(len(buffer)) { if pc == int64(len(buffer)) {
switch p.As { switch p.As {
case obj.ANOP, obj.AFUNCDATA, obj.APCDATA, obj.ATEXT: case obj.ANOP, obj.AFUNCDATA, obj.APCDATA, obj.ATEXT:
...@@ -2549,8 +2548,7 @@ func branchMask(ctxt *obj.Link, p *obj.Prog) uint32 { ...@@ -2549,8 +2548,7 @@ func branchMask(ctxt *obj.Link, p *obj.Prog) uint32 {
return 0xF return 0xF
} }
func asmout(ctxt *obj.Link, asm *[]byte) { func asmout(ctxt *obj.Link, p *obj.Prog, asm *[]byte) {
p := ctxt.Curp
o := oplook(ctxt, p) o := oplook(ctxt, p)
ctxt.Printp = p ctxt.Printp = p
......
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