Discussion:
Overlapping operands in ARM mul and mla instructions
Mark Shinwell
2007-03-15 13:58:51 UTC
Permalink
ARMv6 upwards permits overlapping operands to mul and mla
instructions in a way that previous architecture versions did not.
This patch adjusts gas behaviour accordingly.

Tested with cross to arm-none-eabi.

OK to apply?

Mark

--


2007-03-15 Mark Shinwell <***@codesourcery.com>

gas/
* config/tc-arm.c (do_mul): Don't warn about overlapping
Rd and Rm operands when assembling for v6 or above.
Correctly capitalize register names in the messages.
(do_mlas): Likewise. Delete spurious blank line.

gas/testsuite/
* gas/arm/mul-overlap.s: New.
* gas/arm/mul-overlap.d: New.
* gas/arm/mul-overlap.l: New.
* gas/arm/mul-overlap-v6.s: New.
* gas/arm/mul-overlap-v6.d: New.


Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.314
diff -U3 -p -r1.314 tc-arm.c
--- gas/config/tc-arm.c 15 Mar 2007 12:11:49 -0000 1.314
+++ gas/config/tc-arm.c 15 Mar 2007 13:55:33 -0000
@@ -7051,17 +7051,16 @@ do_lstc (void)
static void
do_mlas (void)
{
- /* This restriction does not apply to mls (nor to mla in v6, but
- that's hard to detect at present). */
+ /* This restriction does not apply to mls (nor to mla in v6 or later). */
if (inst.operands[0].reg == inst.operands[1].reg
+ && !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6)
&& !(inst.instruction & 0x00400000))
- as_tsktsk (_("rd and rm should be different in mla"));
+ as_tsktsk (_("Rd and Rm should be different in mla"));

inst.instruction |= inst.operands[0].reg << 16;
inst.instruction |= inst.operands[1].reg;
inst.instruction |= inst.operands[2].reg << 8;
inst.instruction |= inst.operands[3].reg << 12;
-
}

static void
@@ -7169,8 +7168,9 @@ do_mul (void)
inst.instruction |= inst.operands[1].reg;
inst.instruction |= inst.operands[2].reg << 8;

- if (inst.operands[0].reg == inst.operands[1].reg)
- as_tsktsk (_("rd and rm should be different in mul"));
+ if (inst.operands[0].reg == inst.operands[1].reg
+ && !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6))
+ as_tsktsk (_("Rd and Rm should be different in mul"));
}

/* Long Multiply Parser
Index: gas/testsuite/gas/arm/mul-overlap-v6.s
===================================================================
--- gas/testsuite/gas/arm/mul-overlap-v6.s
+++ gas/testsuite/gas/arm/mul-overlap-v6.s
@@ -0,0 +1,9 @@
+ .arch armv6
+ .text
+ .align 2
+ .global foo
+ .type foo, %function
+foo:
+ mul r0, r0, r0
+ mla r0, r0, r1, r2
+ bx lr
Index: gas/testsuite/gas/arm/mul-overlap.d
===================================================================
--- gas/testsuite/gas/arm/mul-overlap.d
+++ gas/testsuite/gas/arm/mul-overlap.d
@@ -0,0 +1,2 @@
+# name: Overlapping multiplication operands without architecture specification
+# error-output: mul-overlap.l
Index: gas/testsuite/gas/arm/mul-overlap.l
===================================================================
--- gas/testsuite/gas/arm/mul-overlap.l
+++ gas/testsuite/gas/arm/mul-overlap.l
@@ -0,0 +1,3 @@
+[^:]*: Assembler messages:
+[^:]*:6: Rd and Rm should be different in mul
+[^:]*:7: Rd and Rm should be different in mla
Index: gas/testsuite/gas/arm/mul-overlap.s
===================================================================
--- gas/testsuite/gas/arm/mul-overlap.s
+++ gas/testsuite/gas/arm/mul-overlap.s
@@ -0,0 +1,8 @@
+ .text
+ .align 2
+ .global foo
+ .type foo, %function
+foo:
+ mul r0, r0, r0
+ mla r0, r0, r1, r2
+ bx lr
Index: gas/testsuite/gas/arm/mul-overlap-v6.d
===================================================================
--- gas/testsuite/gas/arm/mul-overlap-v6.d
+++ gas/testsuite/gas/arm/mul-overlap-v6.d
@@ -0,0 +1,9 @@
+# name: Overlapping multiplication operands for ARMv6
+# objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*arm.*
+
+Disassembly of section .text:
+0[0-9a-f]+ <[^>]+> e0000090 mul r0, r0, r0
+0[0-9a-f]+ <[^>]+> e0202190 mla r0, r0, r1, r2
+0[0-9a-f]+ <[^>]+> e12fff1e bx lr
Paul Brook
2007-03-15 14:19:23 UTC
Permalink
Post by Mark Shinwell
gas/
* config/tc-arm.c (do_mul): Don't warn about overlapping
Rd and Rm operands when assembling for v6 or above.
Correctly capitalize register names in the messages.
(do_mlas): Likewise. Delete spurious blank line.
gas/testsuite/
* gas/arm/mul-overlap.s: New.
* gas/arm/mul-overlap.d: New.
* gas/arm/mul-overlap.l: New.
* gas/arm/mul-overlap-v6.s: New.
* gas/arm/mul-overlap-v6.d: New.
Ok.
Please check if we already have a test for overlapping mls operands, and add
one if not.

Paul
Mark Shinwell
2007-03-18 16:22:52 UTC
Permalink
Post by Paul Brook
Post by Mark Shinwell
gas/
* config/tc-arm.c (do_mul): Don't warn about overlapping
Rd and Rm operands when assembling for v6 or above.
Correctly capitalize register names in the messages.
(do_mlas): Likewise. Delete spurious blank line.
gas/testsuite/
* gas/arm/mul-overlap.s: New.
* gas/arm/mul-overlap.d: New.
* gas/arm/mul-overlap.l: New.
* gas/arm/mul-overlap-v6.s: New.
* gas/arm/mul-overlap-v6.d: New.
Ok.
Please check if we already have a test for overlapping mls operands, and add
one if not.
Applied thus, with mls testcases.

Mark

--


2007-03-18 Mark Shinwell <***@codesourcery.com>

gas/
* config/tc-arm.c (do_mul): Don't warn about overlapping
Rd and Rm operands when assembling for v6 or above.
Correctly capitalize register names in the messages.
(do_mlas): Likewise. Delete spurious blank line.

gas/testsuite/
* gas/arm/mul-overlap.s: New.
* gas/arm/mul-overlap.d: New.
* gas/arm/mul-overlap.l: New.
* gas/arm/mul-overlap-v6.s: New.
* gas/arm/mul-overlap-v6.d: New.


Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.314
diff -r1.314 tc-arm.c
7054,7055c7054
< /* This restriction does not apply to mls (nor to mla in v6, but
< that's hard to detect at present). */
---
Post by Paul Brook
/* This restriction does not apply to mls (nor to mla in v6 or later). */
7056a7056
Post by Paul Brook
&& !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6)
7058c7058
< as_tsktsk (_("rd and rm should be different in mla"));
---
Post by Paul Brook
as_tsktsk (_("Rd and Rm should be different in mla"));
7064d7063
<
7172,7173c7171,7173
< if (inst.operands[0].reg == inst.operands[1].reg)
< as_tsktsk (_("rd and rm should be different in mul"));
---
Post by Paul Brook
if (inst.operands[0].reg == inst.operands[1].reg
&& !ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6))
as_tsktsk (_("Rd and Rm should be different in mul"));
cvs diff: Diffing gas/doc
cvs diff: Diffing gas/po
cvs diff: Diffing gas/testsuite
cvs diff: Diffing gas/testsuite/config
cvs diff: Diffing gas/testsuite/gas
cvs diff: Diffing gas/testsuite/gas/all
cvs diff: Diffing gas/testsuite/gas/alpha
cvs diff: Diffing gas/testsuite/gas/arc
cvs diff: Diffing gas/testsuite/gas/arm
Index: gas/testsuite/gas/arm/mul-overlap-v6.d
===================================================================
RCS file: gas/testsuite/gas/arm/mul-overlap-v6.d
diff -N gas/testsuite/gas/arm/mul-overlap-v6.d
0a1,10
Post by Paul Brook
# name: Overlapping multiplication operands for ARMv6
# objdump: -dr --prefix-addresses --show-raw-insn
.*: +file format .*arm.*
0[0-9a-f]+ <[^>]+> e0000090 mul r0, r0, r0
0[0-9a-f]+ <[^>]+> e0202190 mla r0, r0, r1, r2
0[0-9a-f]+ <[^>]+> e0602190 mls r0, r0, r1, r2
0[0-9a-f]+ <[^>]+> e12fff1e bx lr
Index: gas/testsuite/gas/arm/mul-overlap-v6.s
===================================================================
RCS file: gas/testsuite/gas/arm/mul-overlap-v6.s
diff -N gas/testsuite/gas/arm/mul-overlap-v6.s
0a1,10
Post by Paul Brook
.arch armv6t2
.text
.align 2
.global foo
.type foo, %function
mul r0, r0, r0
mla r0, r0, r1, r2
mls r0, r0, r1, r2
bx lr
Index: gas/testsuite/gas/arm/mul-overlap.d
===================================================================
RCS file: gas/testsuite/gas/arm/mul-overlap.d
diff -N gas/testsuite/gas/arm/mul-overlap.d
0a1,2
Post by Paul Brook
# name: Overlapping multiplication operands without architecture
specification
Post by Paul Brook
# error-output: mul-overlap.l
Index: gas/testsuite/gas/arm/mul-overlap.l
===================================================================
RCS file: gas/testsuite/gas/arm/mul-overlap.l
diff -N gas/testsuite/gas/arm/mul-overlap.l
0a1,3
Post by Paul Brook
[^:]*:6: Rd and Rm should be different in mul
[^:]*:7: Rd and Rm should be different in mla
Index: gas/testsuite/gas/arm/mul-overlap.s
===================================================================
RCS file: gas/testsuite/gas/arm/mul-overlap.s
diff -N gas/testsuite/gas/arm/mul-overlap.s
0a1,9
Post by Paul Brook
.text
.align 2
.global foo
.type foo, %function
mul r0, r0, r0
mla r0, r0, r1, r2
mls r0, r0, r1, r2
bx lr
Nick Clifton
2007-03-20 12:35:58 UTC
Permalink
Hi Mark,
Post by Mark Shinwell
gas/testsuite/
* gas/arm/mul-overlap.s: New.
* gas/arm/mul-overlap.d: New.
* gas/arm/mul-overlap.l: New.
* gas/arm/mul-overlap-v6.s: New.
* gas/arm/mul-overlap-v6.d: New.
These tests have introduced some new GAS testsuite failures for the
arm-wince-pe and arm-epoc-pe toolchains. Please could you investigate
and fix them ?

Cheers
Nick
Mark Shinwell
2007-03-20 12:44:02 UTC
Permalink
Post by Nick Clifton
Post by Mark Shinwell
gas/testsuite/
* gas/arm/mul-overlap.s: New.
* gas/arm/mul-overlap.d: New.
* gas/arm/mul-overlap.l: New.
* gas/arm/mul-overlap-v6.s: New.
* gas/arm/mul-overlap-v6.d: New.
These tests have introduced some new GAS testsuite failures for the
arm-wince-pe and arm-epoc-pe toolchains. Please could you investigate
and fix them ?
Investigating.
Mark Shinwell
2007-03-20 13:01:57 UTC
Permalink
Post by Nick Clifton
Post by Mark Shinwell
gas/testsuite/
* gas/arm/mul-overlap.s: New.
* gas/arm/mul-overlap.d: New.
* gas/arm/mul-overlap.l: New.
* gas/arm/mul-overlap-v6.s: New.
* gas/arm/mul-overlap-v6.d: New.
These tests have introduced some new GAS testsuite failures for the
arm-wince-pe and arm-epoc-pe toolchains. Please could you investigate
and fix them ?
I have applied the following to fix this. Tested on arm-none-eabi,
arm-wince-pe and arm-epoc-pe.

Mark

--


2007-03-20 Mark Shinwell <***@codesourcery.com>

* gas/arm/mul-overlap.s: Don't use %type.
* gas/arm/mul-overlap.l: Update line numbers.
* gas/arm/mul-overlap-v6.s: Don't use %type.


Index: gas/testsuite/gas/arm/mul-overlap-v6.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/mul-overlap-v6.s,v
retrieving revision 1.1
diff -U3 -p -r1.1 mul-overlap-v6.s
--- gas/testsuite/gas/arm/mul-overlap-v6.s 18 Mar 2007 16:21:27 -0000
1.1
+++ gas/testsuite/gas/arm/mul-overlap-v6.s 20 Mar 2007 12:54:57 -0000
@@ -2,7 +2,6 @@
.text
.align 2
.global foo
- .type foo, %function
foo:
mul r0, r0, r0
mla r0, r0, r1, r2
Index: gas/testsuite/gas/arm/mul-overlap.l
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/mul-overlap.l,v
retrieving revision 1.1
diff -U3 -p -r1.1 mul-overlap.l
--- gas/testsuite/gas/arm/mul-overlap.l 18 Mar 2007 16:21:27 -0000 1.1
+++ gas/testsuite/gas/arm/mul-overlap.l 20 Mar 2007 12:54:57 -0000
@@ -1,3 +1,3 @@
[^:]*: Assembler messages:
-[^:]*:6: Rd and Rm should be different in mul
-[^:]*:7: Rd and Rm should be different in mla
+[^:]*:5: Rd and Rm should be different in mul
+[^:]*:6: Rd and Rm should be different in mla
Index: gas/testsuite/gas/arm/mul-overlap.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/mul-overlap.s,v
retrieving revision 1.1
diff -U3 -p -r1.1 mul-overlap.s
--- gas/testsuite/gas/arm/mul-overlap.s 18 Mar 2007 16:21:27 -0000 1.1
+++ gas/testsuite/gas/arm/mul-overlap.s 20 Mar 2007 12:54:57 -0000
@@ -1,7 +1,6 @@
.text
.align 2
.global foo
- .type foo, %function
foo:
mul r0, r0, r0
mla r0, r0, r1, r2
Nick Clifton
2007-03-20 13:04:09 UTC
Permalink
Hi Mark,
Post by Mark Shinwell
* gas/arm/mul-overlap.s: Don't use %type.
* gas/arm/mul-overlap.l: Update line numbers.
* gas/arm/mul-overlap-v6.s: Don't use %type.
Thanks for doing this.

Cheers
Nick

Loading...