2005-09-02 Paul Brook <paul@codesourcery.com>
authorPaul Brook <paul@codesourcery.com>
Tue, 6 Sep 2005 15:57:06 +0000 (15:57 +0000)
committerPaul Brook <paul@codesourcery.com>
Tue, 6 Sep 2005 15:57:06 +0000 (15:57 +0000)
gas/
* config/tc-arm.c (do_rn_rd): Enforce SWP operand constraints.
gas/testsuite/
* gas/arm/arm3-bad.s: New test.
* gas/arm/arm3-bad.d: New test.
* gas/arm/arm3.s: Avoid illegal instructions.
* gas/arm/arm3.d: Ditto.

gas/ChangeLog
gas/config/tc-arm.c
gas/testsuite/ChangeLog
gas/testsuite/gas/arm/arm3-bad.d [new file with mode: 0644]
gas/testsuite/gas/arm/arm3-bad.l [new file with mode: 0644]
gas/testsuite/gas/arm/arm3-bad.s [new file with mode: 0644]
gas/testsuite/gas/arm/arm3.d
gas/testsuite/gas/arm/arm3.s

index e50ef0666307dfdfd131a10fea34122885606fb1..3745af3c88d809a4ee4ade27fdb616d398fc512c 100644 (file)
@@ -1,3 +1,7 @@
+2005-09-02  Paul Brook  <paul@codesourcery.com>
+
+       * config/tc-arm.c (do_rn_rd): Enforce SWP operand constraints.
+
 2005-09-02  Paul Brook  <paul@codesourcery.com>
 
        * config/tc-arm.c (encode_arm_cp_address): Use
index 16f1db7b7792b5fb3d3ee230391e07665bc877be..23d5bc7e04ea18f543cdc1738e505868f425ec08 100644 (file)
@@ -4339,9 +4339,14 @@ do_rn_rd (void)
 static void
 do_rd_rm_rn (void)
 {
+  unsigned Rn = inst.operands[2].reg;
+  /* Enforce resutrictions on SWP instruction.  */
+  if ((inst.instruction & 0x0fbfffff) == 0x01000090)
+    constraint (Rn == inst.operands[0].reg || Rn == inst.operands[1].reg,
+               _("Rn must not overlap other operands"));
   inst.instruction |= inst.operands[0].reg << 12;
   inst.instruction |= inst.operands[1].reg;
-  inst.instruction |= inst.operands[2].reg << 16;
+  inst.instruction |= Rn << 16;
 }
 
 static void
index 31b279628c2ff87cb0891c7236ed2a9b96331bf2..421db356cd958bdc6fe5c77ff1b6b54154a42226 100644 (file)
@@ -1,3 +1,10 @@
+2005-09-02  Paul Brook  <paul@codesourcery.com>
+
+       * gas/arm/arm3-bad.s: New test.
+       * gas/arm/arm3-bad.d: New test.
+       * gas/arm/arm3.s: Avoid illegal instructions.
+       * gas/arm/arm3.d: Ditto.
+
 2005-09-02  Paul Brook  <paul@codesourcery.com>
 
        * gas/arm/vfp-bad_t2.d, gas/arm/vfp-bad_t2.l, arm/vfp-bad_t2.s,
diff --git a/gas/testsuite/gas/arm/arm3-bad.d b/gas/testsuite/gas/arm/arm3-bad.d
new file mode 100644 (file)
index 0000000..29449b2
--- /dev/null
@@ -0,0 +1,3 @@
+# name: ARM 3 errors
+# as: -mcpu=arm3
+# error-output: arm3-bad.l
diff --git a/gas/testsuite/gas/arm/arm3-bad.l b/gas/testsuite/gas/arm/arm3-bad.l
new file mode 100644 (file)
index 0000000..d55a9b6
--- /dev/null
@@ -0,0 +1,3 @@
+.*arm3-bad.s: Assembler messages:
+.*arm3-bad.s:4: Error: Rn must not overlap other operands -- `swp r0,r1,\[r0\]'
+.*arm3-bad.s:5: Error: Rn must not overlap other operands -- `swp r1,r0,\[r0\]'
diff --git a/gas/testsuite/gas/arm/arm3-bad.s b/gas/testsuite/gas/arm/arm3-bad.s
new file mode 100644 (file)
index 0000000..d3415a0
--- /dev/null
@@ -0,0 +1,7 @@
+       .text
+       .align 0
+l:
+       swp     r0, r1, [r0]
+       swp     r1, r0, [r0]
+       nop
+       nop
index 8f1c8a4b892777e8bc136f21f55d0ca9c61f84a1..06323b1c0cdf464fe91c878916c5d9f046e29be8 100644 (file)
@@ -6,6 +6,6 @@
 
 Disassembly of section .text:
 0+0 <[^>]*> e1080091 ? swp     r0, r1, \[r8\]
-0+4 <[^>]*> e1432093 ? swpb    r2, r3, \[r3\]
-0+8 <[^>]*> a1444091 ? swpgeb  r4, r1, \[r4\]
+0+4 <[^>]*> e1423093 ? swpb    r3, r3, \[r2\]
+0+8 <[^>]*> a1454091 ? swpgeb  r4, r1, \[r5\]
 0+c <[^>]*> e1a00000 ? nop                     \(mov r0,r0\)
index 8de03b91d200096b8eab538a6d995d19b41bc6a4..b3fd794cd9f7441008f45c3ef3f15b8f5717eea9 100644 (file)
@@ -2,6 +2,6 @@
        .align 0
 l:
        swp     r0, r1, [r8]
-       swpb    r2, r3, [r3]
-       swpgeb  r4, r1, [r4]
+       swpb    r3, r3, [r2]
+       swpgeb  r4, r1, [r5]
        nop