On Thu, Jul 18, 2024, 10:00 AM kong lingling <lingling.ko...@gmail.com>
wrote:

> Also add some comment for list cpuid are not supported in 32 bit.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
>
> Ready push to trunk.
>
> gcc/ChangeLog:
>
>         * config/i386/i386-options.cc (ix86_option_override_internal):
>         Remove compiler report error for -mapxf or -muintr with -m32.
>         And just disable them in 32-bit code.
>         * config/i386/i386.opt: Add comment into target help for flags
>         -m32, list cupid like apx are not supported in 32-bit mode.
>         * doc/invoke.texi: Ditto.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/i386/apx-1.c: Removed error test.
> ---
>  gcc/config/i386/i386-options.cc       | 26 ++++++++++++++++----------
>  gcc/config/i386/i386.opt              |  3 ++-
>  gcc/doc/invoke.texi                   |  4 +++-
>  gcc/testsuite/gcc.target/i386/apx-1.c |  1 -
>  4 files changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/gcc/config/i386/i386-options.cc
> b/gcc/config/i386/i386-options.cc
> index 059ef3ae6ad..3afc5107b69 100644
> --- a/gcc/config/i386/i386-options.cc
> +++ b/gcc/config/i386/i386-options.cc
> @@ -2142,16 +2142,22 @@ ix86_option_override_internal (bool main_args_p,
>        opts->x_ix86_stringop_alg = no_stringop;
>      }
>
> -  if (TARGET_APX_F_P (opts->x_ix86_isa_flags2)
> -      && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
> -    error ("%<-mapxf%> is not supported for 32-bit code");
> -  else if (opts->x_ix86_apx_features != apx_none
> -          && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
> -    error ("%<-mapx-features=%> option is not supported for 32-bit code");
> -
> -  if (TARGET_UINTR_P (opts->x_ix86_isa_flags2)
> -      && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
> -    error ("%<-muintr%> not supported for 32-bit code");
> +  /* Some features like apx are not available in 32-bit code.  */
> +  if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
> +    {
> +      opts->x_ix86_apx_features = apx_none;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_APX_F;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AMX_TILE;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AMX_INT8;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AMX_BF16;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AMX_FP16;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AMX_COMPLEX;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_CMPCCXADD;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_CX16;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_PREFETCHI;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_UINTR;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_USER_MSR;
> +    }
>
>    if (ix86_lam_type && !TARGET_LP64_P (opts->x_ix86_isa_flags))
>      error ("%<-mlam=%> option: [u48|u57] not supported for 32-bit code");
> diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
> index 353fffb2343..4f9110f05f9 100644
> --- a/gcc/config/i386/i386.opt
> +++ b/gcc/config/i386/i386.opt
> @@ -667,7 +667,8 @@ Optimize noreturn functions by not saving callee-saved
> registers used in the fun
>
>  m32
>  Target RejectNegative Negative(m64) InverseMask(ISA_64BIT)
> Var(ix86_isa_flags) Save
> -Generate 32bit i386 code.
> +Generate 32bit i386 code. mapxf, mamx, mcx16, mcmpccxadd, mprefetchi,
> muintr and
> +musermsr are not supported in 32-bit mode.
>
>  m64
>  Target RejectNegative Negative(mx32) Mask(ABI_64) Var(ix86_isa_flags) Save
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 403ea9da1ab..41410b9ee76 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -36427,7 +36427,9 @@ on x86-64 processors in 64-bit environments.
>  Generate code for a 16-bit, 32-bit or 64-bit environment.
>  The @option{-m32} option sets @code{int}, @code{long}, and pointer types
>  to 32 bits, and
> -generates code that runs in 32-bit mode.
> +generates code that runs in 32-bit mode.  The @option{-mapxf},
> @option{-mamx},
> +@option{-mcx16}, @option{-mcmpccxadd}, @option{-mprefetchi},
> @option{-muintr}
> +and @option{-musermsr} are not supported in 32-bit mode.
>
>  The @option{-m64} option sets @code{int} to 32 bits and @code{long} and
> pointer
>  types to 64 bits, and generates code for the x86-64 architecture.
> diff --git a/gcc/testsuite/gcc.target/i386/apx-1.c
> b/gcc/testsuite/gcc.target/i386/apx-1.c
> index 4e580ecdf37..3853534cd84 100644
> --- a/gcc/testsuite/gcc.target/i386/apx-1.c
> +++ b/gcc/testsuite/gcc.target/i386/apx-1.c
> @@ -1,6 +1,5 @@
>  /* { dg-do compile } */
>  /* { dg-options "-O2 -mapxf" } */
> -/* { dg-error "'-mapxf' is not supported for 32-bit code" "" { target
> ia32 } 0 } */
>

This looks odd.  Please open a GCC bug if there is a real issue.

Thanks.


>  void
>  apx_hanlder ()
> --
> 2.31.1
>
>
>

Reply via email to