arm64/instgen: make addr the last op in SVE stores This CL generates CL 772520. Change-Id: Ieff3ed502325d5bf20adf5ffc0f2cc915ead8506 Reviewed-on: https://go-review.googlesource.com/c/arch/+/772500 Auto-Submit: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
diff --git a/arm64/instgen/generator.go b/arm64/instgen/generator.go index 98d223f..1950d87 100644 --- a/arm64/instgen/generator.go +++ b/arm64/instgen/generator.go
@@ -1525,6 +1525,12 @@ } } // Try to assemble the GNU version. + // Stores are not reversed in Go, so we reverse them back. + if strings.HasPrefix(name, "ST") { + for i, j := 0, len(gnuAsmOps)-1; i < j; i, j = i+1, j-1 { + gnuAsmOps[i], gnuAsmOps[j] = gnuAsmOps[j], gnuAsmOps[i] + } + } gnuAsm := fmt.Sprintf(".arch_extension sve2p1\n%s %s", name, strings.Join(gnuAsmOps, ", ")) hex, err := assembleGNU(gnuAsm) goAsmStr := fmt.Sprintf("%s %s", enc.GoOp[1:], strings.Join(goAsmOps, ", "))
diff --git a/arm64/instgen/xmlspec/parser.go b/arm64/instgen/xmlspec/parser.go index a285698..5258413 100644 --- a/arm64/instgen/xmlspec/parser.go +++ b/arm64/instgen/xmlspec/parser.go
@@ -751,6 +751,11 @@ // sortOperands reorders the operands of an encoding according to Go assembly syntax. func (enc *EncodingParsed) sortOperands() { + // For stores, we need to make sure the memory is the destination. + // The original order fits just naturally, so no-op. + if strings.HasPrefix(enc.Operands[0].Name, "ST") { + return + } // Reverse args, placing dest last. for i, j := 1, len(enc.Operands)-1; i < j; i, j = i+1, j-1 { enc.Operands[i], enc.Operands[j] = enc.Operands[j], enc.Operands[i]