On Tue, Jan 23, 2024 at 04:44:32PM +0800, Kewen.Lin wrote:
> > --- a/gcc/config/rs6000/rs6000-cpus.def
> > +++ b/gcc/config/rs6000/rs6000-cpus.def
> > @@ -88,6 +88,10 @@
> >                              | OPTION_MASK_POWER10                  \
> >                              | OTHER_POWER10_MASKS)
> >  
> > +/* Flags for a potential future processor that may or may not be 
> > delivered.  */
> > +#define ISA_FUTURE_MASKS   (ISA_3_1_MASKS_SERVER                   \
> > +                            | OPTION_MASK_FUTURE)
> > +
> 
> Nit: Named as "ISA_FUTURE_MASKS_SERVER" seems more accurate as it's 
> constituted
> with ISA_3_1_MASKS_**SERVER** ...

Well the _SERVER stuff was due to the power7 days when we still had to support
the E500 in the main rs6000 tree.  But I will change it to be more consistant
in the future patches.

> ..., then this need to be updated accordingly.
> 
> > diff --git a/gcc/config/rs6000/rs6000-opts.h 
> > b/gcc/config/rs6000/rs6000-opts.h
> > index 33fd0efc936..25890ae3034 100644
> > --- a/gcc/config/rs6000/rs6000-opts.h
> > +++ b/gcc/config/rs6000/rs6000-opts.h
> > @@ -67,7 +67,9 @@ enum processor_type
> >     PROCESSOR_MPCCORE,
> >     PROCESSOR_CELL,
> >     PROCESSOR_PPCA2,
> > -   PROCESSOR_TITAN
> > +   PROCESSOR_TITAN,
> > +
> 
> Nit: unintentional empty line?
> 
> > +   PROCESSOR_FUTURE
> >  };

It was more as a separation.  The MPCCORE, CELL, PPCA2, and TITAN are rather
old processors.  I don't recall why we kept them after the POWER<x>.

Logically we should re-order the list and move MPCCORE, etc. earlier, but I
will delete the blank line in future patches.

> > +static int
> > +rs600_cpu_index_lookup (enum processor_type processor)
> 
> s/rs600_cpu_index_lookup/rs6000_cpu_index_lookup/

I'm going to redo it, and eliminate rs600_cpu_index_lookup.  Thanks for
catching the spelling of rs600 instead of rs6000.

> > +{
> > +  for (size_t i = 0; i < ARRAY_SIZE (processor_target_table); i++)
> > +    if (processor_target_table[i].processor == processor)
> > +      return i;
> > +
> > +  return -1;
> > +}
> 
> Nit: Since this is given with a valid enum processor_type, I think it should
> never return -1?  If so, may be more clear with gcc_unreachable () or adjust
> with initial -1, break when hits and assert it's not -1.

As I said, in looking at it, I think I will rewrite the code that uses it to
call rs6000_cpu_name_lookup instead.

> > +
> >  
> >  /* Return number of consecutive hard regs needed starting at reg REGNO
> >     to hold something of mode MODE.
> > @@ -3756,23 +3768,45 @@ rs6000_option_override_internal (bool global_init_p)
> >      rs6000_isa_flags &= ~OPTION_MASK_POWERPC64;
> >  #endif
> >  
> > +  /* At the moment, we don't have explict -mtune=future support.  If the 
> > user
> 
> Nit: s/explict/explicit/

Thanks.

> 
> > +     explicitly tried to use -mtune=future, give a warning.  If not, use 
> > the
> 
> Nit: s/tried/tries/?

Thanks.  I will reword the comment.

> > +     power10 tuning until future tuning is added.  */
> >    if (rs6000_tune_index >= 0)
> > -    tune_index = rs6000_tune_index;
> > +    {
> > +      enum processor_type cur_proc
> > +   = processor_target_table[rs6000_tune_index].processor;
> > +
> > +      if (cur_proc == PROCESSOR_FUTURE)
> > +   {
> > +     static bool issued_future_tune_warning = false;
> > +     if (!issued_future_tune_warning)
> > +       {
> > +         issued_future_tune_warning = true;
> 
> This seems to ensure we only warn this once, but I noticed that in rs6000/
> only some OPT_Wpsabi related warnings adopt this way, I wonder if we don't
> restrict it like this, for a tiny simple case, how many times it would warn?

In a simple case, you would only get the warning once.  But if you use
__attribute__((__target__(...))) or #pragma target ... you might see it more
than once.

> > +         warning (0, "%qs is not currently supported", "-mtune=future");
> > +       }
> > +> +          rs6000_tune_index = rs600_cpu_index_lookup 
> > (PROCESSOR_POWER10);
> > +   }
> > +      tune_index = rs6000_tune_index;
> > +    }
> >    else if (cpu_index >= 0)
> > -    rs6000_tune_index = tune_index = cpu_index;
> > +    {
> > +      enum processor_type cur_cpu
> > +   = processor_target_table[cpu_index].processor;
> > +
> > +      rs6000_tune_index = tune_index
> > +   = (cur_cpu == PROCESSOR_FUTURE
> > +      ? rs600_cpu_index_lookup (PROCESSOR_POWER10)
> 
> s/rs600_cpu_index_lookup/rs6000_cpu_index_lookup/

See above.

> > +      : cpu_index);
> > +    }
> >    else
> >      {
> > -      size_t i;
> >        enum processor_type tune_proc
> >     = (TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT);
> >  
> > -      tune_index = -1;
> > -      for (i = 0; i < ARRAY_SIZE (processor_target_table); i++)
> > -   if (processor_target_table[i].processor == tune_proc)
> > -     {
> > -       tune_index = i;
> > -       break;
> > -     }
> > +      tune_index = rs600_cpu_index_lookup (tune_proc == PROCESSOR_FUTURE
> > +                                      ? PROCESSOR_POWER10
> > +                                      : tune_proc);
> 
> This part looks useless, as tune_proc is impossible to be PROCESSOR_FUTURE.

Well in theory, you could configure the compiler with --with-cpu=future or
--with-tune=future.

> >      }
> 
> Maybe re-structure the above into:
> 
> bool explicit_tune = false;
> if (rs6000_tune_index >= 0)
>   {
>     tune_index = rs6000_tune_index;
>     explicit_tune = true;
>   }
> else if (cpu_index >= 0)
>   // as before
>   rs6000_tune_index = tune_index = cpu_index;
> else
>   {
>    //as before
>    ...
>   }
> 
> // Check tune_index here instead.
> 
> if (processor_target_table[tune_index].processor == PROCESSOR_FUTURE)
>   {
>     tune_index = rs6000_cpu_index_lookup (PROCESSOR_POWER10);
>     if (explicit_tune)
>       warn ...
>   }
> 
> // as before
> rs6000_tune = processor_target_table[tune_index].processor;
> 
> >  
> >    if (cpu_index >= 0)
> > @@ -4785,6 +4819,7 @@ rs6000_option_override_internal (bool global_init_p)
> >     break;
> >  
> >        case PROCESSOR_POWER10:
> > +      case PROCESSOR_FUTURE:
> >     rs6000_cost = &power10_cost;
> >     break;
> >  
> > @@ -5944,6 +5979,8 @@ rs6000_machine_from_flags (void)
> >    /* Disable the flags that should never influence the .machine selection. 
> >  */
> >    flags &= ~(OPTION_MASK_PPC_GFXOPT | OPTION_MASK_PPC_GPOPT | 
> > OPTION_MASK_ISEL);
> >  
> > +  if ((flags & (ISA_FUTURE_MASKS & ~ISA_3_1_MASKS_SERVER)) != 0)
> > +    return "future";
> >    if ((flags & (ISA_3_1_MASKS_SERVER & ~ISA_3_0_MASKS_SERVER)) != 0)
> >      return "power10";
> >    if ((flags & (ISA_3_0_MASKS_SERVER & ~ISA_2_7_MASKS_SERVER)) != 0)
> > @@ -24500,6 +24537,7 @@ static struct rs6000_opt_mask const 
> > rs6000_opt_masks[] =
> >    { "float128-hardware",   OPTION_MASK_FLOAT128_HW,        false, true  },
> >    { "fprnd",                       OPTION_MASK_FPRND,              false, 
> > true  },
> >    { "power10",                     OPTION_MASK_POWER10,            false, 
> > true  },
> > +  { "future",                      OPTION_MASK_FUTURE,             false, 
> > true  },
> >    { "hard-dfp",                    OPTION_MASK_DFP,                false, 
> > true  },
> >    { "htm",                 OPTION_MASK_HTM,                false, true  },
> >    { "isel",                        OPTION_MASK_ISEL,               false, 
> > true  },
> > diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
> > index 2291fe8d3a3..43209f9a6e7 100644
> > --- a/gcc/config/rs6000/rs6000.h
> > +++ b/gcc/config/rs6000/rs6000.h
> > @@ -163,6 +163,7 @@
> >    mcpu=e5500: -me5500; \
> >    mcpu=e6500: -me6500; \
> >    mcpu=titan: -mtitan; \
> > +  mcpu=future: -mfuture; \
> >    !mcpu*: %{mpower9-vector: -mpower9; \
> >         mpower8-vector|mcrypto|mdirect-move|mhtm: -mpower8; \
> >         mvsx: -mpower7; \
> 
> I think we should also update asm_names in driver-rs6000.cc.

Ok.  Though the driver-rs6000.cc stuff won't kick in until we have a real
system that matches "future".

-- 
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: meiss...@linux.ibm.com

Reply via email to