Commit 12a0a4d4 by Paul Brook Committed by Paul Brook

arm.c (FL_TUNE): Define.

2010-06-03  Paul Brook  <paul@codesourcery.com>

	gcc/
	* config/arm/arm.c (FL_TUNE): Define.
	(arm_default_cpu, arm_cpu_select): Remove.
	(all_cores): Populate core field.
	(arm_selected_arch, arm_selected_cpu, arm_selected_tune): New.
	(arm_find_cpu): New function.
	(arm_handle_option): Lookup cpu/architecture names.
	(arm_override_options): Cleanup mcpu/march/mtune handling.
	(arm_file_start): Ditto.

From-SVN: r160213
parent c3f247f4
2010-06-03 Paul Brook <paul@codesourcery.com>
* config/arm/arm.c (FL_TUNE): Define.
(arm_default_cpu, arm_cpu_select): Remove.
(all_cores): Populate core field.
(arm_selected_arch, arm_selected_cpu, arm_selected_tune): New.
(arm_find_cpu): New function.
(arm_handle_option): Lookup cpu/architecture names.
(arm_override_options): Cleanup mcpu/march/mtune handling.
(arm_file_start): Ditto.
2010-06-03 Alan Modra <amodra@gmail.com> 2010-06-03 Alan Modra <amodra@gmail.com>
PR target/44169 PR target/44169
......
...@@ -527,9 +527,6 @@ enum processor_type arm_tune = arm_none; ...@@ -527,9 +527,6 @@ enum processor_type arm_tune = arm_none;
/* The current tuning set. */ /* The current tuning set. */
const struct tune_params *current_tune; const struct tune_params *current_tune;
/* The default processor used if not overridden by commandline. */
static enum processor_type arm_default_cpu = arm_none;
/* Which floating point hardware to schedule for. */ /* Which floating point hardware to schedule for. */
int arm_fpu_attr; int arm_fpu_attr;
...@@ -585,6 +582,10 @@ static int thumb_call_reg_needed; ...@@ -585,6 +582,10 @@ static int thumb_call_reg_needed;
#define FL_IWMMXT (1 << 29) /* XScale v2 or "Intel Wireless MMX technology". */ #define FL_IWMMXT (1 << 29) /* XScale v2 or "Intel Wireless MMX technology". */
/* Flags that only effect tuning, not available instructions. */
#define FL_TUNE (FL_WBUF | FL_VFPV2 | FL_STRONG | FL_LDSCHED \
| FL_CO_PROC)
#define FL_FOR_ARCH2 FL_NOTM #define FL_FOR_ARCH2 FL_NOTM
#define FL_FOR_ARCH3 (FL_FOR_ARCH2 | FL_MODE32) #define FL_FOR_ARCH3 (FL_FOR_ARCH2 | FL_MODE32)
#define FL_FOR_ARCH3M (FL_FOR_ARCH3 | FL_ARCH3M) #define FL_FOR_ARCH3M (FL_FOR_ARCH3 | FL_ARCH3M)
...@@ -770,7 +771,7 @@ static const struct processors all_cores[] = ...@@ -770,7 +771,7 @@ static const struct processors all_cores[] =
{ {
/* ARM Cores */ /* ARM Cores */
#define ARM_CORE(NAME, IDENT, ARCH, FLAGS, COSTS) \ #define ARM_CORE(NAME, IDENT, ARCH, FLAGS, COSTS) \
{NAME, arm_none, #ARCH, FLAGS | FL_FOR_ARCH##ARCH, &arm_##COSTS##_tune}, {NAME, IDENT, #ARCH, FLAGS | FL_FOR_ARCH##ARCH, &arm_##COSTS##_tune},
#include "arm-cores.def" #include "arm-cores.def"
#undef ARM_CORE #undef ARM_CORE
{NULL, arm_none, NULL, 0, NULL} {NULL, arm_none, NULL, 0, NULL}
...@@ -812,29 +813,12 @@ static const struct processors all_architectures[] = ...@@ -812,29 +813,12 @@ static const struct processors all_architectures[] =
{NULL, arm_none, NULL, 0 , NULL} {NULL, arm_none, NULL, 0 , NULL}
}; };
struct arm_cpu_select
{
const char * string;
const char * name;
const struct processors * processors;
};
/* This is a magic structure. The 'string' field is magically filled in
with a pointer to the value specified by the user on the command line
assuming that the user has specified such a value. */
static struct arm_cpu_select arm_select[] = /* These are populated as commandline arguments are processed, or NULL
{ if not specified. */
/* string name processors */ static const struct processors *arm_selected_arch;
{ NULL, "-mcpu=", all_cores }, static const struct processors *arm_selected_cpu;
{ NULL, "-march=", all_architectures }, static const struct processors *arm_selected_tune;
{ NULL, "-mtune=", all_cores }
};
/* Defines representing the indexes into the above table. */
#define ARM_OPT_SET_CPU 0
#define ARM_OPT_SET_ARCH 1
#define ARM_OPT_SET_TUNE 2
/* The name of the preprocessor macro to define for this architecture. */ /* The name of the preprocessor macro to define for this architecture. */
...@@ -1196,6 +1180,24 @@ arm_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, ...@@ -1196,6 +1180,24 @@ arm_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
return std_gimplify_va_arg_expr (valist, type, pre_p, post_p); return std_gimplify_va_arg_expr (valist, type, pre_p, post_p);
} }
/* Lookup NAME in SEL. */
static const struct processors *
arm_find_cpu (const char *name, const struct processors *sel, const char *desc)
{
if (!(name && *name))
return NULL;
for (; sel->name != NULL; sel++)
{
if (streq (name, sel->name))
return sel;
}
error ("bad value (%s) for %s switch", name, desc);
return NULL;
}
/* Implement TARGET_HANDLE_OPTION. */ /* Implement TARGET_HANDLE_OPTION. */
static bool static bool
...@@ -1204,11 +1206,11 @@ arm_handle_option (size_t code, const char *arg, int value ATTRIBUTE_UNUSED) ...@@ -1204,11 +1206,11 @@ arm_handle_option (size_t code, const char *arg, int value ATTRIBUTE_UNUSED)
switch (code) switch (code)
{ {
case OPT_march_: case OPT_march_:
arm_select[1].string = arg; arm_selected_arch = arm_find_cpu(arg, all_architectures, "-march");
return true; return true;
case OPT_mcpu_: case OPT_mcpu_:
arm_select[0].string = arg; arm_selected_cpu = arm_find_cpu(arg, all_cores, "-mcpu");
return true; return true;
case OPT_mhard_float: case OPT_mhard_float:
...@@ -1220,7 +1222,7 @@ arm_handle_option (size_t code, const char *arg, int value ATTRIBUTE_UNUSED) ...@@ -1220,7 +1222,7 @@ arm_handle_option (size_t code, const char *arg, int value ATTRIBUTE_UNUSED)
return true; return true;
case OPT_mtune_: case OPT_mtune_:
arm_select[2].string = arg; arm_selected_tune = arm_find_cpu(arg, all_cores, "-mtune");
return true; return true;
default: default:
...@@ -1320,88 +1322,52 @@ void ...@@ -1320,88 +1322,52 @@ void
arm_override_options (void) arm_override_options (void)
{ {
unsigned i; unsigned i;
enum processor_type target_arch_cpu = arm_none;
enum processor_type selected_cpu = arm_none;
/* Set up the flags based on the cpu/architecture selected by the user. */ if (arm_selected_arch)
for (i = ARRAY_SIZE (arm_select); i--;)
{ {
struct arm_cpu_select * ptr = arm_select + i; if (arm_selected_cpu)
{
if (ptr->string != NULL && ptr->string[0] != '\0') /* Check for conflict between mcpu and march. */
{ if ((arm_selected_cpu->flags ^ arm_selected_arch->flags) & ~FL_TUNE)
const struct processors * sel; {
warning (0, "switch -mcpu=%s conflicts with -march=%s switch",
for (sel = ptr->processors; sel->name != NULL; sel++) arm_selected_cpu->name, arm_selected_arch->name);
if (streq (ptr->string, sel->name)) /* -march wins for code generation.
{ -mcpu wins for default tuning. */
/* Set the architecture define. */ if (!arm_selected_tune)
if (i != ARM_OPT_SET_TUNE) arm_selected_tune = arm_selected_cpu;
sprintf (arm_arch_name, "__ARM_ARCH_%s__", sel->arch);
arm_selected_cpu = arm_selected_arch;
/* Determine the processor core for which we should }
tune code-generation. */ else
if (/* -mcpu= is a sensible default. */ /* -mcpu wins. */
i == ARM_OPT_SET_CPU arm_selected_arch = NULL;
/* -mtune= overrides -mcpu= and -march=. */ }
|| i == ARM_OPT_SET_TUNE) else
arm_tune = (enum processor_type) (sel - ptr->processors); /* Pick a CPU based on the architecture. */
arm_selected_cpu = arm_selected_arch;
/* Remember the CPU associated with this architecture.
If no other option is used to set the CPU type,
we'll use this to guess the most suitable tuning
options. */
if (i == ARM_OPT_SET_ARCH)
target_arch_cpu = sel->core;
if (i == ARM_OPT_SET_CPU)
selected_cpu = (enum processor_type) (sel - ptr->processors);
if (i != ARM_OPT_SET_TUNE)
{
/* If we have been given an architecture and a processor
make sure that they are compatible. We only generate
a warning though, and we prefer the CPU over the
architecture. */
if (insn_flags != 0 && (insn_flags ^ sel->flags))
warning (0, "switch -mcpu=%s conflicts with -march= switch",
ptr->string);
insn_flags = sel->flags;
}
break;
}
if (sel->name == NULL)
error ("bad value (%s) for %s switch", ptr->string, ptr->name);
}
} }
/* Guess the tuning options from the architecture if necessary. */
if (arm_tune == arm_none)
arm_tune = target_arch_cpu;
/* If the user did not specify a processor, choose one for them. */ /* If the user did not specify a processor, choose one for them. */
if (insn_flags == 0) if (!arm_selected_cpu)
{ {
const struct processors * sel; const struct processors * sel;
unsigned int sought; unsigned int sought;
selected_cpu = (enum processor_type) TARGET_CPU_DEFAULT; arm_selected_cpu = &all_cores[TARGET_CPU_DEFAULT];
if (selected_cpu == arm_none) if (!arm_selected_cpu->name)
{ {
#ifdef SUBTARGET_CPU_DEFAULT #ifdef SUBTARGET_CPU_DEFAULT
/* Use the subtarget default CPU if none was specified by /* Use the subtarget default CPU if none was specified by
configure. */ configure. */
selected_cpu = (enum processor_type) SUBTARGET_CPU_DEFAULT; arm_selected_cpu = &all_cores[SUBTARGET_CPU_DEFAULT];
#endif #endif
/* Default to ARM6. */ /* Default to ARM6. */
if (selected_cpu == arm_none) if (arm_selected_cpu->name)
selected_cpu = arm6; arm_selected_cpu = &all_cores[arm6];
} }
sel = &all_cores[selected_cpu];
sel = arm_selected_cpu;
insn_flags = sel->flags; insn_flags = sel->flags;
/* Now check to see if the user has specified some command line /* Now check to see if the user has specified some command line
...@@ -1462,20 +1428,21 @@ arm_override_options (void) ...@@ -1462,20 +1428,21 @@ arm_override_options (void)
sel = best_fit; sel = best_fit;
} }
insn_flags = sel->flags; arm_selected_cpu = sel;
} }
sprintf (arm_arch_name, "__ARM_ARCH_%s__", sel->arch);
arm_default_cpu = (enum processor_type) (sel - all_cores);
if (arm_tune == arm_none)
arm_tune = arm_default_cpu;
} }
/* The processor for which we should tune should now have been gcc_assert (arm_selected_cpu);
chosen. */ /* The selected cpu may be an architecture, so lookup tuning by core ID. */
gcc_assert (arm_tune != arm_none); if (!arm_selected_tune)
arm_selected_tune = &all_cores[arm_selected_cpu->core];
sprintf (arm_arch_name, "__ARM_ARCH_%s__", arm_selected_cpu->arch);
insn_flags = arm_selected_cpu->flags;
tune_flags = all_cores[(int)arm_tune].flags; arm_tune = arm_selected_tune->core;
current_tune = all_cores[(int)arm_tune].tune; tune_flags = arm_selected_tune->flags;
current_tune = arm_selected_tune->tune;
if (target_fp16_format_name) if (target_fp16_format_name)
{ {
...@@ -1858,7 +1825,7 @@ arm_override_options (void) ...@@ -1858,7 +1825,7 @@ arm_override_options (void)
/* Enable -mfix-cortex-m3-ldrd by default for Cortex-M3 cores. */ /* Enable -mfix-cortex-m3-ldrd by default for Cortex-M3 cores. */
if (fix_cm3_ldrd == 2) if (fix_cm3_ldrd == 2)
{ {
if (selected_cpu == cortexm3) if (arm_selected_cpu->core == cortexm3)
fix_cm3_ldrd = 1; fix_cm3_ldrd = 1;
else else
fix_cm3_ldrd = 0; fix_cm3_ldrd = 0;
...@@ -20167,13 +20134,10 @@ arm_file_start (void) ...@@ -20167,13 +20134,10 @@ arm_file_start (void)
if (TARGET_BPABI) if (TARGET_BPABI)
{ {
const char *fpu_name; const char *fpu_name;
if (arm_select[0].string) if (arm_selected_arch)
asm_fprintf (asm_out_file, "\t.cpu %s\n", arm_select[0].string); asm_fprintf (asm_out_file, "\t.arch %s\n", arm_selected_arch->name);
else if (arm_select[1].string)
asm_fprintf (asm_out_file, "\t.arch %s\n", arm_select[1].string);
else else
asm_fprintf (asm_out_file, "\t.cpu %s\n", asm_fprintf (asm_out_file, "\t.cpu %s\n", arm_selected_cpu->name);
all_cores[arm_default_cpu].name);
if (TARGET_SOFT_FLOAT) if (TARGET_SOFT_FLOAT)
{ {
......
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