On Mon, Nov 9, 2026 at 4:47 PM Shiva S <[email protected]> wrote:
>
> Commit 05601826737 ("genmodes: Use wider types for mode_unit_size array
> based on max size") emits the MODE_UNIT_SIZE_TYPE definition from
> emit_mode_unit_size_inline, whose output is inside the
> "!defined (USED_FOR_TARGET) && GCC_VERSION >= 4001" block of
> insn-modes-inline.h.  When the host compiler is not GCC, the macro is
> then never defined, but machmode.h still uses it.  Emit it into
> insn-modes.h next to CONST_MODE_UNIT_SIZE instead.

LGTM.

> gcc/ChangeLog:
>
>         * genmodes.cc (emit_mode_unit_size_inline): Move the
>         MODE_UNIT_SIZE_TYPE definition from here...
>         (emit_insn_modes_h): ...to here.
>
> Signed-off-by: Shiva <[email protected]>
> ---
>
> Bootstrapped and regression-tested on x86_64-pc-linux-gnu and
> aarch64-unknown-linux-gnu.  I do not have write access; please commit
> if approved.
>
>  gcc/genmodes.cc | 31 ++++++++++++++++---------------
>  1 file changed, 16 insertions(+), 15 deletions(-)
>
> diff --git a/gcc/genmodes.cc b/gcc/genmodes.cc
> index ed8bfd3ba3a..7e5e061c2f3 100644
> --- a/gcc/genmodes.cc
> +++ b/gcc/genmodes.cc
> @@ -1167,21 +1167,6 @@ emit_mode_unit_size_inline (void)
>    int c;
>    struct mode_data *m;
>
> -  unsigned int max_type_size = 0;
> -  for_all_modes (c, m)
> -    {
> -      unsigned int type_size = (c != MODE_PARTIAL_INT && m->component)
> -                               ? m->component->bytesize : m->bytesize;
> -      if (max_type_size < type_size)
> -       max_type_size = type_size;
> -    }
> -  if (max_type_size < (1 << 8))
> -    puts ("#define MODE_UNIT_SIZE_TYPE unsigned char\n");
> -  else if (max_type_size < (1 << 16))
> -    puts ("#define MODE_UNIT_SIZE_TYPE unsigned short\n");
> -  else
> -    puts ("#define MODE_UNIT_SIZE_TYPE unsigned int\n");
> -
>    puts ("\
>  #ifdef __cplusplus\n\
>  inline __attribute__((__always_inline__))\n\
> @@ -1381,6 +1366,22 @@ enum machine_mode\n{");
>    printf ("#define CONST_MODE_SIZE%s\n",
>           adj_bytesize || adj_nunits ? "" : " const");
>    printf ("#define CONST_MODE_UNIT_SIZE%s\n", adj_bytesize ? "" : " const");
> +
> +  unsigned int max_unit_size = 0;
> +  for_all_modes (c, m)
> +    {
> +      unsigned int unit_size = (c != MODE_PARTIAL_INT && m->component)
> +                              ? m->component->bytesize : m->bytesize;
> +      if (max_unit_size < unit_size)
> +       max_unit_size = unit_size;
> +    }
> +  if (max_unit_size < (1 << 8))
> +    puts ("#define MODE_UNIT_SIZE_TYPE unsigned char");
> +  else if (max_unit_size < (1 << 16))
> +    puts ("#define MODE_UNIT_SIZE_TYPE unsigned short");
> +  else
> +    puts ("#define MODE_UNIT_SIZE_TYPE unsigned int");
> +
>    printf ("#define CONST_MODE_BASE_ALIGN%s\n", adj_alignment ? "" : " 
> const");
>  #if 0 /* disabled for backward compatibility, temporary */
>    printf ("#define CONST_REAL_FORMAT_FOR_MODE%s\n", adj_format ? "" :" 
> const");

Reply via email to