PATCH: Additional Thumb instructions for ARMv6K

Zack Weinberg zack@codesourcery.com
Wed Mar 9 01:19:00 GMT 2005


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"},



More information about the Binutils mailing list