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] tic54x: rename typedef of struct symbol_


From: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>

Hi,

generic gas code has a struct symbol, and tic54x typedefs a struct to symbol.
This seems at least rather confusing, and it seems like target specific headers
shouldn't  put such generic names in the global namespace preventing other
generic code from using them.

built and regtested tic54x-coff, ok?

Trev

opcodes/ChangeLog:

2016-05-18  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* tic54x-dis.c (sprint_mmr): Adjust.
	* tic54x-opc.c: Likewise.

gas/ChangeLog:

2016-05-18  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* config/tc-tic54x.c (tic54x_mmregs): Adjust.
	(md_begin): Likewise.
	(encode_condition): Likewise.
	(encode_cc3): Likewise.
	(encode_cc2): Likewise.
	(encode_operand): Likewise.
	(tic54x_undefined_symbol): Likewise.

include/ChangeLog:

2016-05-18  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* opcode/tic54x.h (struct symbol_): typedef to tic54x_symbol instead of
	plain symbol.
---
 gas/config/tc-tic54x.c  | 47 ++++++++++++++++++++++++-----------------------
 include/opcode/tic54x.h |  8 ++++----
 opcodes/tic54x-dis.c    |  2 +-
 opcodes/tic54x-opc.c    | 12 ++++++------
 4 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c
index 845f947..947ba73 100644
--- a/gas/config/tc-tic54x.c
+++ b/gas/config/tc-tic54x.c
@@ -2011,11 +2011,11 @@ tic54x_label (int ignored ATTRIBUTE_UNUSED)
 static void
 tic54x_mmregs (int ignored ATTRIBUTE_UNUSED)
 {
-  symbol *sym;
+  tic54x_symbol *sym;
 
   ILLEGAL_WITHIN_STRUCT ();
 
-  for (sym = (symbol *) mmregs; sym->name; sym++)
+  for (sym = (tic54x_symbol *) mmregs; sym->name; sym++)
     {
       symbolS *symbolP = symbol_new (sym->name, absolute_section,
 				     (valueT) sym->value, &zero_address_frag);
@@ -2963,7 +2963,7 @@ void
 md_begin (void)
 {
   insn_template *tm;
-  symbol *sym;
+  tic54x_symbol *sym;
   const subsym_proc_entry *subsym_proc;
   const math_proc_entry *math_proc;
   const char *hash_err;
@@ -3011,7 +3011,7 @@ md_begin (void)
 		  tm->name, hash_err);
     }
   reg_hash = hash_new ();
-  for (sym = (symbol *) regs; sym->name; sym++)
+  for (sym = (tic54x_symbol *) regs; sym->name; sym++)
     {
       /* Add basic registers to the symbol table.  */
       symbolS *symbolP = symbol_new (sym->name, absolute_section,
@@ -3020,26 +3020,26 @@ md_begin (void)
       symbol_table_insert (symbolP);
       hash_err = hash_insert (reg_hash, sym->name, (char *) sym);
     }
-  for (sym = (symbol *) mmregs; sym->name; sym++)
+  for (sym = (tic54x_symbol *) mmregs; sym->name; sym++)
     hash_err = hash_insert (reg_hash, sym->name, (char *) sym);
   mmreg_hash = hash_new ();
-  for (sym = (symbol *) mmregs; sym->name; sym++)
+  for (sym = (tic54x_symbol *) mmregs; sym->name; sym++)
     hash_err = hash_insert (mmreg_hash, sym->name, (char *) sym);
 
   cc_hash = hash_new ();
-  for (sym = (symbol *) condition_codes; sym->name; sym++)
+  for (sym = (tic54x_symbol *) condition_codes; sym->name; sym++)
     hash_err = hash_insert (cc_hash, sym->name, (char *) sym);
 
   cc2_hash = hash_new ();
-  for (sym = (symbol *) cc2_codes; sym->name; sym++)
+  for (sym = (tic54x_symbol *) cc2_codes; sym->name; sym++)
     hash_err = hash_insert (cc2_hash, sym->name, (char *) sym);
 
   cc3_hash = hash_new ();
-  for (sym = (symbol *) cc3_codes; sym->name; sym++)
+  for (sym = (tic54x_symbol *) cc3_codes; sym->name; sym++)
     hash_err = hash_insert (cc3_hash, sym->name, (char *) sym);
 
   sbit_hash = hash_new ();
-  for (sym = (symbol *) status_bits; sym->name; sym++)
+  for (sym = (tic54x_symbol *) status_bits; sym->name; sym++)
     hash_err = hash_insert (sbit_hash, sym->name, (char *) sym);
 
   misc_symbol_hash = hash_new ();
@@ -3650,7 +3650,7 @@ encode_integer (tic54x_insn *insn,
 static int
 encode_condition (tic54x_insn *insn, struct opstruct *operand)
 {
-  symbol *cc = (symbol *) hash_find (cc_hash, operand->buf);
+  tic54x_symbol *cc = (tic54x_symbol *) hash_find (cc_hash, operand->buf);
   if (!cc)
     {
       as_bad (_("Unrecognized condition code \"%s\""), operand->buf);
@@ -3710,7 +3710,7 @@ encode_condition (tic54x_insn *insn, struct opstruct *operand)
 static int
 encode_cc3 (tic54x_insn *insn, struct opstruct *operand)
 {
-  symbol *cc3 = (symbol *) hash_find (cc3_hash, operand->buf);
+  tic54x_symbol *cc3 = (tic54x_symbol *) hash_find (cc3_hash, operand->buf);
   int value = cc3 ? cc3->value : operand->exp.X_add_number << 8;
 
   if ((value & 0x0300) != value)
@@ -3739,7 +3739,7 @@ encode_arx (tic54x_insn *insn, struct opstruct *operand)
 static int
 encode_cc2 (tic54x_insn *insn, struct opstruct *operand)
 {
-  symbol *cc2 = (symbol *) hash_find (cc2_hash, operand->buf);
+  tic54x_symbol *cc2 = (tic54x_symbol *) hash_find (cc2_hash, operand->buf);
 
   if (!cc2)
     {
@@ -3898,7 +3898,8 @@ encode_operand (tic54x_insn *insn, enum optype type, struct opstruct *operand)
 			     0, 65535, 0xFFFF);
     case OP_SBIT:
       {
-	symbol *sbit = (symbol *) hash_find (sbit_hash, operand->buf);
+	tic54x_symbol *sbit = (tic54x_symbol *)
+	  hash_find (sbit_hash, operand->buf);
 	int value = is_absolute (operand) ?
 	  operand->exp.X_add_number : (sbit ? sbit->value : -1);
 	int reg = 0;
@@ -3912,7 +3913,7 @@ encode_operand (tic54x_insn *insn, enum optype type, struct opstruct *operand)
 	      }
 	    /* Guess the register based on the status bit; "ovb" is the last
 	       status bit defined for st0.  */
-	    if (sbit > (symbol *) hash_find (sbit_hash, "ovb"))
+	    if (sbit > (tic54x_symbol *) hash_find (sbit_hash, "ovb"))
 	      reg = 1;
 	  }
 	if (value == -1)
@@ -5012,22 +5013,22 @@ tic54x_define_label (symbolS *sym)
 symbolS *
 tic54x_undefined_symbol (char *name)
 {
-  symbol *sym;
+  tic54x_symbol *sym;
 
   /* Not sure how to handle predefined symbols.  */
-  if ((sym = (symbol *) hash_find (cc_hash, name)) != NULL ||
-      (sym = (symbol *) hash_find (cc2_hash, name)) != NULL ||
-      (sym = (symbol *) hash_find (cc3_hash, name)) != NULL ||
-      (sym = (symbol *) hash_find (misc_symbol_hash, name)) != NULL ||
-      (sym = (symbol *) hash_find (sbit_hash, name)) != NULL)
+  if ((sym = (tic54x_symbol *) hash_find (cc_hash, name)) != NULL ||
+      (sym = (tic54x_symbol *) hash_find (cc2_hash, name)) != NULL ||
+      (sym = (tic54x_symbol *) hash_find (cc3_hash, name)) != NULL ||
+      (sym = (tic54x_symbol *) hash_find (misc_symbol_hash, name)) != NULL ||
+      (sym = (tic54x_symbol *) hash_find (sbit_hash, name)) != NULL)
     {
       return symbol_new (name, reg_section,
 			 (valueT) sym->value,
 			 &zero_address_frag);
     }
 
-  if ((sym = (symbol *) hash_find (reg_hash, name)) != NULL ||
-      (sym = (symbol *) hash_find (mmreg_hash, name)) != NULL ||
+  if ((sym = (tic54x_symbol *) hash_find (reg_hash, name)) != NULL ||
+      (sym = (tic54x_symbol *) hash_find (mmreg_hash, name)) != NULL ||
       !strcasecmp (name, "a") || !strcasecmp (name, "b"))
     {
       return symbol_new (name, reg_section,
diff --git a/include/opcode/tic54x.h b/include/opcode/tic54x.h
index 49120de..b0af407 100644
--- a/include/opcode/tic54x.h
+++ b/include/opcode/tic54x.h
@@ -26,7 +26,7 @@ typedef struct _symbol
 {
   const char *name;
   unsigned short value;
-} symbol;
+} tic54x_symbol;
 
 enum optype {
   OPT = 0x8000,
@@ -152,9 +152,9 @@ typedef struct _template
 extern const insn_template tic54x_unknown_opcode;
 extern const insn_template tic54x_optab[];
 extern const insn_template tic54x_paroptab[];
-extern const symbol mmregs[], regs[];
-extern const symbol condition_codes[], cc2_codes[], status_bits[];
-extern const symbol cc3_codes[];
+extern const tic54x_symbol mmregs[], regs[];
+extern const tic54x_symbol condition_codes[], cc2_codes[], status_bits[];
+extern const tic54x_symbol cc3_codes[];
 extern const char *misc_symbols[];
 struct disassemble_info;
 extern const insn_template* tic54x_get_insn (struct disassemble_info *, 
diff --git a/opcodes/tic54x-dis.c b/opcodes/tic54x-dis.c
index 804e083..e12349d 100644
--- a/opcodes/tic54x-dis.c
+++ b/opcodes/tic54x-dis.c
@@ -530,7 +530,7 @@ sprint_mmr (disassemble_info *info ATTRIBUTE_UNUSED,
 	    char buf[],
 	    int mmr)
 {
-  symbol *reg = (symbol *) mmregs;
+  tic54x_symbol *reg = (tic54x_symbol *) mmregs;
   while (reg->name != NULL)
     {
       if (mmr == reg->value)
diff --git a/opcodes/tic54x-opc.c b/opcodes/tic54x-opc.c
index f5d489b..3c10680 100644
--- a/opcodes/tic54x-opc.c
+++ b/opcodes/tic54x-opc.c
@@ -24,7 +24,7 @@
 #include "opcode/tic54x.h"
 
 /* these are the only register names not found in mmregs */
-const symbol regs[] = {
+const tic54x_symbol regs[] = {
   { "AR0", 16 },                  { "ar0", 16 },
   { "AR1", 17 },                  { "ar1", 17 },
   { "AR2", 18 },                  { "ar2", 18 },
@@ -38,7 +38,7 @@ const symbol regs[] = {
 
 /* status bits, MM registers, condition codes, etc */
 /* some symbols are only valid for certain chips... */
-const symbol mmregs[] = {
+const tic54x_symbol mmregs[] = {
   { "IMR", 0 },                   { "imr", 0 },
   { "IFR", 1 },                   { "ifr", 1 },
   { "ST0", 6 },                   { "st0", 6 },
@@ -111,7 +111,7 @@ const symbol mmregs[] = {
   { NULL, 0},
 };
 
-const symbol condition_codes[] = {
+const tic54x_symbol condition_codes[] = {
   /* condition codes */
   { "UNC",  0 },                { "unc",  0 },
 #define CC1   0x40
@@ -155,7 +155,7 @@ const symbol condition_codes[] = {
   { NULL, 0 }
 };
 
-const symbol cc2_codes[] = {
+const tic54x_symbol cc2_codes[] = {
   { "UNC", 0 },  { "unc", 0 },
   { "AEQ", 5 },  { "aeq", 5 },
   { "ANEQ", 4 }, { "aneq", 4 },
@@ -172,7 +172,7 @@ const symbol cc2_codes[] = {
   { NULL, 0 },
 };
 
-const symbol cc3_codes[] = {
+const tic54x_symbol cc3_codes[] = {
   { "EQ", 0x0000 },  { "eq", 0x0000 },
   { "LT", 0x0100 },  { "lt", 0x0100 },
   { "GT", 0x0200 },  { "gt", 0x0200 },
@@ -189,7 +189,7 @@ const symbol cc3_codes[] = {
 };
 
 /* FIXME -- also allow decimal digits */
-const symbol status_bits[] = {
+const tic54x_symbol status_bits[] = {
   /* status register 0 */
   { "TC",  12 },                { "tc",  12 },
   { "C",   11 },                { "c",   11 },
-- 
2.7.0


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