aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
diff options
context:
space:
mode:
authorMauri de Souza Meneguzzo <mauri870@gmail.com>2024-10-21 21:47:40 +0000
committerCherry Mui <cherryyz@google.com>2024-10-23 15:18:14 +0000
commit3cb0c039e9bdc4bf8ca7cc31dc7432f9f37d4079 (patch)
tree314a3e98346527d8da60bdfdc073325377ec4141 /src/cmd/internal/obj
parent263b5ecba78f5fa503d1e47ad469d12b45e0a149 (diff)
downloadgo-3cb0c039e9bdc4bf8ca7cc31dc7432f9f37d4079.tar.xz
cmd/asm: add support for LDREXB/STREXB
These are 8-bit ARM Load/Store atomics and are available starting from armv6k. See https://developer.arm.com/documentation/dui0379/e/arm-and-thumb-instructions/strex For #69735 Change-Id: I12623433c89070495c178208ee4758b3cdefd368 GitHub-Last-Rev: d6a797836af1dccdcc6e6554725546b386d01615 GitHub-Pull-Request: golang/go#69959 Cq-Include-Trybots: luci.golang.try:gotip-linux-arm Reviewed-on: https://go-review.googlesource.com/c/go/+/621395 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/internal/obj')
-rw-r--r--src/cmd/internal/obj/arm/a.out.go2
-rw-r--r--src/cmd/internal/obj/arm/anames.go2
-rw-r--r--src/cmd/internal/obj/arm/asm5.go34
3 files changed, 30 insertions, 8 deletions
diff --git a/src/cmd/internal/obj/arm/a.out.go b/src/cmd/internal/obj/arm/a.out.go
index fd695ad0c9..fabd0cb50f 100644
--- a/src/cmd/internal/obj/arm/a.out.go
+++ b/src/cmd/internal/obj/arm/a.out.go
@@ -333,7 +333,9 @@ const (
ALDREX
ASTREX
ALDREXD
+ ALDREXB
ASTREXD
+ ASTREXB
ADMB
diff --git a/src/cmd/internal/obj/arm/anames.go b/src/cmd/internal/obj/arm/anames.go
index f5e92defc9..04537759c1 100644
--- a/src/cmd/internal/obj/arm/anames.go
+++ b/src/cmd/internal/obj/arm/anames.go
@@ -117,7 +117,9 @@ var Anames = []string{
"LDREX",
"STREX",
"LDREXD",
+ "LDREXB",
"STREXD",
+ "STREXB",
"DMB",
"PLD",
"CLZ",
diff --git a/src/cmd/internal/obj/arm/asm5.go b/src/cmd/internal/obj/arm/asm5.go
index a02519c147..bf9623c206 100644
--- a/src/cmd/internal/obj/arm/asm5.go
+++ b/src/cmd/internal/obj/arm/asm5.go
@@ -318,7 +318,9 @@ var optab = []Optab{
{AMOVW, C_REG, C_NONE, C_FREG, 88, 4, 0, 0, 0, 0},
{AMOVW, C_FREG, C_NONE, C_REG, 89, 4, 0, 0, 0, 0},
{ALDREXD, C_SOREG, C_NONE, C_REG, 91, 4, 0, 0, 0, 0},
+ {ALDREXB, C_SOREG, C_NONE, C_REG, 91, 4, 0, 0, 0, 0},
{ASTREXD, C_SOREG, C_REG, C_REG, 92, 4, 0, 0, 0, 0},
+ {ASTREXB, C_SOREG, C_REG, C_REG, 92, 4, 0, 0, 0, 0},
{APLD, C_SOREG, C_NONE, C_NONE, 95, 4, 0, 0, 0, 0},
{obj.AUNDEF, C_NONE, C_NONE, C_NONE, 96, 4, 0, 0, 0, 0},
{ACLZ, C_REG, C_NONE, C_REG, 97, 4, 0, 0, 0, 0},
@@ -1432,7 +1434,9 @@ func buildop(ctxt *obj.Link) {
case ALDREX,
ASTREX,
ALDREXD,
+ ALDREXB,
ASTREXD,
+ ASTREXB,
ADMB,
APLD,
AAND,
@@ -2397,30 +2401,44 @@ func (c *ctxt5) asmout(p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(p.From.Reg) & 15) << 16
o1 |= (uint32(p.To.Reg) & 15) << 12
- case 91: /* ldrexd oreg,reg */
+ case 91: /* ldrexd/ldrexb oreg,reg */
c.aclass(&p.From)
if c.instoffset != 0 {
c.ctxt.Diag("offset must be zero in LDREX")
}
- o1 = 0x1b<<20 | 0xf9f
+
+ switch p.As {
+ case ALDREXD:
+ o1 = 0x1b << 20
+ case ALDREXB:
+ o1 = 0x1d << 20
+ }
+ o1 |= 0xf9f
o1 |= (uint32(p.From.Reg) & 15) << 16
o1 |= (uint32(p.To.Reg) & 15) << 12
o1 |= ((uint32(p.Scond) & C_SCOND) ^ C_SCOND_XOR) << 28
- case 92: /* strexd reg,oreg,reg */
+ case 92: /* strexd/strexb reg,oreg,reg */
c.aclass(&p.From)
if c.instoffset != 0 {
c.ctxt.Diag("offset must be zero in STREX")
}
- if p.Reg&1 != 0 {
- c.ctxt.Diag("source register must be even in STREXD: %v", p)
- }
- if p.To.Reg == p.From.Reg || p.To.Reg == p.Reg || p.To.Reg == p.Reg+1 {
+ if p.To.Reg == p.From.Reg || p.To.Reg == p.Reg || (p.As == ASTREXD && p.To.Reg == p.Reg+1) {
c.ctxt.Diag("cannot use same register as both source and destination: %v", p)
}
- o1 = 0x1a<<20 | 0xf90
+
+ switch p.As {
+ case ASTREXD:
+ if p.Reg&1 != 0 {
+ c.ctxt.Diag("source register must be even in STREXD: %v", p)
+ }
+ o1 = 0x1a << 20
+ case ASTREXB:
+ o1 = 0x1c << 20
+ }
+ o1 |= 0xf90
o1 |= (uint32(p.From.Reg) & 15) << 16
o1 |= (uint32(p.Reg) & 15) << 0
o1 |= (uint32(p.To.Reg) & 15) << 12