Hi Peter,

> On 25 Jul 2019, at 04:30, Peter Bergner <pe...@bergner.org> wrote:
> 
> The -mdejagnu-cpu= option was added as a way for a test case to ensure a
> particular -mcpu= option is used to compile the test, regardless of whether
> the user attempts to override it (purposely or accidentally) via RUNTESTFLAGS.
> This was well and good, but the ASM_CPU_SPEC was not updated to handle
> -mdejagnu-cpu=, so the option passed to the assembler is only determined
> by -mcpu=, even if that is overridden by -mdejagnu-cpu=.  This can cause
> cases of using the wrong assembler option.
> 
> We could just add -mdejagnu-cpu= support to ASM_CPU_SPEC, but that spec entry
> is already WAY too huge and ugly and to add support for -mdejagnu-cpu=, we'd
> have to essentially double the size of that spec.  The patch below takes
> a different approach and removes Segher's original patch altogether and
> instead implements -mdejagnu-cpu= using a DRIVER_SELF_SPECS spec which
> simplifies things by not even needing to touch ASM_CPU_SPEC.  I also added
> support for -mdejagnu-tune=, even though we don't have any test cases
> at the moment that use it, since it was easy to add.

This will break Darwin which has used DRIVER_SELF_SPECS in config/darwin.h
since they were introduced (and the equivalent before).

This is because Darwin has driver self-specs common to the PPC and X86 ports.

If this change is seen the way to go, then I guess one solution would be to 
rename the
driver specs in config/darwin.h => SUBTARGET_DRIVER_SELF_SPECS*** and then
put a dummy DRIVER_SELF_SPECS in i386/i386.h 
and append SUBTARGET_DRIVER_SELF_SPECS  to both the i386.h and rs6000.h 
cases.  (or something along those lines)

> Segher, I tried your suggestion of writing the spec more generically
> (ie, %{mdejagnu-*: ... -m*}), which worked in that it did the correct
> replacement.  However, the %<m... hunk to strip the overridden -mcpu=
> option(s) would need to be written like %<m%* and that does not work
> at all.

not sure what the objective is here - if you want to remove all pre-existing 
-mcpu from
the command line won’t %<mcpu*  work for you? (with the risk of removing 
-mcpunewthing
if it gets invented) ..

thanks
Iain

*** it seems a bit odd that the upper directory contains the SUBTARGET 
designation, but
that’s a pattern used before.

> This passed bootstrap and regtesting with no errors on powerpc64le-linux.
> Ok for trunk?
> 
> Peter
> 
> gcc/
>       PR target/91050
>       * config/rs6000/rs6000.opt (mdejagnu-cpu=): Delete option.
>       * config/rs6000/rs6000.c (rs6000_option_override_internal): Remove
>       use of deleted rs6000_dejagnu_cpu_index variable.
>       * config/rs6000/rs6000.h (DRIVER_SELF_SPECS): Define.
> 
> Index: gcc/config/rs6000/rs6000.opt
> ===================================================================
> --- gcc/config/rs6000/rs6000.opt      (revision 273707)
> +++ gcc/config/rs6000/rs6000.opt      (working copy)
> @@ -388,13 +388,6 @@ mtune=
> Target RejectNegative Joined Var(rs6000_tune_index) Init(-1) 
> Enum(rs6000_cpu_opt_value) Save
> -mtune=       Schedule code for given CPU.
> 
> -; Only for use in the testsuite.  This simply overrides -mcpu=.  With older
> -; versions of Dejagnu the command line arguments you set in RUNTESTFLAGS
> -; override those set in the testcases; with this option, the testcase will
> -; always win.
> -mdejagnu-cpu=
> -Target Undocumented RejectNegative Joined Var(rs6000_dejagnu_cpu_index) 
> Init(-1) Enum(rs6000_cpu_opt_value) Save
> -
> mtraceback=
> Target RejectNegative Joined Enum(rs6000_traceback_type) Var(rs6000_traceback)
> -mtraceback=[full,part,no]    Select type of traceback table.
> Index: gcc/config/rs6000/rs6000.c
> ===================================================================
> --- gcc/config/rs6000/rs6000.c        (revision 273707)
> +++ gcc/config/rs6000/rs6000.c        (working copy)
> @@ -3489,9 +3489,6 @@ rs6000_option_override_internal (bool gl
>   /* Don't override by the processor default if given explicitly.  */
>   set_masks &= ~rs6000_isa_flags_explicit;
> 
> -  if (global_init_p && rs6000_dejagnu_cpu_index >= 0)
> -    rs6000_cpu_index = rs6000_dejagnu_cpu_index;
> -
>   /* Process the -mcpu=<xxx> and -mtune=<xxx> argument.  If the user changed
>      the cpu in a target attribute or pragma, but did not specify a tuning
>      option, use the cpu for the tuning option rather than the option 
> specified
> Index: gcc/config/rs6000/rs6000.h
> ===================================================================
> --- gcc/config/rs6000/rs6000.h        (revision 273707)
> +++ gcc/config/rs6000/rs6000.h        (working copy)
> @@ -77,6 +77,15 @@
> #define PPC405_ERRATUM77 0
> #endif
> 
> +/* Only for use in the testsuite: -mdejagnu-cpu= simply overrides -mcpu=.
> +   With older versions of Dejagnu the command line arguments you set in
> +   RUNTESTFLAGS override those set in the testcases; with this option,
> +   the testcase will always win.  Ditto for -mdejagnu-tune=.  */
> +#define DRIVER_SELF_SPECS \
> +  "%{mdejagnu-cpu=*: %<mcpu=* -mcpu=%*} \
> +   %{mdejagnu-tune=*: %<mtune=* -mtune=%*} \
> +   %{mdejagnu-*: %<mdejagnu-*}"
> +
> #if CHECKING_P
> #define ASM_OPT_ANY ""
> #else

Reply via email to