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 e50ef06..3745af3 100644 (file)
@@ -1,5 +1,9 @@
 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
        BFD_RELOC_ARM_T32_CP_OFF_IMM in thumb mode.
        (do_iwmmxt_wldstbh): Use BFD_RELOC_ARM_T32_CP_OFF_IMM_S2 in thumb
index 16f1db7..23d5bc7 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 31b2796..421db35 100644 (file)
@@ -1,5 +1,12 @@
 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,
        gas/arm/vfp1_t2.d, gas/arm/vfp1_t2.s, gas/arm/vfp1xD_t2.d,
        gas/arm/vfp1xD_t2.s, gas/arm/vfp2_t2.d, gas/arm/vfp2_t2.s): New files.
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 8f1c8a4..06323b1 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 8de03b9..b3fd794 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