diff options
author | Ian Lance Taylor <iant@golang.org> | 2023-03-29 09:01:23 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2023-03-29 09:01:23 -0700 |
commit | 6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced (patch) | |
tree | 1deecdcfbf185c7044bc861d0ace51285c96cb62 /gcc/common | |
parent | 795cffe109e28b248a54b8ee583cbae48368c2a7 (diff) | |
parent | aa8f4242efc99f24de73c59d53996f28db28c13f (diff) | |
download | gcc-6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced.zip gcc-6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced.tar.gz gcc-6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced.tar.bz2 |
Merge from trunk revision aa8f4242efc99f24de73c59d53996f28db28c13f.
Diffstat (limited to 'gcc/common')
55 files changed, 577 insertions, 374 deletions
diff --git a/gcc/common/common-target-def.h b/gcc/common/common-target-def.h index ab39f30..88973a4 100644 --- a/gcc/common/common-target-def.h +++ b/gcc/common/common-target-def.h @@ -1,5 +1,5 @@ /* Default initializers for common target hooks. - Copyright (C) 2011-2022 Free Software Foundation, Inc. + Copyright (C) 2011-2023 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the diff --git a/gcc/common/common-target.def b/gcc/common/common-target.def index c4c6230..4bde551 100644 --- a/gcc/common/common-target.def +++ b/gcc/common/common-target.def @@ -1,5 +1,5 @@ /* Target hook definitions for common hooks. - Copyright (C) 2011-2022 Free Software Foundation, Inc. + Copyright (C) 2011-2023 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the diff --git a/gcc/common/common-target.h b/gcc/common/common-target.h index e90b02c..ea7c601 100644 --- a/gcc/common/common-target.h +++ b/gcc/common/common-target.h @@ -1,5 +1,5 @@ /* Data structure definitions for common hooks. - Copyright (C) 2010-2022 Free Software Foundation, Inc. + Copyright (C) 2010-2023 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the diff --git a/gcc/common/common-targhooks.cc b/gcc/common/common-targhooks.cc index 7499be2..4d04cfc 100644 --- a/gcc/common/common-targhooks.cc +++ b/gcc/common/common-targhooks.cc @@ -1,5 +1,5 @@ /* Default common target hook functions. - Copyright (C) 2003-2022 Free Software Foundation, Inc. + Copyright (C) 2003-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/common-targhooks.h b/gcc/common/common-targhooks.h index 1f03495..8f8aa95 100644 --- a/gcc/common/common-targhooks.h +++ b/gcc/common/common-targhooks.h @@ -1,5 +1,5 @@ /* Default common target hook functions. - Copyright (C) 2003-2022 Free Software Foundation, Inc. + Copyright (C) 2003-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc index 7fac90d..20bc4e1 100644 --- a/gcc/common/config/aarch64/aarch64-common.cc +++ b/gcc/common/config/aarch64/aarch64-common.cc @@ -1,5 +1,5 @@ /* Common hooks for AArch64. - Copyright (C) 2012-2022 Free Software Foundation, Inc. + Copyright (C) 2012-2023 Free Software Foundation, Inc. Contributed by ARM Ltd. This file is part of GCC. @@ -30,6 +30,8 @@ #include "opts.h" #include "flags.h" #include "diagnostic.h" +#include "config/aarch64/aarch64-feature-deps.h" +#include "config/arm/aarch-common.h" #ifdef TARGET_BIG_ENDIAN_DEFAULT #undef TARGET_DEFAULT_TARGET_FLAGS @@ -41,8 +43,6 @@ #undef TARGET_OPTION_OPTIMIZATION_TABLE #define TARGET_OPTION_OPTIMIZATION_TABLE aarch_option_optimization_table -#undef TARGET_OPTION_INIT_STRUCT -#define TARGET_OPTION_INIT_STRUCT aarch64_option_init_struct /* Set default optimization options. */ static const struct default_options aarch_option_optimization_table[] = @@ -65,6 +65,17 @@ static const struct default_options aarch_option_optimization_table[] = { OPT_LEVELS_NONE, 0, NULL, 0 } }; +/* Set OPTS->x_aarch64_asm_isa_flags to FLAGS and update + OPTS->x_aarch64_isa_flags accordingly. */ +void +aarch64_set_asm_isa_flags (gcc_options *opts, aarch64_feature_flags flags) +{ + opts->x_aarch64_asm_isa_flags = flags; + opts->x_aarch64_isa_flags = flags; + if (opts->x_target_flags & MASK_GENERAL_REGS_ONLY) + opts->x_aarch64_isa_flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP); +} + /* Implement TARGET_HANDLE_OPTION. This function handles the target specific options for CPU/target selection. @@ -99,6 +110,7 @@ aarch64_handle_option (struct gcc_options *opts, case OPT_mgeneral_regs_only: opts->x_target_flags |= MASK_GENERAL_REGS_ONLY; + aarch64_set_asm_isa_flags (opts, opts->x_aarch64_asm_isa_flags); return true; case OPT_mfix_cortex_a53_835769: @@ -128,77 +140,73 @@ aarch64_handle_option (struct gcc_options *opts, /* An ISA extension in the co-processor and main instruction set space. */ struct aarch64_option_extension { - const char *const name; - const uint64_t flag_canonical; - const uint64_t flags_on; - const uint64_t flags_off; - const bool is_synthetic; + /* The extension name to pass on to the assembler. */ + const char *name; + /* The smallest set of feature bits to toggle to enable this option. */ + aarch64_feature_flags flag_canonical; + /* If this feature is turned on, these bits also need to be turned on. */ + aarch64_feature_flags flags_on; + /* If this feature is turned off, these bits also need to be turned off. */ + aarch64_feature_flags flags_off; + /* Indicates whether this feature is taken into account during native cpu + detection. */ + bool native_detect_p; }; /* ISA extensions in AArch64. */ -static const struct aarch64_option_extension all_extensions[] = -{ -#define AARCH64_OPT_EXTENSION(NAME, FLAG_CANONICAL, FLAGS_ON, FLAGS_OFF, \ - SYNTHETIC, Z) \ - {NAME, FLAG_CANONICAL, FLAGS_ON, FLAGS_OFF, SYNTHETIC}, -#include "config/aarch64/aarch64-option-extensions.def" - {NULL, 0, 0, 0, false} -}; - -/* A copy of the ISA extensions list for AArch64 sorted by the popcount of - bits and extension turned on. Cached for efficiency. */ -static struct aarch64_option_extension all_extensions_by_on[] = +static constexpr aarch64_option_extension all_extensions[] = { -#define AARCH64_OPT_EXTENSION(NAME, FLAG_CANONICAL, FLAGS_ON, FLAGS_OFF, \ - SYNTHETIC, Z) \ - {NAME, FLAG_CANONICAL, FLAGS_ON, FLAGS_OFF, SYNTHETIC}, +#define AARCH64_OPT_EXTENSION(NAME, IDENT, C, D, E, FEATURE_STRING) \ + {NAME, AARCH64_FL_##IDENT, feature_deps::IDENT ().explicit_on, \ + feature_deps::get_flags_off (feature_deps::root_off_##IDENT), \ + FEATURE_STRING[0]}, #include "config/aarch64/aarch64-option-extensions.def" {NULL, 0, 0, 0, false} }; struct processor_name_to_arch { - const std::string processor_name; - const enum aarch64_arch arch; - const uint64_t flags; + const char *processor_name; + aarch64_arch arch; + aarch64_feature_flags flags; }; struct arch_to_arch_name { - const enum aarch64_arch arch; - const std::string arch_name; - const uint64_t flags; + aarch64_arch arch; + const char *arch_name; + aarch64_feature_flags flags; }; /* Map processor names to the architecture revision they implement and the default set of architectural feature flags they support. */ -static const struct processor_name_to_arch all_cores[] = +static constexpr processor_name_to_arch all_cores[] = { -#define AARCH64_CORE(NAME, X, IDENT, ARCH_IDENT, FLAGS, COSTS, IMP, PART, VARIANT) \ - {NAME, AARCH64_ARCH_##ARCH_IDENT, FLAGS}, +#define AARCH64_CORE(NAME, CORE_IDENT, C, ARCH_IDENT, E, F, G, H, I) \ + {NAME, AARCH64_ARCH_##ARCH_IDENT, feature_deps::cpu_##CORE_IDENT}, #include "config/aarch64/aarch64-cores.def" - {"generic", AARCH64_ARCH_8A, AARCH64_FL_FOR_ARCH8}, + {"generic", AARCH64_ARCH_V8A, feature_deps::V8A ().enable}, {"", aarch64_no_arch, 0} }; /* Map architecture revisions to their string representation. */ -static const struct arch_to_arch_name all_architectures[] = +static constexpr arch_to_arch_name all_architectures[] = { -#define AARCH64_ARCH(NAME, CORE, ARCH_IDENT, ARCH, FLAGS) \ - {AARCH64_ARCH_##ARCH_IDENT, NAME, FLAGS}, +#define AARCH64_ARCH(NAME, B, ARCH_IDENT, D, E) \ + {AARCH64_ARCH_##ARCH_IDENT, NAME, feature_deps::ARCH_IDENT ().enable}, #include "config/aarch64/aarch64-arches.def" {aarch64_no_arch, "", 0} }; /* Parse the architecture extension string STR and update ISA_FLAGS with the architecture features turned on or off. Return a - aarch64_parse_opt_result describing the result. + aarch_parse_opt_result describing the result. When the STR string contains an invalid extension, a copy of the string is created and stored to INVALID_EXTENSION. */ -enum aarch64_parse_opt_result -aarch64_parse_extension (const char *str, uint64_t *isa_flags, - std::string *invalid_extension) +enum aarch_parse_opt_result +aarch64_parse_extension (const char *str, aarch64_feature_flags *isa_flags, + std::string *invalid_extension) { /* The extension string is parsed left to right. */ const struct aarch64_option_extension *opt = NULL; @@ -229,7 +237,7 @@ aarch64_parse_extension (const char *str, uint64_t *isa_flags, adding_ext = 1; if (len == 0) - return AARCH64_PARSE_MISSING_ARG; + return AARCH_PARSE_MISSING_ARG; /* Scan over the extensions table trying to find an exact match. */ @@ -239,9 +247,9 @@ aarch64_parse_extension (const char *str, uint64_t *isa_flags, { /* Add or remove the extension. */ if (adding_ext) - *isa_flags |= (opt->flags_on | opt->flag_canonical); + *isa_flags |= opt->flags_on; else - *isa_flags &= ~(opt->flags_off | opt->flag_canonical); + *isa_flags &= ~opt->flags_off; break; } } @@ -251,13 +259,13 @@ aarch64_parse_extension (const char *str, uint64_t *isa_flags, /* Extension not found in list. */ if (invalid_extension) *invalid_extension = std::string (str, len); - return AARCH64_PARSE_INVALID_FEATURE; + return AARCH_PARSE_INVALID_FEATURE; } str = ext; }; - return AARCH64_PARSE_OK; + return AARCH_PARSE_OK; } /* Append all architecture extension candidates to the CANDIDATES vector. */ @@ -270,78 +278,6 @@ aarch64_get_all_extension_candidates (auto_vec<const char *> *candidates) candidates->safe_push (opt->name); } -/* Comparer to sort aarch64's feature extensions by population count. Largest - first. */ - -typedef const struct aarch64_option_extension opt_ext; - -int opt_ext_cmp (const void* a, const void* b) -{ - opt_ext *opt_a = (opt_ext *)a; - opt_ext *opt_b = (opt_ext *)b; - - /* We consider the total set of bits an options turns on to be the union of - the singleton set containing the option itself and the set of options it - turns on as a dependency. As an example +dotprod turns on FL_DOTPROD and - FL_SIMD. As such the set of bits represented by this option is - {FL_DOTPROD, FL_SIMD}. */ - uint64_t total_flags_a = opt_a->flag_canonical & opt_a->flags_on; - uint64_t total_flags_b = opt_b->flag_canonical & opt_b->flags_on; - int popcnt_a = popcount_hwi ((HOST_WIDE_INT)total_flags_a); - int popcnt_b = popcount_hwi ((HOST_WIDE_INT)total_flags_b); - int order = popcnt_b - popcnt_a; - - /* If they have the same amount of bits set, give it a more - deterministic ordering by using the value of the bits themselves. */ - if (order != 0) - return order; - - if (total_flags_a != total_flags_b) - return total_flags_a < total_flags_b ? 1 : -1; - - return 0; -} - -/* Implement TARGET_OPTION_INIT_STRUCT. */ - -static void -aarch64_option_init_struct (struct gcc_options *opts ATTRIBUTE_UNUSED) -{ - /* Sort the extensions based on how many bits they set, order the larger - counts first. We sort the list because this makes processing the - feature bits O(n) instead of O(n^2). While n is small, the function - to calculate the feature strings is called on every options push, - pop and attribute change (arm_neon headers, lto etc all cause this to - happen quite frequently). It is a trade-off between time and space and - so time won. */ - int n_extensions = ARRAY_SIZE (all_extensions); - qsort (&all_extensions_by_on, n_extensions, - sizeof (struct aarch64_option_extension), opt_ext_cmp); -} - -/* Checks to see if enough bits from the option OPT are enabled in - ISA_FLAG_BITS to be able to replace the individual options with the - canonicalized version of the option. This is done based on two rules: - - 1) Synthetic groups, such as +crypto we only care about the bits that are - turned on. e.g. +aes+sha2 can be replaced with +crypto. - - 2) Options that themselves have a bit, such as +rdma, in this case, all the - feature bits they turn on must be available and the bit for the option - itself must be. In this case it's effectively a reduction rather than a - grouping. e.g. +fp+simd is not enough to turn on +rdma, for that you would - need +rdma+fp+simd which is reduced down to +rdma. -*/ - -static bool -aarch64_contains_opt (uint64_t isa_flag_bits, opt_ext *opt) -{ - uint64_t flags_check - = opt->is_synthetic ? opt->flags_on : opt->flag_canonical; - - return (isa_flag_bits & flags_check) == flags_check; -} - /* Return a string representation of ISA_FLAGS. DEFAULT_ARCH_FLAGS gives the default set of flags which are implied by whatever -march we'd put out. Our job is to figure out the minimal set of "+" and @@ -349,121 +285,67 @@ aarch64_contains_opt (uint64_t isa_flag_bits, opt_ext *opt) that all the "+" flags come before the "+no" flags. */ std::string -aarch64_get_extension_string_for_isa_flags (uint64_t isa_flags, - uint64_t default_arch_flags) +aarch64_get_extension_string_for_isa_flags + (aarch64_feature_flags isa_flags, + aarch64_feature_flags default_arch_flags) { - const struct aarch64_option_extension *opt = NULL; std::string outstr = ""; - uint64_t isa_flag_bits = isa_flags; - - /* Pass one: Minimize the search space by reducing the set of options - to the smallest set that still turns on the same features as before in - conjunction with the bits that are turned on by default for the selected - architecture. */ - for (opt = all_extensions_by_on; opt->name != NULL; opt++) + aarch64_feature_flags current_flags = default_arch_flags; + + /* As a special case, do not assume that the assembler will enable CRC + even if it is the default for the architecture. This is required + because some CPUs had an incorrect specification in older assemblers: + even though CRC should be the default for these cases the -mcpu + values would not turn it on. + + However, assemblers with Armv8-R AArch64 support should not have this + issue, so we don't need this fix when targeting Armv8-R. */ + auto explicit_flags = (!(current_flags & AARCH64_FL_V8R) + ? AARCH64_FL_CRC : 0); + + /* Add the features in isa_flags & ~current_flags using the smallest + possible number of extensions. We can do this by iterating over the + array in reverse order, since the array is sorted topologically. + But in order to make the output more readable, it seems better + to add the strings in definition order. */ + aarch64_feature_flags added = 0; + for (unsigned int i = ARRAY_SIZE (all_extensions); i-- > 0; ) { - /* If the bit is on by default, then all the options it turns on are also - on by default due to the transitive dependencies. - - If the option is enabled explicitly in the set then we need to emit - an option for it. Since this list is sorted by extensions setting the - largest number of featers first, we can be sure that nothing else will - ever need to set the bits we already set. Consider the following - situation: - - Feat1 = A + B + C - Feat2 = A + B - Feat3 = A + D - Feat4 = B + C - Feat5 = C - - The following results are expected: - - A + C = A + Feat5 - B + C = Feat4 - Feat4 + A = Feat1 - Feat2 + Feat5 = Feat1 - Feat1 + C = Feat1 - Feat3 + Feat4 = Feat1 + D - - This search assumes that all invidual feature bits are use visible, - in other words the user must be able to do +A, +B, +C and +D. */ - if (aarch64_contains_opt (isa_flag_bits | default_arch_flags, opt)) - { - /* We remove all the dependent bits, to prevent them from being turned - on twice. This only works because we assume that all there are - individual options to set all bits standalone. */ - - /* PR target/94396. - - For flags which would already imply a bit that's on by default (e.g - fp16fml which implies +fp,+fp16) we must emit the flags that are not - on by default. i.e. in Armv8.4-a +fp16fml is default if +fp16. So - if a user passes armv8.4-a+fp16 (or +fp16fml) then we need to emit - +fp16. But if +fp16fml is used in an architecture where it is - completely optional we only have to emit the canonical flag. */ - uint64_t toggle_bits = opt->flags_on & default_arch_flags; - /* Now check to see if the canonical flag is on by default. If it - is not then enabling it will enable all bits in flags_on. */ - if ((opt->flag_canonical & default_arch_flags) == 0) - toggle_bits = opt->flags_on; - - isa_flag_bits &= ~toggle_bits; - isa_flag_bits |= opt->flag_canonical; - } - } + auto &opt = all_extensions[i]; - /* By toggling bits on and off, we may have set bits on that are already - enabled by default. So we mask the default set out so we don't emit an - option for them. Instead of checking for this each time during Pass One - we just mask all default bits away at the end. */ - isa_flag_bits &= ~default_arch_flags; - - /* We now have the smallest set of features we need to process. A subsequent - linear scan of the bits in isa_flag_bits will allow us to print the ext - names. However as a special case if CRC was enabled before, always print - it. This is required because some CPUs have an incorrect specification - in older assemblers. Even though CRC should be the default for these - cases the -mcpu values won't turn it on. - - Note that assemblers with Armv8-R AArch64 support should not have this - issue, so we don't need this fix when targeting Armv8-R. */ - if ((isa_flags & AARCH64_ISA_CRC) && !AARCH64_ISA_V8_R) - isa_flag_bits |= AARCH64_ISA_CRC; - - /* Pass Two: - Print the option names that we're sure we must turn on. These are only - optional extension names. Mandatory ones have already been removed and - ones we explicitly want off have been too. */ - for (opt = all_extensions_by_on; opt->name != NULL; opt++) - { - if (isa_flag_bits & opt->flag_canonical) - { - outstr += "+"; - outstr += opt->name; - } - } + /* As a special case, emit +crypto rather than +aes+sha2, + in order to support assemblers that predate the separate + per-feature crypto flags. */ + auto flags = opt.flag_canonical; + if (flags == AARCH64_FL_CRYPTO) + flags = AARCH64_FL_AES | AARCH64_FL_SHA2; - /* Pass Three: - Print out a +no for any mandatory extension that we are - turning off. By this point aarch64_parse_extension would have ensured - that any optional extensions are turned off. The only things left are - things that can't be turned off usually, e.g. something that is on by - default because it's mandatory and we want it off. For turning off bits - we don't guarantee the smallest set of flags, but instead just emit all - options the user has specified. - - The assembler requires all +<opts> to be printed before +no<opts>. */ - for (opt = all_extensions_by_on; opt->name != NULL; opt++) - { - if ((~isa_flags) & opt->flag_canonical - && !((~default_arch_flags) & opt->flag_canonical)) + if ((flags & isa_flags & (explicit_flags | ~current_flags)) == flags) { - outstr += "+no"; - outstr += opt->name; + current_flags |= opt.flags_on; + added |= opt.flag_canonical; } } + for (auto &opt : all_extensions) + if (added & opt.flag_canonical) + { + outstr += "+"; + outstr += opt.name; + } + + /* Remove the features in current_flags & ~isa_flags. If the feature does + not have an HWCAPs then it shouldn't be taken into account for feature + detection because one way or another we can't tell if it's available + or not. */ + for (auto &opt : all_extensions) + if (opt.native_detect_p + && (opt.flag_canonical & current_flags & ~isa_flags)) + { + current_flags &= ~opt.flags_off; + outstr += "+no"; + outstr += opt.name; + } return outstr; } @@ -517,7 +399,7 @@ aarch64_rewrite_selected_cpu (const char *name) || a_to_an->arch == aarch64_no_arch) fatal_error (input_location, "unknown value %qs for %<-mcpu%>", name); - uint64_t extensions = p_to_a->flags; + aarch64_feature_flags extensions = p_to_a->flags; aarch64_parse_extension (extension_str.c_str (), &extensions, NULL); std::string outstr = a_to_an->arch_name diff --git a/gcc/common/config/alpha/alpha-common.cc b/gcc/common/config/alpha/alpha-common.cc index 72804ee..ec185d8 100644 --- a/gcc/common/config/alpha/alpha-common.cc +++ b/gcc/common/config/alpha/alpha-common.cc @@ -1,5 +1,5 @@ /* Common hooks for DEC Alpha. - Copyright (C) 1992-2022 Free Software Foundation, Inc. + Copyright (C) 1992-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/arc/arc-common.cc b/gcc/common/config/arc/arc-common.cc index e69c4a4..95f5dd6 100644 --- a/gcc/common/config/arc/arc-common.cc +++ b/gcc/common/config/arc/arc-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Synopsys DesignWare ARC - Copyright (C) 1994-2022 Free Software Foundation, Inc. + Copyright (C) 1994-2023 Free Software Foundation, Inc. Contributor: Joern Rennecke <joern.rennecke@embecosm.com> on behalf of Synopsys Inc. Claudiu Zissulescu <Claudiu.Zissulescu@synopsys.com> @@ -44,8 +44,6 @@ arc_option_init_struct (struct gcc_options *opts ATTRIBUTE_UNUSED) #define OPT_LEVELS_3_PLUS_SPEED_ONLY OPT_LEVELS_3_PLUS static const struct default_options arc_option_optimization_table[] = { - { OPT_LEVELS_ALL, OPT_mRcq, NULL, 1 }, - { OPT_LEVELS_ALL, OPT_mRcw, NULL, 1 }, { OPT_LEVELS_ALL, OPT_msize_level_, NULL, 1 }, { OPT_LEVELS_ALL, OPT_mearly_cbranchsi, NULL, 1 }, { OPT_LEVELS_ALL, OPT_mbbit_peephole, NULL, 1 }, @@ -56,7 +54,6 @@ static const struct default_options arc_option_optimization_table[] = { OPT_LEVELS_SIZE, OPT_fsection_anchors, NULL, 1 }, { OPT_LEVELS_SIZE, OPT_mcase_vector_pcrel, NULL, 1 }, { OPT_LEVELS_SIZE, OPT_msize_level_, NULL, 3 }, - { OPT_LEVELS_SIZE, OPT_mmillicode, NULL, 1 }, { OPT_LEVELS_SIZE, OPT_fif_conversion, NULL, 0 }, { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 }, { OPT_LEVELS_3_PLUS_SPEED_ONLY, OPT_msize_level_, NULL, 0 }, diff --git a/gcc/common/config/arm/arm-common.cc b/gcc/common/config/arm/arm-common.cc index c38812f..f8b6046 100644 --- a/gcc/common/config/arm/arm-common.cc +++ b/gcc/common/config/arm/arm-common.cc @@ -1,5 +1,5 @@ /* Common hooks for ARM. - Copyright (C) 1991-2022 Free Software Foundation, Inc. + Copyright (C) 1991-2023 Free Software Foundation, Inc. This file is part of GCC. @@ -685,8 +685,10 @@ arm_canon_arch_option_1 (int argc, const char **argv, bool arch_for_multilib) auto_sbitmap target_isa (isa_num_bits); auto_sbitmap base_isa (isa_num_bits); auto_sbitmap fpu_isa (isa_num_bits); + auto_sbitmap ignore_multilib_isa (isa_num_bits); bitmap_clear (fpu_isa); + bitmap_clear (ignore_multilib_isa); const arch_option *selected_arch = NULL; @@ -719,15 +721,6 @@ arm_canon_arch_option_1 (int argc, const char **argv, bool arch_for_multilib) arm_initialize_isa (target_isa, selected_arch->common.isa_bits); arm_parse_option_features (target_isa, &selected_arch->common, strchr (arch, '+')); - if (arch_for_multilib) - { - const enum isa_feature removable_bits[] = {ISA_IGNORE_FOR_MULTILIB, - isa_nobit}; - sbitmap isa_bits = sbitmap_alloc (isa_num_bits); - arm_initialize_isa (isa_bits, removable_bits); - bitmap_and_compl (target_isa, target_isa, isa_bits); - } - if (fpu && strcmp (fpu, "auto") != 0) { /* We assume that architectures do not have any FPU bits @@ -806,6 +799,16 @@ arm_canon_arch_option_1 (int argc, const char **argv, bool arch_for_multilib) bitmap_clear_bit (target_isa, isa_bit_vfpv2); } + /* Here we remove feature isa bits from -mlibarch string which are not + necessary for multilib string comparsion. */ + if ((arch || cpu) && arch_for_multilib) + { + const enum isa_feature removable_bits[] = {ISA_IGNORE_FOR_MULTILIB, + isa_nobit}; + arm_initialize_isa (ignore_multilib_isa, removable_bits); + bitmap_and_compl (target_isa, target_isa, ignore_multilib_isa); + } + /* If we don't have a selected architecture by now, something's badly wrong. */ gcc_assert (selected_arch); diff --git a/gcc/common/config/avr/avr-common.cc b/gcc/common/config/avr/avr-common.cc index f4e3f55..2ad0244 100644 --- a/gcc/common/config/avr/avr-common.cc +++ b/gcc/common/config/avr/avr-common.cc @@ -1,5 +1,5 @@ /* Common hooks for ATMEL AVR. - Copyright (C) 1998-2022 Free Software Foundation, Inc. + Copyright (C) 1998-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/bfin/bfin-common.cc b/gcc/common/config/bfin/bfin-common.cc index ac31c84..e64e384 100644 --- a/gcc/common/config/bfin/bfin-common.cc +++ b/gcc/common/config/bfin/bfin-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Blackfin. - Copyright (C) 2005-2022 Free Software Foundation, Inc. + Copyright (C) 2005-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/bpf/bpf-common.cc b/gcc/common/config/bpf/bpf-common.cc index 7d5eabe..6b90561 100644 --- a/gcc/common/config/bpf/bpf-common.cc +++ b/gcc/common/config/bpf/bpf-common.cc @@ -1,5 +1,5 @@ /* Common hooks for eBPF. - Copyright (C) 2019-2022 Free Software Foundation, Inc. + Copyright (C) 2019-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/c6x/c6x-common.cc b/gcc/common/config/c6x/c6x-common.cc index c160a37..60ae279 100644 --- a/gcc/common/config/c6x/c6x-common.cc +++ b/gcc/common/config/c6x/c6x-common.cc @@ -1,5 +1,5 @@ /* TI C6X common hooks. - Copyright (C) 2011-2022 Free Software Foundation, Inc. + Copyright (C) 2011-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/cris/cris-common.cc b/gcc/common/config/cris/cris-common.cc index 46cfee3..b08d601 100644 --- a/gcc/common/config/cris/cris-common.cc +++ b/gcc/common/config/cris/cris-common.cc @@ -1,5 +1,5 @@ /* Common hooks for CRIS. - Copyright (C) 1998-2022 Free Software Foundation, Inc. + Copyright (C) 1998-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/csky/csky-common.cc b/gcc/common/config/csky/csky-common.cc index 69f4878..4e22b20 100644 --- a/gcc/common/config/csky/csky-common.cc +++ b/gcc/common/config/csky/csky-common.cc @@ -1,5 +1,5 @@ /* Common hooks for CSKY. - Copyright (C) 2018-2022 Free Software Foundation, Inc. + Copyright (C) 2018-2023 Free Software Foundation, Inc. Contributed by C-SKY Microsystems and Mentor Graphics. This file is part of GCC. diff --git a/gcc/common/config/default-common.cc b/gcc/common/config/default-common.cc index 1c204c9..201ff17 100644 --- a/gcc/common/config/default-common.cc +++ b/gcc/common/config/default-common.cc @@ -1,5 +1,5 @@ /* Default common target hooks initializer. - Copyright (C) 2011-2022 Free Software Foundation, Inc. + Copyright (C) 2011-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/epiphany/epiphany-common.cc b/gcc/common/config/epiphany/epiphany-common.cc index 175d5a0..f99d450 100644 --- a/gcc/common/config/epiphany/epiphany-common.cc +++ b/gcc/common/config/epiphany/epiphany-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Adapteva Epiphany - Copyright (C) 1994-2022 Free Software Foundation, Inc. + Copyright (C) 1994-2023 Free Software Foundation, Inc. Contributed by Embecosm on behalf of Adapteva, Inc. This file is part of GCC. diff --git a/gcc/common/config/fr30/fr30-common.cc b/gcc/common/config/fr30/fr30-common.cc index 4df5175..8b650d1 100644 --- a/gcc/common/config/fr30/fr30-common.cc +++ b/gcc/common/config/fr30/fr30-common.cc @@ -1,5 +1,5 @@ /* Common hooks for FR30. - Copyright (C) 1998-2022 Free Software Foundation, Inc. + Copyright (C) 1998-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/frv/frv-common.cc b/gcc/common/config/frv/frv-common.cc index ab0fdad..0304fb1 100644 --- a/gcc/common/config/frv/frv-common.cc +++ b/gcc/common/config/frv/frv-common.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2022 Free Software Foundation, Inc. +/* Copyright (C) 1997-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/gcn/gcn-common.cc b/gcc/common/config/gcn/gcn-common.cc index 7c04bd5..65b73fe 100644 --- a/gcc/common/config/gcn/gcn-common.cc +++ b/gcc/common/config/gcn/gcn-common.cc @@ -1,5 +1,5 @@ /* Common hooks for GCN - Copyright (C) 2016-2022 Free Software Foundation, Inc. + Copyright (C) 2016-2023 Free Software Foundation, Inc. This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free diff --git a/gcc/common/config/h8300/h8300-common.cc b/gcc/common/config/h8300/h8300-common.cc index bfbda22..3dbec74 100644 --- a/gcc/common/config/h8300/h8300-common.cc +++ b/gcc/common/config/h8300/h8300-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Renesas H8/300. - Copyright (C) 1992-2022 Free Software Foundation, Inc. + Copyright (C) 1992-2023 Free Software Foundation, Inc. This file is part of GCC. @@ -32,6 +32,8 @@ static const struct default_options h8300_option_optimization_table[] = and/or variable-cycle branches where (cycle count taken != cycle count not taken). */ { OPT_LEVELS_ALL, OPT_freorder_blocks, NULL, 0 }, + /* Enable redundant extension instructions removal at -O2 and higher. */ + { OPT_LEVELS_2_PLUS, OPT_free, NULL, 1 }, { OPT_LEVELS_NONE, 0, NULL, 0 } }; diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h index bbced8a..5bde0cd 100644 --- a/gcc/common/config/i386/cpuinfo.h +++ b/gcc/common/config/i386/cpuinfo.h @@ -1,5 +1,5 @@ /* Get CPU type and Features for x86 processors. - Copyright (C) 2012-2022 Free Software Foundation, Inc. + Copyright (C) 2012-2023 Free Software Foundation, Inc. Contributed by Sriraman Tallam (tmsriram@google.com) This file is part of GCC. @@ -76,6 +76,8 @@ has_cpu_feature (struct __processor_model *cpu_model, } } +/* Save FEATURE to either CPU_MODEL or CPU_FEATURES2. */ + static inline void set_cpu_feature (struct __processor_model *cpu_model, unsigned int *cpu_features2, @@ -100,6 +102,32 @@ set_cpu_feature (struct __processor_model *cpu_model, } } +/* Drop FEATURE from either CPU_MODEL or CPU_FEATURES2. */ + +static inline void +reset_cpu_feature (struct __processor_model *cpu_model, + unsigned int *cpu_features2, + enum processor_features feature) +{ + unsigned index, offset; + unsigned f = feature; + + if (f < 32) + { + /* The first 32 features. */ + cpu_model->__cpu_features[0] &= ~(1U << f); + } + else + { + /* The rest of features. cpu_features2[i] contains features from + (32 + i * 32) to (31 + 32 + i * 32), inclusively. */ + f -= 32; + index = f / 32; + offset = f % 32; + cpu_features2[index] &= ~(1U << offset); + } +} + /* Get the specific type of AMD CPU and return AMD CPU name. Return NULL for unknown AMD CPU. */ @@ -253,13 +281,27 @@ get_amd_cpu (struct __processor_model *cpu_model, break; case 0x19: cpu_model->__cpu_type = AMDFAM19H; - /* AMD family 19h version 1. */ + /* AMD family 19h. */ if (model <= 0x0f) { cpu = "znver3"; CHECK___builtin_cpu_is ("znver3"); cpu_model->__cpu_subtype = AMDFAM19H_ZNVER3; } + else if ((model >= 0x10 && model <= 0x1f) + || (model >= 0x60 && model <= 0xaf)) + { + cpu = "znver4"; + CHECK___builtin_cpu_is ("znver4"); + cpu_model->__cpu_subtype = AMDFAM19H_ZNVER4; + } + else if (has_cpu_feature (cpu_model, cpu_features2, + FEATURE_AVX512F)) + { + cpu = "znver4"; + CHECK___builtin_cpu_is ("znver4"); + cpu_model->__cpu_subtype = AMDFAM19H_ZNVER4; + } else if (has_cpu_feature (cpu_model, cpu_features2, FEATURE_VAES)) { @@ -496,6 +538,11 @@ get_intel_cpu (struct __processor_model *cpu_model, case 0x9a: case 0xbf: /* Alder Lake. */ + case 0xb7: + /* Raptor Lake. */ + case 0xaa: + case 0xac: + /* Meteor Lake. */ cpu = "alderlake"; CHECK___builtin_cpu_is ("corei7"); CHECK___builtin_cpu_is ("alderlake"); @@ -504,12 +551,35 @@ get_intel_cpu (struct __processor_model *cpu_model, break; case 0x8f: /* Sapphire Rapids. */ + case 0xcf: + /* Emerald Rapids. */ cpu = "sapphirerapids"; CHECK___builtin_cpu_is ("corei7"); CHECK___builtin_cpu_is ("sapphirerapids"); 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 0xad: + case 0xae: + /* Granite Rapids. */ + cpu = "graniterapids"; + CHECK___builtin_cpu_is ("corei7"); + CHECK___builtin_cpu_is ("graniterapids"); + cpu_model->__cpu_type = INTEL_COREI7; + cpu_model->__cpu_subtype = INTEL_COREI7_GRANITERAPIDS; + break; + case 0xb6: + /* Grand Ridge. */ + cpu = "grandridge"; + CHECK___builtin_cpu_is ("grandridge"); + cpu_model->__cpu_type = INTEL_GRANDRIDGE; + break; case 0x17: case 0x1d: /* Penryn. */ @@ -531,8 +601,8 @@ get_intel_cpu (struct __processor_model *cpu_model, static inline const char * get_zhaoxin_cpu (struct __processor_model *cpu_model, - struct __processor_model2 *cpu_model2, - unsigned int *cpu_features2) + struct __processor_model2 *cpu_model2, + unsigned int *cpu_features2) { const char *cpu = NULL; unsigned int family = cpu_model2->__cpu_family; @@ -545,11 +615,11 @@ get_zhaoxin_cpu (struct __processor_model *cpu_model, cpu_model->__cpu_type = ZHAOXIN_FAM7H; if (model == 0x3b) { - cpu = "lujiazui"; - CHECK___builtin_cpu_is ("lujiazui"); - cpu_model->__cpu_features[0] &= ~(1U <<(FEATURE_AVX & 31)); - cpu_features2[0] &= ~(1U <<((FEATURE_F16C - 32) & 31)); - cpu_model->__cpu_subtype = ZHAOXIN_FAM7H_LUJIAZUI; + cpu = "lujiazui"; + CHECK___builtin_cpu_is ("lujiazui"); + reset_cpu_feature (cpu_model, cpu_features2, FEATURE_AVX); + reset_cpu_feature (cpu_model, cpu_features2, FEATURE_F16C); + cpu_model->__cpu_subtype = ZHAOXIN_FAM7H_LUJIAZUI; } break; default: @@ -783,16 +853,33 @@ get_available_features (struct __processor_model *cpu_model, __cpuid_count (7, 1, eax, ebx, ecx, edx); if (eax & bit_HRESET) set_feature (FEATURE_HRESET); + if (eax & bit_CMPCCXADD) + set_feature(FEATURE_CMPCCXADD); + if (edx & bit_PREFETCHI) + set_feature (FEATURE_PREFETCHI); + if (eax & bit_RAOINT) + set_feature (FEATURE_RAOINT); if (avx_usable) { if (eax & bit_AVXVNNI) set_feature (FEATURE_AVXVNNI); + if (eax & bit_AVXIFMA) + set_feature (FEATURE_AVXIFMA); + if (edx & bit_AVXVNNIINT8) + set_feature (FEATURE_AVXVNNIINT8); + if (edx & bit_AVXNECONVERT) + set_feature (FEATURE_AVXNECONVERT); } if (avx512_usable) { if (eax & bit_AVX512BF16) set_feature (FEATURE_AVX512BF16); } + if (amx_usable) + { + if (eax & bit_AMX_FP16) + set_feature (FEATURE_AMX_FP16); + } } /* Get Advanced Features at level 0xd (eax = 0xd, ecx = 1). */ @@ -929,6 +1016,10 @@ cpu_indicator_init (struct __processor_model *cpu_model, extended_model = (eax >> 12) & 0xf0; extended_family = (eax >> 20) & 0xff; + /* Find available features. */ + get_available_features (cpu_model, cpu_model2, cpu_features2, + ecx, edx); + if (vendor == signature_INTEL_ebx) { /* Adjust model and family for Intel CPUS. */ @@ -943,9 +1034,6 @@ cpu_indicator_init (struct __processor_model *cpu_model, cpu_model2->__cpu_family = family; cpu_model2->__cpu_model = model; - /* Find available features. */ - get_available_features (cpu_model, cpu_model2, cpu_features2, - ecx, edx); /* Get CPU type. */ get_intel_cpu (cpu_model, cpu_model2, cpu_features2); cpu_model->__cpu_vendor = VENDOR_INTEL; @@ -962,9 +1050,6 @@ cpu_indicator_init (struct __processor_model *cpu_model, cpu_model2->__cpu_family = family; cpu_model2->__cpu_model = model; - /* Find available features. */ - get_available_features (cpu_model, cpu_model2, cpu_features2, - ecx, edx); /* Get CPU type. */ get_amd_cpu (cpu_model, cpu_model2, cpu_features2); cpu_model->__cpu_vendor = VENDOR_AMD; @@ -972,22 +1057,17 @@ cpu_indicator_init (struct __processor_model *cpu_model, else if (vendor == signature_CENTAUR_ebx && family < 0x07) cpu_model->__cpu_vendor = VENDOR_CENTAUR; else if (vendor == signature_SHANGHAI_ebx - || vendor == signature_CENTAUR_ebx) + || vendor == signature_CENTAUR_ebx) { /* Adjust model and family for ZHAOXIN CPUS. */ if (family == 0x07) - { - model += extended_model; - } + model += extended_model; cpu_model2->__cpu_family = family; cpu_model2->__cpu_model = model; - /* Find available features. */ - get_available_features (cpu_model, cpu_model2, cpu_features2, - ecx, edx); /* Get CPU type. */ - get_zhaoxin_cpu (cpu_model, cpu_model2,cpu_features2); + get_zhaoxin_cpu (cpu_model, cpu_model2, cpu_features2); cpu_model->__cpu_vendor = VENDOR_ZHAOXIN; } else if (vendor == signature_CYRIX_ebx) diff --git a/gcc/common/config/i386/i386-common.cc b/gcc/common/config/i386/i386-common.cc index c0c2ad7..0181e06 100644 --- a/gcc/common/config/i386/i386-common.cc +++ b/gcc/common/config/i386/i386-common.cc @@ -1,5 +1,5 @@ /* IA-32 common hooks. - Copyright (C) 1988-2022 Free Software Foundation, Inc. + Copyright (C) 1988-2023 Free Software Foundation, Inc. This file is part of GCC. @@ -76,6 +76,7 @@ along with GCC; see the file COPYING3. If not see (OPTION_MASK_ISA_AVX512VL | OPTION_MASK_ISA_AVX512F_SET) #define OPTION_MASK_ISA_AVX512IFMA_SET \ (OPTION_MASK_ISA_AVX512IFMA | OPTION_MASK_ISA_AVX512F_SET) +#define OPTION_MASK_ISA2_AVXIFMA_SET OPTION_MASK_ISA2_AVXIFMA #define OPTION_MASK_ISA_AVX512VBMI_SET \ (OPTION_MASK_ISA_AVX512VBMI | OPTION_MASK_ISA_AVX512BW_SET) #define OPTION_MASK_ISA2_AVX5124FMAPS_SET OPTION_MASK_ISA2_AVX5124FMAPS @@ -105,8 +106,17 @@ along with GCC; see the file COPYING3. If not see #define OPTION_MASK_ISA_CLWB_SET OPTION_MASK_ISA_CLWB #define OPTION_MASK_ISA2_AVX512VP2INTERSECT_SET OPTION_MASK_ISA2_AVX512VP2INTERSECT #define OPTION_MASK_ISA2_AMX_TILE_SET OPTION_MASK_ISA2_AMX_TILE -#define OPTION_MASK_ISA2_AMX_INT8_SET OPTION_MASK_ISA2_AMX_INT8 -#define OPTION_MASK_ISA2_AMX_BF16_SET OPTION_MASK_ISA2_AMX_BF16 +#define OPTION_MASK_ISA2_AMX_INT8_SET \ + (OPTION_MASK_ISA2_AMX_TILE | OPTION_MASK_ISA2_AMX_INT8) +#define OPTION_MASK_ISA2_AMX_BF16_SET \ + (OPTION_MASK_ISA2_AMX_TILE | OPTION_MASK_ISA2_AMX_BF16) +#define OPTION_MASK_ISA2_AVXVNNIINT8_SET OPTION_MASK_ISA2_AVXVNNIINT8 +#define OPTION_MASK_ISA2_AVXNECONVERT_SET OPTION_MASK_ISA2_AVXNECONVERT +#define OPTION_MASK_ISA2_CMPCCXADD_SET OPTION_MASK_ISA2_CMPCCXADD +#define OPTION_MASK_ISA2_AMX_FP16_SET \ + (OPTION_MASK_ISA2_AMX_TILE | OPTION_MASK_ISA2_AMX_FP16) +#define OPTION_MASK_ISA2_PREFETCHI_SET OPTION_MASK_ISA2_PREFETCHI +#define OPTION_MASK_ISA2_RAOINT_SET OPTION_MASK_ISA2_RAOINT /* SSE4 includes both SSE4.1 and SSE4.2. -msse4 should be the same as -msse4.2. */ @@ -212,7 +222,9 @@ along with GCC; see the file COPYING3. If not see #define OPTION_MASK_ISA_AVX2_UNSET \ (OPTION_MASK_ISA_AVX2 | OPTION_MASK_ISA_AVX512F_UNSET) #define OPTION_MASK_ISA2_AVX2_UNSET \ - (OPTION_MASK_ISA2_AVXVNNI_UNSET | OPTION_MASK_ISA2_AVX512F_UNSET) + (OPTION_MASK_ISA2_AVXIFMA_UNSET | OPTION_MASK_ISA2_AVXVNNI_UNSET \ + | OPTION_MASK_ISA2_AVXVNNIINT8_UNSET | OPTION_MASK_ISA2_AVXNECONVERT_UNSET \ + | OPTION_MASK_ISA2_AVX512F_UNSET) #define OPTION_MASK_ISA_AVX512F_UNSET \ (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_AVX512CD_UNSET \ | OPTION_MASK_ISA_AVX512PF_UNSET | OPTION_MASK_ISA_AVX512ER_UNSET \ @@ -230,6 +242,7 @@ along with GCC; see the file COPYING3. If not see (OPTION_MASK_ISA_AVX512BW | OPTION_MASK_ISA_AVX512VBMI_UNSET) #define OPTION_MASK_ISA_AVX512VL_UNSET OPTION_MASK_ISA_AVX512VL #define OPTION_MASK_ISA_AVX512IFMA_UNSET OPTION_MASK_ISA_AVX512IFMA +#define OPTION_MASK_ISA2_AVXIFMA_UNSET OPTION_MASK_ISA2_AVXIFMA #define OPTION_MASK_ISA_AVX512VBMI_UNSET OPTION_MASK_ISA_AVX512VBMI #define OPTION_MASK_ISA2_AVX5124FMAPS_UNSET OPTION_MASK_ISA2_AVX5124FMAPS #define OPTION_MASK_ISA2_AVX5124VNNIW_UNSET OPTION_MASK_ISA2_AVX5124VNNIW @@ -267,7 +280,9 @@ along with GCC; see the file COPYING3. If not see #define OPTION_MASK_ISA2_SERIALIZE_UNSET OPTION_MASK_ISA2_SERIALIZE #define OPTION_MASK_ISA2_AVX512VP2INTERSECT_UNSET OPTION_MASK_ISA2_AVX512VP2INTERSECT #define OPTION_MASK_ISA2_TSXLDTRK_UNSET OPTION_MASK_ISA2_TSXLDTRK -#define OPTION_MASK_ISA2_AMX_TILE_UNSET OPTION_MASK_ISA2_AMX_TILE +#define OPTION_MASK_ISA2_AMX_TILE_UNSET \ + (OPTION_MASK_ISA2_AMX_TILE | OPTION_MASK_ISA2_AMX_INT8_UNSET \ + | OPTION_MASK_ISA2_AMX_BF16_UNSET | OPTION_MASK_ISA2_AMX_FP16_UNSET) #define OPTION_MASK_ISA2_AMX_INT8_UNSET OPTION_MASK_ISA2_AMX_INT8 #define OPTION_MASK_ISA2_AMX_BF16_UNSET OPTION_MASK_ISA2_AMX_BF16 #define OPTION_MASK_ISA2_UINTR_UNSET OPTION_MASK_ISA2_UINTR @@ -275,6 +290,12 @@ along with GCC; see the file COPYING3. If not see #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 +#define OPTION_MASK_ISA2_AVXVNNIINT8_UNSET OPTION_MASK_ISA2_AVXVNNIINT8 +#define OPTION_MASK_ISA2_AVXNECONVERT_UNSET OPTION_MASK_ISA2_AVXNECONVERT +#define OPTION_MASK_ISA2_CMPCCXADD_UNSET OPTION_MASK_ISA2_CMPCCXADD +#define OPTION_MASK_ISA2_AMX_FP16_UNSET OPTION_MASK_ISA2_AMX_FP16 +#define OPTION_MASK_ISA2_PREFETCHI_UNSET OPTION_MASK_ISA2_PREFETCHI +#define OPTION_MASK_ISA2_RAOINT_UNSET OPTION_MASK_ISA2_RAOINT /* SSE4 includes both SSE4.1 and SSE4.2. -mno-sse4 should the same as -mno-sse4.1. */ @@ -1124,6 +1145,107 @@ ix86_handle_option (struct gcc_options *opts, } return true; + case OPT_mavxifma: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_AVXIFMA_SET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVXIFMA_SET; + opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX2_SET; + opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX2_SET; + } + else + { + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVXIFMA_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVXIFMA_UNSET; + } + return true; + + case OPT_mavxvnniint8: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_AVXVNNIINT8_SET; + opts->x_ix86_isa_flags2_explicit |= + OPTION_MASK_ISA2_AVXVNNIINT8_SET; + opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX2_SET; + opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX2_SET; + } + else + { + opts->x_ix86_isa_flags2 &= + ~OPTION_MASK_ISA2_AVXVNNIINT8_UNSET; + opts->x_ix86_isa_flags2_explicit |= + OPTION_MASK_ISA2_AVXVNNIINT8_UNSET; + } + return true; + + case OPT_mavxneconvert: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_AVXNECONVERT_SET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVXNECONVERT_SET; + opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX2_SET; + opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX2_SET; + } + else + { + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVXNECONVERT_UNSET; + opts->x_ix86_isa_flags2_explicit + |= OPTION_MASK_ISA2_AVXNECONVERT_UNSET; + } + return true; + + case OPT_mcmpccxadd: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_CMPCCXADD_SET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_CMPCCXADD_SET; + } + else + { + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_CMPCCXADD_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_CMPCCXADD_UNSET; + } + return true; + + case OPT_mamx_fp16: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_AMX_FP16_SET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AMX_FP16_SET; + } + else + { + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AMX_FP16_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AMX_FP16_UNSET; + } + return true; + + case OPT_mprefetchi: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_PREFETCHI_SET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_PREFETCHI_SET; + } + else + { + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_PREFETCHI_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_PREFETCHI_UNSET; + } + return true; + + case OPT_mraoint: + if (value) + { + opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_RAOINT_SET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_RAOINT_SET; + } + else + { + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_RAOINT_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_RAOINT_UNSET; + } + return true; + case OPT_mfma: if (value) { @@ -1686,6 +1808,15 @@ static const struct default_options ix86_option_optimization_table[] = /* The STC algorithm produces the smallest code at -Os, for x86. */ { OPT_LEVELS_2_PLUS, OPT_freorder_blocks_algorithm_, NULL, REORDER_BLOCKS_ALGORITHM_STC }, + + /* Turn on -funroll-loops with -munroll-only-small-loops to enable small + loop unrolling at -O2. */ + { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_funroll_loops, NULL, 1 }, + { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_munroll_only_small_loops, NULL, 1 }, + /* Turns off -frename-registers and -fweb which are enabled by + funroll-loops. */ + { OPT_LEVELS_ALL, OPT_frename_registers, NULL, 0 }, + { OPT_LEVELS_ALL, OPT_fweb, NULL, 0 }, /* Turn off -fschedule-insns by default. It tends to make the problem with not enough registers even worse. */ { OPT_LEVELS_ALL, OPT_fschedule_insns, NULL, 0 }, @@ -1802,6 +1933,8 @@ const char *const processor_names[] = "goldmont", "goldmont-plus", "tremont", + "sierraforest", + "grandridge", "knl", "knm", "skylake", @@ -1815,6 +1948,7 @@ const char *const processor_names[] = "sapphirerapids", "alderlake", "rocketlake", + "graniterapids", "intel", "lujiazui", "geode", @@ -1830,7 +1964,8 @@ const char *const processor_names[] = "btver2", "znver1", "znver2", - "znver3" + "znver3", + "znver4" }; /* Guarantee that the array is aligned with enum processor_type. */ @@ -1927,8 +2062,16 @@ const pta processor_alias_table[] = M_CPU_SUBTYPE (INTEL_COREI7_COOPERLAKE), P_PROC_AVX512F}, {"sapphirerapids", PROCESSOR_SAPPHIRERAPIDS, CPU_HASWELL, PTA_SAPPHIRERAPIDS, M_CPU_SUBTYPE (INTEL_COREI7_SAPPHIRERAPIDS), P_PROC_AVX512F}, + {"emeraldrapids", PROCESSOR_SAPPHIRERAPIDS, CPU_HASWELL, PTA_SAPPHIRERAPIDS, + M_CPU_SUBTYPE (INTEL_COREI7_SAPPHIRERAPIDS), P_PROC_AVX512F}, {"alderlake", PROCESSOR_ALDERLAKE, CPU_HASWELL, PTA_ALDERLAKE, M_CPU_SUBTYPE (INTEL_COREI7_ALDERLAKE), P_PROC_AVX2}, + {"raptorlake", PROCESSOR_ALDERLAKE, CPU_HASWELL, PTA_ALDERLAKE, + M_CPU_SUBTYPE (INTEL_COREI7_ALDERLAKE), P_PROC_AVX2}, + {"meteorlake", PROCESSOR_ALDERLAKE, CPU_HASWELL, PTA_ALDERLAKE, + M_CPU_SUBTYPE (INTEL_COREI7_ALDERLAKE), P_PROC_AVX2}, + {"graniterapids", PROCESSOR_GRANITERAPIDS, CPU_HASWELL, PTA_GRANITERAPIDS, + M_CPU_SUBTYPE (INTEL_COREI7_GRANITERAPIDS), P_PROC_AVX512F}, {"bonnell", PROCESSOR_BONNELL, CPU_ATOM, PTA_BONNELL, M_CPU_TYPE (INTEL_BONNELL), P_PROC_SSSE3}, {"atom", PROCESSOR_BONNELL, CPU_ATOM, PTA_BONNELL, @@ -1943,6 +2086,10 @@ 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}, + {"grandridge", PROCESSOR_GRANDRIDGE, CPU_HASWELL, PTA_GRANDRIDGE, + M_CPU_TYPE (INTEL_GRANDRIDGE), 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, @@ -2062,37 +2209,17 @@ const pta processor_alias_table[] = | PTA_MOVBE | PTA_MWAITX, M_CPU_SUBTYPE (AMDFAM15H_BDVER4), P_PROC_AVX2}, {"znver1", PROCESSOR_ZNVER1, CPU_ZNVER1, - PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 - | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1 - | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_AVX2 - | PTA_BMI | PTA_BMI2 | PTA_F16C | PTA_FMA | PTA_PRFCHW - | PTA_FXSR | PTA_XSAVE | PTA_XSAVEOPT | PTA_FSGSBASE - | PTA_RDRND | PTA_MOVBE | PTA_MWAITX | PTA_ADX | PTA_RDSEED - | PTA_CLZERO | PTA_CLFLUSHOPT | PTA_XSAVEC | PTA_XSAVES - | PTA_SHA | PTA_LZCNT | PTA_POPCNT, + PTA_ZNVER1, M_CPU_SUBTYPE (AMDFAM17H_ZNVER1), P_PROC_AVX2}, {"znver2", PROCESSOR_ZNVER2, CPU_ZNVER2, - PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 - | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1 - | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_AVX2 - | PTA_BMI | PTA_BMI2 | PTA_F16C | PTA_FMA | PTA_PRFCHW - | PTA_FXSR | PTA_XSAVE | PTA_XSAVEOPT | PTA_FSGSBASE - | PTA_RDRND | PTA_MOVBE | PTA_MWAITX | PTA_ADX | PTA_RDSEED - | PTA_CLZERO | PTA_CLFLUSHOPT | PTA_XSAVEC | PTA_XSAVES - | PTA_SHA | PTA_LZCNT | PTA_POPCNT | PTA_CLWB | PTA_RDPID - | PTA_WBNOINVD, + PTA_ZNVER2, M_CPU_SUBTYPE (AMDFAM17H_ZNVER2), P_PROC_AVX2}, {"znver3", PROCESSOR_ZNVER3, CPU_ZNVER3, - PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 - | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1 - | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_AVX2 - | PTA_BMI | PTA_BMI2 | PTA_F16C | PTA_FMA | PTA_PRFCHW - | PTA_FXSR | PTA_XSAVE | PTA_XSAVEOPT | PTA_FSGSBASE - | PTA_RDRND | PTA_MOVBE | PTA_MWAITX | PTA_ADX | PTA_RDSEED - | PTA_CLZERO | PTA_CLFLUSHOPT | PTA_XSAVEC | PTA_XSAVES - | PTA_SHA | PTA_LZCNT | PTA_POPCNT | PTA_CLWB | PTA_RDPID - | PTA_WBNOINVD | PTA_VAES | PTA_VPCLMULQDQ | PTA_PKU, + PTA_ZNVER3, M_CPU_SUBTYPE (AMDFAM19H_ZNVER3), P_PROC_AVX2}, + {"znver4", PROCESSOR_ZNVER4, CPU_ZNVER4, + PTA_ZNVER4, + M_CPU_SUBTYPE (AMDFAM19H_ZNVER4), P_PROC_AVX512F}, {"btver1", PROCESSOR_BTVER1, CPU_GENERIC, PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 | PTA_SSSE3 | PTA_SSE4A | PTA_ABM | PTA_CX16 | PTA_PRFCHW diff --git a/gcc/common/config/i386/i386-cpuinfo.h b/gcc/common/config/i386/i386-cpuinfo.h index 643fbd9..b5933b85 100644 --- a/gcc/common/config/i386/i386-cpuinfo.h +++ b/gcc/common/config/i386/i386-cpuinfo.h @@ -1,5 +1,5 @@ /* Get CPU type and Features for x86 processors. - Copyright (C) 2012-2022 Free Software Foundation, Inc. + Copyright (C) 2012-2023 Free Software Foundation, Inc. Contributed by Sriraman Tallam (tmsriram@google.com) This file is part of GCC. @@ -34,8 +34,10 @@ enum processor_vendor VENDOR_CENTAUR, VENDOR_CYRIX, VENDOR_NSC, - BUILTIN_VENDOR_MAX = VENDOR_OTHER, - VENDOR_MAX + + /* Maximum values must be at the end of this enum. */ + VENDOR_MAX, + BUILTIN_VENDOR_MAX = VENDOR_OTHER }; /* Any new types or subtypes have to be inserted at the end. */ @@ -58,6 +60,8 @@ enum processor_types INTEL_TREMONT, AMDFAM19H, ZHAOXIN_FAM7H, + INTEL_SIERRAFOREST, + INTEL_GRANDRIDGE, CPU_TYPE_MAX, BUILTIN_CPU_TYPE_MAX = CPU_TYPE_MAX }; @@ -92,6 +96,8 @@ enum processor_subtypes AMDFAM19H_ZNVER3, INTEL_COREI7_ROCKETLAKE, ZHAOXIN_FAM7H_LUJIAZUI, + AMDFAM19H_ZNVER4, + INTEL_COREI7_GRANITERAPIDS, CPU_SUBTYPE_MAX }; @@ -240,6 +246,13 @@ enum processor_features FEATURE_X86_64_V2, FEATURE_X86_64_V3, FEATURE_X86_64_V4, + FEATURE_AVXIFMA, + FEATURE_AVXVNNIINT8, + FEATURE_AVXNECONVERT, + FEATURE_CMPCCXADD, + FEATURE_AMX_FP16, + FEATURE_PREFETCHI, + FEATURE_RAOINT, CPU_FEATURE_MAX }; diff --git a/gcc/common/config/i386/i386-isas.h b/gcc/common/config/i386/i386-isas.h index 2d0646a..8ed1428 100644 --- a/gcc/common/config/i386/i386-isas.h +++ b/gcc/common/config/i386/i386-isas.h @@ -1,5 +1,5 @@ /* i386 ISA table. - Copyright (C) 2020-2022 Free Software Foundation, Inc. + Copyright (C) 2020-2023 Free Software Foundation, Inc. This file is part of GCC. @@ -175,4 +175,13 @@ ISA_NAMES_TABLE_START ISA_NAMES_TABLE_ENTRY("x86-64-v2", FEATURE_X86_64_V2, P_X86_64_V2, NULL) ISA_NAMES_TABLE_ENTRY("x86-64-v3", FEATURE_X86_64_V3, P_X86_64_V3, NULL) ISA_NAMES_TABLE_ENTRY("x86-64-v4", FEATURE_X86_64_V4, P_X86_64_V4, NULL) + ISA_NAMES_TABLE_ENTRY("avxifma", FEATURE_AVXIFMA, P_NONE, "-mavxifma") + ISA_NAMES_TABLE_ENTRY("avxvnniint8", FEATURE_AVXVNNIINT8, + P_NONE, "-mavxvnniint8") + ISA_NAMES_TABLE_ENTRY("avxneconvert", FEATURE_AVXNECONVERT, + P_NONE, "-mavxneconvert") + ISA_NAMES_TABLE_ENTRY("cmpccxadd", FEATURE_CMPCCXADD, P_NONE, "-mcmpccxadd") + ISA_NAMES_TABLE_ENTRY("amx-fp16", FEATURE_AMX_FP16, P_NONE, "-mamx-fp16") + ISA_NAMES_TABLE_ENTRY("prefetchi", FEATURE_PREFETCHI, P_NONE, "-mprefetchi") + ISA_NAMES_TABLE_ENTRY("raoint", FEATURE_RAOINT, P_NONE, "-mraoint") ISA_NAMES_TABLE_END diff --git a/gcc/common/config/ia64/ia64-common.cc b/gcc/common/config/ia64/ia64-common.cc index 6da01ab..9b7b7f0 100644 --- a/gcc/common/config/ia64/ia64-common.cc +++ b/gcc/common/config/ia64/ia64-common.cc @@ -1,5 +1,5 @@ /* Common hooks for IA64. - Copyright (C) 1999-2022 Free Software Foundation, Inc. + Copyright (C) 1999-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/iq2000/iq2000-common.cc b/gcc/common/config/iq2000/iq2000-common.cc index 576949d..70bb8f0 100644 --- a/gcc/common/config/iq2000/iq2000-common.cc +++ b/gcc/common/config/iq2000/iq2000-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Vitesse IQ2000. - Copyright (C) 2003-2022 Free Software Foundation, Inc. + Copyright (C) 2003-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/lm32/lm32-common.cc b/gcc/common/config/lm32/lm32-common.cc index cdf2d14..370d55d 100644 --- a/gcc/common/config/lm32/lm32-common.cc +++ b/gcc/common/config/lm32/lm32-common.cc @@ -1,6 +1,6 @@ /* Common hooks for Lattice Mico32. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/loongarch/loongarch-common.cc b/gcc/common/config/loongarch/loongarch-common.cc index f8b4660..fce32fa 100644 --- a/gcc/common/config/loongarch/loongarch-common.cc +++ b/gcc/common/config/loongarch/loongarch-common.cc @@ -1,5 +1,5 @@ /* Common hooks for LoongArch. - Copyright (C) 2021-2022 Free Software Foundation, Inc. + Copyright (C) 2021-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/m32r/m32r-common.cc b/gcc/common/config/m32r/m32r-common.cc index 9592097..7141e8e 100644 --- a/gcc/common/config/m32r/m32r-common.cc +++ b/gcc/common/config/m32r/m32r-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Renesas M32R. - Copyright (C) 1996-2022 Free Software Foundation, Inc. + Copyright (C) 1996-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/m68k/m68k-common.cc b/gcc/common/config/m68k/m68k-common.cc index f5ea217..fd21439 100644 --- a/gcc/common/config/m68k/m68k-common.cc +++ b/gcc/common/config/m68k/m68k-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Motorola 68000 family. - Copyright (C) 1987-2022 Free Software Foundation, Inc. + Copyright (C) 1987-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/mcore/mcore-common.cc b/gcc/common/config/mcore/mcore-common.cc index 8c12299..cf66cd7 100644 --- a/gcc/common/config/mcore/mcore-common.cc +++ b/gcc/common/config/mcore/mcore-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Motorola MCore. - Copyright (C) 1993-2022 Free Software Foundation, Inc. + Copyright (C) 1993-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/microblaze/microblaze-common.cc b/gcc/common/config/microblaze/microblaze-common.cc index 21b35f5..8750b02 100644 --- a/gcc/common/config/microblaze/microblaze-common.cc +++ b/gcc/common/config/microblaze/microblaze-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Xilinx MicroBlaze. - Copyright (C) 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2009-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/mips/mips-common.cc b/gcc/common/config/mips/mips-common.cc index b8ee4f3..9676cd0 100644 --- a/gcc/common/config/mips/mips-common.cc +++ b/gcc/common/config/mips/mips-common.cc @@ -1,5 +1,5 @@ /* Common hooks for MIPS. - Copyright (C) 1989-2022 Free Software Foundation, Inc. + Copyright (C) 1989-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/mmix/mmix-common.cc b/gcc/common/config/mmix/mmix-common.cc index fd91ece..25cd7d1 100644 --- a/gcc/common/config/mmix/mmix-common.cc +++ b/gcc/common/config/mmix/mmix-common.cc @@ -1,5 +1,5 @@ /* Common hooks for MMIX. - Copyright (C) 2000-2022 Free Software Foundation, Inc. + Copyright (C) 2000-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/mn10300/mn10300-common.cc b/gcc/common/config/mn10300/mn10300-common.cc index a0a3a25..f57b884 100644 --- a/gcc/common/config/mn10300/mn10300-common.cc +++ b/gcc/common/config/mn10300/mn10300-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Matsushita MN10300 series. - Copyright (C) 1996-2022 Free Software Foundation, Inc. + Copyright (C) 1996-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/msp430/msp430-common.cc b/gcc/common/config/msp430/msp430-common.cc index 7da7390..4e833e6 100644 --- a/gcc/common/config/msp430/msp430-common.cc +++ b/gcc/common/config/msp430/msp430-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Texas Instruments MSP430. - Copyright (C) 2014-2022 Free Software Foundation, Inc. + Copyright (C) 2014-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/nds32/nds32-common.cc b/gcc/common/config/nds32/nds32-common.cc index a2ce0bb..bd2e2b1 100644 --- a/gcc/common/config/nds32/nds32-common.cc +++ b/gcc/common/config/nds32/nds32-common.cc @@ -1,5 +1,5 @@ /* Common hooks of Andes NDS32 cpu for GNU compiler - Copyright (C) 2012-2022 Free Software Foundation, Inc. + Copyright (C) 2012-2023 Free Software Foundation, Inc. Contributed by Andes Technology Corporation. This file is part of GCC. diff --git a/gcc/common/config/nios2/nios2-common.cc b/gcc/common/config/nios2/nios2-common.cc index 3a2e481..b520b2e 100644 --- a/gcc/common/config/nios2/nios2-common.cc +++ b/gcc/common/config/nios2/nios2-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Altera Nios II. - Copyright (C) 2012-2022 Free Software Foundation, Inc. + Copyright (C) 2012-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/nvptx/nvptx-common.cc b/gcc/common/config/nvptx/nvptx-common.cc index 6d434b9..fbcc87d 100644 --- a/gcc/common/config/nvptx/nvptx-common.cc +++ b/gcc/common/config/nvptx/nvptx-common.cc @@ -1,5 +1,5 @@ /* NVPTX common hooks. - Copyright (C) 2014-2022 Free Software Foundation, Inc. + Copyright (C) 2014-2023 Free Software Foundation, Inc. Contributed by Bernd Schmidt <bernds@codesourcery.com> This file is part of GCC. diff --git a/gcc/common/config/or1k/or1k-common.cc b/gcc/common/config/or1k/or1k-common.cc index 075851e..c03711d 100644 --- a/gcc/common/config/or1k/or1k-common.cc +++ b/gcc/common/config/or1k/or1k-common.cc @@ -1,5 +1,5 @@ /* Common hooks for OpenRISC - Copyright (C) 2018-2022 Free Software Foundation, Inc. + Copyright (C) 2018-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/pa/pa-common.cc b/gcc/common/config/pa/pa-common.cc index cee2b5b..9f8c737 100644 --- a/gcc/common/config/pa/pa-common.cc +++ b/gcc/common/config/pa/pa-common.cc @@ -1,5 +1,5 @@ /* HPPA common hooks. - Copyright (C) 1992-2022 Free Software Foundation, Inc. + Copyright (C) 1992-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/pdp11/pdp11-common.cc b/gcc/common/config/pdp11/pdp11-common.cc index 81a57bb..6dc8793 100644 --- a/gcc/common/config/pdp11/pdp11-common.cc +++ b/gcc/common/config/pdp11/pdp11-common.cc @@ -1,5 +1,5 @@ /* Common hooks for pdp11. - Copyright (C) 1994-2022 Free Software Foundation, Inc. + Copyright (C) 1994-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/pru/pru-common.cc b/gcc/common/config/pru/pru-common.cc index 3e37fe8..933d361 100644 --- a/gcc/common/config/pru/pru-common.cc +++ b/gcc/common/config/pru/pru-common.cc @@ -1,5 +1,5 @@ /* Common hooks for TI PRU - Copyright (C) 2014-2022 Free Software Foundation, Inc. + Copyright (C) 2014-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 7721916..ef221be 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -1,5 +1,5 @@ /* Common hooks for RISC-V. - Copyright (C) 2016-2022 Free Software Foundation, Inc. + Copyright (C) 2016-2023 Free Software Foundation, Inc. This file is part of GCC. @@ -51,6 +51,11 @@ static const riscv_implied_info_t riscv_implied_info[] = {"d", "f"}, {"f", "zicsr"}, {"d", "zicsr"}, + + {"zdinx", "zfinx"}, + {"zfinx", "zicsr"}, + {"zdinx", "zicsr"}, + {"zk", "zkn"}, {"zk", "zkr"}, {"zk", "zkt"}, @@ -99,6 +104,9 @@ static const riscv_implied_info_t riscv_implied_info[] = {"zfh", "zfhmin"}, {"zfhmin", "f"}, + + {"zhinx", "zhinxmin"}, + {"zhinxmin", "zfinx"}, {NULL, NULL} }; @@ -145,6 +153,8 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"c", ISA_SPEC_CLASS_20190608, 2, 0}, {"c", ISA_SPEC_CLASS_2P2, 2, 0}, + {"h", ISA_SPEC_CLASS_NONE, 1, 0}, + {"v", ISA_SPEC_CLASS_NONE, 1, 0}, {"zicsr", ISA_SPEC_CLASS_20191213, 2, 0}, @@ -153,11 +163,18 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"zifencei", ISA_SPEC_CLASS_20191213, 2, 0}, {"zifencei", ISA_SPEC_CLASS_20190608, 2, 0}, + {"zawrs", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zba", ISA_SPEC_CLASS_NONE, 1, 0}, {"zbb", ISA_SPEC_CLASS_NONE, 1, 0}, {"zbc", ISA_SPEC_CLASS_NONE, 1, 0}, {"zbs", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zfinx", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zdinx", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zhinx", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zhinxmin", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zbkb", ISA_SPEC_CLASS_NONE, 1, 0}, {"zbkc", ISA_SPEC_CLASS_NONE, 1, 0}, {"zbkx", ISA_SPEC_CLASS_NONE, 1, 0}, @@ -202,6 +219,22 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"zmmul", ISA_SPEC_CLASS_NONE, 1, 0}, + {"svinval", ISA_SPEC_CLASS_NONE, 1, 0}, + {"svnapot", ISA_SPEC_CLASS_NONE, 1, 0}, + + {"xtheadba", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadbb", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadbs", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadcmo", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadcondmov", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadfmemidx", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadfmv", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadint", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadmac", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadmemidx", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadmempair", ISA_SPEC_CLASS_NONE, 1, 0}, + {"xtheadsync", ISA_SPEC_CLASS_NONE, 1, 0}, + /* Terminate the list. */ {NULL, ISA_SPEC_CLASS_NONE, 0, 0} }; @@ -224,6 +257,14 @@ static const riscv_cpu_info riscv_cpu_tables[] = {NULL, NULL, NULL} }; +static const char *riscv_tunes[] = +{ +#define RISCV_TUNE(TUNE_NAME, PIPELINE_MODEL, TUNE_INFO) \ + TUNE_NAME, +#include "../../../config/riscv/riscv-cores.def" + NULL +}; + static const char *riscv_supported_std_ext (void); static riscv_subset_list *current_subset_list = NULL; @@ -353,21 +394,18 @@ multi_letter_subset_rank (const std::string &subset) gcc_assert (subset.length () >= 2); int high_order = -1; int low_order = 0; - /* The order between multi-char extensions: s -> h -> z -> x. */ + /* The order between multi-char extensions: s -> z -> x. */ char multiletter_class = subset[0]; switch (multiletter_class) { case 's': high_order = 0; break; - case 'h': - high_order = 1; - break; case 'z': - high_order = 2; + high_order = 1; break; case 'x': - high_order = 3; + high_order = 2; break; default: gcc_unreachable (); @@ -663,7 +701,7 @@ riscv_subset_list::lookup (const char *subset, int major_version, static const char * riscv_supported_std_ext (void) { - return "mafdqlcbkjtpvn"; + return "mafdqlcbkjtpvnh"; } /* Parsing subset version. @@ -822,7 +860,7 @@ riscv_subset_list::parse_std_ext (const char *p) { char subset[2] = {0, 0}; - if (*p == 'x' || *p == 's' || *p == 'h' || *p == 'z') + if (*p == 'x' || *p == 's' || *p == 'z') break; if (*p == '_') @@ -947,7 +985,7 @@ riscv_subset_list::handle_combine_ext () Arguments: `p`: Current parsing position. - `ext_type`: What kind of extensions, 's', 'h', 'z' or 'x'. + `ext_type`: What kind of extensions, 's', 'z' or 'x'. `ext_type_str`: Full name for kind of extension. */ const char * @@ -1089,12 +1127,6 @@ riscv_subset_list::parse (const char *arch, location_t loc) if (p == NULL) goto fail; - /* Parsing hypervisor extension. */ - p = subset_list->parse_multiletter_ext (p, "h", "hypervisor extension"); - - if (p == NULL) - goto fail; - /* Parsing sub-extensions. */ p = subset_list->parse_multiletter_ext (p, "z", "sub-extension"); @@ -1158,16 +1190,24 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = {"f", &gcc_options::x_target_flags, MASK_HARD_FLOAT}, {"d", &gcc_options::x_target_flags, MASK_DOUBLE_FLOAT}, {"c", &gcc_options::x_target_flags, MASK_RVC}, + {"v", &gcc_options::x_target_flags, MASK_FULL_V}, {"v", &gcc_options::x_target_flags, MASK_VECTOR}, {"zicsr", &gcc_options::x_riscv_zi_subext, MASK_ZICSR}, {"zifencei", &gcc_options::x_riscv_zi_subext, MASK_ZIFENCEI}, + {"zawrs", &gcc_options::x_riscv_za_subext, MASK_ZAWRS}, + {"zba", &gcc_options::x_riscv_zb_subext, MASK_ZBA}, {"zbb", &gcc_options::x_riscv_zb_subext, MASK_ZBB}, {"zbc", &gcc_options::x_riscv_zb_subext, MASK_ZBC}, {"zbs", &gcc_options::x_riscv_zb_subext, MASK_ZBS}, + {"zfinx", &gcc_options::x_riscv_zinx_subext, MASK_ZFINX}, + {"zdinx", &gcc_options::x_riscv_zinx_subext, MASK_ZDINX}, + {"zhinx", &gcc_options::x_riscv_zinx_subext, MASK_ZHINX}, + {"zhinxmin", &gcc_options::x_riscv_zinx_subext, MASK_ZHINXMIN}, + {"zbkb", &gcc_options::x_riscv_zk_subext, MASK_ZBKB}, {"zbkc", &gcc_options::x_riscv_zk_subext, MASK_ZBKC}, {"zbkx", &gcc_options::x_riscv_zk_subext, MASK_ZBKX}, @@ -1218,13 +1258,29 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = {"zmmul", &gcc_options::x_riscv_zm_subext, MASK_ZMMUL}, + {"svinval", &gcc_options::x_riscv_sv_subext, MASK_SVINVAL}, + {"svnapot", &gcc_options::x_riscv_sv_subext, MASK_SVNAPOT}, + + {"xtheadba", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADBA}, + {"xtheadbb", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADBB}, + {"xtheadbs", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADBS}, + {"xtheadcmo", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADCMO}, + {"xtheadcondmov", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADCONDMOV}, + {"xtheadfmemidx", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADFMEMIDX}, + {"xtheadfmv", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADFMV}, + {"xtheadint", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADINT}, + {"xtheadmac", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADMAC}, + {"xtheadmemidx", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADMEMIDX}, + {"xtheadmempair", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADMEMPAIR}, + {"xtheadsync", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADSYNC}, + {NULL, NULL, 0} }; /* Parse a RISC-V ISA string into an option mask. Must clear or set all arch dependent mask bits, in case more than one -march string is passed. */ -static void +void riscv_parse_arch_string (const char *isa, struct gcc_options *opts, location_t loc) @@ -1509,7 +1565,7 @@ riscv_check_conds ( for (itr = conds.begin (); itr != conds.end (); ++itr) { - /* We'll check march= and mabi= in ohter place. */ + /* We'll check march= and mabi= in other place. */ if (prefixed_with (*itr, "march=") || prefixed_with (*itr, "mabi=")) continue; @@ -1671,7 +1727,10 @@ riscv_compute_multilib ( /* Record highest match score multi-lib setting. */ if (match_score > max_match_score) - best_match_multi_lib = i; + { + best_match_multi_lib = i; + max_match_score = match_score; + } } if (best_match_multi_lib == -1) @@ -1687,11 +1746,50 @@ riscv_compute_multilib ( #define TARGET_COMPUTE_MULTILIB riscv_compute_multilib #endif +vec<const char *> +riscv_get_valid_option_values (int option_code, + const char *prefix ATTRIBUTE_UNUSED) +{ + vec<const char *> v; + v.create (0); + opt_code opt = (opt_code) option_code; + + switch (opt) + { + case OPT_mtune_: + { + const char **tune = &riscv_tunes[0]; + for (;*tune; ++tune) + v.safe_push (*tune); + + const riscv_cpu_info *cpu_info = &riscv_cpu_tables[0]; + for (;cpu_info->name; ++cpu_info) + v.safe_push (cpu_info->name); + } + break; + case OPT_mcpu_: + { + const riscv_cpu_info *cpu_info = &riscv_cpu_tables[0]; + for (;cpu_info->name; ++cpu_info) + v.safe_push (cpu_info->name); + } + break; + default: + break; + } + + return v; +} + /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */ static const struct default_options riscv_option_optimization_table[] = { { OPT_LEVELS_1_PLUS, OPT_fsection_anchors, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_free, NULL, 1 }, +#if TARGET_DEFAULT_ASYNC_UNWIND_TABLES == 1 + { OPT_LEVELS_ALL, OPT_fasynchronous_unwind_tables, NULL, 1 }, + { OPT_LEVELS_ALL, OPT_funwind_tables, NULL, 1}, +#endif { OPT_LEVELS_NONE, 0, NULL, 0 } }; @@ -1701,4 +1799,7 @@ static const struct default_options riscv_option_optimization_table[] = #undef TARGET_HANDLE_OPTION #define TARGET_HANDLE_OPTION riscv_handle_option +#undef TARGET_GET_VALID_OPTION_VALUES +#define TARGET_GET_VALID_OPTION_VALUES riscv_get_valid_option_values + struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; diff --git a/gcc/common/config/rs6000/rs6000-common.cc b/gcc/common/config/rs6000/rs6000-common.cc index 8e393d0..2140c44 100644 --- a/gcc/common/config/rs6000/rs6000-common.cc +++ b/gcc/common/config/rs6000/rs6000-common.cc @@ -1,5 +1,5 @@ /* Common hooks for IBM RS/6000. - Copyright (C) 1991-2022 Free Software Foundation, Inc. + Copyright (C) 1991-2023 Free Software Foundation, Inc. This file is part of GCC. @@ -119,19 +119,8 @@ rs6000_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, #else case OPT_m64: #endif - opts->x_rs6000_isa_flags |= OPTION_MASK_POWERPC64; opts->x_rs6000_isa_flags |= (~opts_set->x_rs6000_isa_flags & OPTION_MASK_PPC_GFXOPT); - opts_set->x_rs6000_isa_flags |= OPTION_MASK_POWERPC64; - break; - -#ifdef TARGET_USES_AIX64_OPT - case OPT_maix32: -#else - case OPT_m32: -#endif - opts->x_rs6000_isa_flags &= ~OPTION_MASK_POWERPC64; - opts_set->x_rs6000_isa_flags |= OPTION_MASK_POWERPC64; break; case OPT_mminimal_toc: diff --git a/gcc/common/config/rx/rx-common.cc b/gcc/common/config/rx/rx-common.cc index 36ee9d2..5c6fad4 100644 --- a/gcc/common/config/rx/rx-common.cc +++ b/gcc/common/config/rx/rx-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Renesas RX. - Copyright (C) 2008-2022 Free Software Foundation, Inc. + Copyright (C) 2008-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/s390/s390-common.cc b/gcc/common/config/s390/s390-common.cc index be3e6f2..207ef3d 100644 --- a/gcc/common/config/s390/s390-common.cc +++ b/gcc/common/config/s390/s390-common.cc @@ -1,5 +1,5 @@ /* Common hooks for IBM S/390 and zSeries. - Copyright (C) 1999-2022 Free Software Foundation, Inc. + Copyright (C) 1999-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/sh/sh-common.cc b/gcc/common/config/sh/sh-common.cc index b6c62f7..4f393d2 100644 --- a/gcc/common/config/sh/sh-common.cc +++ b/gcc/common/config/sh/sh-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Renesas / SuperH SH. - Copyright (C) 1993-2022 Free Software Foundation, Inc. + Copyright (C) 1993-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/sparc/sparc-common.cc b/gcc/common/config/sparc/sparc-common.cc index c075e64..310dff9 100644 --- a/gcc/common/config/sparc/sparc-common.cc +++ b/gcc/common/config/sparc/sparc-common.cc @@ -1,5 +1,5 @@ /* Common hooks for SPARC. - Copyright (C) 1987-2022 Free Software Foundation, Inc. + Copyright (C) 1987-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/v850/v850-common.cc b/gcc/common/config/v850/v850-common.cc index 830bf7f..c4917cd 100644 --- a/gcc/common/config/v850/v850-common.cc +++ b/gcc/common/config/v850/v850-common.cc @@ -1,5 +1,5 @@ /* Common hooks for NEC V850 series. - Copyright (C) 1996-2022 Free Software Foundation, Inc. + Copyright (C) 1996-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/vax/vax-common.cc b/gcc/common/config/vax/vax-common.cc index 58f172e..9eef82d 100644 --- a/gcc/common/config/vax/vax-common.cc +++ b/gcc/common/config/vax/vax-common.cc @@ -1,5 +1,5 @@ /* Common hooks for VAX. - Copyright (C) 1987-2022 Free Software Foundation, Inc. + Copyright (C) 1987-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/visium/visium-common.cc b/gcc/common/config/visium/visium-common.cc index 28dd1ff..663b351 100644 --- a/gcc/common/config/visium/visium-common.cc +++ b/gcc/common/config/visium/visium-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Visium. - Copyright (C) 2002-2022 Free Software Foundation, Inc. + Copyright (C) 2002-2023 Free Software Foundation, Inc. Contributed by C.Nettleton,J.P.Parkes and P.Garbett. This file is part of GCC. diff --git a/gcc/common/config/xstormy16/xstormy16-common.cc b/gcc/common/config/xstormy16/xstormy16-common.cc index 83414d8..60597e7 100644 --- a/gcc/common/config/xstormy16/xstormy16-common.cc +++ b/gcc/common/config/xstormy16/xstormy16-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Xstormy16. - Copyright (C) 1997-2022 Free Software Foundation, Inc. + Copyright (C) 1997-2023 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/common/config/xtensa/xtensa-common.cc b/gcc/common/config/xtensa/xtensa-common.cc index 0f27763..cfc4992 100644 --- a/gcc/common/config/xtensa/xtensa-common.cc +++ b/gcc/common/config/xtensa/xtensa-common.cc @@ -1,5 +1,5 @@ /* Common hooks for Tensilica's Xtensa architecture. - Copyright (C) 2001-2022 Free Software Foundation, Inc. + Copyright (C) 2001-2023 Free Software Foundation, Inc. This file is part of GCC. |