This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, ARM]: Fix diagnostics & disallow ARM instructions on V7M cores


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]