From d6a797836af1dccdcc6e6554725546b386d01615 Mon Sep 17 00:00:00 2001 From: Mauri de Souza Meneguzzo Date: Mon, 21 Oct 2024 18:39:57 -0300 Subject: [PATCH] code review changes for registers Change-Id: I39443f35c07db45a60ce90bf202306042a0c8e1b --- src/cmd/asm/internal/asm/testdata/armerror.s | 2 -- src/cmd/internal/obj/arm/asm5.go | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cmd/asm/internal/asm/testdata/armerror.s b/src/cmd/asm/internal/asm/testdata/armerror.s index 0a296ab7de..8aa16aa9cf 100644 --- a/src/cmd/asm/internal/asm/testdata/armerror.s +++ b/src/cmd/asm/internal/asm/testdata/armerror.s @@ -261,8 +261,6 @@ TEXT errors(SB),$0 STREXD R0, (R2), R2 // ERROR "cannot use same register as both source and destination" STREXD R1, (R4), R7 // ERROR "must be even" STREXB R0, (R2), R0 // ERROR "cannot use same register as both source and destination" - STREXB R0, (R2), R1 // ERROR "cannot use same register as both source and destination" STREXB R0, (R2), R2 // ERROR "cannot use same register as both source and destination" - STREXB R1, (R4), R7 // ERROR "must be even" END diff --git a/src/cmd/internal/obj/arm/asm5.go b/src/cmd/internal/obj/arm/asm5.go index 075713e724..bf9623c206 100644 --- a/src/cmd/internal/obj/arm/asm5.go +++ b/src/cmd/internal/obj/arm/asm5.go @@ -2425,15 +2425,15 @@ func (c *ctxt5) asmout(p *obj.Prog, o *Optab, out []uint32) { 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) } 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