This patch adds machinery to genmodes.c so that largest possible sizes
of various data structures can be determined at gcc build time. These
functions create 3 symbols that are available in insn-modes.h:
MAX_BITSIZE_MODE_INT - the bitsize of the largest int.
MAX_BITSIZE_MODE_PARTIAL_INT - the bitsize of the largest partial int.
MAX_BITSIZE_MODE_ANY_INT - the largest bitsize of any kind of int.
Index: gcc/genmodes.c
===================================================================
--- gcc/genmodes.c (revision 191978)
+++ gcc/genmodes.c (working copy)
@@ -849,6 +849,38 @@ calc_wider_mode (void)
#define print_closer() puts ("};")
+/* Compute the max bitsize of some of the classes of integers. It may
+ be that there are needs for the other integer classes, and this
+ code is easy to extend. */
+static void
+emit_max_int (void)
+{
+ unsigned int max, mmax;
+ struct mode_data *i;
+ int j;
+
+ puts ("");
+ for (max = 1, i = modes[MODE_INT]; i; i = i->next)
+ if (max < i->bytesize)
+ max = i->bytesize;
+ printf ("#define MAX_BITSIZE_MODE_INT %d*BITS_PER_UNIT\n", max);
+ mmax = max;
+ for (max = 1, i = modes[MODE_PARTIAL_INT]; i; i = i->next)
+ if (max < i->bytesize)
+ max = i->bytesize;
+ printf ("#define MAX_BITSIZE_MODE_PARTIAL_INT %d*BITS_PER_UNIT\n", max);
+ if (max > mmax)
+ mmax = max;
+ printf ("#define MAX_BITSIZE_MODE_ANY_INT %d*BITS_PER_UNIT\n", mmax);
+
+ mmax = 0;
+ for (j = 0; j < MAX_MODE_CLASS; j++)
+ for (i = modes[j]; i; i = i->next)
+ if (mmax < i->bytesize)
+ mmax = i->bytesize;
+ printf ("#define MAX_BITSIZE_MODE_ANY_MODE %d*BITS_PER_UNIT\n", mmax);
+}
+
static void
emit_insn_modes_h (void)
{
@@ -913,6 +945,7 @@ enum machine_mode\n{");
#endif
printf ("#define CONST_MODE_IBIT%s\n", adj_ibit ? "" : " const");
printf ("#define CONST_MODE_FBIT%s\n", adj_fbit ? "" : " const");
+ emit_max_int ();
puts ("\
\n\
#endif /* insn-modes.h */");
2012-10-5 Kenneth Zadeck <zad...@naturalbridge.com>
* genmodes.c (emit_max_int): New function.
(emit_insn_modes_h): Added call to emit_max_function.