public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Additional Thumb instructions for ARMv6K
@ 2005-03-09  1:19 Zack Weinberg
  2005-03-09 11:43 ` Richard Earnshaw
  2005-03-09 12:26 ` Nick Clifton
  0 siblings, 2 replies; 6+ messages in thread
From: Zack Weinberg @ 2005-03-09  1:19 UTC (permalink / raw)
  To: binutils


ARMv6K adds five new Thumb instructions.  This patch adds assembler
support for them.

The only possibly problematic part of this patch is the NOP changes.
One of the new instructions is a preferred opcode for NOP (which has
historically been done with "mov r8,r8"); I changed both what you get
if you explicitly write "nop" and the opcode used for alignment in
code sections, when (cpu_variant & ARM_EXT_V6K).  This *might* cause
problems for existing code.  Please advise.

zw

gas:
        * config/tc-arm.c (do_t_nop): Issue instruction 0xbf00 when
        assembling for V6K and up.
        (arm_handle_align): Likewise, when padding code segments.
        (thumb_opcode): Add sev, wfe, wfi, yield.
opcodes:
        * arm-dis.c (thumb_opcodes): Add nop, yield, wfe, wfi, sev.

gas/testsuite:
        * gas/arm/thumbv6k.s, gas/arm/thumbv6k.d: New test pair.
        * gas/arm/arm.exp: Run it.

===================================================================
Index: gas/config/tc-arm.c
--- gas/config/tc-arm.c	23 Feb 2005 12:28:03 -0000	1.193
+++ gas/config/tc-arm.c	9 Mar 2005 01:13:09 -0000
@@ -9176,6 +9176,10 @@ do_t_nop (char * str)
 {
   /* Do nothing.  */
   end_of_line (str);
+
+  /* V6K introduces a preferred encoding for this instruction.  */
+  if (cpu_variant & ARM_EXT_V6K)
+    inst.instruction = 0xbf00;
 }
 
 /* Handle the Format 4 instructions that do not have equivalents in other
@@ -10950,6 +10954,12 @@ static const struct thumb_opcode tinsns[
   {"sxtb",	0xb240,		2,	ARM_EXT_V6,  do_t_arit},
   {"uxth",	0xb280,		2,	ARM_EXT_V6,  do_t_arit},
   {"uxtb",	0xb2c0,		2,	ARM_EXT_V6,  do_t_arit},
+
+  /* ARM V6K.  */
+  {"sev",	0xbf40,		2,	ARM_EXT_V6K, do_empty},
+  {"wfe",	0xbf20,		2,	ARM_EXT_V6K, do_empty},
+  {"wfi",	0xbf30,		2,	ARM_EXT_V6K, do_empty},
+  {"yield",	0xbf10,		2,	ARM_EXT_V6K, do_empty},
 };
 
 void
@@ -14715,8 +14725,10 @@ arm_handle_align (fragS * fragP)
 {
   static char const arm_noop[4] = { 0x00, 0x00, 0xa0, 0xe1 };
   static char const thumb_noop[2] = { 0xc0, 0x46 };
+  static char const thumb_6k_noop[2] = { 0x00, 0xbf };
   static char const arm_bigend_noop[4] = { 0xe1, 0xa0, 0x00, 0x00 };
   static char const thumb_bigend_noop[2] = { 0x46, 0xc0 };
+  static char const thumb_6k_bigend_noop[2] = { 0xbf, 0x00 };
 
   int bytes, fix, noop_size;
   char * p;
@@ -14734,10 +14746,20 @@ arm_handle_align (fragS * fragP)
 
   if (fragP->tc_frag_data)
     {
-      if (target_big_endian)
-	noop = thumb_bigend_noop;
+      if (cpu_variant & ARM_EXT_V6K)
+	{
+	  if (target_big_endian)
+	    noop = thumb_6k_bigend_noop;
+	  else
+	    noop = thumb_6k_noop;
+	}
       else
-	noop = thumb_noop;
+	{
+	  if (target_big_endian)
+	    noop = thumb_bigend_noop;
+	  else
+	    noop = thumb_noop;
+	}
       noop_size = sizeof (thumb_noop);
     }
   else
===================================================================
Index: gas/testsuite/gas/arm/arm.exp
--- gas/testsuite/gas/arm/arm.exp	4 Mar 2005 15:28:36 -0000	1.35
+++ gas/testsuite/gas/arm/arm.exp	9 Mar 2005 01:13:09 -0000
@@ -50,6 +50,7 @@ if {[istarget *arm*-*-*] || [istarget "x
     run_dump_test "maverick"    
     run_dump_test "archv6"
     run_dump_test "thumbv6"
+    run_dump_test "thumbv6k"
     run_dump_test "arch6zk"
     
     run_errors_test "vfp-bad" "-mfpu=vfp" "VFP errors"
===================================================================
Index: gas/testsuite/gas/arm/thumbv6k.d
--- gas/testsuite/gas/arm/thumbv6k.d	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/thumbv6k.d	9 Mar 2005 01:13:09 -0000
@@ -0,0 +1,15 @@
+#name: THUMB V6K instructions
+#as: -march=armv6k -mthumb
+#objdump: -dr --prefix-addresses --show-raw-insn -M force-thumb
+
+.*: +file format .*arm.*
+
+Disassembly of section .text:
+0+000 <[^>]*> bf00 *	nop
+0+002 <[^>]*> bf10 *	yield
+0+004 <[^>]*> bf20 *	wfe
+0+006 <[^>]*> bf30 *	wfi
+0+008 <[^>]*> bf40 *	sev
+0+00a <[^>]*> bf00 *	nop
+0+00c <[^>]*> bf00 *	nop
+0+00e <[^>]*> bf00 *	nop
===================================================================
Index: gas/testsuite/gas/arm/thumbv6k.s
--- gas/testsuite/gas/arm/thumbv6k.s	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/thumbv6k.s	9 Mar 2005 01:13:09 -0000
@@ -0,0 +1,14 @@
+	.text
+	.align 0
+	.thumb
+label:
+	nop
+	yield
+	wfe
+	wfi
+	sev
+	# arm-aout wants the segment padded to an 16-byte boundary;
+	# do this explicitly so it's consistent for all object formats.
+	nop
+	nop
+	nop
===================================================================
Index: opcodes/arm-dis.c
--- opcodes/arm-dis.c	29 Nov 2004 10:12:57 -0000	1.41
+++ opcodes/arm-dis.c	9 Mar 2005 01:13:10 -0000
@@ -622,6 +622,13 @@ static const struct thumb_opcode thumb_o
 {
   /* Thumb instructions.  */
 
+  /* ARM V6K no-argument instructions.  */
+  {ARM_EXT_V6K, 0xbf00, 0xffff, "nop"},
+  {ARM_EXT_V6K, 0xbf10, 0xffff, "yield"},
+  {ARM_EXT_V6K, 0xbf20, 0xffff, "wfe"},
+  {ARM_EXT_V6K, 0xbf30, 0xffff, "wfi"},
+  {ARM_EXT_V6K, 0xbf40, 0xffff, "sev"},
+
   /* ARM V6.  */
   {ARM_EXT_V6, 0xb660, 0xfff8, "cpsie\t%2'a%1'i%0'f"},
   {ARM_EXT_V6, 0xb670, 0xfff8, "cpsid\t%2'a%1'i%0'f"},

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

* Re: PATCH: Additional Thumb instructions for ARMv6K
  2005-03-09  1:19 PATCH: Additional Thumb instructions for ARMv6K Zack Weinberg
@ 2005-03-09 11:43 ` Richard Earnshaw
  2005-03-10 17:09   ` Zack Weinberg
  2005-03-09 12:26 ` Nick Clifton
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Earnshaw @ 2005-03-09 11:43 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: binutils

On Wed, 2005-03-09 at 01:19, Zack Weinberg wrote:
> ARMv6K adds five new Thumb instructions.  This patch adds assembler
> support for them.
> 
> The only possibly problematic part of this patch is the NOP changes.
> One of the new instructions is a preferred opcode for NOP (which has
> historically been done with "mov r8,r8"); I changed both what you get
> if you explicitly write "nop" and the opcode used for alignment in
> code sections, when (cpu_variant & ARM_EXT_V6K).  This *might* cause
> problems for existing code.  Please advise.

Hmm, I think we've got a problem here.  Gas is normally configured to
default to the pseudo CPU 'all' which permits instructions from any
architecture.  That means that unless the user has explicitly set a cpu
(or gcc has done it for you) then the new nop will match rather than the
old (because of the way the selection logic works as a bit-field and
mask).

I'm not sure that's desirable because it might break existing code that
did not expect to have to supply a CPU option.  

[You probably won't have noticed this because the basic thumb
instruction set test in gas isn't a dump test -- probably something else
that should be fixed.  In fact, I think all the thumb tests in gas use
an explicit -mcpu= argument.]

However, we might have to break the -mcpu=all assumption anyway when we
come to adding build attributes for the EABI; we don't want to end up
marking all objects as requiring an ARMv6 (or higher) core simply
because the user didn't set something explicitly on the command line. 

One partial solution is to pick some architecture (<ARMv6K) and to make
'all' mean anything up to that architecture -- anything after that must
supply a command-line flag (and we should add some configury magic to
permit selecting a specific cpu as the default).  We could do this and
at the same time deprecate 'all' so that it could be ultimately removed.

I'm open to other suggestions as well.

The changes other than the NOP work are OK to install (if they can
feasibly be separated out).

R.

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

* Re: PATCH: Additional Thumb instructions for ARMv6K
  2005-03-09  1:19 PATCH: Additional Thumb instructions for ARMv6K Zack Weinberg
  2005-03-09 11:43 ` Richard Earnshaw
@ 2005-03-09 12:26 ` Nick Clifton
  2005-03-10 17:45   ` Zack Weinberg
  1 sibling, 1 reply; 6+ messages in thread
From: Nick Clifton @ 2005-03-09 12:26 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: binutils

Hi Zack,

> The only possibly problematic part of this patch is the NOP changes.

Do you have a patch for the ARM simulator to handle these new 
instructions ?  Especially the NOP instruction ?

Cheers
   Nick

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

* Re: PATCH: Additional Thumb instructions for ARMv6K
  2005-03-09 11:43 ` Richard Earnshaw
@ 2005-03-10 17:09   ` Zack Weinberg
  0 siblings, 0 replies; 6+ messages in thread
From: Zack Weinberg @ 2005-03-10 17:09 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: binutils

Richard Earnshaw <rearnsha@gcc.gnu.org> writes:

> Hmm, I think we've got a problem here.  Gas is normally configured to
> default to the pseudo CPU 'all' which permits instructions from any
> architecture.  That means that unless the user has explicitly set a cpu
> (or gcc has done it for you) then the new nop will match rather than the
> old (because of the way the selection logic works as a bit-field and
> mask).
>
> I'm not sure that's desirable because it might break existing code that
> did not expect to have to supply a CPU option.  

I did notice this effect in testing, and it surprised me, but I wasn't
sure what to do about it.

> One partial solution is to pick some architecture (<ARMv6K) and to make
> 'all' mean anything up to that architecture -- anything after that must
> supply a command-line flag (and we should add some configury magic to
> permit selecting a specific cpu as the default).  We could do this and
> at the same time deprecate 'all' so that it could be ultimately removed.

This sounds like a sensible solution, but I do not know what a
reasonable default choice would be.

> The changes other than the NOP work are OK to install (if they can
> feasibly be separated out).

I can split them out and resubmit, but it may be a couple of days
before I get to it.

zw

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

* Re: PATCH: Additional Thumb instructions for ARMv6K
  2005-03-09 12:26 ` Nick Clifton
@ 2005-03-10 17:45   ` Zack Weinberg
  2005-03-11 10:27     ` Nick Clifton
  0 siblings, 1 reply; 6+ messages in thread
From: Zack Weinberg @ 2005-03-10 17:45 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Nick Clifton <nickc@redhat.com> writes:

> Hi Zack,
>
>> The only possibly problematic part of this patch is the NOP changes.
>
> Do you have a patch for the ARM simulator to handle these new
> instructions ?  Especially the NOP instruction ?

I don't.  CodeSourcery's client is not paying us to improve the
simulator, and there are also intellectual-property issues.

This version of the patch drops the NOP changes (except for the
disassembler recognizing 0xbf00 as a Thumb NOP).  Will you take this
without corresponding simulator improvements?

zw

gas:
        * config/tc-arm.c (tinsns): Add ARMv6K instructions sev, wfe,
        wfi, yield.
opcodes:
        * arm-dis.c (thumb_opcodes): Add ARMv6K instructions nop, sev,
        wfe, wfi, yield.
gas/testsuite:
        * gas/arm/thumbv6k.d, gas/arm/thumbv6k.s: New dump test.
        * gas/arm/arm.exp: Run it.

===================================================================
Index: gas/config/tc-arm.c
--- gas/config/tc-arm.c	23 Feb 2005 12:28:03 -0000	1.193
+++ gas/config/tc-arm.c	10 Mar 2005 17:43:18 -0000
@@ -10950,6 +10950,12 @@ static const struct thumb_opcode tinsns[
   {"sxtb",	0xb240,		2,	ARM_EXT_V6,  do_t_arit},
   {"uxth",	0xb280,		2,	ARM_EXT_V6,  do_t_arit},
   {"uxtb",	0xb2c0,		2,	ARM_EXT_V6,  do_t_arit},
+
+  /* ARM V6K.  */
+  {"sev",	0xbf40,		2,	ARM_EXT_V6K, do_empty},
+  {"wfe",	0xbf20,		2,	ARM_EXT_V6K, do_empty},
+  {"wfi",	0xbf30,		2,	ARM_EXT_V6K, do_empty},
+  {"yield",	0xbf10,		2,	ARM_EXT_V6K, do_empty},
 };
 
 void
===================================================================
Index: gas/testsuite/gas/arm/arm.exp
--- gas/testsuite/gas/arm/arm.exp	4 Mar 2005 15:28:36 -0000	1.35
+++ gas/testsuite/gas/arm/arm.exp	10 Mar 2005 17:43:18 -0000
@@ -50,6 +50,7 @@ if {[istarget *arm*-*-*] || [istarget "x
     run_dump_test "maverick"    
     run_dump_test "archv6"
     run_dump_test "thumbv6"
+    run_dump_test "thumbv6k"
     run_dump_test "arch6zk"
     
     run_errors_test "vfp-bad" "-mfpu=vfp" "VFP errors"
===================================================================
Index: gas/testsuite/gas/arm/thumbv6k.d
--- gas/testsuite/gas/arm/thumbv6k.d	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/thumbv6k.d	10 Mar 2005 17:43:18 -0000
@@ -0,0 +1,15 @@
+#name: THUMB V6K instructions
+#as: -march=armv6k -mthumb
+#objdump: -dr --prefix-addresses --show-raw-insn -M force-thumb
+
+.*: +file format .*arm.*
+
+Disassembly of section .text:
+0+000 <[^>]*> bf10 *	yield
+0+002 <[^>]*> bf20 *	wfe
+0+004 <[^>]*> bf30 *	wfi
+0+006 <[^>]*> bf40 *	sev
+0+008 <[^>]*> 46c0 *	nop[ \t]+\(mov r8, r8\)
+0+00a <[^>]*> 46c0 *	nop[ \t]+\(mov r8, r8\)
+0+00c <[^>]*> 46c0 *	nop[ \t]+\(mov r8, r8\)
+0+00e <[^>]*> 46c0 *	nop[ \t]+\(mov r8, r8\)
===================================================================
Index: gas/testsuite/gas/arm/thumbv6k.s
--- gas/testsuite/gas/arm/thumbv6k.s	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/thumbv6k.s	10 Mar 2005 17:43:18 -0000
@@ -0,0 +1,14 @@
+	.text
+	.align 0
+	.thumb
+label:
+	yield
+	wfe
+	wfi
+	sev
+	# arm-aout wants the segment padded to an 16-byte boundary;
+	# do this explicitly so it's consistent for all object formats.
+	nop
+	nop
+	nop
+	nop
===================================================================
Index: opcodes/arm-dis.c
--- opcodes/arm-dis.c	29 Nov 2004 10:12:57 -0000	1.41
+++ opcodes/arm-dis.c	10 Mar 2005 17:43:19 -0000
@@ -622,6 +622,13 @@ static const struct thumb_opcode thumb_o
 {
   /* Thumb instructions.  */
 
+  /* ARM V6K no-argument instructions.  */
+  {ARM_EXT_V6K, 0xbf00, 0xffff, "nop"},
+  {ARM_EXT_V6K, 0xbf10, 0xffff, "yield"},
+  {ARM_EXT_V6K, 0xbf20, 0xffff, "wfe"},
+  {ARM_EXT_V6K, 0xbf30, 0xffff, "wfi"},
+  {ARM_EXT_V6K, 0xbf40, 0xffff, "sev"},
+
   /* ARM V6.  */
   {ARM_EXT_V6, 0xb660, 0xfff8, "cpsie\t%2'a%1'i%0'f"},
   {ARM_EXT_V6, 0xb670, 0xfff8, "cpsid\t%2'a%1'i%0'f"},

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

* Re: PATCH: Additional Thumb instructions for ARMv6K
  2005-03-10 17:45   ` Zack Weinberg
@ 2005-03-11 10:27     ` Nick Clifton
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Clifton @ 2005-03-11 10:27 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: binutils

Hi Zack,

> This version of the patch drops the NOP changes (except for the
> disassembler recognizing 0xbf00 as a Thumb NOP).  Will you take this
> without corresponding simulator improvements?

Yes.

> gas:
>         * config/tc-arm.c (tinsns): Add ARMv6K instructions sev, wfe,
>         wfi, yield.
> opcodes:
>         * arm-dis.c (thumb_opcodes): Add ARMv6K instructions nop, sev,
>         wfe, wfi, yield.
> gas/testsuite:
>         * gas/arm/thumbv6k.d, gas/arm/thumbv6k.s: New dump test.
>         * gas/arm/arm.exp: Run it.

Approved - please apply.

Cheers
   Nick

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

end of thread, other threads:[~2005-03-11 10:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-09  1:19 PATCH: Additional Thumb instructions for ARMv6K Zack Weinberg
2005-03-09 11:43 ` Richard Earnshaw
2005-03-10 17:09   ` Zack Weinberg
2005-03-09 12:26 ` Nick Clifton
2005-03-10 17:45   ` Zack Weinberg
2005-03-11 10:27     ` 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).