On Fri, Oct 14, 2022 at 3:57 PM Haochen Jiang via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> gcc/ChangeLog:
>
>         * common/config/i386/cpuinfo.h (get_intel_cpu):
>         Add Sierra Forest.
>         * common/config/i386/i386-common.cc
>         (processor_names): Add Sierra Forest.
>         (processor_alias_table): Ditto.
>         * common/config/i386/i386-cpuinfo.h
>         (enum processor_types): Add INTEL_SIERRAFOREST.
>         * config.gcc: Add -march=sierraforest.
>         * config/i386/driver-i386.cc (host_detect_local_cpu):
>         Handle Sierra Forest.
>         * config/i386/i386-c.cc (ix86_target_macros_internal):
>         Ditto.
>         * config/i386/i386-options.cc (m_SIERRAFOREST): New define.
>         (processor_cost_table): Add sierra forest.
>         * config/i386/i386.h (enum processor_type):
>         Add PROCESSOR_SIERRA_FOREST.
>         (PTA_SIERRAFOREST): Ditto.
>         * doc/extend.texi: Add sierra forest.
>         * doc/invoke.texi: Ditto.
>
> gcc/testsuite/ChangeLog:
>
>         * g++.target/i386/mv16.C: Add sierra forest.
>         * gcc.target/i386/funcspec-56.inc: Handle new march.
Ok, please commit this patch after CMPCCXADD patch.
> ---
>  gcc/common/config/i386/cpuinfo.h              | 6 ++++++
>  gcc/common/config/i386/i386-common.cc         | 3 +++
>  gcc/common/config/i386/i386-cpuinfo.h         | 1 +
>  gcc/config.gcc                                | 3 ++-
>  gcc/config/i386/driver-i386.cc                | 5 ++++-
>  gcc/config/i386/i386-c.cc                     | 7 +++++++
>  gcc/config/i386/i386-options.cc               | 2 ++
>  gcc/config/i386/i386.h                        | 3 +++
>  gcc/doc/extend.texi                           | 3 +++
>  gcc/doc/invoke.texi                           | 8 ++++++++
>  gcc/testsuite/g++.target/i386/mv16.C          | 6 ++++++
>  gcc/testsuite/gcc.target/i386/funcspec-56.inc | 1 +
>  12 files changed, 46 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/common/config/i386/cpuinfo.h 
> b/gcc/common/config/i386/cpuinfo.h
> index f73834b086c..cc499c46ed0 100644
> --- a/gcc/common/config/i386/cpuinfo.h
> +++ b/gcc/common/config/i386/cpuinfo.h
> @@ -516,6 +516,12 @@ get_intel_cpu (struct __processor_model *cpu_model,
>        cpu_model->__cpu_type = INTEL_COREI7;
>        cpu_model->__cpu_subtype = INTEL_COREI7_SAPPHIRERAPIDS;
>        break;
> +    case 0xaf:
> +      /* Sierra Forest.  */
> +      cpu = "sierraforest";
> +      CHECK___builtin_cpu_is ("sierraforest");
> +      cpu_model->__cpu_type = INTEL_SIERRAFOREST;
> +      break;
>      case 0x17:
>      case 0x1d:
>        /* Penryn.  */
> diff --git a/gcc/common/config/i386/i386-common.cc 
> b/gcc/common/config/i386/i386-common.cc
> index 75966779d82..6ccc4d2f03c 100644
> --- a/gcc/common/config/i386/i386-common.cc
> +++ b/gcc/common/config/i386/i386-common.cc
> @@ -1874,6 +1874,7 @@ const char *const processor_names[] =
>    "goldmont",
>    "goldmont-plus",
>    "tremont",
> +  "sierraforest",
>    "knl",
>    "knm",
>    "skylake",
> @@ -2019,6 +2020,8 @@ const pta processor_alias_table[] =
>      M_CPU_TYPE (INTEL_GOLDMONT_PLUS), P_PROC_SSE4_2},
>    {"tremont", PROCESSOR_TREMONT, CPU_HASWELL, PTA_TREMONT,
>      M_CPU_TYPE (INTEL_TREMONT), P_PROC_SSE4_2},
> +  {"sierraforest", PROCESSOR_SIERRAFOREST, CPU_HASWELL, PTA_SIERRAFOREST,
> +    M_CPU_SUBTYPE (INTEL_SIERRAFOREST), P_PROC_AVX2},
>    {"knl", PROCESSOR_KNL, CPU_SLM, PTA_KNL,
>      M_CPU_TYPE (INTEL_KNL), P_PROC_AVX512F},
>    {"knm", PROCESSOR_KNM, CPU_SLM, PTA_KNM,
> diff --git a/gcc/common/config/i386/i386-cpuinfo.h 
> b/gcc/common/config/i386/i386-cpuinfo.h
> index 5a61d817007..a71a10ebbd7 100644
> --- a/gcc/common/config/i386/i386-cpuinfo.h
> +++ b/gcc/common/config/i386/i386-cpuinfo.h
> @@ -58,6 +58,7 @@ enum processor_types
>    INTEL_TREMONT,
>    AMDFAM19H,
>    ZHAOXIN_FAM7H,
> +  INTEL_SIERRAFOREST,
>    CPU_TYPE_MAX,
>    BUILTIN_CPU_TYPE_MAX = CPU_TYPE_MAX
>  };
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index fe063bfbb26..c0e10a72bd5 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -665,7 +665,8 @@ slm nehalem westmere sandybridge ivybridge haswell 
> broadwell bonnell \
>  silvermont knl knm skylake-avx512 cannonlake icelake-client icelake-server \
>  skylake goldmont goldmont-plus tremont cascadelake tigerlake cooperlake \
>  sapphirerapids alderlake rocketlake eden-x2 nano nano-1000 nano-2000 
> nano-3000 \
> -nano-x2 eden-x4 nano-x4 lujiazui x86-64 x86-64-v2 x86-64-v3 x86-64-v4 native"
> +nano-x2 eden-x4 nano-x4 lujiazui x86-64 x86-64-v2 x86-64-v3 x86-64-v4 \
> +sierraforest native"
>
>  # Additional x86 processors supported by --with-cpu=.  Each processor
>  # MUST be separated by exactly one space.
> diff --git a/gcc/config/i386/driver-i386.cc b/gcc/config/i386/driver-i386.cc
> index ef567045c67..be205a56ea2 100644
> --- a/gcc/config/i386/driver-i386.cc
> +++ b/gcc/config/i386/driver-i386.cc
> @@ -589,8 +589,11 @@ const char *host_detect_local_cpu (int argc, const char 
> **argv)
>               /* This is unknown family 0x6 CPU.  */
>               if (has_feature (FEATURE_AVX))
>                 {
> +                 /* Assume Sierra Forest.  */
> +                 if (has_feature (FEATURE_AVXVNNIINT8))
> +                   cpu = "sierraforest";
>                   /* Assume Tiger Lake */
> -                 if (has_feature (FEATURE_AVX512VP2INTERSECT))
> +                 else if (has_feature (FEATURE_AVX512VP2INTERSECT))
>                     cpu = "tigerlake";
>                   /* Assume Sapphire Rapids.  */
>                   else if (has_feature (FEATURE_TSXLDTRK))
> diff --git a/gcc/config/i386/i386-c.cc b/gcc/config/i386/i386-c.cc
> index 9885a724d0f..4494c412995 100644
> --- a/gcc/config/i386/i386-c.cc
> +++ b/gcc/config/i386/i386-c.cc
> @@ -198,6 +198,10 @@ ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
>        def_or_undef (parse_in, "__tremont");
>        def_or_undef (parse_in, "__tremont__");
>        break;
> +    case PROCESSOR_SIERRAFOREST:
> +      def_or_undef (parse_in, "__sierraforest");
> +      def_or_undef (parse_in, "__sierraforest__");
> +      break;
>      case PROCESSOR_KNL:
>        def_or_undef (parse_in, "__knl");
>        def_or_undef (parse_in, "__knl__");
> @@ -377,6 +381,9 @@ ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
>      case PROCESSOR_TREMONT:
>        def_or_undef (parse_in, "__tune_tremont__");
>        break;
> +    case PROCESSOR_SIERRAFOREST:
> +      def_or_undef (parse_in, "__tune_sierraforest__");
> +      break;
>      case PROCESSOR_KNL:
>        def_or_undef (parse_in, "__tune_knl__");
>        break;
> diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
> index fb872afdfb5..4526dc09fc4 100644
> --- a/gcc/config/i386/i386-options.cc
> +++ b/gcc/config/i386/i386-options.cc
> @@ -136,6 +136,7 @@ along with GCC; see the file COPYING3.  If not see
>  #define m_GOLDMONT (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT)
>  #define m_GOLDMONT_PLUS (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT_PLUS)
>  #define m_TREMONT (HOST_WIDE_INT_1U<<PROCESSOR_TREMONT)
> +#define m_SIERRAFOREST (HOST_WIDE_INT_1U<<PROCESSOR_SIERRAFOREST)
>  #define m_INTEL (HOST_WIDE_INT_1U<<PROCESSOR_INTEL)
>
>  #define m_LUJIAZUI (HOST_WIDE_INT_1U<<PROCESSOR_LUJIAZUI)
> @@ -747,6 +748,7 @@ static const struct processor_costs 
> *processor_cost_table[] =
>    &slm_cost,
>    &slm_cost,
>    &tremont_cost,
> +  &alderlake_cost,
>    &slm_cost,
>    &slm_cost,
>    &skylake_cost,
> diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
> index 372a2cff8fe..f01bc17fefd 100644
> --- a/gcc/config/i386/i386.h
> +++ b/gcc/config/i386/i386.h
> @@ -2226,6 +2226,7 @@ enum processor_type
>    PROCESSOR_GOLDMONT,
>    PROCESSOR_GOLDMONT_PLUS,
>    PROCESSOR_TREMONT,
> +  PROCESSOR_SIERRAFOREST,
>    PROCESSOR_KNL,
>    PROCESSOR_KNM,
>    PROCESSOR_SKYLAKE,
> @@ -2345,6 +2346,8 @@ constexpr wide_int_bitmask PTA_ALDERLAKE = PTA_TREMONT 
> | PTA_ADX | PTA_AVX
>    | PTA_AVX2 | PTA_BMI | PTA_BMI2 | PTA_F16C | PTA_FMA | PTA_LZCNT
>    | PTA_PCONFIG | PTA_PKU | PTA_VAES | PTA_VPCLMULQDQ | PTA_SERIALIZE
>    | PTA_HRESET | PTA_KL | PTA_WIDEKL | PTA_AVXVNNI;
> +constexpr wide_int_bitmask PTA_SIERRAFOREST = PTA_ALDERLAKE | PTA_AVXIFMA
> +  | PTA_AVXVNNIINT8 | PTA_AVXNECONVERT | PTA_CMPCCXADD;
>  constexpr wide_int_bitmask PTA_KNM = PTA_KNL | PTA_AVX5124VNNIW
>    | PTA_AVX5124FMAPS | PTA_AVX512VPOPCNTDQ;
>
> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
> index 34c23240dfb..adee772f7bc 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -21888,6 +21888,9 @@ Intel Atom Goldmont Plus CPU.
>  @item tremont
>  Intel Atom Tremont CPU.
>
> +@item sierraforest
> +Intel Atom Sierra Forest CPU.
> +
>  @item knl
>  Intel Knights Landing CPU.
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index cbbc0201828..962c6c177b6 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -31984,6 +31984,14 @@ RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, 
> FSGSBASE, PTWRITE, RDPID,
>  SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
>  support.
>
> +@item sierraforest
> +Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
> +SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
> +XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
> +MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
> +PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
> +AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
> +
>  @item knl
>  Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, 
> SSE3,
>  SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, 
> FSGSBASE,
> diff --git a/gcc/testsuite/g++.target/i386/mv16.C 
> b/gcc/testsuite/g++.target/i386/mv16.C
> index 68392872931..11530817d1c 100644
> --- a/gcc/testsuite/g++.target/i386/mv16.C
> +++ b/gcc/testsuite/g++.target/i386/mv16.C
> @@ -92,6 +92,10 @@ int __attribute__ ((target("arch=rocketlake"))) foo () {
>    return 24;
>  }
>
> +int __attribute__ ((target("arch=sierraforest"))) foo () {
> +  return 25;
> +}
> +
>  int main ()
>  {
>    int val = foo ();
> @@ -130,6 +134,8 @@ int main ()
>      assert (val == 23);
>    else if (__builtin_cpu_is ("rocketlake"))
>      assert (val == 24);
> +  else if (__builtin_cpu_is ("sierraforest"))
> +    assert (val == 25);
>    else
>      assert (val == 0);
>
> diff --git a/gcc/testsuite/gcc.target/i386/funcspec-56.inc 
> b/gcc/testsuite/gcc.target/i386/funcspec-56.inc
> index 2e35a7ae50e..f7e9c243597 100644
> --- a/gcc/testsuite/gcc.target/i386/funcspec-56.inc
> +++ b/gcc/testsuite/gcc.target/i386/funcspec-56.inc
> @@ -179,6 +179,7 @@ extern void test_arch_silvermont (void)             
> __attribute__((__target__("arch=silverm
>  extern void test_arch_goldmont (void)          
> __attribute__((__target__("arch=goldmont")));
>  extern void test_arch_goldmont_plus (void)     
> __attribute__((__target__("arch=goldmont-plus")));
>  extern void test_arch_tremont (void)           
> __attribute__((__target__("arch=tremont")));
> +extern void test_arch_sierraforest (void)       
> __attribute__((__target__("arch=sierraforest")));
>  extern void test_arch_knl (void)               
> __attribute__((__target__("arch=knl")));
>  extern void test_arch_knm (void)               
> __attribute__((__target__("arch=knm")));
>  extern void test_arch_skylake (void)           
> __attribute__((__target__("arch=skylake")));
> --
> 2.18.1
>


-- 
BR,
Hongtao

Reply via email to