Commit ffee7aa9 by James Greenhalgh Committed by James Greenhalgh

[AArch64] Fix behaviour of -mcpu option to match ARM.

gcc/

	* common/config/aarch64/aarch64-common.c
	(aarch64_handle_option): Don't handle any option order logic here.
	* config/aarch64/aarch64.c (aarch64_parse_arch): Do not override
	selected_cpu, warn on architecture version mismatch.
	(aarch64_override_options): Fix parsing order for option strings.

From-SVN: r206803
parent c7169779
2014-01-20 James Greenhalgh <james.greenhalgh@arm.com>
* common/config/aarch64/aarch64-common.c
(aarch64_handle_option): Don't handle any option order logic here.
* config/aarch64/aarch64.c (aarch64_parse_arch): Do not override
selected_cpu, warn on architecture version mismatch.
(aarch64_override_options): Fix parsing order for option strings.
2014-01-20 Jan-Benedict Glaw <jbglaw@lug-owl.de> 2014-01-20 Jan-Benedict Glaw <jbglaw@lug-owl.de>
Iain Sandoe <iain@codesourcery.com> Iain Sandoe <iain@codesourcery.com>
......
...@@ -52,10 +52,10 @@ static const struct default_options aarch_option_optimization_table[] = ...@@ -52,10 +52,10 @@ static const struct default_options aarch_option_optimization_table[] =
/* Implement TARGET_HANDLE_OPTION. /* Implement TARGET_HANDLE_OPTION.
This function handles the target specific options for CPU/target selection. This function handles the target specific options for CPU/target selection.
march wins over mcpu, so when march is defined, mcpu takes the same value, -mcpu=CPU is shorthand for -march=ARCH_FOR_CPU, -mtune=CPU.
otherwise march remains undefined. mtune can be used with either march or If either of -march or -mtune is given, they override their
mcpu. If march and mcpu are used together, the rightmost option wins. respective component of -mcpu. This logic is implemented
mtune can be used with either march or mcpu. */ in config/aarch64/aarch64.c:aarch64_override_options. */
static bool static bool
aarch64_handle_option (struct gcc_options *opts, aarch64_handle_option (struct gcc_options *opts,
...@@ -70,12 +70,10 @@ aarch64_handle_option (struct gcc_options *opts, ...@@ -70,12 +70,10 @@ aarch64_handle_option (struct gcc_options *opts,
{ {
case OPT_march_: case OPT_march_:
opts->x_aarch64_arch_string = arg; opts->x_aarch64_arch_string = arg;
opts->x_aarch64_cpu_string = arg;
return true; return true;
case OPT_mcpu_: case OPT_mcpu_:
opts->x_aarch64_cpu_string = arg; opts->x_aarch64_cpu_string = arg;
opts->x_aarch64_arch_string = NULL;
return true; return true;
case OPT_mtune_: case OPT_mtune_:
......
...@@ -5101,6 +5101,8 @@ aarch64_parse_arch (void) ...@@ -5101,6 +5101,8 @@ aarch64_parse_arch (void)
{ {
selected_arch = arch; selected_arch = arch;
aarch64_isa_flags = selected_arch->flags; aarch64_isa_flags = selected_arch->flags;
if (!selected_cpu)
selected_cpu = &all_cores[selected_arch->core]; selected_cpu = &all_cores[selected_arch->core];
if (ext != NULL) if (ext != NULL)
...@@ -5109,6 +5111,12 @@ aarch64_parse_arch (void) ...@@ -5109,6 +5111,12 @@ aarch64_parse_arch (void)
aarch64_parse_extension (ext); aarch64_parse_extension (ext);
} }
if (strcmp (selected_arch->arch, selected_cpu->arch))
{
warning (0, "switch -mcpu=%s conflicts with -march=%s switch",
selected_cpu->name, selected_arch->name);
}
return; return;
} }
} }
...@@ -5197,20 +5205,21 @@ aarch64_parse_tune (void) ...@@ -5197,20 +5205,21 @@ aarch64_parse_tune (void)
static void static void
aarch64_override_options (void) aarch64_override_options (void)
{ {
/* march wins over mcpu, so when march is defined, mcpu takes the same value, /* -mcpu=CPU is shorthand for -march=ARCH_FOR_CPU, -mtune=CPU.
otherwise march remains undefined. mtune can be used with either march or If either of -march or -mtune is given, they override their
mcpu. */ respective component of -mcpu.
if (aarch64_arch_string) So, first parse AARCH64_CPU_STRING, then the others, be careful
with -march as, if -mcpu is not present on the command line, march
must set a sensible default CPU. */
if (aarch64_cpu_string)
{ {
aarch64_parse_arch (); aarch64_parse_cpu ();
aarch64_cpu_string = NULL;
} }
if (aarch64_cpu_string) if (aarch64_arch_string)
{ {
aarch64_parse_cpu (); aarch64_parse_arch ();
selected_arch = NULL;
} }
if (aarch64_tune_string) if (aarch64_tune_string)
......
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