From 9a64e435419869030e27d54f0433810b8b56d1ac Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Tue, 6 Sep 2005 15:57:06 +0000 Subject: [PATCH] 2005-09-02 Paul Brook 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 | 4 ++++ gas/config/tc-arm.c | 7 ++++++- gas/testsuite/ChangeLog | 7 +++++++ gas/testsuite/gas/arm/arm3-bad.d | 3 +++ gas/testsuite/gas/arm/arm3-bad.l | 3 +++ gas/testsuite/gas/arm/arm3-bad.s | 7 +++++++ gas/testsuite/gas/arm/arm3.d | 4 ++-- gas/testsuite/gas/arm/arm3.s | 4 ++-- 8 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 gas/testsuite/gas/arm/arm3-bad.d create mode 100644 gas/testsuite/gas/arm/arm3-bad.l create mode 100644 gas/testsuite/gas/arm/arm3-bad.s diff --git a/gas/ChangeLog b/gas/ChangeLog index e50ef066630..3745af3c88d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,7 @@ +2005-09-02 Paul Brook + + * config/tc-arm.c (do_rn_rd): Enforce SWP operand constraints. + 2005-09-02 Paul Brook * config/tc-arm.c (encode_arm_cp_address): Use diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 16f1db7b779..23d5bc7e04e 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -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 diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 31b279628c2..421db356cd9 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2005-09-02 Paul Brook + + * 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 * 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 index 00000000000..29449b22193 --- /dev/null +++ b/gas/testsuite/gas/arm/arm3-bad.d @@ -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 index 00000000000..d55a9b61512 --- /dev/null +++ b/gas/testsuite/gas/arm/arm3-bad.l @@ -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 index 00000000000..d3415a044c5 --- /dev/null +++ b/gas/testsuite/gas/arm/arm3-bad.s @@ -0,0 +1,7 @@ + .text + .align 0 +l: + swp r0, r1, [r0] + swp r1, r0, [r0] + nop + nop diff --git a/gas/testsuite/gas/arm/arm3.d b/gas/testsuite/gas/arm/arm3.d index 8f1c8a4b892..06323b1c0cd 100644 --- a/gas/testsuite/gas/arm/arm3.d +++ b/gas/testsuite/gas/arm/arm3.d @@ -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\) diff --git a/gas/testsuite/gas/arm/arm3.s b/gas/testsuite/gas/arm/arm3.s index 8de03b91d20..b3fd794cd9f 100644 --- a/gas/testsuite/gas/arm/arm3.s +++ b/gas/testsuite/gas/arm/arm3.s @@ -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 -- 2.30.2