From patchwork Tue Nov 17 22:10:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 545784 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 2A66A14145C for ; Wed, 18 Nov 2015 09:11:15 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=NaYd0j+D; 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:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=BxMpsVjyJigSVwPi6MCjp1cJjkrHciyUx4wxGDzCaTLlNCYxEdhgy XYlT1dH3HvXRvz1qIAU+YFX4kBFt9PuPoNkoUytZrGUhCNiRFDxxN7QD9aFdPAU6 8LRB3IE8JRE/6YNinDwg61Ds/wmUR1ZLMg/JWCs8EiDZvEMRqqvvT0= 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; s= default; bh=7lmqyOJkN1BjAIVvOeEB09Qki8U=; b=NaYd0j+DgSyerYxD/ckC ifkmw1xdkYXErl4t2+cRjuuvPU9ytmO81jYRnFKYS9pEa/sbB4uaOKOwwlp91Gvi 16J91BcQVpZnJMk7vfDuCu91mrNj4aZ2ixcGImMsZbf++eVcyCXoetWnwB4/yvxc ioKyzThluknCLyszrO0cysw= Received: (qmail 73786 invoked by alias); 17 Nov 2015 22:10:45 -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 73706 invoked by uid 89); 17 Nov 2015 22:10:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-io0-f174.google.com Received: from mail-io0-f174.google.com (HELO mail-io0-f174.google.com) (209.85.223.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 17 Nov 2015 22:10:44 +0000 Received: by iofh3 with SMTP id h3so34215854iof.3 for ; Tue, 17 Nov 2015 14:10:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MTo1CKYUct4fCYTV2OvNb06ArDy6U4072jdUP4/65kc=; b=kfDQHoXf+LSOGa2U3u1r05/OQIrlIrSPupBk7Hu2TuqBw9Y+pRuKp/vrB0kymlOFhu 3BhaQrCFLhw4Rd5RSUDmvxXLWh1SCy+z5HrSrf8Z4FCPgP8k3CSynXNok/A6Ut4ZOJog uZssayXhyNzQpeduklAQy3yX/5CfR2xJlxWfAnyFtBw/rld5p+jao4JTw9hB6oP7DSx3 yvWYrICRFTeCEtRRuGb5pX72gppD+TF8M/SYyhqut4tP61K1QMnnXuoR2i900GMJfY5B xKNBu2HGo6ZNpc3RD2Im8qZp/OGO7t7+0Gwj5YAi35n7lzr1e2JuunGoz6VGNCoeEXYv A5hA== X-Gm-Message-State: ALoCoQlEhS8TGr3OV/48BCswApgZkeHwG0YgHlkutE69UXsTOIL2JFKmX4h2+v0gtzO4Uaxjzm5R X-Received: by 10.107.158.10 with SMTP id h10mr41513808ioe.63.1447798242057; Tue, 17 Nov 2015 14:10:42 -0800 (PST) Received: from localhost.localdomain ([64.2.3.194]) by smtp.gmail.com with ESMTPSA id o77sm68097ioe.11.2015.11.17.14.10.40 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Nov 2015 14:10:41 -0800 (PST) Received: from localhost.localdomain (apinskidesktop [127.0.0.1]) by localhost.localdomain (8.14.3/8.14.3/Debian-9.4) with ESMTP id tAHMAdPH029652 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Tue, 17 Nov 2015 14:10:39 -0800 Received: (from apinski@localhost) by localhost.localdomain (8.14.3/8.14.3/Submit) id tAHMAdBo029651; Tue, 17 Nov 2015 14:10:39 -0800 From: Andrew Pinski To: gcc-patches@gcc.gnu.org Cc: Andrew Pinski Subject: [PATCH 3/5] [AARCH64] Fix part num and implement indendent. Date: Tue, 17 Nov 2015 14:10:36 -0800 Message-Id: <1447798238-29608-4-git-send-email-apinski@cavium.com> In-Reply-To: <1447798238-29608-1-git-send-email-apinski@cavium.com> References: <1447798238-29608-1-git-send-email-apinski@cavium.com> 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. 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);