From patchwork Fri Jan 10 17:23:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alice Carlotti X-Patchwork-Id: 104507 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 24EBD3856DC8 for ; Fri, 10 Jan 2025 17:24:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2062d.outbound.protection.outlook.com [IPv6:2a01:111:f403:2612::62d]) by sourceware.org (Postfix) with ESMTPS id DEDB1385AC1C for ; Fri, 10 Jan 2025 17:23:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DEDB1385AC1C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DEDB1385AC1C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2612::62d ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736529816; cv=pass; b=Zuyfd9GEZLXS4mML+EfSck3n+bf0LNDfgIi4hQDk8782uOp3hVJ0nHkrQh6r37PV3z8WUX3jZg2jm9PUDFRk0oDAM+qvrijGPOlYQMm4wv9j5C00h0rWmg8RLljcSOwt4qS42fewl9uccTmdcK68T/Bn5wLZteHCEXqlxWH3430= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736529816; c=relaxed/simple; bh=jxv4Mty+4afpRiWuxl29VhstURcDN9QncTBWhHqa5rw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=XHZ0m/16s5xGzZgtKmoOdciEixlGG9Dd90VLPTT9yQVnsPrG/48ioVrSdjRhYTzWEfx9HUud8V6C7G308cXwa1lAMsekINpGhr4nJ9gDi8Ljh/9USgrZ35qGnw48Qjn1IqFwBX1OcEbs7eybTS91c8aUenCr/K4Mr6HHSZ94wTQ= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=raH27w2rzBBWML9ceX4zbdEWS25eijRE3IJ8LD7Zbt+ctDlGBhhIsnrrvQ1HDCbFpd91evBIt5rBPkkatu+Sf/cDDkARWxrVYfTpdQh2ttQvyr1KLCpJUCuuSU7xpLn9r942n87usa0yyH5OCzIkhhz1zPoYrCaPnvMeOeI1wO4UernMaOlKlYGYAJQepIaz4XvsCmw/u+efClWovFfYiyLNH3D8J7b23fiYCsG6wiHaFnuaFoQ553AfV8ZtbeOKC7zLfHOHbPxP3jQv04mQ6umziK/C8p6j59i0mX1JnbCcSMFpZyRblOwHkIJsL63cE+1Utk+krnN9aJmFYYUTMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kn+6V8ZvBXmfrJtQlhhRXjgsdUnncJV3cXYkNwnjyAw=; b=n9XMKxdkLfI+eq5UB4DLbH6tN3KuADgSnuiWKpxjjcbwqJIJpX67GFsQkPznCqZAkhCmHuqFenp2qkhsidlIXqHcmWzpkUAWFe+TNfuBlsublvRNHrxdAtujleDLjvNqOtGyYliv8VIEVvDXNfSxx6PsKb58Ay6JDZAEqwQYM6pkFcK1cTqgR3JxGTnAv8g8DKeB5epdZqIxtXW+QvUf1MFJJBaBkJct42jEw0jIIzmT9W3waG89YYP+BlqzcIwEkDCj92OmVsl4tR3FA9gKut5o82YKt3m98FmSOz6uZnuscnL2iL/0oxqgaQQZkbmlt1q+csYrcIVohqKb0KnyHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kn+6V8ZvBXmfrJtQlhhRXjgsdUnncJV3cXYkNwnjyAw=; b=HhrKbIMycj080LcIlv1nziyhsVJg1lthd5LRxQYxitKshhSnl9G+X5X/FAJTBsLh09MKee8hCNUby1ntjBjvb6tjJ1zKHwPsmK1kzwk4RLthrhZ9+K5Z82S4xGKHFlobLt7lyXKRnBSQJ5JH2wmadQ+qxNUgx+CHKL/y8gqktfE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DU0PR08MB8255.eurprd08.prod.outlook.com (2603:10a6:10:411::9) by PA4PR08MB7457.eurprd08.prod.outlook.com (2603:10a6:102:2a4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.14; Fri, 10 Jan 2025 17:23:20 +0000 Received: from DU0PR08MB8255.eurprd08.prod.outlook.com ([fe80::cbc8:c020:6a1b:d27a]) by DU0PR08MB8255.eurprd08.prod.outlook.com ([fe80::cbc8:c020:6a1b:d27a%3]) with mapi id 15.20.8335.011; Fri, 10 Jan 2025 17:23:20 +0000 Date: Fri, 10 Jan 2025 17:23:13 +0000 From: Andrew Carlotti To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford , Kyrylo Tkachov Subject: [PATCH 05/11] aarch64: Adjust option parsing parameter types. Message-ID: <38daa7b2-5c55-67aa-8459-fa374ce168c7@e124511.cambridge.arm.com> References: Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: LO4P302CA0024.GBRP302.PROD.OUTLOOK.COM (2603:10a6:600:2c1::10) To DU0PR08MB8255.eurprd08.prod.outlook.com (2603:10a6:10:411::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR08MB8255:EE_|PA4PR08MB7457:EE_ X-MS-Office365-Filtering-Correlation-Id: e89fd78f-87b6-47d2-68ec-08dd319b7a71 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: CzYjFgeGeiimY/rLWUfNY0X35FUVTT+NGLxP/x0Ta/Tu7HvOxbDO0ofCWPUcIUrlrAkJ8jzURcrk6s55sGlcq9T1Tlvfl7f/NbcOll1RhTRrt0QE8T6iYxQ7LFZC/Kj5qZhVzpHo5C7l7RSuYKJyh2Ca6vlHtOdzzrGRvegqbu+mlwr8eevW7D2D77a0mQpVqVb9gvbvm5AmyH+/NXrOK34vriLhYuHUAx4Mvx7j9xZpezMpf8Tv/k9RGFp8/L7JsCPjtScHVHOLT8NmZDYAPiIm/8GwWsNRUuYOtbX7Z9PSLv2pkssDkzhbg0xFdKVk3014a4oYaJdxLt7nKxAiUX7HfuFhqPB0pOxU7rGn5fRfCEMjWIX8MrZkc25DR4JZ3J+Nz3c9PDgmxa1FLjvHPJH8naj2dDZuxyxyznVf9Gsgjf7f2aIzEwF7zIyGyoXCSp8YLZ6HTzVh+J6vtJpR9VKoR5KbizxXqN++o2uYXQ0gT1NisLStZCvUuwQZZ1yUkz74K83Id0D2xG/jPlDdtdNeHz7RLio502tftSgAmfpGeUQGpszTIRlTO/qnszfrp+gix2mpNftxp3dpxEuamY5L0SqdUjxzleNFV9BeWkBhFqPtzcjoJAVmdcw+4yCFSsRTJ/Qga6WzRdqiQNTiTv0qpeTmHuGfK23E0hDim73b3Sk0/qo0fZtSF/fAy3GKJUtM+xOt15pNExktmxcszya0Vs7S52/5yLr/TRocryqHMCB06L+DfcFPDizXjHF4H73kUDlhgMHW9EpvGQk6IsEWXMD4PYWZwc1OnNpHCwJaUZiS6updZgjOSZXaxjGXBOI0OV0TEMJh39yHic5DFlCK7zA/w8z+5uraTtvzoXZoO8bH8nNOPbwDCOZ9XUJx/AbrQdVv8WK+w1DlgKIiHsWNWPBjsi5INr7+Fvme3upNuTzSk4YpK6uDilD3ThZjmaeAETXUX+zQc3dcOwxdXoaGNlhoHKciLdRdx9xbCBfbJuSvdsWiu9ZJkq3ZY9qLYG3yH36XtC5bXRY4oKy1JkVifG2FsGbndkPFjZNjRXn12kFL+lm6mbGXdL+ECVwdazzutqFFO3WQFGM5MV2eLEHebSHuwMP2WH0/nqd7w+5SMVZfoy2q3AU77Io0hqcv5UY1WTKwI8eO87E4YXGXLCXYaAShiunX4vCjBhMEQDtpFTb+gj17X3wxGpxoy+jh2Ic22VDj00s6GoCDi/T/yafSONQMvA3QbaXolJW7xaNYevISk2GYh4MZWxP/XjgIvDMmYuJecNXVnpcuWPgpcY0gIJyRiCYDWcEavVAOQeDyMMqe5Lw5A3T3U9o5N28JC1bYEadwLTdW+WmHlCrvJzj/2QKiB20UFmCB6Inem2NTh73uLL9GojcGYUlgLFVX X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR08MB8255.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: //BfpUyID7PsuBnkvuconHW9Z2SV7SKY7IxSVyBjZsSegZ0I0LEIP1k2TXhZZpPuAQhbXjWdo7vqBsrL5RJUq/9DlX+Nbr08N80ergSIbpj0qNvcSJq/Bz0GXvg6fyoLUtS34uJj8sDiw8FEG2KHw+KNUsXtibxMiB5z6iwKHoB9JUNiTtQugiBxaiot8UnnS5QMQh3VuL39KO+JGUGvX/UKDZI4sMuG4fy8qz6pKgccA0LVJDMykopae2vFhGirKNbtdh4ONpfbPdbL6XokoPEHQfM5QrsJIiEQp50gp+5hkwIHPYjPAc2+4bVFj9cZ2bev0wc3TpH1QMCPjCl1p2jsz7Hbx4vg3oyAMjj1Mq+vzAWIKhbgbn7QIzxvVe0+8MZ1s/9BXURigHz5erZEPYWKwB9FvmLiaIZBkExkzk1Ib1MvS4pG1cDdfTyX1thI9adBluUuC6jWH1J/Er7YEeQ4gmJOZSDcQtm3mB7yYtjD5z4ThoKau1qnUrvUZS0ZpL5R3Flr9n9g9HrbYdUUjae3d7bRjhnIulEuZmlszH7tA2+32Md/GmCyw3DxdEF5BmujRzVTPLyN4Qtjm7Ra1lGhGKHUnEivQ1kfoHO2yIEFdsyuuRJ0z6WEhrED9NPeK4duNIUPdzPBc1EJKYSnwXx+I2DnZ8n15lvKIBEV5KXyXgQ55W3/eiO2Mvk+DjvNkQMASWCy1aOkXmxEZsVQVe2przj/O+K3b8oewG3bQGWnYa9T86J0EJ7XStLqYuzyHMPw8pTEa3JgK3Lf+ySsNKv/RM3eRib8VdDL1w1Jb8eOzZbb1oZT24vUHPNJoqp0hS2IarjKPu3NFaC0jnZdPwODipvNWo/U5ZZyXx/ytA2YYrFco/pmdeuclSuEXPsiVc7P2RMWayq0BmykhdjJTNj7mVoD6wUM5w7y5LNQKwNOV1bgrNf6sOdURWBSraAgl+SDeea+KDA/Bw4PNbvcNJsOAVwYZI+mW+UpO+sxkctJR3I0Yuv92EjMPo4Z24kbvQbJ69kMHKya3qLF03xPQaDg/aEuz0vkRXG5RWznHeB4R72W9+ZgfYWE3yH44I77fo4HzobKgoGBZ/z3mtpc0tAVdTqMKrKje8H1v+QGxf4s3vznKoS6aiGGEIDyXp09lhsxEh6Q7B0A1rsNn/gc5TefKsITkc2i/CoI9r5MUhed17irvYmk5udEy0Zh5BKunbvEP/r9zDDLzK+I1Z3Rw3eJGXH66Ris5G4JzNDs6z1ed4s6T3mRDvxxrHGyAyVG7fzDva59g0qdnLnP/Qpmq3VqsvHAS83jiRFMdzT0U1M1c4koEzWZ/wVHaCEyEz13AqrvzyDuqnKJeDowKBC1ztpT4jaFKLqYXV38DJVwLx4PvqY7nBgE4nJnZEykj2UZ5AwGkwAVu6M7k9jDqVuzCg+pkooO05LyjpvmyodJ8NRsS3BrI5wU+M25tVEG8Hl4+CEogt5y5Q9EwTUu6uwLROnayQsU/iHnblmikVYZXPgn+PnnfF5zzN1s+gRd6gXYfDz9V3RO95xwq+vqO7O6W4nAZghTjrK64Hv0d1GDOfD/GbaiOLnxjY7eFkuKo7ZctXX7wfDQLmm2HfOHK3wVOg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: e89fd78f-87b6-47d2-68ec-08dd319b7a71 X-MS-Exchange-CrossTenant-AuthSource: DU0PR08MB8255.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 17:23:20.1724 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wZ8M1FfnjGO0WtTvPNx3697nJ3zj6WrHREpLlYIYmOesYDeT41AOfY//w2pSpvaMcG7dEVK4FvAqmRE9f4dDFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7457 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Replace `const struct processor *` in output parameters with `aarch64_arch` or `aarch64_cpu`. Replace `std:string` parameter in aarch64_print_hint_for_extensions with `char *`. Also name the return parameters more clearly and consistently. gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_print_hint_for_extensions): Receive string as a char *. (aarch64_parse_arch): Don't return a const struct processor *. (aarch64_parse_cpu): Ditto. (aarch64_parse_tune): Ditto. (aarch64_validate_mtune): Ditto. (aarch64_validate_mcpu): Ditto, and use temporary variables for march/mcpu cross-check. (aarch64_validate_march): Ditto. (aarch64_override_options): Adjust for changed parameter types. (aarch64_handle_attr_arch): Ditto. (aarch64_handle_attr_cpu): Ditto. (aarch64_handle_attr_tune): Ditto. diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index d8a2916d8230cc25122f21818b88fd347e72693a..9b44d08f3e5fe6b4a7aa8f040e7001e3070b362d 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -18217,16 +18217,16 @@ better_main_loop_than_p (const vector_costs *uncast_other) const static void initialize_aarch64_code_model (struct gcc_options *); -/* Parse the TO_PARSE string and put the architecture struct that it - selects into RES and the architectural features into ISA_FLAGS. +/* Parse the TO_PARSE string and put the architecture that it + selects into RES_ARCH and the architectural features into RES_FLAGS. Return an aarch_parse_opt_result describing the parse result. - If there is an error parsing, RES and ISA_FLAGS are left unchanged. + If there is an error parsing, RES_ARCH and RES_FLAGS are left unchanged. When the TO_PARSE string contains an invalid extension, a copy of the string is created and stored to INVALID_EXTENSION. */ static enum aarch_parse_opt_result -aarch64_parse_arch (const char *to_parse, const struct processor **res, - aarch64_feature_flags *isa_flags, +aarch64_parse_arch (const char *to_parse, aarch64_arch *res_arch, + aarch64_feature_flags *res_flags, std::string *invalid_extension) { const char *ext; @@ -18250,21 +18250,21 @@ aarch64_parse_arch (const char *to_parse, const struct processor **res, if (strlen (arch->name) == len && strncmp (arch->name, to_parse, len) == 0) { - auto isa_temp = arch->flags; + auto isa_flags = arch->flags; if (ext != NULL) { /* TO_PARSE string contains at least one extension. */ enum aarch_parse_opt_result ext_res - = aarch64_parse_extension (ext, &isa_temp, invalid_extension); + = aarch64_parse_extension (ext, &isa_flags, invalid_extension); if (ext_res != AARCH_PARSE_OK) return ext_res; } /* Extension parsing was successful. Confirm the result arch and ISA flags. */ - *res = arch; - *isa_flags = isa_temp; + *res_arch = arch->arch; + *res_flags = isa_flags; return AARCH_PARSE_OK; } } @@ -18273,16 +18273,16 @@ aarch64_parse_arch (const char *to_parse, const struct processor **res, return AARCH_PARSE_INVALID_ARG; } -/* Parse the TO_PARSE string and put the result tuning in RES and the - architecture flags in ISA_FLAGS. Return an aarch_parse_opt_result - describing the parse result. If there is an error parsing, RES and - ISA_FLAGS are left unchanged. +/* Parse the TO_PARSE string and put the result tuning in RES_CPU and the + architecture flags in RES_FLAGS. Return an aarch_parse_opt_result + describing the parse result. If there is an error parsing, RES_CPU and + RES_FLAGS are left unchanged. When the TO_PARSE string contains an invalid extension, a copy of the string is created and stored to INVALID_EXTENSION. */ static enum aarch_parse_opt_result -aarch64_parse_cpu (const char *to_parse, const struct processor **res, - aarch64_feature_flags *isa_flags, +aarch64_parse_cpu (const char *to_parse, aarch64_cpu *res_cpu, + aarch64_feature_flags *res_flags, std::string *invalid_extension) { const char *ext; @@ -18305,21 +18305,21 @@ aarch64_parse_cpu (const char *to_parse, const struct processor **res, { if (strlen (cpu->name) == len && strncmp (cpu->name, to_parse, len) == 0) { - auto isa_temp = cpu->flags; + auto isa_flags = cpu->flags; if (ext != NULL) { /* TO_PARSE string contains at least one extension. */ enum aarch_parse_opt_result ext_res - = aarch64_parse_extension (ext, &isa_temp, invalid_extension); + = aarch64_parse_extension (ext, &isa_flags, invalid_extension); if (ext_res != AARCH_PARSE_OK) return ext_res; } /* Extension parsing was successfull. Confirm the result cpu and ISA flags. */ - *res = cpu; - *isa_flags = isa_temp; + *res_cpu = cpu->ident; + *res_flags = isa_flags; return AARCH_PARSE_OK; } } @@ -18328,12 +18328,12 @@ aarch64_parse_cpu (const char *to_parse, const struct processor **res, return AARCH_PARSE_INVALID_ARG; } -/* Parse the TO_PARSE string and put the cpu it selects into RES. +/* Parse the TO_PARSE string and put the cpu it selects into RES_CPU. Return an aarch_parse_opt_result describing the parse result. - If the parsing fails the RES does not change. */ + If the parsing fails then RES_CPU does not change. */ static enum aarch_parse_opt_result -aarch64_parse_tune (const char *to_parse, const struct processor **res) +aarch64_parse_tune (const char *to_parse, aarch64_cpu *res_cpu) { const struct processor *cpu; @@ -18342,7 +18342,7 @@ aarch64_parse_tune (const char *to_parse, const struct processor **res) { if (strcmp (cpu->name, to_parse) == 0) { - *res = cpu; + *res_cpu = cpu->ident; return AARCH_PARSE_OK; } } @@ -18937,12 +18937,12 @@ aarch64_print_hint_for_arch (const char *str) that most closely resembles what the user passed in STR. */ void -aarch64_print_hint_for_extensions (const std::string &str) +aarch64_print_hint_for_extensions (const char *str) { auto_vec candidates; aarch64_get_all_extension_candidates (&candidates); char *s; - const char *hint = candidates_list_and_hint (str.c_str (), s, candidates); + const char *hint = candidates_list_and_hint (str, s, candidates); if (hint) inform (input_location, "valid arguments are: %s;" " did you mean %qs?", s, hint); @@ -18954,16 +18954,16 @@ aarch64_print_hint_for_extensions (const std::string &str) /* Validate a command-line -mcpu option. Parse the cpu and extensions (if any) specified in STR and throw errors if appropriate. Put the results if - they are valid in RES and ISA_FLAGS. Return whether the option is + they are valid in RES_CPU and RES_FLAGS. Return whether the option is valid. */ static bool -aarch64_validate_mcpu (const char *str, const struct processor **res, - aarch64_feature_flags *isa_flags) +aarch64_validate_mcpu (const char *str, aarch64_cpu *res_cpu, + aarch64_feature_flags *res_flags) { std::string invalid_extension; enum aarch_parse_opt_result parse_res - = aarch64_parse_cpu (str, res, isa_flags, &invalid_extension); + = aarch64_parse_cpu (str, res_cpu, res_flags, &invalid_extension); if (parse_res == AARCH_PARSE_OK) return true; @@ -18974,19 +18974,24 @@ aarch64_validate_mcpu (const char *str, const struct processor **res, error ("missing cpu name in %<-mcpu=%s%>", str); break; case AARCH_PARSE_INVALID_ARG: - error ("unknown value %qs for %<-mcpu%>", str); - aarch64_print_hint_for_core (str); - /* A common user error is confusing -march and -mcpu. - If the -mcpu string matches a known architecture then suggest - -march=. */ - parse_res = aarch64_parse_arch (str, res, isa_flags, &invalid_extension); - if (parse_res == AARCH_PARSE_OK) - inform (input_location, "did you mean %<-march=%s%>?", str); - break; + { + error ("unknown value %qs for %<-mcpu%>", str); + aarch64_print_hint_for_core (str); + /* A common user error is confusing -march and -mcpu. + If the -mcpu string matches a known architecture then suggest + -march=. */ + aarch64_arch temp_arch; + aarch64_feature_flags temp_flags; + parse_res = aarch64_parse_arch (str, &temp_arch, &temp_flags, + &invalid_extension); + if (parse_res == AARCH_PARSE_OK) + inform (input_location, "did you mean %<-march=%s%>?", str); + break; + } case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs in %<-mcpu=%s%>", invalid_extension.c_str (), str); - aarch64_print_hint_for_extensions (invalid_extension); + aarch64_print_hint_for_extensions (invalid_extension.c_str ()); break; default: gcc_unreachable (); @@ -19070,16 +19075,16 @@ aarch64_validate_sls_mitigation (const char *const_str) /* Validate a command-line -march option. Parse the arch and extensions (if any) specified in STR and throw errors if appropriate. Put the - results, if they are valid, in RES and ISA_FLAGS. Return whether the + results, if they are valid, in RES_ARCH and RES_FLAGS. Return whether the option is valid. */ static bool -aarch64_validate_march (const char *str, const struct processor **res, - aarch64_feature_flags *isa_flags) +aarch64_validate_march (const char *str, aarch64_arch *res_arch, + aarch64_feature_flags *res_flags) { std::string invalid_extension; enum aarch_parse_opt_result parse_res - = aarch64_parse_arch (str, res, isa_flags, &invalid_extension); + = aarch64_parse_arch (str, res_arch, res_flags, &invalid_extension); if (parse_res == AARCH_PARSE_OK) return true; @@ -19090,18 +19095,23 @@ aarch64_validate_march (const char *str, const struct processor **res, error ("missing arch name in %<-march=%s%>", str); break; case AARCH_PARSE_INVALID_ARG: - error ("unknown value %qs for %<-march%>", str); - aarch64_print_hint_for_arch (str); - /* A common user error is confusing -march and -mcpu. - If the -march string matches a known CPU suggest -mcpu. */ - parse_res = aarch64_parse_cpu (str, res, isa_flags, &invalid_extension); - if (parse_res == AARCH_PARSE_OK) - inform (input_location, "did you mean %<-mcpu=%s%>?", str); - break; + { + error ("unknown value %qs for %<-march%>", str); + aarch64_print_hint_for_arch (str); + /* A common user error is confusing -march and -mcpu. + If the -march string matches a known CPU suggest -mcpu. */ + aarch64_cpu temp_cpu; + aarch64_feature_flags temp_flags; + parse_res = aarch64_parse_cpu (str, &temp_cpu, &temp_flags, + &invalid_extension); + if (parse_res == AARCH_PARSE_OK) + inform (input_location, "did you mean %<-mcpu=%s%>?", str); + break; + } case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs in %<-march=%s%>", invalid_extension.c_str (), str); - aarch64_print_hint_for_extensions (invalid_extension); + aarch64_print_hint_for_extensions (invalid_extension.c_str ()); break; default: gcc_unreachable (); @@ -19112,14 +19122,14 @@ aarch64_validate_march (const char *str, const struct processor **res, /* Validate a command-line -mtune option. Parse the cpu specified in STR and throw errors if appropriate. Put the - result, if it is valid, in RES. Return whether the option is + result, if it is valid, in RES_CPU. Return whether the option is valid. */ static bool -aarch64_validate_mtune (const char *str, const struct processor **res) +aarch64_validate_mtune (const char *str, aarch64_cpu *res_cpu) { enum aarch_parse_opt_result parse_res - = aarch64_parse_tune (str, res); + = aarch64_parse_tune (str, res_cpu); if (parse_res == AARCH_PARSE_OK) return true; @@ -19247,9 +19257,9 @@ aarch64_override_options (void) aarch64_feature_flags arch_isa = 0; aarch64_set_asm_isa_flags (0); - const struct processor *cpu = NULL; - const struct processor *arch = NULL; - const struct processor *tune = NULL; + aarch64_cpu cpu = aarch64_no_cpu; + aarch64_arch arch = aarch64_no_arch; + aarch64_cpu tune = aarch64_no_cpu; if (aarch64_harden_sls_string) aarch64_validate_sls_mitigation (aarch64_harden_sls_string); @@ -19275,7 +19285,7 @@ aarch64_override_options (void) SUBTARGET_OVERRIDE_OPTIONS; #endif - if (cpu && arch) + if (cpu != aarch64_no_cpu && arch != aarch64_no_arch) { /* If both -mcpu and -march are specified, warn if they are not feature compatible. feature compatible means that the inclusion of the @@ -19293,29 +19303,31 @@ aarch64_override_options (void) ext_diff.c_str ()); } - selected_arch = arch->arch; + selected_arch = arch; aarch64_set_asm_isa_flags (arch_isa | AARCH64_FL_DEFAULT_ISA_MODE); } - else if (cpu) + else if (cpu != aarch64_no_cpu) { - selected_arch = cpu->arch; + selected_arch = aarch64_get_tune_cpu (cpu)->arch; aarch64_set_asm_isa_flags (cpu_isa | AARCH64_FL_DEFAULT_ISA_MODE); } - else if (arch) + else if (arch != aarch64_no_arch) { - cpu = &all_cores[arch->ident]; - selected_arch = arch->arch; + cpu = aarch64_get_arch (arch)->ident; + selected_arch = arch; aarch64_set_asm_isa_flags (arch_isa | AARCH64_FL_DEFAULT_ISA_MODE); } else { /* No -mcpu or -march specified, so use the default CPU. */ - cpu = &all_cores[TARGET_CPU_DEFAULT]; - selected_arch = cpu->arch; - aarch64_set_asm_isa_flags (cpu->flags | AARCH64_FL_DEFAULT_ISA_MODE); + cpu = TARGET_CPU_DEFAULT; + const processor *cpu_info = aarch64_get_tune_cpu (cpu); + selected_arch = cpu_info->arch; + aarch64_set_asm_isa_flags (cpu_info->flags + | AARCH64_FL_DEFAULT_ISA_MODE); } - selected_tune = tune ? tune->ident : cpu->ident; + selected_tune = (tune != aarch64_no_cpu) ? tune : cpu; if (aarch_enable_bti == 2) { @@ -19619,7 +19631,7 @@ struct aarch64_attribute_info static bool aarch64_handle_attr_arch (const char *str) { - const struct processor *tmp_arch = NULL; + aarch64_arch tmp_arch = aarch64_no_arch; std::string invalid_extension; aarch64_feature_flags tmp_flags; enum aarch_parse_opt_result parse_res @@ -19627,8 +19639,8 @@ aarch64_handle_attr_arch (const char *str) if (parse_res == AARCH_PARSE_OK) { - gcc_assert (tmp_arch); - selected_arch = tmp_arch->arch; + gcc_assert (tmp_arch != aarch64_no_arch); + selected_arch = tmp_arch; aarch64_set_asm_isa_flags (tmp_flags | (aarch64_asm_isa_flags & AARCH64_FL_ISA_MODES)); return true; @@ -19646,7 +19658,7 @@ aarch64_handle_attr_arch (const char *str) case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %s of value %qs in " "% pragma or attribute", invalid_extension.c_str (), str); - aarch64_print_hint_for_extensions (invalid_extension); + aarch64_print_hint_for_extensions (invalid_extension.c_str ()); break; default: gcc_unreachable (); @@ -19660,7 +19672,7 @@ aarch64_handle_attr_arch (const char *str) static bool aarch64_handle_attr_cpu (const char *str) { - const struct processor *tmp_cpu = NULL; + aarch64_cpu tmp_cpu = aarch64_no_cpu; std::string invalid_extension; aarch64_feature_flags tmp_flags; enum aarch_parse_opt_result parse_res @@ -19668,9 +19680,9 @@ aarch64_handle_attr_cpu (const char *str) if (parse_res == AARCH_PARSE_OK) { - gcc_assert (tmp_cpu); - selected_tune = tmp_cpu->ident; - selected_arch = tmp_cpu->arch; + gcc_assert (tmp_cpu != aarch64_no_cpu); + selected_tune = tmp_cpu; + selected_arch = aarch64_get_tune_cpu (tmp_cpu)->arch; aarch64_set_asm_isa_flags (tmp_flags | (aarch64_asm_isa_flags & AARCH64_FL_ISA_MODES)); return true; @@ -19688,7 +19700,7 @@ aarch64_handle_attr_cpu (const char *str) case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs of value %qs in " "% pragma or attribute", invalid_extension.c_str (), str); - aarch64_print_hint_for_extensions (invalid_extension); + aarch64_print_hint_for_extensions (invalid_extension.c_str ()); break; default: gcc_unreachable (); @@ -19711,14 +19723,14 @@ aarch64_handle_attr_branch_protection (const char* str) static bool aarch64_handle_attr_tune (const char *str) { - const struct processor *tmp_tune = NULL; + aarch64_cpu tmp_tune = aarch64_no_cpu; enum aarch_parse_opt_result parse_res = aarch64_parse_tune (str, &tmp_tune); if (parse_res == AARCH_PARSE_OK) { - gcc_assert (tmp_tune); - selected_tune = tmp_tune->ident; + gcc_assert (tmp_tune != aarch64_no_cpu); + selected_tune = tmp_tune; return true; }