From patchwork Thu Nov 3 18:10:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard Earnshaw (lists)" X-Patchwork-Id: 690960 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 3t8tLf69htz9t2N for ; Fri, 4 Nov 2016 05:10:48 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wOW+DWPN; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=bKff2Ey5OnjpsF6YhMY2VMISxzWYDTwx1QA8iQ9DRuLU2Y2LIM 4DxJIPE8p/2BtM2yq5FDgL8gXnl6TG6UqtN11ym9a1TFWjV1OcyICN9ae0DgAohq BbJkv79LGmCL+Mxul8iz5wFrKMbMVoAvUOqq+Pkacm7qr1lU01gncWWGs= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=8b2P5Fr3L9nzPhwjkd9MsUNDvD8=; b=wOW+DWPNe1IBnckbTdTT ZNIgvRRk4cpVodQ5oSsyJc39GYgpQRUwKiISOX/OmQrXtAol7PwdjB8DklnZ5Vks kwlSGnYQbZgSSzWLAVPGYTaS4jI8ltfGCDAI1DampVxI507NtH3Ei0pRgH86x9qt oOHQvJU/4Di1Vvbkjym5vAs= Received: (qmail 8739 invoked by alias); 3 Nov 2016 18:10: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 8681 invoked by uid 89); 3 Nov 2016 18:10:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=sought, clobber, convoluted, xval X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Nov 2016 18:10:32 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8A5A716; Thu, 3 Nov 2016 11:10:30 -0700 (PDT) Received: from e105689-lin.cambridge.arm.com (e105689-lin.cambridge.arm.com [10.2.207.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 18D0A3F25D; Thu, 3 Nov 2016 11:10:29 -0700 (PDT) To: gcc-patches From: "Richard Earnshaw (lists)" Subject: [PATCH] [ARM] Eliminate SUBTARGET_CPU_DEFAULT Message-ID: <3be9718a-90e2-eaf4-9c80-47720072567e@arm.com> Date: Thu, 3 Nov 2016 18:10:28 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 Over the years, GCC has had various ways of setting the default CPU. As things have changed, the ARM back-end hasn't necessarily kept up with some of the changes and this has resulted in some convoluted logic in places. This patch cleans up some of this and eliminates entirely the need for SUBTARGET_CPU_DEFAULT and for the generic ARM code to provide a definition of TARGET_CPU_DEFAULT. Instead, all the default selection logic for the ARM cpus is pushed into config.gcc, making it much easier to understand which processor is used for each target. * config.gcc (arm-wrs-vxworks): Set target_cpu_cname. (arm*-freebsd*): Likewise. (arm*-*-netbsdelf*): Likewise. (arm*-*-linux*): Likewise. (arm*-*-uclinux*eabi*): Likewise. (arm*-*-phoenix*): Likewise. (arm*-*-eabi*, arm*-*-symbianelf*, arm*-*-rtems*): Likewise. (arm*-*-*): Don't clobber target_cpu_cname when --with-cpu is not specified. Default to arm6 if target_cpu_cname is not set. * arm/arm.c (arm_option_override): Simplify logic. Assert that the default cpu has been correctly configured. * arm/arm.h (TARGET_CPU_DEFAULT): Delete. (target_cpus): Delete TARGET_CPU_generic, add TARGET_CPU_num_cores. * arm/freebsd.h (SUBTARGET_CPU_DEFAULT): Delete. * arm/linux-eabi.h (SUBTARGET_CPU_DEFAULT): Delete. * arm/linux-elf.h (SUBTARGET_CPU_DEFAULT): Delete. * arm/symbian.h (SUBTARGET_CPU_DEFAULT): Delete. * arm/unknown-elf.h (SUBTARGET_CPU_DEFAULT): Delete. Tested by running builds for all supported configurations to check that correct default CPUs are selected and by running full bootstrap on arm-linux-gnueabihf. Applied to trunk. diff --git a/gcc/config.gcc b/gcc/config.gcc index f9148dd..6d98d96 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1049,6 +1049,7 @@ arm-wrs-vxworks) tm_file="elfos.h arm/elf.h arm/aout.h ${tm_file} vx-common.h vxworks.h arm/vxworks.h" extra_options="${extra_options} arm/vxworks.opt" tmake_file="${tmake_file} arm/t-arm arm/t-vxworks" + target_cpu_cname="arm6" ;; arm*-*-freebsd*) # ARM FreeBSD EABI tm_file="dbxelf.h elfos.h ${fbsd_tm_file} arm/elf.h" @@ -1061,11 +1062,15 @@ arm*-*-freebsd*) # ARM FreeBSD EABI tm_file="${tm_file} arm/bpabi.h arm/freebsd.h arm/aout.h arm/arm.h" case $target in armv6*-*-freebsd*) + target_cpu_cname="arm1176jzfs" tm_defines="${tm_defines} TARGET_FREEBSD_ARMv6=1" if test $fbsd_major -ge 11; then tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1" fi ;; + *) + target_cpu_cname="arm9" + ;; esac with_tls=${with_tls:-gnu} ;; @@ -1073,6 +1078,7 @@ arm*-*-netbsdelf*) tm_file="dbxelf.h elfos.h netbsd.h netbsd-elf.h arm/elf.h arm/aout.h ${tm_file} arm/netbsd-elf.h" extra_options="${extra_options} netbsd.opt netbsd-elf.opt" tmake_file="${tmake_file} arm/t-arm" + target_cpu_cname="arm6" ;; arm*-*-linux-*) # ARM GNU/Linux with ELF tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h" @@ -1084,6 +1090,7 @@ arm*-*-linux-*) # ARM GNU/Linux with ELF esac tmake_file="${tmake_file} arm/t-arm arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi" tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h arm/aout.h vxworks-dummy.h arm/arm.h" + target_cpu_cname="arm10tdmi" # Define multilib configuration for arm-linux-androideabi. case ${target} in *-androideabi) @@ -1098,6 +1105,7 @@ arm*-*-uclinux*eabi*) # ARM ucLinux tm_file="dbxelf.h elfos.h arm/unknown-elf.h arm/elf.h arm/linux-gas.h arm/uclinux-elf.h glibc-stdint.h" tmake_file="${tmake_file} arm/t-arm arm/t-arm-elf arm/t-bpabi" tm_file="$tm_file arm/bpabi.h arm/uclinux-eabi.h arm/aout.h vxworks-dummy.h arm/arm.h" + target_cpu_cname="arm7tdmi" # The EABI requires the use of __cxa_atexit. default_use_cxa_atexit=yes ;; @@ -1106,6 +1114,7 @@ arm*-*-phoenix*) tm_file="${tm_file} newlib-stdint.h phoenix.h" tm_file="${tm_file} arm/aout.h arm/arm.h" tmake_file="${tmake_file} arm/t-arm arm/t-bpabi arm/t-phoenix" + target_cpu_cname="arm7tdmi" ;; arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*) case ${target} in @@ -1115,6 +1124,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*) default_use_cxa_atexit=yes tm_file="dbxelf.h elfos.h arm/unknown-elf.h arm/elf.h arm/bpabi.h" tmake_file="${tmake_file} arm/t-arm arm/t-arm-elf" + target_cpu_cname="arm7tdmi" case ${target} in arm*-*-eabi*) tm_file="$tm_file newlib-stdint.h" @@ -1130,6 +1140,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*) # We do not include t-bpabi for Symbian OS because the system # provides its own implementation of the BPABI functions. tmake_file="${tmake_file} arm/t-symbian" + target_cpu_cname="arm10tdmi" ;; esac tm_file="${tm_file} arm/aout.h vxworks-dummy.h arm/arm.h" @@ -3638,8 +3649,10 @@ case "${target}" in ${srcdir}/config/arm/arm-cores.def | \ sed -e 's/^[^,]*,[ ]*//' | \ sed -e 's/,.*$//'` - eval "target_${which}_cname=$new_val" - echo "For $val real value is $new_val" + if [ x"$val" != x ] ; then + eval "target_${which}_cname=$new_val" + echo "For $val real value is $new_val" + fi true else echo "Unknown CPU used in --with-$which=$val" 1>&2 @@ -4313,7 +4326,7 @@ case ${target} in arm*-*-*) if test x$target_cpu_cname = x then - target_cpu_default2=TARGET_CPU_generic + target_cpu_default2=TARGET_CPU_arm6 else target_cpu_default2=TARGET_CPU_$target_cpu_cname fi diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 5add0d6..6dc2d2d 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3104,17 +3104,7 @@ arm_option_override (void) arm_feature_set sought = ARM_FSET_EMPTY;; arm_selected_cpu = &all_cores[TARGET_CPU_DEFAULT]; - if (!arm_selected_cpu->name) - { -#ifdef SUBTARGET_CPU_DEFAULT - /* Use the subtarget default CPU if none was specified by - configure. */ - arm_selected_cpu = &all_cores[SUBTARGET_CPU_DEFAULT]; -#endif - /* Default to ARM6. */ - if (!arm_selected_cpu->name) - arm_selected_cpu = &all_cores[arm6]; - } + gcc_assert (arm_selected_cpu->name); sel = arm_selected_cpu; insn_flags = sel->flags; diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index b2d8422..3d11555 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -55,7 +55,8 @@ enum target_cpus TARGET_CPU_##INTERNAL_IDENT, #include "arm-cores.def" #undef ARM_CORE - TARGET_CPU_generic + /* Total number of CPUs we handle. */ + TARGET_CPU_num_cores }; /* The processor for which instructions should be scheduled. */ @@ -83,12 +84,6 @@ extern GTY(()) rtx arm_target_insn; /* Callback to output language specific object attributes. */ extern void (*arm_lang_output_object_attributes_hook)(void); -/* Just in case configure has failed to define anything. */ -#ifndef TARGET_CPU_DEFAULT -#define TARGET_CPU_DEFAULT TARGET_CPU_generic -#endif - - #undef CPP_SPEC #define CPP_SPEC "%(subtarget_cpp_spec) \ %{mfloat-abi=soft:%{mfloat-abi=hard: \ diff --git a/gcc/config/arm/freebsd.h b/gcc/config/arm/freebsd.h index 0ade4e9..949c397 100644 --- a/gcc/config/arm/freebsd.h +++ b/gcc/config/arm/freebsd.h @@ -112,14 +112,6 @@ #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE BITS_PER_WORD -#if defined (TARGET_FREEBSD_ARMv6) -#undef SUBTARGET_CPU_DEFAULT -#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm1176jzs -#else -#undef SUBTARGET_CPU_DEFAULT -#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm9 -#endif - /* FreeBSD 10 does not support unaligned access for armv6 and up. Unaligned access support was added in FreeBSD 11. */ #if FBSD_MAJOR < 11 diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h index ace8481..9cfcf9f 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -41,12 +41,6 @@ #undef ARM_DEFAULT_ABI #define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX -/* Default to armv5t so that thumb shared libraries work. - The ARM10TDMI core is the default for armv5t, so set - SUBTARGET_CPU_DEFAULT to achieve this. */ -#undef SUBTARGET_CPU_DEFAULT -#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi - /* TARGET_BIG_ENDIAN_DEFAULT is set in config.gcc for big endian configurations. */ #undef TARGET_LINKER_EMULATION diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h index a94bd2d..cc17b51 100644 --- a/gcc/config/arm/linux-elf.h +++ b/gcc/config/arm/linux-elf.h @@ -45,8 +45,6 @@ #undef TARGET_DEFAULT #define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT) -#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6 - #define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p" /* We do not have any MULTILIB_OPTIONS specified, so there are no diff --git a/gcc/config/arm/symbian.h b/gcc/config/arm/symbian.h index fc9c350..af078d5 100644 --- a/gcc/config/arm/symbian.h +++ b/gcc/config/arm/symbian.h @@ -59,12 +59,6 @@ /* Support the "dllimport" attribute. */ #define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1 -/* Symbian OS assumes ARM V5 or above. Since -march=armv5 is - equivalent to making the ARM 10TDMI core the default, we can set - SUBTARGET_CPU_DEFAULT and get an equivalent effect. */ -#undef SUBTARGET_CPU_DEFAULT -#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi - /* The assembler should assume VFP FPU format, and armv5t. */ #undef SUBTARGET_ASM_FLOAT_SPEC #define SUBTARGET_ASM_FLOAT_SPEC \ diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h index fafe057..e5c0507 100644 --- a/gcc/config/arm/unknown-elf.h +++ b/gcc/config/arm/unknown-elf.h @@ -88,10 +88,6 @@ } \ while (0) -#ifndef SUBTARGET_CPU_DEFAULT -#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm7tdmi -#endif - /* The libgcc udivmod functions may throw exceptions. If newlib is configured to support long longs in I/O, then printf will depend on udivmoddi4, which will depend on the exception unwind routines,