From patchwork Thu Jul 16 15:20:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 496725 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 CB8651402A9 for ; Fri, 17 Jul 2015 01:21:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Jh0Ob8W/; 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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=yjzid7qzTdwCNXDx3yvz/zijLeusrzpd3J2vmJUREU6 7mOkjcF35pKrOVxvZRdHBviG0AdZl3IkxyTE9XZ3kF7MQGzSjYqx6v793ASXZ52/ K0CLZ61uFPeqELcS4t86FoM653HtBtyjWPbI/RAHpsBaDGzdPIuD1Pw7OtztjWOM = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=ZJFpidxrcyj537LnfcnRJKZOKLA=; b=Jh0Ob8W/ycx625EP6 TOQT6Ws40A5RUsW/9tZzEchvoSSON2JsKrA/EaYGNUkgNs5ANZq74WYaLYRb+20g v7Ns5dJVteAVlgE6GJ/Thp7Um6qMLLcfUUkgng/FUExWZAdU0rXZf84pQPYSGUih l9eGwcS3pO3/BDoRLGYhf6i/RY= Received: (qmail 42136 invoked by alias); 16 Jul 2015 15:20:51 -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 42002 invoked by uid 89); 16 Jul 2015 15:20:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Jul 2015 15:20:40 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-28-UBaB_4uGTxucGJQwz-fAuQ-1; Thu, 16 Jul 2015 16:20:34 +0100 Received: from [10.2.207.50] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 16 Jul 2015 16:20:33 +0100 Message-ID: <55A7CBC1.1000503@arm.com> Date: Thu, 16 Jul 2015 16:20:33 +0100 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Marcus Shawcroft , Richard Earnshaw , James Greenhalgh Subject: [PATCH][AArch64][2/14] Refactor arches handling, add arch enum identifier X-MC-Unique: UBaB_4uGTxucGJQwz-fAuQ-1 X-IsSubscribed: yes Hi all, In this second patch I want to get to the point where I can get an enum that I can use to index all_architectures to get the current architecture being used, similar to what we do in patch 1/N. The closest thing to what I want in aarch64-arches.def is the 3rd field which specifies the architecture revision. Unfortunately, it is used sometimes as an integer and sometimes as a string when defining the __ARM_ARCH macro in TARGET_CPU_CPP_BUILTINS. I've decided to create a new field that is to be used as part of an enum name to uniquely identify each entry in aarch64-arches.def. The revision number (currently only '8') is left there since we need it for the ACLE predefs, but we might consider moving that out in the future... In any case, with this patch we can now get an enum that can be used to access the architecture information from all_architectures and can be easily saved and restored for SWITCHABLE_TARGET functionality. Bootstrapped with and without LTO and tested on aarch64 as part of the series. Ok for trunk? Thanks, Kyrill P.S. I think we should consider creating a separate struct definition for cores and architectures as the information we want to store about each starts to diverge and it's sometimes confusing as to what a 'struct processor*' pointer is referencing. But such a refactoring would interfere too much with what I'm trying to do in this patch series and is not strictly required for it. Although, once the dust settles on this series, I believe it will be easier to split them up. 2015-07-16 Kyrylo Tkachov * config/aarch64/aarch64.h (TARGET_CPU_CPP_BUILTINS): Define __ARM_ARCH_8A directly rather than with cpp_define_formatted. * config/aarch64/aarch64.c (struct processor): Add arch field. (all_architectures): Handle above, move above all_cores. (all_cores): Handle above. (aarch64_parse_arch): Handle above changes. * config/aarch64/aarch64-arches.def (armv8-a): Extend according to above. Update comments. (armv8.1-a): Likewise. * config/aarch64/aarch64-cores.def: Update according to above. * config/aarch64/aarch64-opts.h (aarch64_arch): New enum. * config/aarch64/driver-aarch64.c (struct aarch64_arch): Rename to aarch64_arch_driver_info. commit ea24da31afa938379e1e679de581360b05f4e0f5 Author: Kyrylo Tkachov Date: Mon May 11 12:09:34 2015 +0100 [AArch64][2/N] Refactor arches handling, add arch enum identifier diff --git a/gcc/config/aarch64/aarch64-arches.def b/gcc/config/aarch64/aarch64-arches.def index abbfce6..3b4fb73 100644 --- a/gcc/config/aarch64/aarch64-arches.def +++ b/gcc/config/aarch64/aarch64-arches.def @@ -19,12 +19,17 @@ /* Before using #include to read this file, define a macro: - AARCH64_ARCH(NAME, CORE, ARCH, FLAGS) + AARCH64_ARCH(NAME, CORE, ARCH_IDENT, ARCH_REV, FLAGS) The NAME is the name of the architecture, represented as a string constant. The CORE is the identifier for a core representative of - this architecture. ARCH is the architecture revision. FLAGS are - the flags implied by the architecture. */ + this architecture. ARCH_IDENT is the architecture identifier. It must be + unique and be syntactically valid to appear as part of an enum identifier. + ARCH_REV is an integer specifying the architecture major revision. + FLAGS are the flags implied by the architecture. + Due to the assumptions about the positions of these fields in config.gcc, + the NAME should be kept as the first argument and FLAGS as the last. */ + +AARCH64_ARCH("armv8-a", generic, 8A, 8, AARCH64_FL_FOR_ARCH8) +AARCH64_ARCH("armv8.1-a", generic, 8_1A, 8, AARCH64_FL_FOR_ARCH8_1) -AARCH64_ARCH("armv8-a", generic, 8, AARCH64_FL_FOR_ARCH8) -AARCH64_ARCH("armv8.1-a", generic, 8, AARCH64_FL_FOR_ARCH8_1) diff --git a/gcc/config/aarch64/aarch64-cores.def b/gcc/config/aarch64/aarch64-cores.def index c4e22fe..0ab1ca8 100644 --- a/gcc/config/aarch64/aarch64-cores.def +++ b/gcc/config/aarch64/aarch64-cores.def @@ -21,13 +21,14 @@ Before using #include to read this file, define a macro: - AARCH64_CORE(CORE_NAME, CORE_IDENT, SCHEDULER_IDENT, ARCH, FLAGS, COSTS, IMP, PART) + AARCH64_CORE(CORE_NAME, CORE_IDENT, SCHEDULER_IDENT, ARCH_IDENT, FLAGS, COSTS, IMP, PART) The CORE_NAME is the name of the core, represented as a string constant. The CORE_IDENT is the name of the core, represented as an identifier. The SCHEDULER_IDENT is the name of the core for which scheduling decisions will be made, represented as an identifier. - ARCH is the architecture revision implemented by the chip. + ARCH_IDENT is the architecture implemented by the chip as specified in + aarch64-arches.def. FLAGS are the bitwise-or of the traits that apply to that core. This need not include flags implied by the architecture. COSTS is the name of the rtx_costs routine to use. @@ -39,14 +40,15 @@ /* V8 Architecture Processors. */ -AARCH64_CORE("cortex-a53", cortexa53, cortexa53, 8, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa53, "0x41", "0xd03") -AARCH64_CORE("cortex-a57", cortexa57, cortexa57, 8, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa57, "0x41", "0xd07") -AARCH64_CORE("cortex-a72", cortexa72, cortexa57, 8, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa72, "0x41", "0xd08") -AARCH64_CORE("exynos-m1", exynosm1, cortexa57, 8, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, cortexa72, "0x53", "0x001") -AARCH64_CORE("thunderx", thunderx, thunderx, 8, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, thunderx, "0x43", "0x0a1") -AARCH64_CORE("xgene1", xgene1, xgene1, 8, AARCH64_FL_FOR_ARCH8, xgene1, "0x50", "0x000") +AARCH64_CORE("cortex-a53", cortexa53, cortexa53, 8A, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa53, "0x41", "0xd03") +AARCH64_CORE("cortex-a57", cortexa57, cortexa57, 8A, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa57, "0x41", "0xd07") +AARCH64_CORE("cortex-a72", cortexa72, cortexa57, 8A, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa72, "0x41", "0xd08") +AARCH64_CORE("exynos-m1", exynosm1, cortexa57, 8A, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, cortexa72, "0x53", "0x001") +AARCH64_CORE("thunderx", thunderx, thunderx, 8A, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, thunderx, "0x43", "0x0a1") +AARCH64_CORE("xgene1", xgene1, xgene1, 8A, AARCH64_FL_FOR_ARCH8, xgene1, "0x50", "0x000") /* V8 big.LITTLE implementations. */ -AARCH64_CORE("cortex-a57.cortex-a53", cortexa57cortexa53, cortexa53, 8, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa57, "0x41", "0xd07.0xd03") -AARCH64_CORE("cortex-a72.cortex-a53", cortexa72cortexa53, cortexa53, 8, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa72, "0x41", "0xd08.0xd03") +AARCH64_CORE("cortex-a57.cortex-a53", cortexa57cortexa53, cortexa53, 8A, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa57, "0x41", "0xd07.0xd03") +AARCH64_CORE("cortex-a72.cortex-a53", cortexa72cortexa53, cortexa53, 8A, AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC, cortexa72, "0x41", "0xd08.0xd03") + diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h index 24bfd9f..bf6bb7b 100644 --- a/gcc/config/aarch64/aarch64-opts.h +++ b/gcc/config/aarch64/aarch64-opts.h @@ -35,6 +35,15 @@ enum aarch64_processor aarch64_none }; +enum aarch64_arch +{ +#define AARCH64_ARCH(NAME, CORE, ARCH_IDENT, ARCH_REV, FLAGS) \ + AARCH64_ARCH_##ARCH_IDENT, +#include "aarch64-arches.def" +#undef AARCH64_ARCH + aarch64_no_arch +}; + /* TLS types. */ enum aarch64_tls_type { TLS_TRADITIONAL, diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 75e0d70..32b974a 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -500,33 +500,36 @@ struct processor const char *const name; enum aarch64_processor ident; enum aarch64_processor sched_core; - const char *arch; + enum aarch64_arch arch; unsigned architecture_version; const unsigned long flags; const struct tune_params *const tune; }; +/* Architectures implementing AArch64. */ +static const struct processor all_architectures[] = +{ +#define AARCH64_ARCH(NAME, CORE, ARCH_IDENT, ARCH_REV, FLAGS) \ + {NAME, CORE, CORE, AARCH64_ARCH_##ARCH_IDENT, ARCH_REV, FLAGS, NULL}, +#include "aarch64-arches.def" +#undef AARCH64_ARCH + {NULL, aarch64_none, aarch64_none, aarch64_no_arch, 0, 0, NULL} +}; + /* Processor cores implementing AArch64. */ static const struct processor all_cores[] = { #define AARCH64_CORE(NAME, IDENT, SCHED, ARCH, FLAGS, COSTS, IMP, PART) \ - {NAME, IDENT, SCHED, #ARCH, ARCH, FLAGS, &COSTS##_tunings}, + {NAME, IDENT, SCHED, AARCH64_ARCH_##ARCH, \ + all_architectures[AARCH64_ARCH_##ARCH].architecture_version, \ + FLAGS, &COSTS##_tunings}, #include "aarch64-cores.def" #undef AARCH64_CORE - {"generic", generic, cortexa53, "8", 8, - AARCH64_FL_FOR_ARCH8, &generic_tunings}, - {NULL, aarch64_none, aarch64_none, NULL, 0, 0, NULL} + {"generic", generic, cortexa53, AARCH64_ARCH_8A, 8, + AARCH64_FL_FOR_ARCH8, &generic_tunings}, + {NULL, aarch64_none, aarch64_none, aarch64_no_arch, 0, 0, NULL} }; -/* Architectures implementing AArch64. */ -static const struct processor all_architectures[] = -{ -#define AARCH64_ARCH(NAME, CORE, ARCH, FLAGS) \ - {NAME, CORE, CORE, #ARCH, ARCH, FLAGS, NULL}, -#include "aarch64-arches.def" -#undef AARCH64_ARCH - {NULL, aarch64_none, aarch64_none, NULL, 0, 0, NULL} -}; /* Target specification. These are populated as commandline arguments are processed, or NULL if not specified. */ @@ -7209,10 +7212,11 @@ aarch64_parse_arch (void) aarch64_parse_extension (ext); } - if (strcmp (selected_arch->arch, selected_cpu->arch)) + if (selected_arch->arch != selected_cpu->arch) { warning (0, "switch -mcpu=%s conflicts with -march=%s switch", - selected_cpu->name, selected_arch->name); + all_architectures[selected_cpu->arch].name, + selected_arch->name); } return; diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 3851564..2a097af 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -34,8 +34,7 @@ ("__ARM_ALIGN_MAX_STACK_PWR", 16); \ builtin_define_with_int_value \ ("__ARM_ARCH", aarch64_architecture_version); \ - cpp_define_formatted \ - (parse_in, "__ARM_ARCH_%dA", aarch64_architecture_version); \ + builtin_define ("__ARM_ARCH_8A"); \ builtin_define ("__ARM_ARCH_ISA_A64"); \ builtin_define_with_int_value \ ("__ARM_ARCH_PROFILE", 'A'); \ diff --git a/gcc/config/aarch64/driver-aarch64.c b/gcc/config/aarch64/driver-aarch64.c index d0be6db..ae4d5a0 100644 --- a/gcc/config/aarch64/driver-aarch64.c +++ b/gcc/config/aarch64/driver-aarch64.c @@ -54,16 +54,16 @@ static struct aarch64_core_data cpu_data [] = #undef AARCH64_CORE -struct aarch64_arch +struct aarch64_arch_driver_info { const char* id; const char* name; }; -#define AARCH64_ARCH(NAME, CORE, ARCH, FLAGS) \ - { #ARCH, NAME }, +#define AARCH64_ARCH(NAME, CORE, ARCH_IDENT, ARCH_REV, FLAGS) \ + { #ARCH_IDENT, NAME }, -static struct aarch64_arch aarch64_arches [] = +static struct aarch64_arch_driver_info aarch64_arches [] = { #include "aarch64-arches.def" {NULL, NULL}