Commit 0b97b8f8 by Richard Earnshaw Committed by Richard Earnshaw

[arm] Generate a canonical form for -march


This patch uses the driver and some spec rewrite rules to generate a
canonicalized form of the -march= option.  We want to do this for
several reasons, all relating to making multi-lib selection sane.

1) It can remove redundant extension options to produce a minimal
list.

2) The general syntax of the option permits a plethora of features,
these are permitted in any order.  Canonicalization ensures that there
is a single ordering of the options that are needed.

3) It can use additional options to remove extensions that aren't
relevant, such as removing all features that relate to the FPU when
use of that is disabled.

Once we have this information in a sensible form the multilib rules
can be vastly simplified making for much more understandable Makefile
fragments.

	* common/config/arm/arm-common.c: Define INCLUDE_LIST.
	(configargs.h): Include it.
	(arm_print_hint_for_fpu_option): New function.
	(arm_parse_fpu_option): New function.
	(candidate_extension): New class.
	(arm_canon_for_multilib): New function.
	* config/arm/arm.h (CANON_ARCH_SPEC_FUNCTION): New macro.
	(EXTRA_SPEC_FUNCTIONS): Add CANON_ARCH_SPEC_FUNCTION.
	(ARCH_CANONICAL_SPECS): New macro.
	(DRIVER_SELF_SPECS): Add ARCH_CANONICAL_SPECS.

From-SVN: r249292
parent a4af8a10
2017-06-16 Richard Earnshaw <rearnsha@arm.com> 2017-06-16 Richard Earnshaw <rearnsha@arm.com>
* common/config/arm/arm-common.c: Define INCLUDE_LIST.
(configargs.h): Include it.
(arm_print_hint_for_fpu_option): New function.
(arm_parse_fpu_option): New function.
(candidate_extension): New class.
(arm_canon_for_multilib): New function.
* config/arm/arm.h (CANON_ARCH_SPEC_FUNCTION): New macro.
(EXTRA_SPEC_FUNCTIONS): Add CANON_ARCH_SPEC_FUNCTION.
(ARCH_CANONICAL_SPECS): New macro.
(DRIVER_SELF_SPECS): Add ARCH_CANONICAL_SPECS.
2017-06-16 Richard Earnshaw <rearnsha@arm.com>
* config.gcc (arm*-*-*): Ensure both target_cpu_cname and with_cpu * config.gcc (arm*-*-*): Ensure both target_cpu_cname and with_cpu
are set after handling multilib fragments. Set target_cpu_default2 are set after handling multilib fragments. Set target_cpu_default2
from with_cpu. from with_cpu.
......
...@@ -2250,9 +2250,15 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); ...@@ -2250,9 +2250,15 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
# define MCPU_MTUNE_NATIVE_SPECS "" # define MCPU_MTUNE_NATIVE_SPECS ""
#endif #endif
const char *arm_canon_arch_option (int argc, const char **argv);
#define CANON_ARCH_SPEC_FUNCTION \
{ "canon_arch", arm_canon_arch_option },
# define EXTRA_SPEC_FUNCTIONS \ # define EXTRA_SPEC_FUNCTIONS \
MCPU_MTUNE_NATIVE_FUNCTIONS \ MCPU_MTUNE_NATIVE_FUNCTIONS \
ASM_CPU_SPEC_FUNCTIONS \ ASM_CPU_SPEC_FUNCTIONS \
CANON_ARCH_SPEC_FUNCTION \
TARGET_MODE_SPEC_FUNCTIONS TARGET_MODE_SPEC_FUNCTIONS
/* Automatically add -mthumb for Thumb-only targets if mode isn't specified /* Automatically add -mthumb for Thumb-only targets if mode isn't specified
...@@ -2264,7 +2270,19 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); ...@@ -2264,7 +2270,19 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
#define TARGET_MODE_SPECS \ #define TARGET_MODE_SPECS \
" %{!marm:%{!mthumb:%:target_mode_check(%{march=*:arch %*;mcpu=*:cpu %*;:})}}" " %{!marm:%{!mthumb:%:target_mode_check(%{march=*:arch %*;mcpu=*:cpu %*;:})}}"
#define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS TARGET_MODE_SPECS /* Generate a canonical string to represent the architecture selected. */
#define ARCH_CANONICAL_SPECS \
" -march=%:canon_arch(%{mcpu=*: cpu %*} " \
" %{march=*: arch %*} " \
" %{mfpu=*: fpu %*} " \
" %{mfloat-abi=*: abi %*}" \
" %<march=*) "
#define DRIVER_SELF_SPECS \
MCPU_MTUNE_NATIVE_SPECS \
TARGET_MODE_SPECS \
ARCH_CANONICAL_SPECS
#define TARGET_SUPPORTS_WIDE_INT 1 #define TARGET_SUPPORTS_WIDE_INT 1
/* For switching between functions with different target attributes. */ /* For switching between functions with different target attributes. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment