From patchwork Wed Apr 6 10:10:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 65158 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp957163lbc; Wed, 6 Apr 2016 03:11:41 -0700 (PDT) X-Received: by 10.98.75.214 with SMTP id d83mr36957635pfj.22.1459937501216; Wed, 06 Apr 2016 03:11:41 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 12si3697290pfm.92.2016.04.06.03.11.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Apr 2016 03:11:41 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-424445-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-424445-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-424445-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=jsH5PSB6Av7WL2Jd bSTvxugniIDAwa+5AF6owswupDS2LrzpHYEInJA0S3Qx8eSBEau5FIsDlyoSvxg9 AA78LeOpQEHpS9QtPRtJ6lOY+HXZPdAbj79NilJ6jdQArS86aVwT6PyVOy6PcX2O dDOKvPi4HB8kz1GWJRaxLhiKaVk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=idmjqDKBLzvhzUM3rtSb1S C7jVk=; b=jRkYWQn8lOUqLyMarF7l4ldPvLDprHyvTGNH/GCQbltmiIttVDTizI 9CJJbhEJTpU8vB83qu+nxQ7WI31JSnhHADOISfDtmlKpeqL1GQ/QeOfp0BVuds9N B9kWQv67bBozh5PcHWURMH6HNmFk5ze/hKk5mRfahwphmQjdI20dw= Received: (qmail 83014 invoked by alias); 6 Apr 2016 10:11:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 82899 invoked by uid 89); 6 Apr 2016 10:10:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=HAuthentication-Results:gcc.gnu.org, HAuthentication-Results:pass, james.greenhalgh@arm.com, sk:james.g X-HELO: emea01-db3-obe.outbound.protection.outlook.com Received: from mail-db3on0100.outbound.protection.outlook.com (HELO emea01-db3-obe.outbound.protection.outlook.com) (157.55.234.100) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA256 encrypted) ESMTPS; Wed, 06 Apr 2016 10:10:48 +0000 Received: from AM3PR07CA0042.eurprd07.prod.outlook.com (10.141.45.170) by VI1PR07MB1693.eurprd07.prod.outlook.com (10.166.143.13) with Microsoft SMTP Server (TLS) id 15.1.453.11; Wed, 6 Apr 2016 10:10:35 +0000 Received: from DB3FFO11FD051.protection.gbl (2a01:111:f400:7e04::174) by AM3PR07CA0042.outlook.office365.com (2a01:111:e400:882c::42) with Microsoft SMTP Server (TLS) id 15.1.453.11 via Frontend Transport; Wed, 6 Apr 2016 10:10:36 +0000 Authentication-Results: spf=pass (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=none (message not signed) header.d=none; gcc.gnu.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by DB3FFO11FD051.mail.protection.outlook.com (10.47.217.82) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Wed, 6 Apr 2016 10:10:35 +0000 Received: from e107456-lin.cambridge.arm.com (10.1.2.79) by mail.arm.com (10.1.105.66) with Microsoft SMTP Server id 14.3.279.2; Wed, 6 Apr 2016 11:10:32 +0100 From: James Greenhalgh To: CC: , , Subject: [Patch AArch64 3/3] Fix up for pr70133 Date: Wed, 6 Apr 2016 11:10:03 +0100 Message-ID: <1459937403-22657-4-git-send-email-james.greenhalgh@arm.com> In-Reply-To: <1459937403-22657-1-git-send-email-james.greenhalgh@arm.com> References: <1459937403-22657-1-git-send-email-james.greenhalgh@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131044110354504580; (7f4fb8e1-17aa-4746-8602-08d27e8c8cd0); () X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:NLI; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(377424004)(199003)(4326007)(77096005)(6806005)(104016004)(5003600100002)(19580395003)(19580405001)(1096002)(76176999)(1220700001)(2476003)(110136002)(2906002)(50226001)(450100001)(164054004)(512874002)(5008740100001)(84326002)(33646002)(92566002)(2950100001)(50986999)(4610100001)(2351001)(229853001)(86362001)(5890100001)(568964002)(106466001)(586003)(36756003)(87936001)(189998001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR07MB1693; H:nebula.arm.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD051; 1:qXOCBYgHNe64dPE2Y5MYPCXW03yCU3dAW+E4S12zrs6gmv6JZqYG6zz6H8pTQKuzlGghaCxgrFiO/9Yf568YMqw6E/fNYQiZd8hTKpHJkNr1F6PI1Fi+XvuUj3I1aRyBts6MHkMEn7X7yJQX4zw5sKOAFeonhXjUlSspIOZgHZ74dBh7uZ/4UV/0m8NxWC2TAZB2wE/dkIzdzqic7WI5mk9lVIQf82zKjWPj4aFrfpWFXPMvYMgzpoAIt7Fn5MLJzXT0aAL89QfQfrFQB3cTKcB8eG7BJfGagxCHHg4Nir5PQ05TXFF9JCIOFs8OJBNrGEZUiodcoPd5CvfG0opN/CE0x+JviuxjBaAv6FVm/sBbBufPNR990RuslcOKmhxIfR9Vv3Vppe0nolNEiwPoofwft25Z+RUaQNd33edS3mD5XuCfORjS2ICdid3HKokMF6nfIQKbFO3OkB/JDylI58mLBlbQQJKlFtr43zui7cbrKwc4Ezebl8wEY/jeEdghJGDM7HZCf/LKeSDj3TR7IXDoA2RoQKdhkGCkzKnjxY0= X-MS-Office365-Filtering-Correlation-Id: 3e527a74-270d-4c7d-fa23-08d35e03b20a X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1693; 2:sYIrlQjVyX1bpiMLoSfuNzGiQlhhZdN2iwJ6AGIF88e36JDunLLwewobGRKleZ5uvbKfeVqtiCVS0RpqJ9WfpbdG3fP0xc7kJULkW1+8tAXBS8flQQpD6dW2Qhj+98OdtfqZ+LqIooKtTY97lhZ4otM1V+uY/Kk4v0XXmqLC5Sb8OPUpRyo13tZ83xv1uyzd; 3:sE3ytg79eABvu1+ZroTtodWGUJ24TIi2pNFPx5aMx3AY/ZMCMNZTO6JOFhAh4L9DevBbzqwremHAAw4HulDdTp6v14GY0Si6ph9wMaUlLMGYeDY3vkrpVwKYvKXvYIIksjjAOdbljDzoBgpYBvJXrOrPb5pCCR6Zpzo9d0U+WqYsbodJzS78JB8t7EHIbb5xn06iYLB/jdLkl2F5h/hITWLqq5IZA4D/xlVKdq2lYfGCC9C2Ihyr4kJN6ooFt3Y1Aepez4j3Kr/KdSOrDv0fow== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:VI1PR07MB1693; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1693; 25:9fjDhP3r1DFP97R53btoav1VAP+LXWGVkUD06o76DbefxGUnthQJSkNiquQwUS1PhUQqjkyfjMjXLXXjPKPUFnE+mEwDwV4NzDiTkjOgYqOi+6JIam1sa1Go97h9Vf8ytrtdbewGSrhJvdT9jztfy6g7uYPBpNNJtgiGMw+XfENPFR7RBz7Q1BohbE16XPk2ZWzXLqDNFhkNgRfCYLGEiFiYli9RUBD8euGNsrjlSt4JExNLWnISYazuKJKYGM4Oa3/yLWHa2cZxcXu22Qt00EXWR/BAOLGbAXnoiP75LfGQw5EElZhEDJuwGXLPeZ+i9FIIx6NNRjigsg08/ziCJ6obptqmgjQPiojWWjFqUkNy9mGmyu790ujE+k3jSlYQO68hJDKsutFUx/+7Eoq06KAU75pyLQTkNp7TpqNwPTEHnOc/rfFwlk48fHQ+R94Z6jW/E7A3GfsjDhGY/KMuoTYWJAXziIbp9icQrMzCQaDKiyh3KiLGuy/UaPEbNS7+aG3BeYKzXme3IVqZ/DyyppD3CIAWDL1dKSnLBiWxWbMz0QNYbYg2J+NhIGxKSjJwWiSe0F0NHfxqbhvYcN3I4Tf74XyR3TrLs1zL8v7YaufZCsoD1MGHKrk1hO/mw5RYkG6GXH0N3oyuPjyUID/E0kIPOGinuVL/SYbbaQD7Nu1RRBdSJT1qRPt3DAi6CqwqyqDh87pTuAGeRW/Fm1BJrA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(102415293)(102615271)(601004)(2401047)(13018025)(13016025)(8121501046)(13024025)(5005006)(13023025)(3002001)(10201501046)(6055026); SRVR:VI1PR07MB1693; BCL:0; PCL:0; RULEID:(400006); SRVR:VI1PR07MB1693; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1693; 4:EnGZjuseEYGuNrYS6QJKhCLurfiIQqRAityNavhJZMjXksVi4Ba1d5i5QNrvHAdMEsz5+dhJHkYAhvrmgN4xEPI++ZFRYvN0W2Jir6TXhAzyItXgrHbbiZuTGHgyKlVqxUu4vn+9j0ISQboDrvzSknlb3t7s15yj7R8oFQo3GEtEqmHVE6Yn2Ok8rooBcJtx3fF0De03wuKfPxLpreKhFWfxqiAN8/BggMX8voWxWu8ngN/VMQ/X5wFIufbZ6BloB+ksPNgVDsNlHc3S2iHsMOCLykq++GHklqa4FdZ/G3W/aojuhbVkkhul05Egah+AMWfgQOgC9VTSZKXJlnpY/J0/dgeTMgDvNBDVfe0nsxvSsTmVX65gZNt+WjQjg9vSxNBX5etW5NyQ1y8PihFXVVKRq3eV4Tmj11Orh+vcRZa0HvS0q4MdfYdYghkosE6ZDUtmy1Ke1NhFFxvshHp69/2reV7PmCj7GaYYTJFi+CN2jRN5vOOKy6xKMx/6+dM8 X-Forefront-PRVS: 0904004ECB X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR07MB1693; 23:8BXJH+De9jdseyDLszTZUFDY38+0fzBJ8ZTJ3h0sk?= =?us-ascii?Q?2YIyL8/PztYgMfNDKzgxUPWo6dZIvq5Lckkv1VD5EiSjecq1R/EXu9D1zNhG?= =?us-ascii?Q?BSJeKz/EWRri7wcZO1JzvSLtr08g/6IMRWg0HWjqovvGbwRQb5wA/7xX59dL?= =?us-ascii?Q?jdSzoSfQcqG7Pk15RI1PkyCA7+I5YoPFh6tT+8+BENQ98c0tK2mv1vtsqBjG?= =?us-ascii?Q?xyj7VRvXv9CmMHSor7YmyzjN2pq4RaDPLttTPzZ9r3m2XS0uQa+wxhSzFipx?= =?us-ascii?Q?esXp+AYwaq6RLeQhtm6i/fLAd/pDwakbwYrgy0Tp3Jo9HVrt5mXcnaR7FggB?= =?us-ascii?Q?b2y3w9unjLHe3OMg6B5k76IcAOU3fXcLSpsdZPOdXPFma916CZzBJh0RiPTI?= =?us-ascii?Q?AXoydkFf224db/86uGKpPz8iZa8uE4e/2eoW0u4aGW7H3CJBMo7C3lx5dL0K?= =?us-ascii?Q?/IgBRhxF0I08/ivuECasDUVhKBRBx6eUBdj9G95c7F/qfqtwasNG86ok09fx?= =?us-ascii?Q?hbONv6k/08xcWvg5zPdFbRUxhPNwezH5SrSkmVsE45nEW76TecmZxHBYvbbF?= =?us-ascii?Q?ep3eX/pGNqnJ+tjGP+VoViKEqVJnF8EFRduMq4ZxjkZXRDJwDiXT1zo84lih?= =?us-ascii?Q?h6BUiLGcXPWRVjiwDxSr1qGG0fTS69TAksnkMlCnqZFGx1MUC3q+QiycMQ+a?= =?us-ascii?Q?nve2NczXrAJemO1jGSpgm9cWHzCJZl0jFLBbRUo7RNCCCr2E2hoGS28iQ9gq?= =?us-ascii?Q?RPLPv5chZkh/FJecxGh58wUXLi1TlXaLGT44MUS1Lpd5Qd/fsbeH9HotrC99?= =?us-ascii?Q?8nY1d+GJaLbazwEI22YTfQkU2M5AfIFee5jvdXlJXdC0vY99cm9C3u/WJ5v7?= =?us-ascii?Q?IQSNrc3Ioq7sqO4X7Y2CDrPCt4xap1DOG6XfWdkG9N+MM3D0HpyEF5oZRHys?= =?us-ascii?Q?V2M09Wx3iSP/6CGwWDNHBgekC+Xvfr1QbuMm3NLgZ1YO1PCeQCOnauGSfF6p?= =?us-ascii?Q?EmMqiah44UnJ3F9DbKPe2aNrSm00N03fGVNWaQoJdFEmpy/wSCwLikmDzZlA?= =?us-ascii?Q?YMx2EU=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1693; 5:leM0xehX2GFLHc1NcIURrM0drkMdKuruZeHCiNJzoXmEEqPr2E+fVVg0zfS6vgWOmnDaicfvVfpeHxb5NexUR18uqdLfXL7793cTf14FC1v6ZLj/vWgd3ZCVyS6jH70hwMdFRwI5FTNmYk7YkvNkmZbXC+87IQh/R5xc2Bx5jvU=; 24:RJMtQgOtAdFdIjpgX6r2CrYlXH4hh0LeqnnrbFg+SC/rbhctQcN+MwH3HK+as3QM3GpnWkE+GP5K1h5mhbcR3NJjHgW1MLoPaqtvcU1b6yk= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2016 10:10:35.2008 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB1693 X-IsSubscribed: yes Hi, Having updated the way we parse and output extension strings, now we just need to wire up the native detection to use these new features. In doing some cleanup and rename I ended up fixing 8-spaces to tabs in about half the file. I've done the rest while I'm here to save us from some a mixed-style file. Bootstrapped on aarch64-none-linux-gnu, then tested with defaults and an explicit -march=native passed (on a system detected as cortex-a57+crypto, and again on a system detected as cortex-a72.cortex-a53+crypto). I also set up a dummy /proc/cpuinfo and used that to manually check the input data in pr70133. OK? Thanks, James --- 2016-04-06 James Greenhalgh PR target/70133 * config/aarch64/driver-aarch64.c (aarch64_get_extension_string_for_isa_flags): New. (arch_extension): Rename to... (aarch64_arch_extension): ...This. (ext_to_feat_string): Rename to... (aarch64_extensions): ...This. (aarch64_core_data): Keep track of architecture extension flags. (cpu_data): Rename to... (aarch64_cpu_data): ...This. (aarch64_arch_driver_info): Keep track of architecture extension flags. (get_arch_name_from_id): Rename to... (get_arch_from_id): ...This, change return type. (host_detect_local_cpu): Update and reformat for renames, handle extensions through common infrastructure. diff --git a/gcc/config/aarch64/driver-aarch64.c b/gcc/config/aarch64/driver-aarch64.c index 8925ec1..ce771ec 100644 --- a/gcc/config/aarch64/driver-aarch64.c +++ b/gcc/config/aarch64/driver-aarch64.c @@ -18,9 +18,16 @@ . */ #include "config.h" +#define INCLUDE_STRING #include "system.h" +#include "coretypes.h" +#include "tm.h" -struct arch_extension +/* Defined in common/config/aarch64/aarch64-common.c. */ +std::string aarch64_get_extension_string_for_isa_flags (unsigned long, + unsigned long); + +struct aarch64_arch_extension { const char *ext; unsigned int flag; @@ -29,7 +36,7 @@ struct arch_extension #define AARCH64_OPT_EXTENSION(EXT_NAME, FLAG_CANONICAL, FLAGS_ON, FLAGS_OFF, FEATURE_STRING) \ { EXT_NAME, FLAG_CANONICAL, FEATURE_STRING }, -static struct arch_extension ext_to_feat_string[] = +static struct aarch64_arch_extension aarch64_extensions[] = { #include "aarch64-option-extensions.def" }; @@ -42,15 +49,16 @@ struct aarch64_core_data const char* arch; const char* implementer_id; const char* part_no; + const unsigned long flags; }; #define AARCH64_CORE(CORE_NAME, CORE_IDENT, SCHED, ARCH, FLAGS, COSTS, IMP, PART) \ - { CORE_NAME, #ARCH, IMP, PART }, + { CORE_NAME, #ARCH, IMP, PART, FLAGS }, -static struct aarch64_core_data cpu_data [] = +static struct aarch64_core_data aarch64_cpu_data[] = { #include "aarch64-cores.def" - { NULL, NULL, NULL, NULL } + { NULL, NULL, NULL, NULL, 0 } }; #undef AARCH64_CORE @@ -59,37 +67,37 @@ struct aarch64_arch_driver_info { const char* id; const char* name; + const unsigned long flags; }; #define AARCH64_ARCH(NAME, CORE, ARCH_IDENT, ARCH_REV, FLAGS) \ - { #ARCH_IDENT, NAME }, + { #ARCH_IDENT, NAME, FLAGS }, -static struct aarch64_arch_driver_info aarch64_arches [] = +static struct aarch64_arch_driver_info aarch64_arches[] = { #include "aarch64-arches.def" - {NULL, NULL} + {NULL, NULL, 0} }; #undef AARCH64_ARCH -/* Return the full architecture name string corresponding to the - identifier ID. */ +/* Return an aarch64_arch_driver_info for the architecture described + by ID, or NULL if ID describes something we don't know about. */ -static const char* -get_arch_name_from_id (const char* id) +static struct aarch64_arch_driver_info* +get_arch_from_id (const char* id) { unsigned int i = 0; for (i = 0; aarch64_arches[i].id != NULL; i++) { if (strcmp (id, aarch64_arches[i].id) == 0) - return aarch64_arches[i].name; + return &aarch64_arches[i]; } return NULL; } - /* Check wether the string CORE contains the same CPU part numbers as BL_STRING. For example CORE="{0xd03, 0xd07}" and BL_STRING="0xd07.0xd03" should return true. */ @@ -98,7 +106,7 @@ static bool valid_bL_string_p (const char** core, const char* bL_string) { return strstr (bL_string, core[0]) != NULL - && strstr (bL_string, core[1]) != NULL; + && strstr (bL_string, core[1]) != NULL; } /* Return true iff ARR contains STR in one of its two elements. */ @@ -142,7 +150,7 @@ host_detect_local_cpu (int argc, const char **argv) { const char *arch_id = NULL; const char *res = NULL; - static const int num_exts = ARRAY_SIZE (ext_to_feat_string); + static const int num_exts = ARRAY_SIZE (aarch64_extensions); char buf[128]; FILE *f = NULL; bool arch = false; @@ -156,6 +164,8 @@ host_detect_local_cpu (int argc, const char **argv) unsigned int n_imps = 0; bool processed_exts = false; const char *ext_string = ""; + unsigned long extension_flags = 0; + unsigned long default_flags = 0; gcc_assert (argc); @@ -184,60 +194,71 @@ host_detect_local_cpu (int argc, const char **argv) { if (strstr (buf, "implementer") != NULL) { - for (i = 0; cpu_data[i].name != NULL; i++) - if (strstr (buf, cpu_data[i].implementer_id) != NULL - && !contains_string_p (imps, cpu_data[i].implementer_id)) + for (i = 0; aarch64_cpu_data[i].name != NULL; i++) + if (strstr (buf, aarch64_cpu_data[i].implementer_id) != NULL + && !contains_string_p (imps, + aarch64_cpu_data[i].implementer_id)) { - if (n_imps == 2) - goto not_found; + if (n_imps == 2) + goto not_found; - imps[n_imps++] = cpu_data[i].implementer_id; + imps[n_imps++] = aarch64_cpu_data[i].implementer_id; - break; + break; } - continue; + continue; } if (strstr (buf, "part") != NULL) { - for (i = 0; cpu_data[i].name != NULL; i++) - if (strstr (buf, cpu_data[i].part_no) != NULL - && !contains_string_p (cores, cpu_data[i].part_no)) + for (i = 0; aarch64_cpu_data[i].name != NULL; i++) + if (strstr (buf, aarch64_cpu_data[i].part_no) != NULL + && !contains_string_p (cores, aarch64_cpu_data[i].part_no)) { - if (n_cores == 2) - goto not_found; + if (n_cores == 2) + goto not_found; - cores[n_cores++] = cpu_data[i].part_no; - core_idx = i; - arch_id = cpu_data[i].arch; - break; + cores[n_cores++] = aarch64_cpu_data[i].part_no; + core_idx = i; + arch_id = aarch64_cpu_data[i].arch; + break; } - continue; - } + continue; + } if (!tune && !processed_exts && strstr (buf, "Features") != NULL) - { - for (i = 0; i < num_exts; i++) - { - bool enabled = true; - char *p = NULL; - char *feat_string = concat (ext_to_feat_string[i].feat_string, NULL); - - p = strtok (feat_string, " "); - - while (p != NULL) - { - if (strstr (buf, p) == NULL) - { - enabled = false; - break; - } - p = strtok (NULL, " "); - } - ext_string = concat (ext_string, "+", enabled ? "" : "no", - ext_to_feat_string[i].ext, NULL); - } - processed_exts = true; - } + { + for (i = 0; i < num_exts; i++) + { + char *p = NULL; + char *feat_string + = concat (aarch64_extensions[i].feat_string, NULL); + bool enabled = true; + + /* This may be a multi-token feature string. We need + to match all parts, which could be in any order. + If this isn't a multi-token feature string, strtok is + just going to return a pointer to feat_string. */ + p = strtok (feat_string, " "); + while (p != NULL) + { + if (strstr (buf, p) == NULL) + { + /* Failed to match this token. Turn off the + features we'd otherwise enable. */ + enabled = false; + break; + } + p = strtok (NULL, " "); + } + + if (enabled) + extension_flags |= aarch64_extensions[i].flag; + else + extension_flags &= ~(aarch64_extensions[i].flag); + } + + processed_exts = true; + } } fclose (f); @@ -252,44 +273,56 @@ host_detect_local_cpu (int argc, const char **argv) if (arch) { - const char* arch_name = get_arch_name_from_id (arch_id); + struct aarch64_arch_driver_info* arch_info = get_arch_from_id (arch_id); /* We got some arch indentifier that's not in aarch64-arches.def? */ - if (!arch_name) - goto not_found; + if (!arch_info) + goto not_found; - res = concat ("-march=", arch_name, NULL); + res = concat ("-march=", arch_info->name, NULL); + default_flags = arch_info->flags; } /* We have big.LITTLE. */ else if (n_cores == 2) { - for (i = 0; cpu_data[i].name != NULL; i++) - { - if (strchr (cpu_data[i].part_no, '.') != NULL - && strncmp (cpu_data[i].implementer_id, imps[0], strlen (imps[0]) - 1) == 0 - && valid_bL_string_p (cores, cpu_data[i].part_no)) - { - res = concat ("-m", cpu ? "cpu" : "tune", "=", cpu_data[i].name, NULL); - break; - } - } + for (i = 0; aarch64_cpu_data[i].name != NULL; i++) + { + if (strchr (aarch64_cpu_data[i].part_no, '.') != NULL + && strncmp (aarch64_cpu_data[i].implementer_id, + imps[0], + strlen (imps[0]) - 1) == 0 + && valid_bL_string_p (cores, aarch64_cpu_data[i].part_no)) + { + res = concat ("-m", + cpu ? "cpu" : "tune", "=", + aarch64_cpu_data[i].name, + NULL); + default_flags = aarch64_cpu_data[i].flags; + break; + } + } if (!res) - goto not_found; + goto not_found; } /* The simple, non-big.LITTLE case. */ else { - if (strncmp (cpu_data[core_idx].implementer_id, imps[0], - strlen (imps[0]) - 1) != 0) - goto not_found; + if (strncmp (aarch64_cpu_data[core_idx].implementer_id, imps[0], + strlen (imps[0]) - 1) != 0) + goto not_found; res = concat ("-m", cpu ? "cpu" : "tune", "=", - cpu_data[core_idx].name, NULL); + aarch64_cpu_data[core_idx].name, NULL); + default_flags = aarch64_cpu_data[core_idx].flags; } if (tune) return res; + ext_string + = aarch64_get_extension_string_for_isa_flags (extension_flags, + default_flags).c_str (); + res = concat (res, ext_string, NULL); return res;