diff options
Diffstat (limited to 'gcc/common')
-rw-r--r-- | gcc/common/config/i386/cpuinfo.h | 19 | ||||
-rw-r--r-- | gcc/common/config/i386/i386-common.c | 86 | ||||
-rw-r--r-- | gcc/common/config/i386/i386-cpuinfo.h | 3 | ||||
-rw-r--r-- | gcc/common/config/i386/i386-isas.h | 3 |
4 files changed, 93 insertions, 18 deletions
diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h index 1e8324e..7a93e17 100644 --- a/gcc/common/config/i386/cpuinfo.h +++ b/gcc/common/config/i386/cpuinfo.h @@ -523,6 +523,8 @@ get_available_features (struct __processor_model *cpu_model, int avx_usable = 0; int avx512_usable = 0; int amx_usable = 0; + /* Check if KL is usable. */ + int has_kl = 0; if ((ecx & bit_OSXSAVE)) { /* Check if XMM, YMM, OPMASK, upper 256 bits of ZMM0-ZMM15 and @@ -667,6 +669,8 @@ get_available_features (struct __processor_model *cpu_model, if (edx & bit_AMX_BF16) set_feature (FEATURE_AMX_BF16); } + if (ecx & bit_KL) + has_kl = 1; if (avx512_usable) { if (ebx & bit_AVX512F) @@ -733,6 +737,21 @@ get_available_features (struct __processor_model *cpu_model, set_feature (FEATURE_PTWRITE); } + /* Get Advanced Features at level 0x19 (eax = 0x19). */ + if (max_cpuid_level >= 0x19) + { + set_feature (FEATURE_AESKLE); + __cpuid (19, eax, ebx, ecx, edx); + /* Check if OS support keylocker. */ + if (ebx & bit_AESKLE) + { + if (ebx & bit_WIDEKL) + set_feature (FEATURE_WIDEKL); + if (has_kl) + set_feature (FEATURE_KL); + } + } + /* Check cpuid level of extended features. */ __cpuid (0x80000000, ext_level, ebx, ecx, edx); diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c index bfdca85..e29320d 100644 --- a/gcc/common/config/i386/i386-common.c +++ b/gcc/common/config/i386/i386-common.c @@ -165,6 +165,9 @@ along with GCC; see the file COPYING3. If not see #define OPTION_MASK_ISA2_TSXLDTRK_SET OPTION_MASK_ISA2_TSXLDTRK #define OPTION_MASK_ISA2_UINTR_SET OPTION_MASK_ISA2_UINTR #define OPTION_MASK_ISA2_HRESET_SET OPTION_MASK_ISA2_HRESET +#define OPTION_MASK_ISA2_KL_SET OPTION_MASK_ISA2_KL +#define OPTION_MASK_ISA2_WIDEKL_SET \ + (OPTION_MASK_ISA2_WIDEKL | OPTION_MASK_ISA2_KL_SET) /* Define a set of ISAs which aren't available when a given ISA is disabled. MMX and SSE ISAs are handled separately. */ @@ -258,6 +261,9 @@ along with GCC; see the file COPYING3. If not see #define OPTION_MASK_ISA2_AMX_BF16_UNSET OPTION_MASK_ISA2_AMX_BF16 #define OPTION_MASK_ISA2_UINTR_UNSET OPTION_MASK_ISA2_UINTR #define OPTION_MASK_ISA2_HRESET_UNSET OPTION_MASK_ISA2_HRESET +#define OPTION_MASK_ISA2_KL_UNSET \ + (OPTION_MASK_ISA2_KL | OPTION_MASK_ISA2_WIDEKL_UNSET) +#define OPTION_MASK_ISA2_WIDEKL_UNSET OPTION_MASK_ISA2_WIDEKL /* SSE4 includes both SSE4.1 and SSE4.2. -mno-sse4 should the same as -mno-sse4.1. */ @@ -304,6 +310,16 @@ along with GCC; see the file COPYING3. If not see | OPTION_MASK_ISA2_AVX512VP2INTERSECT_UNSET) #define OPTION_MASK_ISA2_GENERAL_REGS_ONLY_UNSET \ (OPTION_MASK_ISA2_AVX512F_UNSET) +#define OPTION_MASK_ISA2_AVX2_UNSET OPTION_MASK_ISA2_AVX512F_UNSET +#define OPTION_MASK_ISA2_AVX_UNSET OPTION_MASK_ISA2_AVX2_UNSET +#define OPTION_MASK_ISA2_SSE4_2_UNSET OPTION_MASK_ISA2_AVX_UNSET +#define OPTION_MASK_ISA2_SSE4_1_UNSET OPTION_MASK_ISA2_SSE4_2_UNSET +#define OPTION_MASK_ISA2_SSE4_UNSET OPTION_MASK_ISA2_SSE4_1_UNSET +#define OPTION_MASK_ISA2_SSSE3_UNSET OPTION_MASK_ISA2_SSE4_1_UNSET +#define OPTION_MASK_ISA2_SSE3_UNSET OPTION_MASK_ISA2_SSSE3_UNSET +#define OPTION_MASK_ISA2_SSE2_UNSET \ + (OPTION_MASK_ISA2_SSE3_UNSET | OPTION_MASK_ISA2_KL_UNSET) +#define OPTION_MASK_ISA2_SSE_UNSET OPTION_MASK_ISA2_SSE2_UNSET #define OPTION_MASK_ISA2_AVX512BW_UNSET OPTION_MASK_ISA2_AVX512BF16_UNSET @@ -399,8 +415,8 @@ ix86_handle_option (struct gcc_options *opts, { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSE_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_SSE_UNSET; } return true; @@ -414,8 +430,8 @@ ix86_handle_option (struct gcc_options *opts, { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE2_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE2_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSE2_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_SSE2_UNSET; } return true; @@ -429,8 +445,8 @@ ix86_handle_option (struct gcc_options *opts, { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE3_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE3_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSE3_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_SSE3_UNSET; } return true; @@ -444,8 +460,8 @@ ix86_handle_option (struct gcc_options *opts, { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSSE3_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSSE3_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSSE3_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_SSSE3_UNSET; } return true; @@ -459,8 +475,8 @@ ix86_handle_option (struct gcc_options *opts, { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE4_1_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE4_1_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSE4_1_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_SSE4_1_UNSET; } return true; @@ -474,8 +490,8 @@ ix86_handle_option (struct gcc_options *opts, { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE4_2_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE4_2_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSE4_2_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_SSE4_2_UNSET; } return true; @@ -489,8 +505,8 @@ ix86_handle_option (struct gcc_options *opts, { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX_UNSET; } return true; @@ -504,8 +520,8 @@ ix86_handle_option (struct gcc_options *opts, { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX2_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX2_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX2_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX2_UNSET; } return true; @@ -691,6 +707,40 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_ENQCMD_UNSET; opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_ENQCMD_UNSET; } + return true; + + case OPT_mkl: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_KL_SET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_KL_SET; + + /* The Keylocker instructions need XMM registers from SSE2. */ + opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE2_SET; + opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE2_SET; + } + else + { + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_KL_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_KL_UNSET; + } + return true; + + case OPT_mwidekl: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_WIDEKL_SET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_WIDEKL_SET; + + /* The Widekl instructions need XMM registers from SSE2. */ + opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE2_SET; + opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE2_SET; + } + else + { + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_WIDEKL_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_WIDEKL_UNSET; + } return true; case OPT_mserialize: @@ -1043,8 +1093,8 @@ ix86_handle_option (struct gcc_options *opts, case OPT_mno_sse4: opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE4_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE4_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSE4_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_SSE4_UNSET; return true; case OPT_msse4a: diff --git a/gcc/common/config/i386/i386-cpuinfo.h b/gcc/common/config/i386/i386-cpuinfo.h index 8c3f782..2138220 100644 --- a/gcc/common/config/i386/i386-cpuinfo.h +++ b/gcc/common/config/i386/i386-cpuinfo.h @@ -221,6 +221,9 @@ enum processor_features FEATURE_AMX_BF16, FEATURE_UINTR, FEATURE_HRESET, + FEATURE_KL, + FEATURE_AESKLE, + FEATURE_WIDEKL, CPU_FEATURE_MAX }; diff --git a/gcc/common/config/i386/i386-isas.h b/gcc/common/config/i386/i386-isas.h index 888e325..921db06 100644 --- a/gcc/common/config/i386/i386-isas.h +++ b/gcc/common/config/i386/i386-isas.h @@ -165,4 +165,7 @@ ISA_NAMES_TABLE_START ISA_NAMES_TABLE_ENTRY("amx-bf16", FEATURE_AMX_BF16, P_NONE, "-mamx-bf16") ISA_NAMES_TABLE_ENTRY("uintr", FEATURE_UINTR, P_NONE, "-muintr") ISA_NAMES_TABLE_ENTRY("hreset", FEATURE_HRESET, P_NONE, "-mhreset") + ISA_NAMES_TABLE_ENTRY("kl", FEATURE_KL, P_NONE, "-mkl") + ISA_NAMES_TABLE_ENTRY("aeskle", FEATURE_AESKLE, P_NONE, NULL) + ISA_NAMES_TABLE_ENTRY("widekl", FEATURE_WIDEKL, P_NONE, "-mwidekl") ISA_NAMES_TABLE_END |