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]

[patch] tc-arm.c: Issue a warning for comparison instructions with an 's' suffix.


Hi,

Attached is a patch to issue a warning for comparison instructions
like tsts, cmps, and cmns with an 's' suffix.  These comparison
instructions set the condition codes, so the 's' is redundant.

Tested on arm-none-eabi.  OK to apply?

Kazu Hirata

2006-05-03  Kazu Hirata  <kazu@codesourcery.com>

	* config/tc-arm.c (opcode_tag): Add OT_cinfix3_deprecated.
	(opcode_lookup): Issue a warning for opcode with
	OT_cinfix3_deprecated.  Otherwise treat OT_cinfix3_deprecated
	identical to OT_cinfix3.
	(TxC3w, TC3w, tC3w): New.
	(insns): Use tC3w and TC3w for comparison instructions with
	's' suffix.

2006-05-03  Kazu Hirata  <kazu@codesourcery.com>

	* gas/arm/armv1.d (error-output): New.
	* gas/arm/armv1.l: New.
	* gas/arm/thumb32.d (error-output): New.
	* gas/arm/thumb32.l: New.

Index: config/tc-arm.c
===================================================================
--- config/tc-arm.c	26 Apr 2006 16:03:02 -0000	1.261
+++ config/tc-arm.c	1 May 2006 21:37:18 -0000
@@ -12112,6 +12112,8 @@ enum opcode_tag
   OT_cinfix3,		/* Instruction takes a conditional infix,
 			   beginning at character index 3.  (In
 			   unified mode, it becomes a suffix.)  */
+  OT_cinfix3_deprecated, /* The same as OT_cinfix3.  This is used for
+			    tsts, cmps, cmns, and teqs. */
   OT_cinfix3_legacy,	/* Legacy instruction takes a conditional infix at
 			   character index 3, even in unified mode.  Used for
 			   legacy instructions where suffix and infix forms
@@ -12268,6 +12270,7 @@ opcode_lookup (char **str)
 	  break;
 
 	case OT_cinfix3:
+	case OT_cinfix3_deprecated:
 	case OT_odd_infix_unc:
 	  if (!unified_syntax)
 	    return 0;
@@ -12314,11 +12317,16 @@ opcode_lookup (char **str)
   memmove (affix + 2, affix, (end - affix) - 2);
   memcpy (affix, save, 2);
 
-  if (opcode && (opcode->tag == OT_cinfix3 || opcode->tag == OT_csuf_or_in3
-		 || opcode->tag == OT_cinfix3_legacy))
+  if (opcode
+      && (opcode->tag == OT_cinfix3
+	  || opcode->tag == OT_cinfix3_deprecated
+	  || opcode->tag == OT_csuf_or_in3
+	  || opcode->tag == OT_cinfix3_legacy))
     {
       /* step CM */
-      if (unified_syntax && opcode->tag == OT_cinfix3)
+      if (unified_syntax
+	  && (opcode->tag == OT_cinfix3
+	      || opcode->tag == OT_cinfix3_deprecated))
 	as_warn (_("conditional infixes are deprecated in unified syntax"));
 
       inst.cond = cond->value;
@@ -12357,6 +12365,9 @@ md_assemble (char *str)
       return;
     }
 
+  if (opcode->tag == OT_cinfix3_deprecated)
+    as_warn (_("s suffix on comparison instruction is deprecated"));
+
   if (thumb_mode)
     {
       arm_feature_set variant;
@@ -12858,10 +12869,17 @@ static struct asm_barrier_opt barrier_op
 #define TxC3(mnem, op, top, nops, ops, ae, te) \
   { #mnem, OPS##nops ops, OT_cinfix3, 0x##op, top, ARM_VARIANT, \
     THUMB_VARIANT, do_##ae, do_##te }
+#define TxC3w(mnem, op, top, nops, ops, ae, te) \
+  { #mnem, OPS##nops ops, OT_cinfix3_deprecated, 0x##op, top, ARM_VARIANT, \
+    THUMB_VARIANT, do_##ae, do_##te }
 #define TC3(mnem, aop, top, nops, ops, ae, te) \
        TxC3(mnem, aop, 0x##top, nops, ops, ae, te)
+#define TC3w(mnem, aop, top, nops, ops, ae, te) \
+       TxC3w(mnem, aop, 0x##top, nops, ops, ae, te)
 #define tC3(mnem, aop, top, nops, ops, ae, te) \
        TxC3(mnem, aop, T_MNEM_##top, nops, ops, ae, te)
+#define tC3w(mnem, aop, top, nops, ops, ae, te) \
+       TxC3w(mnem, aop, T_MNEM_##top, nops, ops, ae, te)
 
 /* Mnemonic with a conditional infix in an unusual place.  Each and every variant has to
    appear in the condition table.  */
@@ -13024,13 +13042,13 @@ static const struct asm_opcode insns[] =
     for setting PSR flag bits.  They are obsolete in V6 and do not
     have Thumb equivalents. */
  tCE(tst,	1100000, tst,	   2, (RR, SH),      cmp,  t_mvn_tst),
- tC3(tsts,	1100000, tst,	   2, (RR, SH),      cmp,  t_mvn_tst),
+ tC3w(tsts,	1100000, tst,	   2, (RR, SH),      cmp,  t_mvn_tst),
   CL(tstp,	110f000,     	   2, (RR, SH),      cmp),
  tCE(cmp,	1500000, cmp,	   2, (RR, SH),      cmp,  t_mov_cmp),
- tC3(cmps,	1500000, cmp,	   2, (RR, SH),      cmp,  t_mov_cmp),
+ tC3w(cmps,	1500000, cmp,	   2, (RR, SH),      cmp,  t_mov_cmp),
   CL(cmpp,	150f000,     	   2, (RR, SH),      cmp),
  tCE(cmn,	1700000, cmn,	   2, (RR, SH),      cmp,  t_mvn_tst),
- tC3(cmns,	1700000, cmn,	   2, (RR, SH),      cmp,  t_mvn_tst),
+ tC3w(cmns,	1700000, cmn,	   2, (RR, SH),      cmp,  t_mvn_tst),
   CL(cmnp,	170f000,     	   2, (RR, SH),      cmp),
 
  tCE(mov,	1a00000, mov,	   2, (RR, SH),      mov,  t_mov_cmp),
@@ -13084,7 +13102,7 @@ static const struct asm_opcode insns[] =
  TCE(rsb,	0600000, ebc00000, 3, (RR, oRR, SH), arit, t_rsb),
  TC3(rsbs,	0700000, ebd00000, 3, (RR, oRR, SH), arit, t_rsb),
  TCE(teq,	1300000, ea900f00, 2, (RR, SH),      cmp,  t_mvn_tst),
- TC3(teqs,	1300000, ea900f00, 2, (RR, SH),      cmp,  t_mvn_tst),
+ TC3w(teqs,	1300000, ea900f00, 2, (RR, SH),      cmp,  t_mvn_tst),
   CL(teqp,	130f000,           2, (RR, SH),      cmp),
 
  TC3(ldrt,	4300000, f8500e00, 2, (RR, ADDR),    ldstt, t_ldstt),
Index: testsuite/gas/arm/armv1.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/armv1.d,v
retrieving revision 1.4
diff -u -r1.4 armv1.d
--- testsuite/gas/arm/armv1.d	16 Mar 2006 15:08:47 -0000	1.4
+++ testsuite/gas/arm/armv1.d	2 May 2006 14:37:28 -0000
@@ -1,6 +1,7 @@
 #objdump: -dr --prefix-addresses --show-raw-insn
 #name: ARM v1 instructions
 #as: -mcpu=arm7t
+#error-output: armv1.l
 
 # Test the ARM v1 instructions
 
Index: testsuite/gas/arm/thumb32.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/thumb32.d,v
retrieving revision 1.17
diff -u -r1.17 thumb32.d
--- testsuite/gas/arm/thumb32.d	21 Mar 2006 14:35:27 -0000	1.17
+++ testsuite/gas/arm/thumb32.d	2 May 2006 14:37:29 -0000
@@ -3,7 +3,8 @@
 # objdump: -dr --prefix-addresses --show-raw-insn
 # The arm-aout and arm-pe ports do not support Thumb branch relocations.
 # not-target: *-*-*aout* *-*-pe
+# error-output: thumb32.l
 
 .*: +file format .*arm.*
 
--- /dev/null	2006-03-11 08:41:44.866675760 -0800
+++ testsuite/gas/arm/armv1.l	2006-05-01 19:41:48.000000000 -0700
@@ -0,1 +1,6 @@
+[^:]*: Assembler messages:
+[^:]*:26: Warning: s suffix on comparison instruction is deprecated
+[^:]*:29: Warning: s suffix on comparison instruction is deprecated
+[^:]*:32: Warning: s suffix on comparison instruction is deprecated
+[^:]*:35: Warning: s suffix on comparison instruction is deprecated
--- /dev/null	2006-03-11 08:41:44.866675760 -0800
+++ testsuite/gas/arm/thumb32.l	2006-05-01 19:41:48.000000000 -0700
@@ -0,0 +1,17 @@
+[^;]*: Assembler messages:
+[^;]*:446: Warning: s suffix on comparison instruction is deprecated
+[^;]*:446: Warning: s suffix on comparison instruction is deprecated
+[^;]*:446: Warning: s suffix on comparison instruction is deprecated
+[^;]*:446: Warning: s suffix on comparison instruction is deprecated
+[^;]*:447: Warning: s suffix on comparison instruction is deprecated
+[^;]*:447: Warning: s suffix on comparison instruction is deprecated
+[^;]*:447: Warning: s suffix on comparison instruction is deprecated
+[^;]*:447: Warning: s suffix on comparison instruction is deprecated
+[^;]*:448: Warning: s suffix on comparison instruction is deprecated
+[^;]*:448: Warning: s suffix on comparison instruction is deprecated
+[^;]*:448: Warning: s suffix on comparison instruction is deprecated
+[^;]*:448: Warning: s suffix on comparison instruction is deprecated
+[^;]*:449: Warning: s suffix on comparison instruction is deprecated
+[^;]*:449: Warning: s suffix on comparison instruction is deprecated
+[^;]*:449: Warning: s suffix on comparison instruction is deprecated
+[^;]*:449: Warning: s suffix on comparison instruction is deprecated


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