From patchwork Tue Jan 24 23:51:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 719457 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 3v7Q2q4VQCz9sD6 for ; Wed, 25 Jan 2017 10:52:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="n0x/MPeu"; 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 :in-reply-to:references; q=dns; s=default; b=E4DHdfKzoCZO8Si6D5M 9f9xjfR55mCFj8Pb84qNB3R73udKQn+zv1ifHuzM8Ai10r0eCSlVHfDfFw0/Yu2v 1OB5jxmO5nRidW8pLLMGRnMi7jF6ovjFqbvk0oF9H9aoTJzdcOKygOHflTCrnjZJ OZw/Nb7BiZcj7E/wmJE6KaEs= 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 :in-reply-to:references; s=default; bh=4u4IQp3HMpziEfergL8quYJoE FI=; b=n0x/MPeucFf1o9A7lV8ATmQfZNK0wnjGik3QLNJUgL72hCX2i8FAFCLuS 6EIgJFojtoYXEMwCHAp1w41rdn04ScfOQPlg0a4EHCpr5/SdVRYLdz5BzbT/uRuz HvUp1GEtvzf0IktwMaw3Bgqo3frGJ10TNSNPnQns3TeBPG8tOU= Received: (qmail 73515 invoked by alias); 24 Jan 2017 23:52:06 -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 73483 invoked by uid 89); 24 Jan 2017 23:52:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=arch_info, H*x:2.5.1, H*UA:2.5.1, arc700 X-HELO: mail-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 24 Jan 2017 23:51:57 +0000 Received: by mail-wm0-f44.google.com with SMTP id c85so2836991wmi.1 for ; Tue, 24 Jan 2017 15:51:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=eSIO9dC8YSxwoK5e2ZgHCHPcOvd76pXvjm+tqPEzd4o=; b=UlF12ZcHlCSXzEgBwJTbczE5edpud2hfe4xNdiM0zP8nR16GXliLaxSoatPL62Rjjh OZp6+3pKBEb94GIQluGo8F5djT+hzmbqCs+I0S29zIv3L/NPVIA4pMEK0g7MU7+KfPPT rsYjUvMAgX8oyIStmExA6HIMf8ZhaWmq5i8P27R78utESrLyzlL9ZF1NWtA+Yu+mB/mW dIBfMwJAyr7vj6MrMmuD1Mnws+plS+TUocKEq29YVQcT48mzYjrfSIgmntR0pPx4SYO7 wV+V4YJtpQptGunscqQG/VKvvwSrnsY/gEHbuaSgLPDw1Jnc/BnnqNNyD8GGfiFoaaSA LbVQ== X-Gm-Message-State: AIkVDXI6cddZF2pXBhiMscv1yOXUwkRsfNJCCqyCTwKRDP1HsG4ZhGcU96TQ5BhHFdwrrQ== X-Received: by 10.28.68.10 with SMTP id r10mr21041207wma.68.1485301915053; Tue, 24 Jan 2017 15:51:55 -0800 (PST) Received: from localhost (host81-151-161-49.range81-151.btcentralplus.com. [81.151.161.49]) by smtp.gmail.com with ESMTPSA id v4sm1904944wmv.18.2017.01.24.15.51.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 15:51:54 -0800 (PST) From: Andrew Burgess To: gcc-patches@gcc.gnu.org Cc: Claudiu.Zissulescu@synopsys.com, Andrew Burgess Subject: [PATCH 1/2] ARC: Make arc_selected_cpu global Date: Tue, 24 Jan 2017 23:51:43 +0000 Message-Id: <9a5127346cba6defcbe1a3c19f9c424a3ec92f52.1485300574.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes Currently we only make the base_architecture globally available, this means we can tell if we have selected arc700/archs/etc but it's not possible to tell if the user has selected a specific cpu variant, for example nps400. One problem this causes is, for example, in arc-c.def, if we want to add an __NPS400__ define then we need a flag we can check to determine if this is the right thing to do. In this commit the arc_selected_cpu variable (previously local within arc.c) has been made global. Two other variables arc_base_cpu and arc_selected_arch have been deleted, all of this information can be found within (or through) arc_selected_cpu. All uses of arc_base_cpu and arc_selected_arch have been updated. This commit does not introduce any new defines (like __NPS400__), this is just a restructuring commit. The declaration of arc_selected_cpu has moved into arc-arch.h, in contrast to the declaration of arc_base_cpu which was previously in arc.h. This avoids a compilation issue when building libgcc, as the structure and enums declared in arc-arch.h are not included for libgcc then declaring an arc_selected_cpu (a struct type) in arc.h would result in an unknown struct error. We got away with this for arc_base_cpu as that was an enum type. The declaration of arc_selected_cpu in arc.h could have been wrapped in a '#ifndef IN_LIBGCC2 ... #endif', but it felt neater to simply move the declaration into arc-arch.h. gcc/ChangeLog: * config/arc/arc-arch.h (arc_arch_t): Move unchanged to earlier in file. (arc_cpu_t): Change base_architecture field, arch, to a arc_arc_t pointer, arch_info. (arc_cpu_types): Fill the arch_info field with a pointer into the arc_arch_types table. (arc_selected_cpu): Declare. * config/arc/arc.c (arc_selected_cpu): Make global. (arc_selected_arch): Delete. (arc_base_cpu): Delete. (arc_override_options): Remove references to deleted variables, update access to arch information. (ARC_OPT): Update access to arch information. (ARC_OPTX): Likewise. * config/arc/arc.h (arc_base_cpu): Remove declaration. (TARGET_ARC600): Update access to arch information. (TARGET_ARC601): Likewise. (TARGET_ARC700): Likewise. (TARGET_EM): Likewise. (TARGET_HS): Likewise. * config/arc/driver-arc.c (arc_cpu_to_as): Update access to arch information. --- gcc/ChangeLog | 25 +++++++++++++++++++++++ gcc/config/arc/arc-arch.h | 50 ++++++++++++++++++++++----------------------- gcc/config/arc/arc.c | 35 ++++++++++++++----------------- gcc/config/arc/arc.h | 15 +++++++------- gcc/config/arc/driver-arc.c | 2 +- 5 files changed, 74 insertions(+), 53 deletions(-) diff --git a/gcc/config/arc/arc-arch.h b/gcc/config/arc/arc-arch.h index 832338b..2344a4b 100644 --- a/gcc/config/arc/arc-arch.h +++ b/gcc/config/arc/arc-arch.h @@ -47,6 +47,23 @@ enum base_architecture BASE_ARCH_END }; +/* Architecture specific propoerties. */ + +typedef struct +{ + /* Architecture name. */ + const char *const name; + + /* Architecture class. */ + enum base_architecture arch_id; + + /* All allowed flags for this architecture. */ + const unsigned long long flags; + + /* Default flags for this architecture. It is a subset of + FLAGS. */ + const unsigned long long dflags; +} arc_arch_t; /* Tune variants. Needs to match the attr_tune enum. */ @@ -66,7 +83,7 @@ typedef struct const char *const name; /* Architecture class. */ - enum base_architecture arch; + const arc_arch_t *arch_info; /* Specific processor type. */ enum processor_type processor; @@ -76,28 +93,8 @@ typedef struct /* Tune value. */ enum arc_tune_attr tune; -} arc_cpu_t; - - -/* Architecture specific propoerties. */ - -typedef struct -{ - /* Architecture name. */ - const char *const name; - - /* Architecture class. */ - enum base_architecture arch; - - /* All allowed flags for this architecture. */ - const unsigned long long flags; - - /* Default flags for this architecture. It is a subset of - FLAGS. */ - const unsigned long long dflags; -} arc_arch_t; - +} arc_cpu_t; const arc_arch_t arc_arch_types[] = { @@ -111,13 +108,16 @@ const arc_arch_t arc_arch_types[] = const arc_cpu_t arc_cpu_types[] = { - {"none", BASE_ARCH_NONE, PROCESSOR_NONE, 0, ARC_TUNE_NONE}, + {"none", NULL, PROCESSOR_NONE, 0, ARC_TUNE_NONE}, #define ARC_CPU(NAME, ARCH, FLAGS, TUNE) \ - {#NAME, BASE_ARCH_##ARCH, PROCESSOR_##NAME, FLAGS, ARC_TUNE_##TUNE}, + {#NAME, &arc_arch_types [BASE_ARCH_##ARCH], PROCESSOR_##NAME, FLAGS, ARC_TUNE_##TUNE }, #include "arc-cpus.def" #undef ARC_CPU - {NULL, BASE_ARCH_END, PROCESSOR_NONE, 0, ARC_TUNE_NONE} + {NULL, NULL, PROCESSOR_NONE, 0, ARC_TUNE_NONE} }; +/* Currently selected cpu type. */ +extern const arc_cpu_t *arc_selected_cpu; + #endif #endif /* GCC_ARC_ARCH_H */ diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 9089ef4..8a838f9 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -243,11 +243,8 @@ static bool arc_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT, enum by_pieces_operation op, bool); -static const arc_cpu_t *arc_selected_cpu; -static const arc_arch_t *arc_selected_arch; - -/* Global var which sets the current compilation architecture. */ -enum base_architecture arc_base_cpu; +/* Globally visible information about currently selected cpu. */ +const arc_cpu_t *arc_selected_cpu; /* Implements target hook vector_mode_supported_p. */ @@ -787,11 +784,9 @@ arc_override_options (void) /* Set the default cpu options. */ arc_selected_cpu = &arc_cpu_types[(int) arc_cpu]; - arc_selected_arch = &arc_arch_types[(int) arc_selected_cpu->arch]; - arc_base_cpu = arc_selected_arch->arch; /* Set the architectures. */ - switch (arc_selected_arch->arch) + switch (arc_selected_cpu->arch_info->arch_id) { case BASE_ARCH_em: arc_cpu_string = "EM"; @@ -822,16 +817,16 @@ arc_override_options (void) if ((arc_selected_cpu->flags & CODE) \ && ((target_flags_explicit & MASK) == 0)) \ target_flags |= MASK; \ - if (arc_selected_arch->dflags & CODE) \ + if (arc_selected_cpu->arch_info->dflags & CODE) \ target_flags |= MASK; \ } while (0); -#define ARC_OPTX(NAME, CODE, VAR, VAL, DOC) \ - do { \ - if ((arc_selected_cpu->flags & CODE) \ - && (VAR == DEFAULT_##VAR)) \ - VAR = VAL; \ - if (arc_selected_arch->dflags & CODE) \ - VAR = VAL; \ +#define ARC_OPTX(NAME, CODE, VAR, VAL, DOC) \ + do { \ + if ((arc_selected_cpu->flags & CODE) \ + && (VAR == DEFAULT_##VAR)) \ + VAR = VAL; \ + if (arc_selected_cpu->arch_info->dflags & CODE) \ + VAR = VAL; \ } while (0); #include "arc-options.def" @@ -844,18 +839,18 @@ arc_override_options (void) #define ARC_OPTX(NAME, CODE, VAR, VAL, DOC) \ do { \ if ((VAR == VAL) \ - && (!(arc_selected_arch->flags & CODE))) \ + && (!(arc_selected_cpu->arch_info->flags & CODE))) \ { \ error ("%s is not available for %s architecture", \ - DOC, arc_selected_arch->name); \ + DOC, arc_selected_cpu->arch_info->name); \ } \ } while (0); #define ARC_OPT(NAME, CODE, MASK, DOC) \ do { \ if ((target_flags & MASK) \ - && (!(arc_selected_arch->flags & CODE))) \ + && (!(arc_selected_cpu->arch_info->flags & CODE))) \ error ("%s is not available for %s architecture", \ - DOC, arc_selected_arch->name); \ + DOC, arc_selected_cpu->arch_info->name); \ } while (0); #include "arc-options.def" diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index 9cf7668..d6d9012 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -215,15 +215,16 @@ extern const char *arc_cpu_to_as (int argc, const char **argv); use conditional execution? */ #define TARGET_AT_DBR_CONDEXEC (!TARGET_ARC700 && !TARGET_V2) -extern enum base_architecture arc_base_cpu; - -#define TARGET_ARC600 ((arc_base_cpu == BASE_ARCH_6xx) \ +#define TARGET_ARC600 ((arc_selected_cpu->arch_info->arch_id \ + == BASE_ARCH_6xx) \ && (TARGET_BARREL_SHIFTER)) -#define TARGET_ARC601 ((arc_base_cpu == BASE_ARCH_6xx) \ +#define TARGET_ARC601 ((arc_selected_cpu->arch_info->arch_id \ + == BASE_ARCH_6xx) \ && (!TARGET_BARREL_SHIFTER)) -#define TARGET_ARC700 (arc_base_cpu == BASE_ARCH_700) -#define TARGET_EM (arc_base_cpu == BASE_ARCH_em) -#define TARGET_HS (arc_base_cpu == BASE_ARCH_hs) +#define TARGET_ARC700 (arc_selected_cpu->arch_info->arch_id \ + == BASE_ARCH_700) +#define TARGET_EM (arc_selected_cpu->arch_info->arch_id == BASE_ARCH_em) +#define TARGET_HS (arc_selected_cpu->arch_info->arch_id == BASE_ARCH_hs) #define TARGET_V2 (TARGET_EM || TARGET_HS) #ifdef ARC_MULTILIB_CPU_DEFAULT diff --git a/gcc/config/arc/driver-arc.c b/gcc/config/arc/driver-arc.c index 4b816e6..0e13878 100644 --- a/gcc/config/arc/driver-arc.c +++ b/gcc/config/arc/driver-arc.c @@ -47,7 +47,7 @@ arc_cpu_to_as (int argc, const char **argv) } } - switch (arc_selected_cpu->arch) + switch (arc_selected_cpu->arch_info->arch_id) { case BASE_ARCH_em: if (arc_selected_cpu->flags & FL_CD)