From patchwork Thu Sep 29 10:42:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1684380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=VwZDPnk4; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MdVMl4Vhxz1ypH for ; Thu, 29 Sep 2022 20:43:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 739103856960 for ; Thu, 29 Sep 2022 10:43:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 739103856960 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664448225; bh=S/2IeGty8iYNtJPZtL+YDFR/2miAk4nlkT84H4f8e3w=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=VwZDPnk46S60EKm4VZbFFgqrckO6oKBpYZKqm477wokvQHcdbJrhOr9lkFVrt9Gu7 XKF+A7/puNhK5HDvhbXlpvzSYu6QZRyqCbeXj/hg7+eL9UKkxrfnTWgVENownwB6eF eHaI+rywhsD9PxTditZ5Ig4RPri2mTwenYPGbF8o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id D69363851141 for ; Thu, 29 Sep 2022 10:42:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D69363851141 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4573C15BF for ; Thu, 29 Sep 2022 03:42:38 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F12D3F73B for ; Thu, 29 Sep 2022 03:42:31 -0700 (PDT) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH 14/17] aarch64: Make more use of aarch64_feature_flags References: Date: Thu, 29 Sep 2022 11:42:29 +0100 In-Reply-To: (Richard Sandiford's message of "Thu, 29 Sep 2022 11:39:11 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-45.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Sandiford via Gcc-patches From: Richard Sandiford Reply-To: Richard Sandiford Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" A previous patch added a aarch64_feature_flags typedef, to abstract the representation of the feature flags. This patch makes existing code use the typedef too. Hope I've caught them all! gcc/ * common/config/aarch64/aarch64-common.cc: Use aarch64_feature_flags for feature flags throughout. * config/aarch64/aarch64-protos.h: Likewise. * config/aarch64/aarch64-sve-builtins.h: Likewise. * config/aarch64/aarch64-sve-builtins.cc: Likewise. * config/aarch64/aarch64.cc: Likewise. * config/aarch64/aarch64.opt: Likewise. * config/aarch64/driver-aarch64.cc: Likewise. --- gcc/common/config/aarch64/aarch64-common.cc | 19 +++++++------- gcc/config/aarch64/aarch64-protos.h | 5 ++-- gcc/config/aarch64/aarch64-sve-builtins.cc | 29 ++++++++++++--------- gcc/config/aarch64/aarch64-sve-builtins.h | 9 ++++--- gcc/config/aarch64/aarch64.cc | 29 +++++++++++---------- gcc/config/aarch64/aarch64.opt | 2 +- gcc/config/aarch64/driver-aarch64.cc | 10 +++---- 7 files changed, 56 insertions(+), 47 deletions(-) diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc index 918ac844dcf..bebcfd4c9d3 100644 --- a/gcc/common/config/aarch64/aarch64-common.cc +++ b/gcc/common/config/aarch64/aarch64-common.cc @@ -128,9 +128,9 @@ aarch64_handle_option (struct gcc_options *opts, struct aarch64_option_extension { const char *name; - uint64_t flag_canonical; - uint64_t flags_on; - uint64_t flags_off; + aarch64_feature_flags flag_canonical; + aarch64_feature_flags flags_on; + aarch64_feature_flags flags_off; }; /* ISA extensions in AArch64. */ @@ -149,14 +149,14 @@ struct processor_name_to_arch { const char *processor_name; aarch64_arch arch; - uint64_t flags; + aarch64_feature_flags flags; }; struct arch_to_arch_name { aarch64_arch arch; const char *arch_name; - uint64_t flags; + aarch64_feature_flags flags; }; /* Map processor names to the architecture revision they implement and @@ -186,7 +186,7 @@ static constexpr arch_to_arch_name all_architectures[] = 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, +aarch64_parse_extension (const char *str, aarch64_feature_flags *isa_flags, std::string *invalid_extension) { /* The extension string is parsed left to right. */ @@ -266,8 +266,9 @@ aarch64_get_all_extension_candidates (auto_vec *candidates) 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) { std::string outstr = ""; @@ -375,7 +376,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/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index 5ecdb8af863..d1af307c488 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -1034,10 +1034,11 @@ bool aarch64_handle_option (struct gcc_options *, struct gcc_options *, const struct cl_decoded_option *, location_t); const char *aarch64_rewrite_selected_cpu (const char *name); enum aarch64_parse_opt_result aarch64_parse_extension (const char *, - uint64_t *, + aarch64_feature_flags *, std::string *); void aarch64_get_all_extension_candidates (auto_vec *candidates); -std::string aarch64_get_extension_string_for_isa_flags (uint64_t, uint64_t); +std::string aarch64_get_extension_string_for_isa_flags (aarch64_feature_flags, + aarch64_feature_flags); rtl_opt_pass *make_pass_fma_steering (gcc::context *); rtl_opt_pass *make_pass_track_speculation (gcc::context *); diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc index c06e99339e3..b927a886ef3 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc @@ -82,7 +82,7 @@ public: /* The architecture extensions that the function requires, as a set of AARCH64_FL_* flags. */ - uint64_t required_extensions; + aarch64_feature_flags required_extensions; /* True if the decl represents an overloaded function that needs to be resolved by function_resolver. */ @@ -694,13 +694,16 @@ check_required_registers (location_t location, tree fndecl) Report an error against LOCATION if not. */ static bool check_required_extensions (location_t location, tree fndecl, - uint64_t required_extensions) + aarch64_feature_flags required_extensions) { - uint64_t missing_extensions = required_extensions & ~aarch64_isa_flags; + auto missing_extensions = required_extensions & ~aarch64_isa_flags; if (missing_extensions == 0) return check_required_registers (location, fndecl); - static const struct { uint64_t flag; const char *name; } extensions[] = { + static const struct { + aarch64_feature_flags flag; + const char *name; + } extensions[] = { #define AARCH64_OPT_EXTENSION(EXT_NAME, IDENT, C, D, E, F) \ { AARCH64_FL_##IDENT, EXT_NAME }, #include "aarch64-option-extensions.def" @@ -992,7 +995,7 @@ function_builder::get_attributes (const function_instance &instance) registered_function & function_builder::add_function (const function_instance &instance, const char *name, tree fntype, tree attrs, - uint64_t required_extensions, + aarch64_feature_flags required_extensions, bool overloaded_p, bool placeholder_p) { @@ -1034,11 +1037,12 @@ function_builder::add_function (const function_instance &instance, one-to-one mapping between "short" and "full" names, and if standard overload resolution therefore isn't necessary. */ void -function_builder::add_unique_function (const function_instance &instance, - tree return_type, - vec &argument_types, - uint64_t required_extensions, - bool force_direct_overloads) +function_builder:: +add_unique_function (const function_instance &instance, + tree return_type, + vec &argument_types, + aarch64_feature_flags required_extensions, + bool force_direct_overloads) { /* Add the function under its full (unique) name. */ char *name = get_name (instance, false); @@ -1081,8 +1085,9 @@ function_builder::add_unique_function (const function_instance &instance, features are available as part of resolving the function to the relevant unique function. */ void -function_builder::add_overloaded_function (const function_instance &instance, - uint64_t required_extensions) +function_builder:: +add_overloaded_function (const function_instance &instance, + aarch64_feature_flags required_extensions) { char *name = get_name (instance, true); if (registered_function **map_value = m_overload_names.get (name)) diff --git a/gcc/config/aarch64/aarch64-sve-builtins.h b/gcc/config/aarch64/aarch64-sve-builtins.h index 24594d58497..63d1db776f7 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.h +++ b/gcc/config/aarch64/aarch64-sve-builtins.h @@ -263,7 +263,7 @@ struct function_group_info /* The architecture extensions that the functions require, as a set of AARCH64_FL_* flags. */ - uint64_t required_extensions; + aarch64_feature_flags required_extensions; }; /* Describes a single fully-resolved function (i.e. one that has a @@ -321,8 +321,9 @@ public: ~function_builder (); void add_unique_function (const function_instance &, tree, - vec &, uint64_t, bool); - void add_overloaded_function (const function_instance &, uint64_t); + vec &, aarch64_feature_flags, bool); + void add_overloaded_function (const function_instance &, + aarch64_feature_flags); void add_overloaded_functions (const function_group_info &, mode_suffix_index); @@ -338,7 +339,7 @@ private: registered_function &add_function (const function_instance &, const char *, tree, tree, - uint64_t, bool, bool); + aarch64_feature_flags, bool, bool); /* The function type to use for functions that are resolved by function_resolver. */ diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 70371afd1c5..21c142e1e56 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -2675,7 +2675,7 @@ struct processor aarch64_processor ident; aarch64_processor sched_core; aarch64_arch arch; - uint64_t flags; + aarch64_feature_flags flags; const tune_params *tune; }; @@ -17121,7 +17121,8 @@ static void initialize_aarch64_code_model (struct gcc_options *); static enum aarch64_parse_opt_result aarch64_parse_arch (const char *to_parse, const struct processor **res, - uint64_t *isa_flags, std::string *invalid_extension) + aarch64_feature_flags *isa_flags, + std::string *invalid_extension) { const char *ext; const struct processor *arch; @@ -17144,7 +17145,7 @@ aarch64_parse_arch (const char *to_parse, const struct processor **res, if (strlen (arch->name) == len && strncmp (arch->name, to_parse, len) == 0) { - uint64_t isa_temp = arch->flags; + auto isa_temp = arch->flags; if (ext != NULL) { @@ -17176,7 +17177,8 @@ aarch64_parse_arch (const char *to_parse, const struct processor **res, static enum aarch64_parse_opt_result aarch64_parse_cpu (const char *to_parse, const struct processor **res, - uint64_t *isa_flags, std::string *invalid_extension) + aarch64_feature_flags *isa_flags, + std::string *invalid_extension) { const char *ext; const struct processor *cpu; @@ -17198,8 +17200,7 @@ aarch64_parse_cpu (const char *to_parse, const struct processor **res, { if (strlen (cpu->name) == len && strncmp (cpu->name, to_parse, len) == 0) { - uint64_t isa_temp = cpu->flags; - + auto isa_temp = cpu->flags; if (ext != NULL) { @@ -17830,7 +17831,7 @@ aarch64_print_hint_for_extensions (const std::string &str) static bool aarch64_validate_mcpu (const char *str, const struct processor **res, - uint64_t *isa_flags) + aarch64_feature_flags *isa_flags) { std::string invalid_extension; enum aarch64_parse_opt_result parse_res @@ -18044,7 +18045,7 @@ aarch64_validate_mbranch_protection (const char *const_str) static bool aarch64_validate_march (const char *str, const struct processor **res, - uint64_t *isa_flags) + aarch64_feature_flags *isa_flags) { std::string invalid_extension; enum aarch64_parse_opt_result parse_res @@ -18139,8 +18140,8 @@ aarch64_convert_sve_vector_bits (aarch64_sve_vector_bits_enum value) static void aarch64_override_options (void) { - uint64_t cpu_isa = 0; - uint64_t arch_isa = 0; + aarch64_feature_flags cpu_isa = 0; + aarch64_feature_flags arch_isa = 0; aarch64_isa_flags = 0; const struct processor *cpu = NULL; @@ -18588,7 +18589,7 @@ static bool aarch64_handle_attr_isa_flags (char *str) { enum aarch64_parse_opt_result parse_res; - uint64_t isa_flags = aarch64_isa_flags; + auto isa_flags = aarch64_isa_flags; /* We allow "+nothing" in the beginning to clear out all architectural features if the user wants to handpick specific features. */ @@ -18860,7 +18861,7 @@ aarch64_process_target_attr (tree args) { /* Check if token is possibly an arch extension without leading '+'. */ - uint64_t isa_temp = 0; + aarch64_feature_flags isa_temp = 0; auto with_plus = std::string ("+") + token; enum aarch64_parse_opt_result ext_res = aarch64_parse_extension (with_plus.c_str (), &isa_temp, nullptr); @@ -22476,7 +22477,7 @@ aarch64_declare_function_name (FILE *stream, const char* name, const struct processor *this_arch = aarch64_get_arch (targ_options->x_selected_arch); - uint64_t isa_flags = targ_options->x_aarch64_isa_flags; + auto isa_flags = targ_options->x_aarch64_isa_flags; std::string extension = aarch64_get_extension_string_for_isa_flags (isa_flags, this_arch->flags); @@ -22580,7 +22581,7 @@ aarch64_start_file (void) const struct processor *default_arch = aarch64_get_arch (default_options->x_selected_arch); - uint64_t default_isa_flags = default_options->x_aarch64_isa_flags; + auto default_isa_flags = default_options->x_aarch64_isa_flags; std::string extension = aarch64_get_extension_string_for_isa_flags (default_isa_flags, default_arch->flags); diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt index d8e1f42a3a6..f6ae4499a16 100644 --- a/gcc/config/aarch64/aarch64.opt +++ b/gcc/config/aarch64/aarch64.opt @@ -28,7 +28,7 @@ TargetVariable enum aarch64_arch selected_arch = aarch64_no_arch TargetVariable -uint64_t aarch64_isa_flags = 0 +aarch64_feature_flags aarch64_isa_flags = 0 TargetVariable unsigned aarch64_enable_bti = 2 diff --git a/gcc/config/aarch64/driver-aarch64.cc b/gcc/config/aarch64/driver-aarch64.cc index be41e2923db..52ff537908e 100644 --- a/gcc/config/aarch64/driver-aarch64.cc +++ b/gcc/config/aarch64/driver-aarch64.cc @@ -31,7 +31,7 @@ struct aarch64_arch_extension { const char *ext; - uint64_t flag; + aarch64_feature_flags flag; const char *feat_string; }; @@ -50,7 +50,7 @@ struct aarch64_core_data unsigned char implementer_id; /* Exactly 8 bits */ unsigned int part_no; /* 12 bits + 12 bits */ unsigned variant; - uint64_t flags; + aarch64_feature_flags flags; }; #define AARCH64_BIG_LITTLE(BIG, LITTLE) \ @@ -75,7 +75,7 @@ struct aarch64_arch_driver_info { const char* id; const char* name; - uint64_t flags; + aarch64_feature_flags flags; }; /* Skip the leading "V" in the architecture name. */ @@ -261,8 +261,8 @@ host_detect_local_cpu (int argc, const char **argv) unsigned int variants[2] = { ALL_VARIANTS, ALL_VARIANTS }; unsigned int n_variants = 0; bool processed_exts = false; - uint64_t extension_flags = 0; - uint64_t default_flags = 0; + aarch64_feature_flags extension_flags = 0; + aarch64_feature_flags default_flags = 0; std::string buf; size_t sep_pos = -1; char *fcpu_info;