From patchwork Sun Oct 23 22:37:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 685634 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t2Dnk2m4Sz9t87 for ; Mon, 24 Oct 2016 09:37:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=GefmyPpe; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:cc:content-type; q=dns; s=default; b=tLqsUcMsYRXkzqlns1x1224MxA8aN0NuFhUkiVYH79T YF2No4+cInRctvGpEex/qiwDI4ObU2YbovhnsxCumrxtb6moOQD3nyNzMQnrIf/G Q2Pd4z6WrrVPlAIanW4m3w0fEPz5klVtH4PLvdFgP4dirPkEoW3uYnFRq60wS8XQ = 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 :mime-version:from:date:message-id:subject:to:cc:content-type; s=default; bh=4bEU3twapzUATh3SsJmM4OcIdec=; b=GefmyPpejlY4DlIAe HuJUWeV+gS92kDSVMko908rIZVnz56VbPEOoJs51l8TL4Rq2AxfKYqqycItSoGFh CbdeAvmf/26CiJ49JpBvk+sN5AI2Si1vBiPrpgvzrYIC8yb6FtMNUX6EirgxYh2C xBaYpufpHzImZ1zio5ZybyNLd4= Received: (qmail 77245 invoked by alias); 23 Oct 2016 22:37:35 -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 77231 invoked by uid 89); 23 Oct 2016 22:37:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.1 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=imp, Rewrite, cpu_data, INVALID_CORE X-HELO: mail-yw0-f196.google.com Received: from mail-yw0-f196.google.com (HELO mail-yw0-f196.google.com) (209.85.161.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Oct 2016 22:37:24 +0000 Received: by mail-yw0-f196.google.com with SMTP id w3so5925115ywg.0 for ; Sun, 23 Oct 2016 15:37:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=qO2ioxabV8yHWxpbrKrLTEtRZVYu7Xjv16T+CiyVGtI=; b=Mk+w6HUVv1kWNe9wOY/5RbThxGXrpSkegkBon5XzjrP0wvbTtFAPgonDO+CdQZadMq KvDnQzU1ECv1fonGB3OdY9+oiYONKThr+AkEuxHnCBlVKY1/SdTGU+zbjYI4ByOtELNO l0PwrzpViN6p5oHENTIUOJxwSFXN+74FfGimQJSOqkOy0pr/QEU72Vhu0+w7ATNndU71 QNp0KIumGhhrSpi8ByZ/Rh/eNbervJWHleVQJbfGNOWGbxO1vueB9eF1Jo8rjKhaXhrk Psn7SHemByxZDvi/c8lCL0UsnKkPgG4P1fwgMz6MjHV/Zhi42VsNVaOI2GuSr3CYMBnf vzoQ== X-Gm-Message-State: ABUngvddEpuq6jhR3fV6SYWcI+YWQnHwU4uRQRjV2vwDdhf+BnlTunJxg8M2aJhB5YBR878Rr7C4IptF8Cn+0Q== X-Received: by 10.129.169.74 with SMTP id g71mr12080243ywh.92.1477262242887; Sun, 23 Oct 2016 15:37:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.76.78 with HTTP; Sun, 23 Oct 2016 15:37:22 -0700 (PDT) From: Andrew Pinski Date: Sun, 23 Oct 2016 15:37:22 -0700 Message-ID: Subject: Re: [PATCH 3/5] [AARCH64] Fix part num and implement dependency To: Andrew Pinski Cc: GCC Patches X-IsSubscribed: yes On Tue, Nov 17, 2015 at 2:10 PM, Andrew Pinski wrote: > > The way the current code was written assumes all cores have an unique part > num which is not true. What they have is an unique pair of implementer and > part num. This changes the code to look up that pair after the parsing > of the two is done. > > Someone should test this on a big.little target too just to make sure > the parsing is done correctly as I don't have access to one off hand. > > OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. Here is an updated version of this patch after the other patches have now gone in. OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions and -mcpu=native still works. Thanks, Andrew Pinski > > Thanks, > Andrew Pinski > > > * config/aarch64/driver-aarch64.c (host_detect_local_cpu): > Rewrite handling of part num to handle the case where > multiple implementers share the same part num. > --- > gcc/config/aarch64/driver-aarch64.c | 46 ++++++++++++++++++++++--------------- > 1 file changed, 28 insertions(+), 18 deletions(-) > > diff --git a/gcc/config/aarch64/driver-aarch64.c b/gcc/config/aarch64/driver-aarch64.c > index 92388a9..ea1e856 100644 > --- a/gcc/config/aarch64/driver-aarch64.c > +++ b/gcc/config/aarch64/driver-aarch64.c > @@ -158,7 +158,7 @@ host_detect_local_cpu (int argc, const char **argv) > bool tune = false; > bool cpu = false; > unsigned int i = 0; > - unsigned int core_idx = 0; > + int core_idx = -1; > unsigned char imp = INVALID_IMP; > unsigned int cores[2] = { INVALID_CORE, INVALID_CORE }; > unsigned int n_cores = 0; > @@ -206,18 +206,13 @@ host_detect_local_cpu (int argc, const char **argv) > if (strstr (buf, "part") != NULL) > { > unsigned ccore = parse_field (buf); > - for (i = 0; cpu_data[i].name != NULL; i++) > - if (ccore == cpu_data[i].part_no > - && !contains_core_p (cores, ccore)) > - { > - if (n_cores == 2) > - goto not_found; > - > - cores[n_cores++] = ccore; > - core_idx = i; > - arch_id = cpu_data[i].arch; > - break; > - } > + if (!contains_core_p (cores, ccore)) > + { > + if (n_cores == 2) > + goto not_found; > + > + cores[n_cores++] = ccore; > + } > continue; > } > if (!tune && !processed_exts && strstr (buf, "Features") != NULL) > @@ -253,11 +248,19 @@ host_detect_local_cpu (int argc, const char **argv) > if (n_cores == 0 || n_cores > 2 || imp == INVALID_IMP) > goto not_found; > > - if (arch && !arch_id) > - goto not_found; > - > if (arch) > { > + /* Search for one of the cores in the list. */ > + for (i = 0; cpu_data[i].name != NULL; i++) > + if (cpu_data[i].implementer_id == imp > + && contains_core_p (cores, cpu_data[i].part_no)) > + { > + arch_id = cpu_data[i].arch; > + break; > + } > + if (!arch_id) > + goto not_found; > + > const char* arch_name = get_arch_name_from_id (arch_id); > > /* We got some arch indentifier that's not in aarch64-arches.def? */ > @@ -284,8 +287,15 @@ host_detect_local_cpu (int argc, const char **argv) > /* The simple, non-big.LITTLE case. */ > else > { > - if (cpu_data[core_idx].implementer_id != imp) > - goto not_found; > + for (i = 0; cpu_data[i].name != NULL; i++) > + if (cores[0] == cpu_data[i].part_no > + && cpu_data[i].implementer_id == imp) > + { > + core_idx = i; > + break; > + } > + if (core_idx == -1) > + goto not_found; > > res = concat ("-m", cpu ? "cpu" : "tune", "=", > cpu_data[core_idx].name, NULL); > -- > 1.9.1 > Index: config/aarch64/driver-aarch64.c =================================================================== --- config/aarch64/driver-aarch64.c (revision 241437) +++ config/aarch64/driver-aarch64.c (working copy) @@ -169,7 +169,6 @@ host_detect_local_cpu (int argc, const c bool tune = false; bool cpu = false; unsigned int i = 0; - unsigned int core_idx = 0; unsigned char imp = INVALID_IMP; unsigned int cores[2] = { INVALID_CORE, INVALID_CORE }; unsigned int n_cores = 0; @@ -219,18 +218,13 @@ host_detect_local_cpu (int argc, const c if (strstr (buf, "part") != NULL) { unsigned ccore = parse_field (buf); - for (i = 0; aarch64_cpu_data[i].name != NULL; i++) - if (ccore == aarch64_cpu_data[i].part_no - && !contains_core_p (cores, ccore)) - { - if (n_cores == 2) - goto not_found; - - cores[n_cores++] = ccore; - core_idx = i; - arch_id = aarch64_cpu_data[i].arch; - break; - } + if (!contains_core_p (cores, ccore)) + { + if (n_cores == 2) + goto not_found; + + cores[n_cores++] = ccore; + } continue; } if (!tune && !processed_exts && strstr (buf, "Features") != NULL) @@ -276,11 +270,19 @@ host_detect_local_cpu (int argc, const c if (n_cores == 0 || n_cores > 2 || imp == INVALID_IMP) goto not_found; - if (arch && !arch_id) - goto not_found; - if (arch) { + /* Search for one of the cores in the list. */ + for (i = 0; aarch64_cpu_data[i].name != NULL; i++) + if (aarch64_cpu_data[i].implementer_id == imp + && contains_core_p (cores, aarch64_cpu_data[i].part_no)) + { + arch_id = aarch64_cpu_data[i].arch; + break; + } + if (!arch_id) + goto not_found; + 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? */ @@ -312,7 +314,15 @@ host_detect_local_cpu (int argc, const c /* The simple, non-big.LITTLE case. */ else { - if (aarch64_cpu_data[core_idx].implementer_id != imp) + int core_idx = -1; + for (i = 0; aarch64_cpu_data[i].name != NULL; i++) + if (cores[0] == aarch64_cpu_data[i].part_no + && aarch64_cpu_data[i].implementer_id == imp) + { + core_idx = i; + break; + } + if (core_idx == -1) goto not_found; res = concat ("-m", cpu ? "cpu" : "tune", "=",