cmd/asm: handle CMPF and CMPD on ARM
These instructions are special cases that were missed in the translation.
The second argument must go into the Reg field not the To field.
Fixes #12458
For Go 1.5.1
Change-Id: Iad57c60c7e38e3bcfafda483ed5037ce670e8816
Reviewed-on: https://go-review.googlesource.com/14183
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/src/cmd/asm/internal/arch/arm.go b/src/cmd/asm/internal/arch/arm.go
index c030214..8df994e 100644
--- a/src/cmd/asm/internal/arch/arm.go
+++ b/src/cmd/asm/internal/arch/arm.go
@@ -121,6 +121,15 @@
return false
}
+// IsARMFloatCmp reports whether the op is a floating comparison instruction.
+func IsARMFloatCmp(op int) bool {
+ switch op {
+ case arm.ACMPF, arm.ACMPD:
+ return true
+ }
+ return false
+}
+
// ARMMRCOffset implements the peculiar encoding of the MRC and MCR instructions.
// The difference between MRC and MCR is represented by a bit high in the word, not
// in the usual way by the opcode itself. Asm must use AMRC for both instructions, so
diff --git a/src/cmd/asm/internal/asm/asm.go b/src/cmd/asm/internal/asm/asm.go
index 0d2c12f..e098961 100644
--- a/src/cmd/asm/internal/asm/asm.go
+++ b/src/cmd/asm/internal/asm/asm.go
@@ -469,6 +469,11 @@
}
p.errorf("unrecognized addressing for %s", obj.Aconv(op))
}
+ if arch.IsARMFloatCmp(op) {
+ prog.From = a[0]
+ prog.Reg = p.getRegister(prog, op, &a[1])
+ break
+ }
} else if p.arch.Thechar == '7' && arch.IsARM64CMP(op) {
prog.From = a[0]
prog.Reg = p.getRegister(prog, op, &a[1])
diff --git a/src/cmd/asm/internal/asm/testdata/arm.out b/src/cmd/asm/internal/asm/testdata/arm.out
index ffd520d..7d79bf3 100644
--- a/src/cmd/asm/internal/asm/testdata/arm.out
+++ b/src/cmd/asm/internal/asm/testdata/arm.out
@@ -55,4 +55,6 @@
273 00055 (testdata/arm.s:273) CALL foo(SB)
274 00056 (testdata/arm.s:274) JMP foo(SB)
275 00057 (testdata/arm.s:275) CALL foo(SB)
-284 00058 (testdata/arm.s:284) END
+278 00058 (testdata/arm.s:278) CMPF F1, F2
+279 00059 (testdata/arm.s:279) CMPD F1, F2
+288 00060 (testdata/arm.s:288) END
diff --git a/src/cmd/asm/internal/asm/testdata/arm.s b/src/cmd/asm/internal/asm/testdata/arm.s
index 9355792..f5ba3a8 100644
--- a/src/cmd/asm/internal/asm/testdata/arm.s
+++ b/src/cmd/asm/internal/asm/testdata/arm.s
@@ -274,6 +274,10 @@
JMP foo(SB)
CALL foo(SB)
+// CMPF and CMPD are special.
+ CMPF F1, F2
+ CMPD F1, F2
+
//
// END
//