This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: PR target/59587: cpu_names in i386.c is accessed with wrong index
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 25 Dec 2013 23:32:15 +0100
- Subject: Re: PATCH: PR target/59587: cpu_names in i386.c is accessed with wrong index
- Authentication-results: sourceware.org; auth=none
- References: <20131224130844 dot GA13233 at intel dot com> <CAFULd4bjm3=Pq2jtfo=F9VsS4d0G=2y=uywWtrPCK2=dLu4dZQ at mail dot gmail dot com> <CAMe9rOpArtBd3LvGYD2S9UdR=85Jr=3fsO_bkS-j+S9eTL8ceA at mail dot gmail dot com> <CAFULd4ZxXX397sA9NqRZP7rwRqwneT9DPzahn3MFHYFRfDHTWA at mail dot gmail dot com> <CAMe9rOrJqRBn1LyR_9cchRK_4WmeB6gDUFT1eiy6FujJkHa4sA at mail dot gmail dot com> <CAMe9rOqwjO4CJ1UjRR1-ANVqzrTMx1JSfmKSwmwjcYi7w=m=1A at mail dot gmail dot com> <CAFULd4aHtOb=xL43dRhTTJ-44rEeid-+gTchpoz4AZiyHzt3ZA at mail dot gmail dot com> <CAMe9rOpq9DmFiCT1Hi7X19h-24jK6jp1izq=0g6V-OuberSfFQ at mail dot gmail dot com> <CAFULd4ZUVJ5ZKxGGcq4iPtmMn-O1VE3FPfk2YfMF9QbiFUS05w at mail dot gmail dot com> <20131225213156 dot GA24342 at gmail dot com>
On Wed, Dec 25, 2013 at 10:31 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> >>>>>>>> cpu_names in i386.c is only used by ix86_function_specific_print which
>> >>>>>>>> accesses it with enum processor_type index. But cpu_names is defined as
>> >>>>>>>> array with enum target_cpu_default index. This patch adds processor
>> >>>>>>>> names to processor_target_table and uses processor_target_table instead
>> >>>>>>>> of cpu_names. It removes cpu_names and target_cpu_default. Tested on
>> >>>>>>>> Linux/x86-64. OK to install?
>> >>>>>>>
>> >>>>>>> Wait a moment,
>> >>>>>>>
>> >>>>>>> it looks to me that TARGET_CPU_DEFAULT has to be synchronized with
>> >>>>>>> const processor_alias_table, so we are able to define various ISA
>> >>>>>>> extensions by selecting TARGET_CPU_*. The TARGET_CPU_DEFAULT can then
>> >>>>>>
>> >>>>>> TARGET_CPU_DEFAULT sets the default -mtune=, not -march=.
>> >>>>>>
>> >>>>>>> be used to select extensions in the same way as PROCESSOR_* selects
>> >>>>>>> tuning for certain processor.
>> >>>>>>
>> >>>>>> It has been like this for a long time. For x86, TARGET_CPU_DEFAULT
>> >>>>>> isn't defined no matter which configure options are used. We can
>> >>>>>> change config.gcc to set TARGET_CPU_DEFAULT to proper PROCESSOR_XXX or
>> >>>>>> set it to a string "xxx" for processor "xxx".
>> >>>>>> But GCC driver always passes -march=/-mtune= to toplev.c so that
>> >>>>>> TARGET_CPU_DEFAULT is normally used.
>> >>>>
>> >>>> I meant to say "TARGET_CPU_DEFAULT isn't normally used."
>> >>>>
>> >>>>>
>> >>>>> Let me rethink this a bit, please do not commit the patch.
>> >>>>>
>> >>>
>> >>> TARGET_CPU_DEFAULT is left over for 32-bit target before --with-arch=
>> >>> and --with-cpu= were added. Today, -mtune=xxx -march=xxx are
>> >>> always passed to cc1 by GCC driver. If cc1 is run by hand and
>> >>> -mtune=xxx -march=xxx aren't passed to cc1, we should do
>> >>>
>> >>> 1. For 64-bit, it should be the same as -mtune=generic -march=x86_64
>> >>> are passed.
>> >>> 2. For 32-bit, it should be the same as -mtune=cpu -march=cpu are
>> >>> passed, where "cpu" is the target cpu used to configure GCC,
>> >>> like i386 in i386-linux, i486 in i486-linux, .... But there is no i786
>> >>> cpu. i786 is treated as i686. If SUBTARGET32_DEFAULT_CPU
>> >>> is defined, it should be the same -mtune=SUBTARGET32_DEFAULT_CPU
>> >>> -march=SUBTARGET32_DEFAULT_CPU.
>> >>>
>> >>> Here is the patch to implement this.
>> >>
>> >> Let's do one step at a time. So, let's split the patch back to target/59587 fix:
> 2013-12-25 H.J. Lu <hongjiu.lu@intel.com>
>
> PR target/59587
> * config/i386/i386.c (struct ptt): Add a field for processor
> name.
> (processor_target_table): Sync with processor_type. Add
> processor names.
> (cpu_names): Removed.
> (ix86_option_override_internal): Default x_ix86_tune_string
> to processor_target_table[TARGET_CPU_DEFAULT].name.
> (ix86_function_specific_print): Assert arch and tune <
> PROCESSOR_max. Use processor_target_table to print arch and
> tune names.
> * config/i386/i386.h (TARGET_CPU_DEFAULT): Default to
> PROCESSOR_GENERIC.
> (target_cpu_default): Removed.
> (processor_type): Reordered.
OK for mainline and for 4.8 after a few days in mainline.
Thanks,
Uros.