optabs.c (init_optabs): Initialize fixtab...
authorGreg McGary <greg@mcgary.org>
Thu, 24 Aug 2000 20:31:35 +0000 (20:31 +0000)
committerGreg McGary <gkm@gcc.gnu.org>
Thu, 24 Aug 2000 20:31:35 +0000 (20:31 +0000)
* optabs.c (init_optabs): Initialize fixtab, fixtrunctab, floattab,
and extendtab within their proper array boundaries.
* emit-rtl.c (init_emit_once): Pass `const_tiny_rtx' with bounds
for the entire array.

* config/arm/arm.c (arm_override_options): Use ARRAY_SIZE.
* config/alpha/alpha.c (alpha_lookup_xfloating_lib_func): Likewise.
* config/avr/avr.c (order_regs_for_local_alloc): Likewise.
* config/fr30/fr30.c (fr30_print_operand): Likewise.
* config/i386/dgux.c (output_options): Likewise.
* config/i386/dgux.h (ASM_FILE_START): Likewise.
* config/m88k/m88k.c (output_options): Likewise.
* config/m88k/m88k.h (ASM_FILE_START): Likewise.
* config/mcore/mcore.c (mcore_output_inline_const_forced,
layout_mcore_frame, handle_structs_in_regs): Likewise.
* config/mips/mips.c (output_block_move): Likewise.
* config/rs6000/rs6000.c (rs6000_override_options,
rs6000_file_start): Likewise.
* config/sparc/sparc.c (sparc_add_gc_roots): Likewise.
* fixinc/fixfixes.c (FIX_TABLE_CT): Likewise.
* fixinc/fixtests.c (TEST_TABLE_CT): Likewise.
* builtins.c (expand_builtin_setjmp): Likewise.
* expr.c (safe_from_p): Likewise.
* flow.c (life_analysis): Likewise.
* fold-const.c (size_int_type_wide): Likewise.
* gcc.c (translate_options, init_spec, set_spec, main): Likewise.
* genattrtab.c (make_length_attrs): Likewise.
* genopinit.c (gen_insn): Likewise.
* genrecog.c (NUM_KNOWN_PREDS, NUM_SPECIAL_MODE_PREDS): Likewise.
* global.c (global_alloc): Likewise.
* local-alloc.c (find_free_reg): Likewise.
* mips-tdump.c (print_symbol): Likewise.
* mips-tfile.c (parse_def, parse_input): Likewise.
* reload1.c (NUM_ELIMINABLE_REGS): Likewise.
* stmt.c (expand_nl_goto_receiver): Likewise.
* stor-layout.c (set_sizetype): Likewise.
* varasm.c (decode_reg_name): Likewise.
* toplev.c (decode_f_option, decode_W_option,
set_target_switch, print_switch_values): Likewise.
(NUM_ELEM): Remove macro.
(display_help, main): s/NUM_ELEM/ARRAY_SIZE/

From-SVN: r35949

33 files changed:
gcc/ChangeLog
gcc/builtins.c
gcc/config/alpha/alpha.c
gcc/config/arm/arm.c
gcc/config/fr30/fr30.c
gcc/config/i386/dgux.c
gcc/config/i386/dgux.h
gcc/config/m88k/m88k.c
gcc/config/m88k/m88k.h
gcc/config/mcore/mcore.c
gcc/config/mips/mips.c
gcc/config/rs6000/rs6000.c
gcc/config/sparc/sparc.c
gcc/emit-rtl.c
gcc/expr.c
gcc/fixinc/fixfixes.c
gcc/fixinc/fixtests.c
gcc/flow.c
gcc/fold-const.c
gcc/gcc.c
gcc/genattrtab.c
gcc/genopinit.c
gcc/genrecog.c
gcc/global.c
gcc/local-alloc.c
gcc/mips-tdump.c
gcc/mips-tfile.c
gcc/optabs.c
gcc/reload1.c
gcc/stmt.c
gcc/stor-layout.c
gcc/toplev.c
gcc/varasm.c

index b76a4fb..650bb36 100644 (file)
@@ -1,5 +1,49 @@
 2000-08-24  Greg McGary  <greg@mcgary.org>
 
+       * optabs.c (init_optabs): Initialize fixtab, fixtrunctab, floattab,
+       and extendtab within their proper array boundaries.
+       * emit-rtl.c (init_emit_once): Pass `const_tiny_rtx' with bounds
+       for the entire array.
+
+       * config/arm/arm.c (arm_override_options): Use ARRAY_SIZE.
+       * config/alpha/alpha.c (alpha_lookup_xfloating_lib_func): Likewise.
+       * config/avr/avr.c (order_regs_for_local_alloc): Likewise.
+       * config/fr30/fr30.c (fr30_print_operand): Likewise.
+       * config/i386/dgux.c (output_options): Likewise.
+       * config/i386/dgux.h (ASM_FILE_START): Likewise.
+       * config/m88k/m88k.c (output_options): Likewise.
+       * config/m88k/m88k.h (ASM_FILE_START): Likewise.
+       * config/mcore/mcore.c (mcore_output_inline_const_forced,
+       layout_mcore_frame, handle_structs_in_regs): Likewise.
+       * config/mips/mips.c (output_block_move): Likewise.
+       * config/rs6000/rs6000.c (rs6000_override_options,
+       rs6000_file_start): Likewise.
+       * config/sparc/sparc.c (sparc_add_gc_roots): Likewise.
+       * fixinc/fixfixes.c (FIX_TABLE_CT): Likewise.
+       * fixinc/fixtests.c (TEST_TABLE_CT): Likewise.
+       * builtins.c (expand_builtin_setjmp): Likewise.
+       * expr.c (safe_from_p): Likewise.
+       * flow.c (life_analysis): Likewise.
+       * fold-const.c (size_int_type_wide): Likewise.
+       * gcc.c (translate_options, init_spec, set_spec, main): Likewise.
+       * genattrtab.c (make_length_attrs): Likewise.
+       * genopinit.c (gen_insn): Likewise.
+       * genrecog.c (NUM_KNOWN_PREDS, NUM_SPECIAL_MODE_PREDS): Likewise.
+       * global.c (global_alloc): Likewise.
+       * local-alloc.c (find_free_reg): Likewise.
+       * mips-tdump.c (print_symbol): Likewise.
+       * mips-tfile.c (parse_def, parse_input): Likewise.
+       * reload1.c (NUM_ELIMINABLE_REGS): Likewise.
+       * stmt.c (expand_nl_goto_receiver): Likewise.
+       * stor-layout.c (set_sizetype): Likewise.
+       * varasm.c (decode_reg_name): Likewise.
+       * toplev.c (decode_f_option, decode_W_option,
+       set_target_switch, print_switch_values): Likewise.
+       (NUM_ELEM): Remove macro.
+       (display_help, main): s/NUM_ELEM/ARRAY_SIZE/
+
+2000-08-24  Greg McGary  <greg@mcgary.org>
+
        * tree.h (enum tree_index): New member `TI_MAIN_IDENTIFIER'.
        (MAIN_NAME_P, main_identifier_node): New macros.
        * c-common.c (c_common_nodes_and_builtins): Init main_identifier_node.
index d7ce1e7..4f3f7a9 100644 (file)
@@ -417,12 +417,12 @@ expand_builtin_setjmp (buf_addr, target, first_label, next_label)
       size_t i;
       static struct elims {int from, to;} elim_regs[] = ELIMINABLE_REGS;
 
-      for (i = 0; i < sizeof elim_regs / sizeof elim_regs[0]; i++)
+      for (i = 0; i < ARRAY_SIZE (elim_regs); i++)
        if (elim_regs[i].from == ARG_POINTER_REGNUM
            && elim_regs[i].to == HARD_FRAME_POINTER_REGNUM)
          break;
 
-      if (i == sizeof elim_regs / sizeof elim_regs [0])
+      if (i == ARRAY_SIZE (elim_regs))
 #endif
        {
          /* Now restore our arg pointer from the address at which it
index 99535ab..ef6845b 100644 (file)
@@ -1988,7 +1988,7 @@ alpha_lookup_xfloating_lib_func (code)
     };
 
   const struct xfloating_op *ops;
-  const long n = sizeof(osf_xfloating_ops) / sizeof(osf_xfloating_ops[0]);
+  const long n = ARRAY_SIZE (osf_xfloating_ops);
   long i;
 
   /* How irritating.  Nothing to key off for the table.  Hardcode
index 4c7679a..6abe732 100644 (file)
@@ -317,7 +317,7 @@ arm_override_options ()
   unsigned i;
   
   /* Set up the flags based on the cpu/architecture selected by the user.  */
-  for (i = sizeof (arm_select) / sizeof (arm_select[0]); i--;)
+  for (i = ARRAY_SIZE (arm_select); i--;)
     {
       struct arm_cpu_select * ptr = arm_select + i;
       
index 68bae05..c2ee005 100644 (file)
@@ -575,7 +575,7 @@ fr30_print_operand (file, x, code)
       switch (GET_CODE (x0))
        {
        case REG:
-         if ((unsigned) REGNO (x0) >= (sizeof (reg_names) / sizeof (reg_names[0])))
+         if ((unsigned) REGNO (x0) >= ARRAY_SIZE (reg_names))
            abort ();
          fprintf (file, "@%s", reg_names [REGNO (x0)]);
          break;
index 915719d..069a7ac 100644 (file)
@@ -1,5 +1,5 @@
 /* Subroutines for GNU compiler for Intel 80x86 running DG/ux
-   Copyright (C) 1993, 1995, 1997, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1997, 1999, 2000 Free Software Foundation, Inc.
    Currently maintained by (gcc@dg-rtp.dg.com)
 
 This file is part of GNU CC.
@@ -90,7 +90,7 @@ output_options (file, f_options, f_len, W_options, W_len,
       pos = output_option (file, sep, "-W", W_options[j].string,
                           indent, pos, max);
 
-  for (j = 0; j < sizeof m_options / sizeof m_options[0]; j++)
+  for (j = 0; j < ARRAY_SIZE (m_options); j++)
     if (m_options[j].name[0] != '\0'
        && m_options[j].value > 0
        && ((m_options[j].value & target_flags)
index 5b0ca5f..10982c5 100644 (file)
@@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA.  */
 #include "i386/sysv4.h"
 
 #ifndef VERSION_INFO2
-#define VERSION_INFO2   "$Revision: 1.9 $"
+#define VERSION_INFO2   "$Revision: 1.10 $"
 #endif
 
 #ifndef VERSION_STRING
@@ -85,8 +85,8 @@ Boston, MA 02111-1307, USA.  */
 /* Override svr[34].h.  */
 #undef ASM_FILE_START
 #define ASM_FILE_START(FILE) \
-  output_file_start (FILE, f_options, sizeof f_options / sizeof f_options[0], \
-                    W_options, sizeof W_options / sizeof W_options[0])
+  output_file_start (FILE, f_options, ARRAY_SIZE (f_options), \
+                    W_options, ARRAY_SIZE (W_options))
 
 /* ix86 abi specified type for wchar_t */
 
index ab79bf0..86c92e7 100644 (file)
@@ -1544,7 +1544,7 @@ output_options (file, f_options, f_len, W_options, W_len,
       pos = output_option (file, sep, "-W", W_options[j].string,
                           indent, pos, max);
 
-  for (j = 0; j < (long) (sizeof m_options / sizeof m_options[0]); j++)
+  for (j = 0; j < (long) ARRAY_SIZE (m_options); j++)
     if (m_options[j].name[0] != '\0'
        && m_options[j].value > 0
        && ((m_options[j].value & target_flags)
index ca2d0f7..1412ff2 100644 (file)
@@ -1818,9 +1818,9 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS,
 #define ASM_FILE_START(FILE) \
   output_file_start (FILE, \
        (struct m88k_lang_independent_options *) f_options, \
-       sizeof f_options / sizeof f_options[0], \
+       ARRAY_SIZE (f_options), \
        (struct m88k_lang_independent_options *) W_options, \
-       sizeof W_options / sizeof W_options[0])
+       ARRAY_SIZE (W_options))
 
 #undef ASM_FILE_END
 
index 4622ade..8dbcb2b 100644 (file)
@@ -1158,7 +1158,7 @@ mcore_output_inline_const_forced (insn, operands, mode)
   if (mcore_const_ok_for_inline (value))
     return output_inline_const (SImode, operands);
 
-  for (i = 0; (unsigned) i < sizeof (part) / sizeof (part[0]); i++)
+  for (i = 0; (unsigned) i < ARRAY_SIZE (part); i++)
     {
       part[i].shift = 0;
       part[i].low = (value & 0x1F);
@@ -1990,7 +1990,7 @@ layout_mcore_frame (infp)
      (1) run fast,
      (2) reduce instruction space, or
      (3) reduce stack space.  */
-  for (i = 0; i < sizeof (infp->growth) / sizeof (infp->growth[0]); i++)
+  for (i = 0; i < ARRAY_SIZE (infp->growth); i++)
     infp->growth[i] = 0;
 
   regarg      = infp->reg_size + infp->arg_size;
@@ -3139,7 +3139,7 @@ handle_structs_in_regs (mode, type, reg)
         }
 
       /* We assume here that NPARM_REGS == 6.  The assert checks this.  */
-      assert (sizeof (arg_regs) / sizeof (arg_regs[0]) == 6);
+      assert (ARRAY_SIZE (arg_regs) == 6);
       rtvec = gen_rtvec (nregs, arg_regs[0], arg_regs[1], arg_regs[2],
                          arg_regs[3], arg_regs[4], arg_regs[5]);
       
index 629fac1..f059ddd 100644 (file)
@@ -3417,10 +3417,7 @@ output_block_move (insn, operands, num_regs, move_type)
   /* ??? Detect a bug in GCC, where it can give us a register
      the same as one of the addressing registers and reduce
      the number of registers available.  */
-  for (i = 4;
-       i < last_operand
-       && safe_regs < (int)(sizeof(xoperands) / sizeof(xoperands[0]));
-       i++)
+  for (i = 4; i < last_operand && safe_regs < (int) ARRAY_SIZE (xoperands); i++)
     if (! reg_mentioned_p (operands[i], operands[0])
        && ! reg_mentioned_p (operands[i], operands[1]))
       xoperands[safe_regs++] = operands[i];
@@ -3515,8 +3512,8 @@ output_block_move (insn, operands, num_regs, move_type)
        }
     }
 
-  if (num_regs > (int)(sizeof (load_store) / sizeof (load_store[0])))
-    num_regs = sizeof (load_store) / sizeof (load_store[0]);
+  if (num_regs > (int) ARRAY_SIZE (load_store))
+    num_regs = ARRAY_SIZE (load_store);
 
   else if (num_regs < 1)
     abort_with_insn (insn,
index 9e4c11f..18106cb 100644 (file)
@@ -293,7 +293,7 @@ rs6000_override_options (default_cpu)
   rs6000_select[0].string = default_cpu;
   rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
 
-  for (i = 0; i < sizeof (rs6000_select) / sizeof (rs6000_select[0]); i++)
+  for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
     {
       ptr = &rs6000_select[i];
       if (ptr->string != (char *)0 && ptr->string[0] != '\0')
@@ -433,7 +433,7 @@ rs6000_file_start (file, default_cpu)
       sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START);
       rs6000_select[0].string = default_cpu;
 
-      for (i = 0; i < sizeof (rs6000_select) / sizeof (rs6000_select[0]); i++)
+      for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
        {
          ptr = &rs6000_select[i];
          if (ptr->string != (char *)0 && ptr->string[0] != '\0')
index f6a354d..82e9a74 100644 (file)
@@ -8569,8 +8569,6 @@ sparc_add_gc_roots ()
   ggc_add_rtx_root (&get_pc_symbol, 1);
   ggc_add_rtx_root (&sparc_addr_diff_list, 1);
   ggc_add_rtx_root (&sparc_addr_list, 1);
-  ggc_add_root (ultra_pipe_hist, 
-               sizeof (ultra_pipe_hist) / sizeof (ultra_pipe_hist[0]),
-               sizeof (ultra_pipe_hist[0]),
-               &mark_ultrasparc_pipeline_state);
+  ggc_add_root (ultra_pipe_hist, ARRAY_SIZE (ultra_pipe_hist),
+               sizeof (ultra_pipe_hist[0]), &mark_ultrasparc_pipeline_state);
 }
index e219d5a..632c4e2 100644 (file)
@@ -4180,7 +4180,10 @@ init_emit_once (line_numbers)
     if (GET_MODE_CLASS (mode) == MODE_CC)
       const_tiny_rtx[0][(int) mode] = const0_rtx;
 
-  ggc_add_rtx_root (&const_tiny_rtx[0][0], sizeof(const_tiny_rtx)/sizeof(rtx));
+  /* For bounded pointers, `&const_tiny_rtx[0][0]' is not the same as
+     `(rtx *) const_tiny_rtx'.  The former has bounds that only cover
+     `const_tiny_rtx[0]', whereas the latter has bounds that cover all.  */
+  ggc_add_rtx_root ((rtx *) const_tiny_rtx, sizeof const_tiny_rtx / sizeof (rtx));
   ggc_add_rtx_root (&const_true_rtx, 1);
 
 #ifdef RETURN_ADDRESS_POINTER_REGNUM
index 2592a58..a5c306f 100644 (file)
@@ -5404,7 +5404,7 @@ safe_from_p (x, exp, top_p)
       int rtn;
 
       save_expr_count = 0;
-      save_expr_size = sizeof (save_expr_trees) / sizeof (save_expr_trees[0]);
+      save_expr_size = ARRAY_SIZE (save_expr_trees);
       save_expr_rewritten = &save_expr_trees[0];
 
       rtn = safe_from_p (x, exp, 1);
index 4cb3e58..e419126 100644 (file)
@@ -706,7 +706,7 @@ apply_fix( p_fixd, filname )
 #define _FT_(n,p) { n, p },
   static fix_entry_t fix_table[] = { FIXUP_TABLE { NULL, NULL }};
 #undef _FT_
-#define FIX_TABLE_CT ((sizeof(fix_table)/sizeof(fix_table[0]))-1)
+#define FIX_TABLE_CT (ARRAY_SIZE (fix_table)-1)
 
   tCC* fixname = p_fixd->patch_args[0];
   char* buf;
index 0da04b5..3b0c798 100644 (file)
@@ -129,7 +129,7 @@ run_test( tname, fname, text )
 #define _FT_(n,p) { n, p },
   static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }};
 #undef _FT_
-#define TEST_TABLE_CT ((sizeof(test_table)/sizeof(test_table[0]))-1)
+#define TEST_TABLE_CT (ARRAY_SIZE (test_table)-1)
 
   int ct = TEST_TABLE_CT;
   test_entry_t* pte = test_table;
index 1291ac4..c242490 100644 (file)
@@ -2624,7 +2624,7 @@ life_analysis (f, file, flags)
   CLEAR_HARD_REG_SET (elim_reg_set);
 
 #ifdef ELIMINABLE_REGS
-  for (i = 0; i < (int) (sizeof eliminables / sizeof eliminables[0]); i++)
+  for (i = 0; i < (int) ARRAY_SIZE (eliminables); i++)
     SET_HARD_REG_BIT (elim_reg_set, eliminables[i].from);
 #else
   SET_HARD_REG_BIT (elim_reg_set, FRAME_POINTER_REGNUM);
index 88ee674..ecc7c32 100644 (file)
@@ -1870,7 +1870,7 @@ size_int_type_wide (number, type)
   /* If this is a positive number that fits in the table we use to hold
      cached entries, see if it is already in the table and put it there
      if not.  */
-  if (number >= 0 && number < (int) (sizeof size_table / sizeof size_table[0]))
+  if (number >= 0 && number < (int) ARRAY_SIZE (size_table))
     {
       if (size_table[number] != 0)
        for (t = size_table[number]; t != 0; t = TREE_CHAIN (t))
index 243609d..4aa4f94 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -880,7 +880,7 @@ translate_options (argcp, argvp)
        {
          size_t j;
          /* Find a mapping that applies to this option.  */
-         for (j = 0; j < sizeof (option_map) / sizeof (option_map[0]); j++)
+         for (j = 0; j < ARRAY_SIZE (option_map); j++)
            {
              size_t optlen = strlen (option_map[j].name);
              size_t arglen = strlen (argv[i]);
@@ -897,9 +897,7 @@ translate_options (argcp, argvp)
                  if (arglen < optlen)
                    {
                      size_t k;
-                     for (k = j + 1;
-                          k < sizeof (option_map) / sizeof (option_map[0]);
-                          k++)
+                     for (k = j + 1; k < ARRAY_SIZE (option_map); k++)
                        if (strlen (option_map[k].name) >= arglen
                            && !strncmp (argv[i], option_map[k].name, arglen))
                          {
@@ -907,7 +905,7 @@ translate_options (argcp, argvp)
                            break;
                          }
 
-                     if (k != sizeof (option_map) / sizeof (option_map[0]))
+                     if (k != ARRAY_SIZE (option_map))
                        break;
                    }
 
@@ -1130,10 +1128,9 @@ init_spec ()
 
 #ifdef EXTRA_SPECS
   extra_specs = (struct spec_list *)
-    xcalloc (sizeof(struct spec_list),
-            (sizeof(extra_specs_1)/sizeof(extra_specs_1[0])));
+    xcalloc (sizeof (struct spec_list), ARRAY_SIZE (extra_specs_1));
   
-  for (i = (sizeof(extra_specs_1) / sizeof(extra_specs_1[0])) - 1; i >= 0; i--)
+  for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--)
     {
       sl = &extra_specs[i];
       sl->name = extra_specs_1[i].name;
@@ -1145,7 +1142,7 @@ init_spec ()
     }
 #endif
 
-  for (i = (sizeof (static_specs) / sizeof (static_specs[0])) - 1; i >= 0; i--)
+  for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)
     {
       sl = &static_specs[i];
       sl->next = next;
@@ -1174,8 +1171,7 @@ set_spec (name, spec)
   if (!specs)
     {
       struct spec_list *next = (struct spec_list *)0;
-      for (i = (sizeof (static_specs) / sizeof (static_specs[0])) - 1;
-          i >= 0; i--)
+      for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)
        {
          sl = &static_specs[i];
          sl->next = next;
@@ -5170,9 +5166,7 @@ main (argc, argv)
     multilib_exclusions = obstack_finish (&multilib_obstack);
     
     need_space = FALSE;
-    for (i = 0;
-        i < sizeof (multilib_defaults_raw) / sizeof (multilib_defaults_raw[0]);
-        i++)
+    for (i = 0; i < ARRAY_SIZE (multilib_defaults_raw); i++)
       {
        if (need_space)
          obstack_1grow (&multilib_obstack, ' ');
index aedd1d0..a6a9a90 100644 (file)
@@ -2491,7 +2491,7 @@ make_length_attrs ()
   length_attr->is_special = 1;
 
   /* Make each new attribute, in turn.  */
-  for (i = 0; i < sizeof new_names / sizeof new_names[0]; i++)
+  for (i = 0; i < ARRAY_SIZE (new_names); i++)
     {
       make_internal_attr (new_names[i],
                          substitute_address (length_attr->default_val->value,
index dcacc9f..993c347 100644 (file)
@@ -134,7 +134,7 @@ gen_insn (insn)
   /* See if NAME matches one of the patterns we have for the optabs we know
      about.  */
 
-  for (pindex = 0; pindex < sizeof optabs / sizeof optabs[0]; pindex++)
+  for (pindex = 0; pindex < ARRAY_SIZE (optabs); pindex++)
     {
       int force_float = 0, force_int = 0;
       int force_consec = 0;
@@ -221,7 +221,7 @@ gen_insn (insn)
        break;
     }
 
-  if (pindex == sizeof optabs / sizeof optabs[0])
+  if (pindex == ARRAY_SIZE (optabs))
     return;
 
   /* We found a match.  If this pattern is only conditionally present,
index 3e665dc..e506f8d 100644 (file)
@@ -213,7 +213,7 @@ static struct pred_table
                                LABEL_REF, SUBREG, REG, MEM}}
 };
 
-#define NUM_KNOWN_PREDS (sizeof preds / sizeof preds[0])
+#define NUM_KNOWN_PREDS ARRAY_SIZE (preds)
 
 static const char * special_mode_pred_table[] = {
 #ifdef SPECIAL_MODE_PREDICATES
@@ -222,8 +222,7 @@ static const char * special_mode_pred_table[] = {
   "pmode_register_operand"
 };
 
-#define NUM_SPECIAL_MODE_PREDS \
-  (sizeof (special_mode_pred_table) / sizeof (special_mode_pred_table[0]))
+#define NUM_SPECIAL_MODE_PREDS ARRAY_SIZE (special_mode_pred_table)
 
 static struct decision *new_decision
   PARAMS ((const char *, struct decision_head *));
index 62e80af..7f426df 100644 (file)
@@ -342,7 +342,7 @@ global_alloc (file)
   /* Build the regset of all eliminable registers and show we can't use those
      that we already know won't be eliminated.  */
 #ifdef ELIMINABLE_REGS
-  for (i = 0; i < sizeof eliminables / sizeof eliminables[0]; i++)
+  for (i = 0; i < ARRAY_SIZE (eliminables); i++)
     {
       SET_HARD_REG_BIT (eliminable_regset, eliminables[i].from);
 
index 02e9694..f1ac07c 100644 (file)
@@ -1981,7 +1981,7 @@ find_free_reg (class, mode, qtyno, accept_call_clobbered, just_try_suggested,
 
      This is true of any register that can be eliminated.  */
 #ifdef ELIMINABLE_REGS
-  for (i = 0; i < (int) (sizeof eliminables / sizeof eliminables[0]); i++)
+  for (i = 0; i < (int) ARRAY_SIZE (eliminables); i++)
     SET_HARD_REG_BIT (used, eliminables[i].from);
 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
   /* If FRAME_POINTER_REGNUM is not a real register, then protect the one
index f771549..68359ae 100644 (file)
@@ -1033,7 +1033,7 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp)
 
   if (MIPS_IS_STAB(sym_ptr))
     {
-      register int i = sizeof(stab_names) / sizeof(stab_names[0]);
+      register int i = ARRAY_SIZE (stab_names);
       const char *stab_name = "stab";
       short code = MIPS_UNMARK_STAB(sym_ptr->index);
       while (--i >= 0)
index ee0afe5..ff24ce8 100644 (file)
@@ -3283,7 +3283,7 @@ parse_def (name_start)
 
       if (diff)
        {
-         for (j = (sizeof (t.sizes) / sizeof (t.sizes[0])) - 1; j >= 0; j--)
+         for (j = ARRAY_SIZE (t.sizes) - 1; j >= 0; j--)
            t.sizes[ j ] = ((j-diff) >= 0) ? t.sizes[ j-diff ] : 0;
 
          t.num_sizes = i + 1;
@@ -3882,7 +3882,7 @@ parse_input __proto((void))
        p++;
 
       /* See if it's a directive we handle.  If so, dispatch handler.  */
-      for (i = 0; i < sizeof (pseudo_ops) / sizeof (pseudo_ops[0]); i++)
+      for (i = 0; i < ARRAY_SIZE (pseudo_ops); i++)
        if (memcmp (p, pseudo_ops[i].name, pseudo_ops[i].len) == 0
            && ISSPACE ((unsigned char)(p[pseudo_ops[i].len])))
          {
index 6530d83..0a64fad 100644 (file)
@@ -4484,34 +4484,29 @@ mark_optab (arg)
 void
 init_optabs ()
 {
-  int i;
-#ifdef FIXUNS_TRUNC_LIKE_FIX_TRUNC
-  int j;
-#endif
-
-  enum insn_code *p;
+  unsigned int i, j, k;
 
   /* Start by initializing all tables to contain CODE_FOR_nothing.  */
 
-  for (p = fixtab[0][0];
-       p < fixtab[0][0] + sizeof fixtab / sizeof (fixtab[0][0][0]); 
-       p++)
-    *p = CODE_FOR_nothing;
-
-  for (p = fixtrunctab[0][0];
-       p < fixtrunctab[0][0] + sizeof fixtrunctab / sizeof (fixtrunctab[0][0][0]); 
-       p++)
-    *p = CODE_FOR_nothing;
-
-  for (p = floattab[0][0];
-       p < floattab[0][0] + sizeof floattab / sizeof (floattab[0][0][0]); 
-       p++)
-    *p = CODE_FOR_nothing;
-
-  for (p = extendtab[0][0];
-       p < extendtab[0][0] + sizeof extendtab / sizeof extendtab[0][0][0];
-       p++)
-    *p = CODE_FOR_nothing;
+  for (i = 0; i < ARRAY_SIZE (fixtab); i++)
+    for (j = 0; j < ARRAY_SIZE (fixtab[0]); j++)
+      for (k = 0; k < ARRAY_SIZE (fixtab[0][0]); k++)
+       fixtab[i][j][k] = CODE_FOR_nothing;
+
+  for (i = 0; i < ARRAY_SIZE (fixtrunctab); i++)
+    for (j = 0; j < ARRAY_SIZE (fixtrunctab[0]); j++)
+      for (k = 0; k < ARRAY_SIZE (fixtrunctab[0][0]); k++)
+       fixtrunctab[i][j][k] = CODE_FOR_nothing;
+
+  for (i = 0; i < ARRAY_SIZE (floattab); i++)
+    for (j = 0; j < ARRAY_SIZE (floattab[0]); j++)
+      for (k = 0; k < ARRAY_SIZE (floattab[0][0]); k++)
+       floattab[i][j][k] = CODE_FOR_nothing;
+
+  for (i = 0; i < ARRAY_SIZE (extendtab); i++)
+    for (j = 0; j < ARRAY_SIZE (extendtab[0]); j++)
+      for (k = 0; k < ARRAY_SIZE (extendtab[0][0]); k++)
+       extendtab[i][j][k] = CODE_FOR_nothing;
 
   for (i = 0; i < NUM_RTX_CODE; i++)
     setcc_gen_code[i] = CODE_FOR_nothing;
index 5639d2f..8d7caff 100644 (file)
@@ -343,7 +343,7 @@ static struct elim_table_1
   {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}};
 #endif
 
-#define NUM_ELIMINABLE_REGS (sizeof reg_eliminate_1/sizeof reg_eliminate_1[0])
+#define NUM_ELIMINABLE_REGS ARRAY_SIZE (reg_eliminate_1)
 
 /* Record the number of pending eliminations that have an offset not equal
    to their initial offset.  If non-zero, we use a new copy of each
index 7ea077d..2d7566e 100644 (file)
@@ -3395,12 +3395,12 @@ expand_nl_goto_receiver ()
       static struct elims {int from, to;} elim_regs[] = ELIMINABLE_REGS;
       size_t i;
 
-      for (i = 0; i < sizeof elim_regs / sizeof elim_regs[0]; i++)
+      for (i = 0; i < ARRAY_SIZE (elim_regs); i++)
        if (elim_regs[i].from == ARG_POINTER_REGNUM
            && elim_regs[i].to == HARD_FRAME_POINTER_REGNUM)
          break;
 
-      if (i == sizeof elim_regs / sizeof elim_regs [0])
+      if (i == ARRAY_SIZE (elim_regs))
 #endif
        {
          /* Now restore our arg pointer from the address at which it
index 294f2d4..43ae6f2 100644 (file)
@@ -1657,7 +1657,7 @@ set_sizetype (type)
   TYPE_NAME (bitsizetype) = get_identifier ("bit_size_type");
 
   /* Show is a sizetype, is a main type, and has no pointers to it.  */
-  for (i = 0; i < sizeof sizetype_tab / sizeof sizetype_tab[0]; i++)
+  for (i = 0; i < ARRAY_SIZE (sizetype_tab); i++)
     {
       TYPE_IS_SIZETYPE (sizetype_tab[i]) = 1;
       TYPE_MAIN_VARIANT (sizetype_tab[i]) = sizetype_tab[i];
index 55ff15d..2a1b5a7 100644 (file)
@@ -1119,8 +1119,6 @@ lang_independent_options f_options[] =
   "Convert floating point constant to single precision constant"}
 };
 
-#define NUM_ELEM(a)  (sizeof (a) / sizeof ((a)[0]))
-
 /* Table of language-specific options.  */
 
 static struct lang_opt
@@ -3730,7 +3728,7 @@ display_help ()
   printf (_("  -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line.  0 suppresses line-wrapping\n"));
   printf (_("  -fdiagnostics-show-location=[once | never] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n"));
 
-  for (i = NUM_ELEM (f_options); i--;)
+  for (i = ARRAY_SIZE (f_options); i--;)
     {
       const char *description = f_options[i].description;
 
@@ -3746,7 +3744,7 @@ display_help ()
   printf (_("  -w                      Suppress warnings\n"));
   printf (_("  -W                      Enable extra warnings\n"));
 
-  for (i = NUM_ELEM (W_options); i--;)
+  for (i = ARRAY_SIZE (W_options); i--;)
     {
       const char *description = W_options[i].description;
 
@@ -3770,7 +3768,7 @@ display_help ()
   -G <number>             Put global and static data smaller than <number>\n\
                           bytes into a special section (on some targets)\n"));
 
-  for (i = NUM_ELEM (debug_args); i--;)
+  for (i = ARRAY_SIZE (debug_args); i--;)
     {
       if (debug_args[i].description != NULL)
        printf ("  -g%-21s %s\n",
@@ -3798,11 +3796,11 @@ display_help ()
      that the description string is in fact the name of a language, whose
      language specific options are to follow.  */
 
-  if (NUM_ELEM (documented_lang_options) > 1)
+  if (ARRAY_SIZE (documented_lang_options) > 1)
     {
       printf (_("\nLanguage specific options:\n"));
 
-      for (i = 0; i < NUM_ELEM (documented_lang_options); i++)
+      for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
        {
          const char *description = documented_lang_options[i].description;
          const char *option      = documented_lang_options[i].option;
@@ -3837,9 +3835,9 @@ display_help ()
     printf (_("\nThere are undocumented %s specific options as well.\n"),
            lang);
 
-  if (NUM_ELEM (target_switches) > 1
+  if (ARRAY_SIZE (target_switches) > 1
 #ifdef TARGET_OPTIONS
-      || NUM_ELEM (target_options) > 1
+      || ARRAY_SIZE (target_options) > 1
 #endif
       )
     {
@@ -3849,7 +3847,7 @@ display_help ()
 
       printf (_("\nTarget specific options:\n"));
 
-      for (i = NUM_ELEM (target_switches); i--;)
+      for (i = ARRAY_SIZE (target_switches); i--;)
        {
          const char *option      = target_switches[i].name;
          const char *description = target_switches[i].description;
@@ -3868,7 +3866,7 @@ display_help ()
        }
 
 #ifdef TARGET_OPTIONS
-      for (i = NUM_ELEM (target_options); i--;)
+      for (i = ARRAY_SIZE (target_options); i--;)
        {
          const char *option      = target_options[i].prefix;
          const char *description = target_options[i].description;
@@ -3960,7 +3958,7 @@ decode_f_option (arg)
   const char *option_value = NULL;
 
   /* Search for the option in the table of binary f options.  */
-  for (j = sizeof (f_options) / sizeof (f_options[0]); j--;)
+  for (j = ARRAY_SIZE (f_options); j--;)
     {
       if (!strcmp (arg, f_options[j].string))
        {
@@ -4059,7 +4057,7 @@ decode_W_option (arg)
 
   /* Search for the option in the table of binary W options.  */
 
-  for (j = sizeof (W_options) / sizeof (W_options[0]); j--;)
+  for (j = ARRAY_SIZE (W_options); j--;)
     {
       if (!strcmp (arg, W_options[j].string))
        {
@@ -4622,7 +4620,7 @@ main (argc, argv)
             possibility here.  If we do find a match, then if extra_warnings
             is set we generate a warning message, otherwise we will just
             ignore the option.  */
-         for (j = 0; j < NUM_ELEM (documented_lang_options); j++)
+         for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
            {
              option = documented_lang_options[j].option;
 
@@ -4632,7 +4630,7 @@ main (argc, argv)
                break;
            }
 
-         if (j != NUM_ELEM (documented_lang_options))
+         if (j != ARRAY_SIZE (documented_lang_options))
            {
              if (extra_warnings)
                {
@@ -4798,7 +4796,7 @@ set_target_switch (name)
   register size_t j;
   int valid_target_option = 0;
 
-  for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
+  for (j = 0; j < ARRAY_SIZE (target_switches); j++)
     if (!strcmp (target_switches[j].name, name))
       {
        if (target_switches[j].value < 0)
@@ -4810,7 +4808,7 @@ set_target_switch (name)
 
 #ifdef TARGET_OPTIONS
   if (!valid_target_option)
-    for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
+    for (j = 0; j < ARRAY_SIZE (target_options); j++)
       {
        int len = strlen (target_options[j].prefix);
        if (!strncmp (target_options[j].prefix, name, len))
@@ -4925,14 +4923,14 @@ print_switch_values (file, pos, max, indent, sep, term)
   pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
                             _("options enabled: "), "");
 
-  for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++)
+  for (j = 0; j < ARRAY_SIZE (f_options); j++)
     if (*f_options[j].variable == f_options[j].on_value)
       pos = print_single_switch (file, pos, max, indent, sep, term,
                                 "-f", f_options[j].string);
 
   /* Print target specific options.  */
 
-  for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
+  for (j = 0; j < ARRAY_SIZE (target_switches); j++)
     if (target_switches[j].name[0] != '\0'
        && target_switches[j].value > 0
        && ((target_switches[j].value & target_flags)
@@ -4943,7 +4941,7 @@ print_switch_values (file, pos, max, indent, sep, term)
       }
 
 #ifdef TARGET_OPTIONS
-  for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++)
+  for (j = 0; j < ARRAY_SIZE (target_options); j++)
     if (*target_options[j].variable != NULL)
       {
        char prefix[256];
index 5b934e8..b30d089 100644 (file)
@@ -641,7 +641,7 @@ decode_reg_name (asmspec)
        static struct { const char *name; int number; } table[]
          = ADDITIONAL_REGISTER_NAMES;
 
-       for (i = 0; i < (int)(sizeof (table) / sizeof (table[0])); i++)
+       for (i = 0; i < (int) ARRAY_SIZE (table); i++)
          if (! strcmp (asmspec, table[i].name))
            return table[i].number;
       }