public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on V7M  cores
@ 2006-05-12  2:08 Julian Brown
  2006-05-12  5:39 ` Paul Brook
  0 siblings, 1 reply; 8+ messages in thread
From: Julian Brown @ 2006-05-12  2:08 UTC (permalink / raw)
  To: binutils; +Cc: Paul Brook, Richard Earnshaw, Julian Brown

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

Hi,

This patch fixes the case where the diagnostic on attempting to assemble 
files containing ARM instructions on processors which don't support them 
isn't very helpful (e.g. "instruction not supported -- `nop'"). Thumb 
mode is made the default on such cores, and attempts to use the ".arm" 
directive or ARM instructions is faulted.

Tested with "make check" with cross to arm-none-eabi, with a small test 
case added.

OK to apply on mainline? CSL branch?

Cheers,

Julian

ChangeLog (gas):

     * config/tc-arm.c (arm_thumb_only, arm_thumb_only_except): Add
     static vars.
     (md_assemble): Disable 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.
     (s_arm_cpu, s_arm_arch): Likewise.

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.

ChangeLog (include/opcode):

     * arm.h (THUMB_ONLY): New macro. Architectures which support only
     Thumb instructions.
     (THUMB_ONLY_EXCEPT): Bits set here negate the above cases.

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

Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.250.2.15
diff -c -p -r1.250.2.15 tc-arm.c
*** gas/config/tc-arm.c	5 May 2006 18:31:28 -0000	1.250.2.15
--- gas/config/tc-arm.c	11 May 2006 21:13:09 -0000
*************** static const arm_feature_set fpu_neon_ex
*** 215,220 ****
--- 215,224 ----
  static const arm_feature_set fpu_vfp_v3_or_neon_ext =
    ARM_FEATURE (0, FPU_NEON_EXT_V1 | FPU_VFP_EXT_V3);
  
+ static const arm_feature_set arm_thumb_only = ARM_FEATURE (THUMB_ONLY, 0);
+ static const arm_feature_set arm_thumb_only_except =
+   ARM_FEATURE (THUMB_ONLY_EXCEPT, 0);
+ 
  static int mfloat_abi_opt = -1;
  /* Record user cpu selection for object attributes.  */
  static arm_feature_set selected_cpu = ARM_ARCH_NONE;
*************** md_assemble (char *str)
*** 13484,13490 ****
  	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 ||
--- 13488,13495 ----
  	ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used,
  				arm_ext_v6t2);
      }
!   else if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_thumb_only)
!            || ARM_CPU_HAS_FEATURE (cpu_variant, arm_thumb_only_except))
      {
        /* Check that this instruction is supported for this CPU.  */
        if (!opcode->avariant ||
*************** md_assemble (char *str)
*** 13517,13522 ****
--- 13522,13532 ----
  	ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
  				*opcode->avariant);
      }
+   else
+     {
+       as_bad (_("attempt to use ARM instruction on Thumb-only core `%s'"), str);
+       return;
+     }
    output_inst (str);
  }
  
*************** set_constant_flonums (void)
*** 18296,18301 ****
--- 18306,18322 ----
        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_thumb_only)
+       && !ARM_CPU_HAS_FEATURE (cpu_variant, arm_thumb_only_except))
+     opcode_select (16);
+ }
+ 
  void
  md_begin (void)
  {
*************** md_begin (void)
*** 18396,18401 ****
--- 18417,18424 ----
  
    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
*************** s_arm_cpu (int ignored ATTRIBUTE_UNUSED)
*** 19457,19462 ****
--- 19480,19486 ----
  	    selected_cpu_name[i] = 0;
  	  }
  	ARM_MERGE_FEATURE_SETS (cpu_variant, *mcpu_cpu_opt, *mfpu_opt);
+         autoselect_thumb_from_cpu_variant ();
  	*input_line_pointer = saved_char;
  	demand_empty_rest_of_line ();
  	return;
*************** s_arm_arch (int ignored ATTRIBUTE_UNUSED
*** 19490,19495 ****
--- 19514,19520 ----
  	selected_cpu = opt->value;
  	strcpy(selected_cpu_name, opt->name);
  	ARM_MERGE_FEATURE_SETS (cpu_variant, *mcpu_cpu_opt, *mfpu_opt);
+         autoselect_thumb_from_cpu_variant ();
  	*input_line_pointer = saved_char;
  	demand_empty_rest_of_line ();
  	return;
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	11 May 2006 21:13:09 -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	11 May 2006 21:13:09 -0000
***************
*** 0 ****
--- 1,3 ----
+ [^:]*: Assembler messages:
+ [^:]*:11: Error: selected processor does not support ARM opcodes
+ [^:]*:12: Error: attempt to use ARM instruction on Thumb-only core `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	11 May 2006 21:13:09 -0000
***************
*** 0 ****
--- 1,12 ----
+         .arch armv7a
+         .syntax unified
+ 	.text
+ func:
+ 	nop
+ 	movw r0, #0
+ 
+ 	.arch armv7
+ 	nop
+ 	movw r0, #0
+ 	.arm
+ 	nop
Index: include/opcode/arm.h
===================================================================
RCS file: /cvs/src/src/include/opcode/arm.h,v
retrieving revision 1.9.2.1
diff -c -p -r1.9.2.1 arm.h
*** include/opcode/arm.h	3 Apr 2006 00:03:34 -0000	1.9.2.1
--- include/opcode/arm.h	11 May 2006 21:13:10 -0000
***************
*** 45,50 ****
--- 45,55 ----
  #define ARM_EXT_V7R	 0x00200000	/* Arm V7R.                */
  #define ARM_EXT_V7M	 0x00400000	/* Arm V7M.                */
  
+ /* A bitmask of architecture versions which support only Thumb instructions,
+    and exceptions containing bits which nullify that situation.  */
+ #define THUMB_ONLY	  (ARM_EXT_V7 | ARM_EXT_V7M)
+ #define THUMB_ONLY_EXCEPT (ARM_EXT_V7A | ARM_EXT_V7R)
+ 
  /* Co-processor space extensions.  */
  #define ARM_CEXT_XSCALE   0x00000001	/* Allow MIA etc.          */
  #define ARM_CEXT_MAVERICK 0x00000002	/* Use Cirrus/DSP coprocessor.  */

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on V7M  cores
  2006-05-12  2:08 [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on V7M cores Julian Brown
@ 2006-05-12  5:39 ` Paul Brook
  2006-05-12  5:49   ` Paul Brook
  2006-05-12 14:54   ` Julian Brown
  0 siblings, 2 replies; 8+ messages in thread
From: Paul Brook @ 2006-05-12  5:39 UTC (permalink / raw)
  To: binutils; +Cc: Julian Brown, binutils, Richard Earnshaw

On Thursday 11 May 2006 22:23, Julian Brown wrote:
> + #define THUMB_ONLY      (ARM_EXT_V7 | ARM_EXT_V7M)
> + #define THUMB_ONLY_EXCEPT (ARM_EXT_V7A | ARM_EXT_V7R)

I don't think these are necessary.  In opcode_select we already have:

          if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
            as_bad (_("selected processor does not support ARM opcodes"));

That condition should be ok whenever we need to check for a Thumb-only core.

> *************** md_begin (void)
> *** 18396,18401 ****
> --- 18417,18424 ----
>  
>     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;

Defaulting to thumb mode if a Thumb only core is specified on the commandline 
ok I guess, however...
  
>   #if defined OBJ_COFF || defined OBJ_ELF
> *************** s_arm_cpu (int ignored ATTRIBUTE_UNUSED)
> *** 19457,19462 ****
> --- 19480,19486 ----
>             selected_cpu_name[i] = 0;
>           }
>         ARM_MERGE_FEATURE_SETS (cpu_variant, *mcpu_cpu_opt, *mfpu_opt);
> +         autoselect_thumb_from_cpu_variant ();

I don't think making .arch armv7 imply .thumb is a good idea. 
If we do this we should also make .arch armv4 imply .arm.

Paul

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on V7M  cores
  2006-05-12  5:39 ` Paul Brook
@ 2006-05-12  5:49   ` Paul Brook
  2006-05-12 14:54   ` Julian Brown
  1 sibling, 0 replies; 8+ messages in thread
From: Paul Brook @ 2006-05-12  5:49 UTC (permalink / raw)
  To: binutils; +Cc: Julian Brown, binutils, Richard Earnshaw

On Thursday 11 May 2006 22:23, Julian Brown wrote:
> + #define THUMB_ONLY      (ARM_EXT_V7 | ARM_EXT_V7M)
> + #define THUMB_ONLY_EXCEPT (ARM_EXT_V7A | ARM_EXT_V7R)

I don't think these are necessary.  In opcode_select we already have:

          if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
            as_bad (_("selected processor does not support ARM opcodes"));

That condition should be ok whenever we need to check for a Thumb-only core.

> *************** md_begin (void)
> *** 18396,18401 ****
> --- 18417,18424 ----
>  
>     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;

Defaulting to thumb mode if a Thumb only core is specified on the commandline 
ok I guess, however...
  
>   #if defined OBJ_COFF || defined OBJ_ELF
> *************** s_arm_cpu (int ignored ATTRIBUTE_UNUSED)
> *** 19457,19462 ****
> --- 19480,19486 ----
>             selected_cpu_name[i] = 0;
>           }
>         ARM_MERGE_FEATURE_SETS (cpu_variant, *mcpu_cpu_opt, *mfpu_opt);
> +         autoselect_thumb_from_cpu_variant ();

I don't think making .arch armv7 imply .thumb is a good idea. 
If we do this we should also make .arch armv4 imply .arm.

Paul

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on  V7M  cores
  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
  1 sibling, 1 reply; 8+ messages in thread
From: Julian Brown @ 2006-05-12 14:54 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Richard Earnshaw, Julian Brown

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

Hi,

Paul Brook wrote:
> On Thursday 11 May 2006 22:23, Julian Brown wrote:
> 
>>+ #define THUMB_ONLY      (ARM_EXT_V7 | ARM_EXT_V7M)
>>+ #define THUMB_ONLY_EXCEPT (ARM_EXT_V7A | ARM_EXT_V7R)
> 
> I don't think these are necessary.  In opcode_select we already have:
> 
>           if (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v1))
>             as_bad (_("selected processor does not support ARM opcodes"));
> 
> That condition should be ok whenever we need to check for a Thumb-only core.

Yeah, that does make things simpler -- this version of the patch uses 
arm_ext_v1 as a condition instead.

> Defaulting to thumb mode if a Thumb only core is specified on the commandline 
> ok I guess, however...

> I don't think making .arch armv7 imply .thumb is a good idea. 
> If we do this we should also make .arch armv4 imply .arm.

OK, I've only made the auto-selection happen for command-line arch/cpu 
selection only. That probably has less potential for confusion.

Patch re-tested. OK to apply 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-3 --]
[-- Type: text/plain, Size: 3285 bytes --]

Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.250.2.15
diff -c -p -r1.250.2.15 tc-arm.c
*** gas/config/tc-arm.c	5 May 2006 18:31:28 -0000	1.250.2.15
--- gas/config/tc-arm.c	12 May 2006 00:12:05 -0000
*************** md_assemble (char *str)
*** 13484,13490 ****
  	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 ||
--- 13484,13490 ----
  	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)
*** 13517,13522 ****
--- 13517,13528 ----
  	ARM_MERGE_FEATURE_SETS (arm_arch_used, arm_arch_used,
  				*opcode->avariant);
      }
+   else
+     {
+       as_bad (_("attempt to use ARM instruction on Thumb-only core -- `%s'"),
+               str);
+       return;
+     }
    output_inst (str);
  }
  
*************** set_constant_flonums (void)
*** 18296,18301 ****
--- 18302,18317 ----
        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)
*** 18396,18401 ****
--- 18412,18419 ----
  
    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	12 May 2006 00:12:05 -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	12 May 2006 00:12:05 -0000
***************
*** 0 ****
--- 1,3 ----
+ [^:]*: Assembler messages:
+ [^:]*:12: Error: selected processor does not support ARM opcodes
+ [^:]*:13: Error: attempt to use ARM instruction on Thumb-only core -- `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	12 May 2006 00:12:05 -0000
***************
*** 0 ****
--- 1,13 ----
+         .arch armv7a
+         .syntax unified
+ 	.text
+ func:
+ 	nop
+ 	movw r0, #0
+ 
+ 	.arch armv7
+ 	.thumb
+ 	nop
+ 	movw r0, #0
+ 	.arm
+ 	nop

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on  V7M  cores
  2006-05-12 14:54   ` Julian Brown
@ 2006-05-12 21:25     ` Paul Brook
  2006-05-12 22:16       ` Richard Earnshaw
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Brook @ 2006-05-12 21:25 UTC (permalink / raw)
  To: binutils; +Cc: Julian Brown, Richard Earnshaw

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.

Paul

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on V7M  cores
  2006-05-12 21:25     ` Paul Brook
@ 2006-05-12 22:16       ` Richard Earnshaw
  2006-07-19 20:31         ` Julian Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Earnshaw @ 2006-05-12 22:16 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Julian Brown

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.

R.
-- 
Richard Earnshaw             Email: Richard.Earnshaw@arm.com
ARM Ltd                      Phone: +44 1223 400569 (Direct + VoiceMail)
110 Fulbourn Road            Switchboard: +44 1223 400400
Cherry Hinton                Fax: +44 1223 400410
Cambridge CB1 9NJ            Web: http://www.arm.com/
UK

-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on  V7M  cores
  2006-05-12 22:16       ` Richard Earnshaw
@ 2006-07-19 20:31         ` Julian Brown
  2006-08-08 11:54           ` Nick Clifton
  0 siblings, 1 reply; 8+ messages in thread
From: Julian Brown @ 2006-07-19 20:31 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Paul Brook, binutils

[-- 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on   V7M  cores
  2006-07-19 20:31         ` Julian Brown
@ 2006-08-08 11:54           ` Nick Clifton
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Clifton @ 2006-08-08 11:54 UTC (permalink / raw)
  To: Julian Brown; +Cc: Richard Earnshaw, Paul Brook, binutils

Hi Julian,

> 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.
> 

Approved - please apply.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-08-08 11:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-12  2:08 [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on V7M cores 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
2006-08-08 11:54           ` Nick Clifton

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).