public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Julian Brown <julian@codesourcery.com>
To: Richard Earnshaw <Richard.Earnshaw@arm.com>
Cc: Paul Brook <paul@codesourcery.com>,  binutils@sourceware.org
Subject: Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on  V7M  cores
Date: Wed, 19 Jul 2006 20:31:00 -0000	[thread overview]
Message-ID: <44BE9693.9010305@codesourcery.com> (raw)
In-Reply-To: <1147446329.7011.3.camel@pc960.cambridge.arm.com>

[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]

Richard Earnshaw wrote:
> On Fri, 2006-05-12 at 15:54, Paul Brook wrote:
>> On Friday 12 May 2006 01:22, Julian Brown wrote:
>>> +     as_bad (_("attempt to use ARM instruction on Thumb-only core --`%s'"),
>>> +               str); 
>> Other error messages talk about the "selected processor" rather than "core". 
>> Other than that it looks ok. Someone else will have to approve this for 
>> mainline.
> 
> I think the message should be
> 'attempt to use an ARM instruction on a Thumb-only processor'
> 
> ie *an* ARM, and *a* Thumb.

Sorry, I think I forgot about this one: is this version OK for head now?

Cheers,

Julian

ChangeLog:

ChangeLog (gas):

     * config/tc-arm.c (md_assemble): Improve diagnostic when attempting
     to use ARM instructions on non-ARM-supporting cores.
     (autoselect_thumb_from_cpu_variant): New function. Switch on Thumb
     mode automatically based on cpu variant.
     (md_begin): Call above function.

ChangeLog (gas/testsuite):

     * gas/arm/noarm.s: Add test for disabled ARM insns.
     * gas/arm/noarm.d: Drive test for above.
     * gas/arm/noarm.l: Expected error output.

[-- Attachment #2: v7m-no-arm-6 --]
[-- Type: text/plain, Size: 3297 bytes --]

Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.250.2.20
diff -c -p -r1.250.2.20 tc-arm.c
*** gas/config/tc-arm.c	19 Jul 2006 13:08:20 -0000	1.250.2.20
--- gas/config/tc-arm.c	19 Jul 2006 20:29:55 -0000
*************** md_assemble (char *str)
*** 13729,13735 ****
  	ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
  				arm_ext_v6t2);
      }
!   else
      {
        /* Check that this instruction is supported for this CPU.  */
        if (!opcode->avariant ||
--- 13729,13735 ----
  	ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
  				arm_ext_v6t2);
      }
!   else if (ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
      {
        /* Check that this instruction is supported for this CPU.  */
        if (!opcode->avariant ||
*************** md_assemble (char *str)
*** 13762,13767 ****
--- 13762,13773 ----
  	ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
  				*opcode->avariant);
      }
+   else
+     {
+       as_bad (_("attempt to use an ARM instruction on a Thumb-only processor "
+ 		"-- `%s'"), str);
+       return;
+     }
    output_inst (str);
  }
  
*************** set_constant_flonums (void)
*** 18766,18771 ****
--- 18772,18787 ----
        abort ();
  }
  
+ /* Auto-select Thumb mode if it's the only available instruction set for the
+    given architecture.  */
+ 
+ static void
+ autoselect_thumb_from_cpu_variant (void)
+ {
+   if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
+     opcode_select (16);
+ }
+ 
  void
  md_begin (void)
  {
*************** md_begin (void)
*** 18866,18871 ****
--- 18882,18889 ----
  
    ARM_MERGE_FEATURE_SETS (cpu_variant, *mcpu_cpu_opt, *mfpu_opt);
  
+   autoselect_thumb_from_cpu_variant ();
+ 
    arm_arch_used = thumb_arch_used = arm_arch_none;
  
  #if defined OBJ_COFF || defined OBJ_ELF
Index: gas/testsuite/gas/arm/noarm.d
===================================================================
RCS file: gas/testsuite/gas/arm/noarm.d
diff -N gas/testsuite/gas/arm/noarm.d
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gas/testsuite/gas/arm/noarm.d	19 Jul 2006 20:29:55 -0000
***************
*** 0 ****
--- 1,3 ----
+ # name: Disallow ARM instructions on V7M
+ # as: 
+ # error-output: noarm.l
Index: gas/testsuite/gas/arm/noarm.l
===================================================================
RCS file: gas/testsuite/gas/arm/noarm.l
diff -N gas/testsuite/gas/arm/noarm.l
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gas/testsuite/gas/arm/noarm.l	19 Jul 2006 20:29:55 -0000
***************
*** 0 ****
--- 1,3 ----
+ [^:]*: Assembler messages:
+ [^:]*:12: Error: selected processor does not support ARM opcodes
+ [^:]*:13: Error: attempt to use an ARM instruction on a Thumb-only processor -- `nop'
Index: gas/testsuite/gas/arm/noarm.s
===================================================================
RCS file: gas/testsuite/gas/arm/noarm.s
diff -N gas/testsuite/gas/arm/noarm.s
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gas/testsuite/gas/arm/noarm.s	19 Jul 2006 20:29:55 -0000
***************
*** 0 ****
--- 1,13 ----
+         .arch armv7a
+         .syntax unified
+ 	.text
+ func:
+ 	nop
+ 	movw r0, #0
+ 
+ 	.arch armv7
+ 	.thumb
+ 	nop
+ 	movw r0, #0
+ 	.arm
+ 	nop

  reply	other threads:[~2006-07-19 20:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-12  2:08 Julian Brown
2006-05-12  5:39 ` Paul Brook
2006-05-12  5:49   ` Paul Brook
2006-05-12 14:54   ` Julian Brown
2006-05-12 21:25     ` Paul Brook
2006-05-12 22:16       ` Richard Earnshaw
2006-07-19 20:31         ` Julian Brown [this message]
2006-08-08 11:54           ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44BE9693.9010305@codesourcery.com \
    --to=julian@codesourcery.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=binutils@sourceware.org \
    --cc=paul@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).