arm/armasm: fix wrong argument order of ARM's MLA-like instructions

As reported in issue #20096, "MLS R1, R2, R3, R4" is disassembled
to "MLS R3, R1, R2, R4". This patch fixes this type of error
in all MLA-like instructions. And also test cases are added
in the decode test.

Updates #20096

Change-Id: I7f2140e9d98e8f7694892f4ea8cce87f1d2854e6
Reviewed-on: https://go-review.googlesource.com/42171
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/arm/armasm/plan9x.go b/arm/armasm/plan9x.go
index d43cc96..5aaebeb 100644
--- a/arm/armasm/plan9x.go
+++ b/arm/armasm/plan9x.go
@@ -113,6 +113,11 @@
 	for i, j := 0, len(args)-1; i < j; i, j = i+1, j-1 {
 		args[i], args[j] = args[j], args[i]
 	}
+	// For MLA-like instructions, the addend is the third operand.
+	switch inst.Op &^ 15 {
+	case SMLAWT_EQ, SMLAWB_EQ, MLA_EQ, MLS_EQ, SMMLA_EQ, SMMLS_EQ, SMLABB_EQ:
+		args = []string{args[1], args[2], args[0], args[3]}
+	}
 
 	switch inst.Op &^ 15 {
 	case MOV_EQ:
diff --git a/arm/armasm/testdata/decode.txt b/arm/armasm/testdata/decode.txt
index 2048e50..2bd02c8 100644
--- a/arm/armasm/testdata/decode.txt
+++ b/arm/armasm/testdata/decode.txt
@@ -305,3 +305,5 @@
 |76452001	1	gnu	error: unknown instruction
 |97acd647	1	gnu	error: unknown instruction
 ed003be9|	1	plan9	LDMDB [R0,R2-R3,R5-R7], R11!
+923124e0|	1	plan9	MLA R1, R2, R3, R4
+923164e0|	1	plan9	MLS R1, R2, R3, R4