This is the mail archive of the binutils-cvs@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]

[binutils-gdb] [GAS/ARM] Clarify relation between reg_expected_msgs and arm_reg_type


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5aa75429d0531ac6cfe59efd80f1ab01311865b3

commit 5aa75429d0531ac6cfe59efd80f1ab01311865b3
Author: Thomas Preud'homme <thomas.preudhomme@arm.com>
Date:   Wed Nov 22 14:02:49 2017 +0000

    [GAS/ARM] Clarify relation between reg_expected_msgs and arm_reg_type
    
    Uses of reg_expected_msgs rely on each arm_reg_type enumerator to have a
    message entry in the same order as the enumerator declaration. This is
    not clearly stated in the definition of both the arm_reg_type enum and
    the reg_expected_msgs. Worse, there is nothing to ensure both are kept
    in sync.
    
    As an attempt towards this, this patch uses C99 array designators to
    ensure that each message is associated with the right arm_reg_type. A
    comment is also added near the definition of arm_reg_type to point to
    the reg_expected_msgs array. Finally, the array is synced with
    arm_reg_type by adding the missing error message for REG_TYPE_RNB.
    
    2017-11-22  Thomas Preud'homme  <thomas.preudhomme@arm.com>
    
    gas/
    	* config/tc-arm.c (arm_reg_type): Comment on the link with
    	reg_expected_msgs.
    	(reg_expected_msgs): Initialize using array designators with
    	arm_reg_type index.

Diff:
---
 gas/ChangeLog       |  7 +++++++
 gas/config/tc-arm.c | 49 ++++++++++++++++++++++++++-----------------------
 2 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index fa18fb3..1856699 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-22  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+	* config/tc-arm.c (arm_reg_type): Comment on the link with
+	reg_expected_msgs.
+	(reg_expected_msgs): Initialize using array designators with
+	arm_reg_type index.
+
 2017-11-22  Claudiu Zissulescu  <claziss@synopsys.com>
 
 	* testsuite/gas/arc/hregs-err.s: New test.
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index e920637..080e4da 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -571,7 +571,8 @@ struct neon_typed_alias
 };
 
 /* ARM register categories.  This includes coprocessor numbers and various
-   architecture extensions' registers.	*/
+   architecture extensions' registers.  Each entry should have an error message
+   in reg_expected_msgs below.  */
 enum arm_reg_type
 {
   REG_TYPE_RN,
@@ -615,28 +616,30 @@ struct reg_entry
 /* Diagnostics used when we don't get a register of the expected type.	*/
 const char * const reg_expected_msgs[] =
 {
-  N_("ARM register expected"),
-  N_("bad or missing co-processor number"),
-  N_("co-processor register expected"),
-  N_("FPA register expected"),
-  N_("VFP single precision register expected"),
-  N_("VFP/Neon double precision register expected"),
-  N_("Neon quad precision register expected"),
-  N_("VFP single or double precision register expected"),
-  N_("Neon double or quad precision register expected"),
-  N_("Neon single or double precision register expected"),
-  N_("VFP single, double or Neon quad precision register expected"),
-  N_("VFP system register expected"),
-  N_("Maverick MVF register expected"),
-  N_("Maverick MVD register expected"),
-  N_("Maverick MVFX register expected"),
-  N_("Maverick MVDX register expected"),
-  N_("Maverick MVAX register expected"),
-  N_("Maverick DSPSC register expected"),
-  N_("iWMMXt data register expected"),
-  N_("iWMMXt control register expected"),
-  N_("iWMMXt scalar register expected"),
-  N_("XScale accumulator register expected"),
+  [REG_TYPE_RN]	    = N_("ARM register expected"),
+  [REG_TYPE_CP]	    = N_("bad or missing co-processor number"),
+  [REG_TYPE_CN]	    = N_("co-processor register expected"),
+  [REG_TYPE_FN]	    = N_("FPA register expected"),
+  [REG_TYPE_VFS]    = N_("VFP single precision register expected"),
+  [REG_TYPE_VFD]    = N_("VFP/Neon double precision register expected"),
+  [REG_TYPE_NQ]	    = N_("Neon quad precision register expected"),
+  [REG_TYPE_VFSD]   = N_("VFP single or double precision register expected"),
+  [REG_TYPE_NDQ]    = N_("Neon double or quad precision register expected"),
+  [REG_TYPE_NSD]    = N_("Neon single or double precision register expected"),
+  [REG_TYPE_NSDQ]   = N_("VFP single, double or Neon quad precision register"
+			 " expected"),
+  [REG_TYPE_VFC]    = N_("VFP system register expected"),
+  [REG_TYPE_MVF]    = N_("Maverick MVF register expected"),
+  [REG_TYPE_MVD]    = N_("Maverick MVD register expected"),
+  [REG_TYPE_MVFX]   = N_("Maverick MVFX register expected"),
+  [REG_TYPE_MVDX]   = N_("Maverick MVDX register expected"),
+  [REG_TYPE_MVAX]   = N_("Maverick MVAX register expected"),
+  [REG_TYPE_DSPSC]  = N_("Maverick DSPSC register expected"),
+  [REG_TYPE_MMXWR]  = N_("iWMMXt data register expected"),
+  [REG_TYPE_MMXWC]  = N_("iWMMXt control register expected"),
+  [REG_TYPE_MMXWCG] = N_("iWMMXt scalar register expected"),
+  [REG_TYPE_XSCALE] = N_("XScale accumulator register expected"),
+  [REG_TYPE_RNB]    = N_("")
 };
 
 /* Some well known registers that we refer to directly elsewhere.  */


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