This is the mail archive of the binutils@sources.redhat.com 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]

[PATCH] some more z8k cleanups


Hi,

these are mostly cosmetic fixes (remove warnings) for the z8k. One real
bug is addressed with the HOWTO changes, the old version prevented "ld
-r" from work.

regards,
chris



bfd/Changelog:

2001-05-30  Christian Groessler <cpg@aladdin.de>

        * coff-z8k.c: Fix formatting.
	Fix howtos: howto->size was always 1.


gas/Changelog:

2001-05-30  Christian Groessler <cpg@aladdin.de>

        * config/tc-z8k.c: Removed many warnings by removing unused
	variables and tagging unused parameters as such.
	(md_begin): Fixed a typo (","instead of ";").
	(struct ctrl_table): Add parentheses to initialize array
	correctly.
	(struct flag_table): Likewise.
	(struct intr_table): Likewise.
	(struct table): Likewise.
	(check_operand): "#if 0"'ed since it doesn't seem to be used.


opcodes/Changelog:

2001-05-30  Christian Groessler <cpg@aladdin.de>

        * z8k-dis.c: Fix formatting.
        (unpack_instr): Remove unused cases in switch statement. Add
        safety abort() in default case.
        (unparse_instr): Add safety abort() in default case.


---------------------------
Index: bfd/coff-z8k.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-z8k.c,v
retrieving revision 1.5
diff -u -p -r1.5 coff-z8k.c
--- coff-z8k.c	2001/04/24 15:22:23	1.5
+++ coff-z8k.c	2001/05/30 21:19:24
@@ -31,12 +31,12 @@ Foundation, Inc., 59 Temple Place - Suit
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
 
 static reloc_howto_type r_imm32 =
-HOWTO (R_IMM32, 0, 1, 32, false, 0,
+HOWTO (R_IMM32, 0, 2, 32, false, 0,
        complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff,
        0xffffffff, false);
 
 static reloc_howto_type r_imm4l =
-HOWTO (R_IMM4L, 0, 1, 4, false, 0,
+HOWTO (R_IMM4L, 0, 0, 4, false, 0,
        complain_overflow_bitfield, 0, "r_imm4l", true, 0xf, 0xf, false);
 
 static reloc_howto_type r_da =
@@ -45,7 +45,7 @@ HOWTO (R_IMM16, 0, 1, 16, false, 0,
        false);
 
 static reloc_howto_type r_imm8 =
-HOWTO (R_IMM8, 0, 1, 8, false, 0,
+HOWTO (R_IMM8, 0, 0, 8, false, 0,
        complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff,
        false);
 
@@ -55,11 +55,11 @@ HOWTO (R_REL16, 0, 1, 16, false, 0,
        true);
 
 static reloc_howto_type r_jr =
-HOWTO (R_JR, 0, 1, 8, true, 0, complain_overflow_signed, 0,
+HOWTO (R_JR, 0, 0, 8, true, 0, complain_overflow_signed, 0,
        "r_jr", true, 0, 0, true);
 
 static reloc_howto_type r_disp7 =
-HOWTO (R_DISP7, 0, 1, 7, true, 0, complain_overflow_bitfield, 0,
+HOWTO (R_DISP7, 0, 0, 7, true, 0, complain_overflow_bitfield, 0,
        "r_disp7", true, 0, 0, true);
 
 static reloc_howto_type r_callr =
@@ -186,7 +186,8 @@ extra_case (in_abfd, link_info, link_ord
 
     case R_IMM32:
       bfd_put_32 (in_abfd,
-		  bfd_coff_reloc16_get_value (reloc, link_info, input_section),
+		  /* 0x80000000 indicates a long segmented address.  */
+		  bfd_coff_reloc16_get_value (reloc, link_info, input_section) | 0x80000000,
 		  data + *dst_ptr);
       (*dst_ptr) += 4;
       (*src_ptr) += 4;
@@ -218,8 +219,8 @@ extra_case (in_abfd, link_info, link_ord
 	bfd_vma dot = (link_order->offset
 		       + *dst_ptr
 		       + input_section->output_section->vma);
-	int gap = dst - dot - 1;/* -1 since were in the odd byte of the
-				    word and the pc's been incremented */
+	int gap = dst - dot - 1;  /* -1, since we're in the odd byte of the
+                                     word and the pc's been incremented.  */
 
 	if (gap & 1)
 	  abort ();
@@ -245,8 +246,8 @@ extra_case (in_abfd, link_info, link_ord
 	bfd_vma dot = (link_order->offset
 		       + *dst_ptr
 		       + input_section->output_section->vma);
-	int gap = dst - dot - 1;/* -1 since were in the odd byte of the
-				    word and the pc's been incremented */
+	int gap = dst - dot - 1;  /* -1, since we're in the odd byte of the
+                                     word and the pc's been incremented.  */
 
 	if (gap & 1)
 	  abort ();
Index: gas/config/tc-z8k.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-z8k.c,v
retrieving revision 1.10
diff -u -p -r1.10 tc-z8k.c
--- tc-z8k.c	2001/04/24 15:22:24	1.10
+++ tc-z8k.c	2001/05/30 21:19:27
@@ -159,8 +159,6 @@ md_begin ()
   for (opcode = z8k_table; opcode->name; opcode++)
     {
       /* Only enter unique codes into the table.  */
-      char *src = opcode->name;
-
       if (strcmp (opcode->name, prev_name))
 	{
 	  hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
@@ -178,8 +176,8 @@ md_begin ()
     {
       opcode_entry_type *fake_opcode;
       fake_opcode = (opcode_entry_type *) malloc (sizeof (opcode_entry_type));
-      fake_opcode->name = md_pseudo_table[idx].poc_name,
-	fake_opcode->func = (void *) (md_pseudo_table + idx);
+      fake_opcode->name = md_pseudo_table[idx].poc_name;
+      fake_opcode->func = (void *) (md_pseudo_table + idx);
       fake_opcode->opcode = 250;
       hash_insert (opcode_hash_control, fake_opcode->name, fake_opcode);
     }
@@ -404,25 +402,24 @@ struct ctrl_names {
 };
 
 struct ctrl_names ctrl_table[] = {
-  0x2, "fcw",
-  0X3, "refresh",
-  0x4, "psapseg",
-  0x5, "psapoff",
-  0x5, "psap",
-  0x6, "nspseg",
-  0x7, "nspoff",
-  0x7, "nsp",
-  0  , 0
+  { 0x2, "fcw" },
+  { 0x3, "refresh" },
+  { 0x4, "psapseg" },
+  { 0x5, "psapoff" },
+  { 0x5, "psap" },
+  { 0x6, "nspseg" },
+  { 0x7, "nspoff" },
+  { 0x7, "nsp" },
+  { 0  , 0 }
 };
 
 static void
 get_ctrl_operand (ptr, mode, dst)
      char **ptr;
      struct z8k_op *mode;
-     unsigned int dst;
+     unsigned int dst ATTRIBUTE_UNUSED;
 {
   char *src = *ptr;
-  int r;
   int i;
 
   while (*src == ' ')
@@ -455,23 +452,22 @@ struct flag_names {
 };
 
 struct flag_names flag_table[] = {
-  0x1, "p",
-  0x1, "v",
-  0x2, "s",
-  0x4, "z",
-  0x8, "c",
-  0x0, "+",
-  0, 0
+  { 0x1, "p" },
+  { 0x1, "v" },
+  { 0x2, "s" },
+  { 0x4, "z" },
+  { 0x8, "c" },
+  { 0x0, "+" },
+  { 0, 0 }
 };
 
 static void
 get_flags_operand (ptr, mode, dst)
      char **ptr;
      struct z8k_op *mode;
-     unsigned int dst;
+     unsigned int dst ATTRIBUTE_UNUSED;
 {
   char *src = *ptr;
-  int r;
   int i;
   int j;
 
@@ -508,21 +504,20 @@ struct interrupt_names {
 };
 
 struct interrupt_names intr_table[] = {
-  0x1, "nvi",
-  0x2, "vi",
-  0x3, "both",
-  0x3, "all",
-  0, 0
+  { 0x1, "nvi" },
+  { 0x2, "vi" },
+  { 0x3, "both" },
+  { 0x3, "all" },
+  { 0, 0 }
 };
 
 static void
 get_interrupt_operand (ptr, mode, dst)
      char **ptr;
      struct z8k_op *mode;
-     unsigned int dst;
+     unsigned int dst ATTRIBUTE_UNUSED;
 {
   char *src = *ptr;
-  int r;
   int i;
 
   while (*src == ' ')
@@ -555,39 +550,38 @@ struct cc_names {
 };
 
 struct cc_names table[] = {
-  0x0, "f",
-  0x1, "lt",
-  0x2, "le",
-  0x3, "ule",
-  0x4, "ov",
-  0x4, "pe",
-  0x5, "mi",
-  0x6, "eq",
-  0x6, "z",
-  0x7, "c",
-  0x7, "ult",
-  0x8, "t",
-  0x9, "ge",
-  0xa, "gt",
-  0xb, "ugt",
-  0xc, "nov",
-  0xc, "po",
-  0xd, "pl",
-  0xe, "ne",
-  0xe, "nz",
-  0xf, "nc",
-  0xf, "uge",
-  0  , 0
+  { 0x0, "f" },
+  { 0x1, "lt" },
+  { 0x2, "le" },
+  { 0x3, "ule" },
+  { 0x4, "ov" },
+  { 0x4, "pe" },
+  { 0x5, "mi" },
+  { 0x6, "eq" },
+  { 0x6, "z" },
+  { 0x7, "c" },
+  { 0x7, "ult" },
+  { 0x8, "t" },
+  { 0x9, "ge" },
+  { 0xa, "gt" },
+  { 0xb, "ugt" },
+  { 0xc, "nov" },
+  { 0xc, "po" },
+  { 0xd, "pl" },
+  { 0xe, "ne" },
+  { 0xe, "nz" },
+  { 0xf, "nc" },
+  { 0xf, "uge" },
+  { 0  ,  0 }
 };
 
 static void
 get_cc_operand (ptr, mode, dst)
      char **ptr;
      struct z8k_op *mode;
-     unsigned int dst;
+     unsigned int dst ATTRIBUTE_UNUSED;
 {
   char *src = *ptr;
-  int r;
   int i;
 
   while (*src == ' ')
@@ -616,13 +610,10 @@ static void
 get_operand (ptr, mode, dst)
      char **ptr;
      struct z8k_op *mode;
-     unsigned int dst;
+     unsigned int dst ATTRIBUTE_UNUSED;
 {
   char *src = *ptr;
   char *end;
-  unsigned int num;
-  unsigned int len;
-  unsigned int size;
 
   mode->mode = 0;
 
@@ -774,7 +765,7 @@ get_operands (opcode, op_end, operand)
 	      ptr = savptr;
 	      get_operand (&ptr, operand + 0, 0);
 	      if (ptr == 0)
-		return;
+		return NULL;
 	      if (*ptr == ',')
 		ptr++;
 	      get_ctrl_operand (&ptr, operand + 1, 1);
@@ -786,7 +777,7 @@ get_operands (opcode, op_end, operand)
 	  get_operand (&ptr, operand + 0, 0);
 	}
       if (ptr == 0)
-	return;
+	return NULL;
       if (*ptr == ',')
 	ptr++;
       get_operand (&ptr, operand + 1, 1);
@@ -838,8 +829,7 @@ get_specific (opcode, operands)
   int found = 0;
   unsigned int noperands = opcode->noperands;
 
-  unsigned int dispreg;
-  unsigned int this_index = opcode->idx;
+  int this_index = opcode->idx;
 
   while (this_index == opcode->idx && !found)
     {
@@ -848,7 +838,7 @@ get_specific (opcode, operands)
       this_try = opcode++;
       for (i = 0; i < noperands; i++)
 	{
-	  int mode = operands[i].mode;
+	  unsigned int mode = operands[i].mode;
 
 	  if ((mode & CLASS_MASK) != (this_try->arg_info[i] & CLASS_MASK))
 	    {
@@ -912,6 +902,7 @@ get_specific (opcode, operands)
     return 0;
 }
 
+#if 0 /* Not used.  */
 static void
 check_operand (operand, width, string)
      struct z8k_op *operand;
@@ -935,6 +926,7 @@ check_operand (operand, width, string)
     }
 
 }
+#endif
 
 static char buffer[20];
 
@@ -966,17 +958,15 @@ apply_fix (ptr, type, operand, size)
 {
   int n = operand->X_add_number;
 
-  operand->X_add_number = n;
   newfix ((ptr - buffer) / 2, type, operand);
-#if 1
   switch (size)
     {
-    case 8:			/* 8 nibbles == 32 bits  */
+    case 8:			/* 8 nibbles == 32 bits.  */
       *ptr++ = n >> 28;
       *ptr++ = n >> 24;
       *ptr++ = n >> 20;
       *ptr++ = n >> 16;
-    case 4:			/* 4 niblles == 16 bits  */
+    case 4:			/* 4 nibbles == 16 bits.  */
       *ptr++ = n >> 12;
       *ptr++ = n >> 8;
     case 2:
@@ -985,9 +975,7 @@ apply_fix (ptr, type, operand, size)
       *ptr++ = n >> 0;
       break;
     }
-#endif
   return ptr;
-
 }
 
 /* Now we know what sort of opcodes it is.  Let's build the bytes.  */
@@ -997,16 +985,10 @@ apply_fix (ptr, type, operand, size)
 static void
 build_bytes (this_try, operand)
      opcode_entry_type *this_try;
-     struct z8k_op *operand;
+     struct z8k_op *operand ATTRIBUTE_UNUSED;
 {
-  unsigned int i;
-
-  int length;
-  char *output;
   char *output_ptr = buffer;
-  char part;
   int c;
-  char high;
   int nib;
   int nibble;
   unsigned int *class_ptr;
@@ -1017,8 +999,7 @@ build_bytes (this_try, operand)
   memset (buffer, 20, 0);
   class_ptr = this_try->byte_info;
 
- top:
-  for (nibble = 0; c = *class_ptr++; nibble++)
+  for (nibble = 0; (c = *class_ptr++); nibble++)
     {
 
       switch (c & CLASS_MASK)
@@ -1030,7 +1011,7 @@ build_bytes (this_try, operand)
 	  /* Direct address, we don't cope with the SS mode right now.  */
 	  if (segmented_mode)
 	    {
-	      da_operand->X_add_number |= 0x80000000;
+	      /* da_operand->X_add_number |= 0x80000000;  --  Now set at relocation time.  */
 	      output_ptr = apply_fix (output_ptr, R_IMM32, da_operand, 8);
 	    }
 	  else
@@ -1113,11 +1094,11 @@ build_bytes (this_try, operand)
               output_ptr = apply_fix (output_ptr, R_CALLR, da_operand, 4);
               break;
             case ARG_DISP16:
-              output_ptr = apply_fix (output_ptr, R_REL16, da_operand, 4);
-              break;
-            default:
-	  output_ptr = apply_fix (output_ptr, R_IMM16, da_operand, 4);
-            }
+	      output_ptr = apply_fix (output_ptr, R_REL16, da_operand, 4);
+	      break;
+	    default:
+	      output_ptr = apply_fix (output_ptr, R_IMM16, da_operand, 4);
+	    }
 	  da_operand = 0;
 	  break;
 
@@ -1180,16 +1161,13 @@ void
 md_assemble (str)
      char *str;
 {
+  char c;
   char *op_start;
   char *op_end;
-  unsigned int i;
   struct z8k_op operand[3];
   opcode_entry_type *opcode;
   opcode_entry_type *prev_opcode;
 
-  char *dot = 0;
-  char c;
-
   /* Drop leading whitespace.  */
   while (*str == ' ')
     str++;
@@ -1263,21 +1241,21 @@ md_assemble (str)
 
 void
 tc_crawl_symbol_chain (headers)
-     object_headers *headers;
+     object_headers *headers ATTRIBUTE_UNUSED;
 {
   printf (_("call to tc_crawl_symbol_chain \n"));
 }
 
 symbolS *
 md_undefined_symbol (name)
-     char *name;
+     char *name ATTRIBUTE_UNUSED;
 {
   return 0;
 }
 
 void
 tc_headers_hook (headers)
-     object_headers *headers;
+     object_headers *headers ATTRIBUTE_UNUSED;
 {
   printf (_("call to tc_headers_hook \n"));
 }
@@ -1399,9 +1377,9 @@ tc_aout_fix_to_chars ()
 
 void
 md_convert_frag (headers, seg, fragP)
-     object_headers *headers;
-     segT seg;
-     fragS *fragP;
+     object_headers *headers ATTRIBUTE_UNUSED;
+     segT seg ATTRIBUTE_UNUSED;
+     fragS *fragP ATTRIBUTE_UNUSED;
 {
   printf (_("call to md_convert_frag \n"));
   abort ();
@@ -1481,8 +1459,8 @@ md_apply_fix (fixP, val)
 
 int
 md_estimate_size_before_relax (fragP, segment_type)
-     register fragS *fragP;
-     register segT segment_type;
+     register fragS *fragP ATTRIBUTE_UNUSED;
+     register segT segment_type ATTRIBUTE_UNUSED;
 {
   printf (_("call tomd_estimate_size_before_relax \n"));
   abort ();
@@ -1501,14 +1479,14 @@ md_number_to_chars (ptr, use, nbytes)
 
 long
 md_pcrel_from (fixP)
-     fixS *fixP;
+     fixS *fixP ATTRIBUTE_UNUSED;
 {
   abort ();
 }
 
 void
 tc_coff_symbol_emit_hook (s)
-     symbolS *s;
+     symbolS *s ATTRIBUTE_UNUSED;
 {
 }
 
Index: opcodes/z8k-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/z8k-dis.c,v
retrieving revision 1.5
diff -u -p -r1.5 z8k-dis.c
--- z8k-dis.c	2001/04/24 15:22:25	1.5
+++ z8k-dis.c	2001/05/30 21:19:30
@@ -142,7 +142,7 @@ int z8k_lookup_instr PARAMS ((unsigned c
 static void output_instr
   PARAMS ((instr_data_s *, unsigned long, disassemble_info *));
 static void unpack_instr PARAMS ((instr_data_s *, int, disassemble_info *));
-static void unparse_instr PARAMS ((instr_data_s *,int));
+static void unparse_instr PARAMS ((instr_data_s *, int));
 
 static int
 print_insn_z8k (addr, info, is_segmented)
@@ -334,15 +334,6 @@ unpack_instr (instr_data, is_segmented, 
 
       switch (datum_class)
 	{
-	case CLASS_X:
-	  instr_data->address = instr_nibl;
-	  break;
-	case CLASS_BA:
-	  instr_data->displacement = instr_nibl;
-	  break;
-	case CLASS_BX:
-	  instr_data->arg_reg[datum_value] = instr_nibl;
-	  break;
 	case CLASS_DISP:
 	  switch (datum_value)
 	    {
@@ -412,12 +403,6 @@ unpack_instr (instr_data, is_segmented, 
 	case CLASS_CC:
 	  instr_data->cond_code = instr_nibl;
 	  break;
-#if 0
-	case CLASS_CTRL:
-	  instr_data->ctrl_code = instr_nibl;
-	  break;
-#endif
-	case CLASS_DA:
 	case CLASS_ADDRESS:
 	  if (is_segmented)
 	    {
@@ -465,38 +450,21 @@ unpack_instr (instr_data, is_segmented, 
 	case CLASS_BIT:
 	  instr_data->ctrl_code = instr_nibl & 0x7;
 	  break;
-	case CLASS_IR:
-	  instr_data->arg_reg[datum_value] = instr_nibl;
-	  break;
 	case CLASS_FLAGS:
 	  instr_data->flags = instr_nibl;
 	  break;
 	case CLASS_REG:
 	  instr_data->arg_reg[datum_value] = instr_nibl;
 	  break;
-	case CLASS_REG_BYTE:
-	  instr_data->arg_reg[datum_value] = instr_nibl;
-	  break;
-	case CLASS_REG_WORD:
-	  instr_data->arg_reg[datum_value] = instr_nibl;
-	  break;
-	case CLASS_REG_QUAD:
-	  instr_data->arg_reg[datum_value] = instr_nibl;
-	  break;
-	case CLASS_REG_LONG:
-	  instr_data->arg_reg[datum_value] = instr_nibl;
-	  break;
 	case CLASS_REGN0:
 	  instr_data->arg_reg[datum_value] = instr_nibl;
 	  break;
-	case CLASS_PR:
-	  instr_data->arg_reg[datum_value] = instr_nibl;
-	  break;
         case CLASS_DISP8:
 	  instr_data->displacement = instr_data->insn_start + 2  + (signed char)instr_byte * 2;
 	  nibl_count += 1;
           break;
 	default:
+          abort ();
 	  break;
 	}
 
@@ -605,6 +573,7 @@ unparse_instr (instr_data,is_segmented)
 	  strcat (out_str, tmp_str);
 	  break;
 	default:
+          abort ();
 	  break;
 	}
     }
---------------------------


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