[arm] Move cpu and architecture option name parsing

This patch has no functional change.  The code used for parsing -mcpu,
-mtune and -march options is simply moved from arm.c arm-common.c.
The list of FPU options is also moved.  Subsequent patches will make
use of this within the driver.

Some small adjustments are needed as a consequence of moving the
definitions of the data objects to another object file, in that we
no-longer have direct access to the size of the object.

	* common/config/arm/arm-common.c (arm_initialize_isa): Moved here from
	config/arm/arm.c.
	(arm_print_hint_for_cpu_option): Likewise.
	(arm_print_hint_for_arch_option): Likewise.
	(arm_parse_cpu_option_name): Likewise.
	(arm_parse_arch_option_name): Likewise.
	* config/arm/arm.c (arm_identify_fpu_from_isa): Use the computed number
	of entries in the all_fpus list.
	* config/arm/arm-protos.h (all_architectures, all_cores): Declare.
	(arm_parse_cpu_option_name): Declare.
	(arm_parse_arch_option_name): Declare.
	(arm_parse_option_features): Declare.
	(arm_intialize_isa): Declare.
	* config/arm/parsecpu.awk (gen_data): Move CPU and architecture
	data tables to ...
	(gen_comm_data): ... here.  Make definitions non-static.
	* config/arm/arm-cpu-data.h: Regenerated.
	* config/arm/arm-cpu-cdata.h: Regenerated.

From-SVN: r249287
This commit is contained in:
Richard Earnshaw 2017-06-16 21:03:17 +00:00 committed by Richard Earnshaw
parent 050809ed8a
commit 435d12725b
7 changed files with 2840 additions and 2760 deletions

View file

@ -1,3 +1,24 @@
2017-06-16 Richard Earnshaw <rearnsha@arm.com>
* common/config/arm/arm-common.c (arm_initialize_isa): Moved here from
config/arm/arm.c.
(arm_print_hint_for_cpu_option): Likewise.
(arm_print_hint_for_arch_option): Likewise.
(arm_parse_cpu_option_name): Likewise.
(arm_parse_arch_option_name): Likewise.
* config/arm/arm.c (arm_identify_fpu_from_isa): Use the computed number
of entries in the all_fpus list.
* config/arm/arm-protos.h (all_architectures, all_cores): Declare.
(arm_parse_cpu_option_name): Declare.
(arm_parse_arch_option_name): Declare.
(arm_parse_option_features): Declare.
(arm_intialize_isa): Declare.
* config/arm/parsecpu.awk (gen_data): Move CPU and architecture
data tables to ...
(gen_comm_data): ... here. Make definitions non-static.
* config/arm/arm-cpu-data.h: Regenerated.
* config/arm/arm-cpu-cdata.h: Regenerated.
2017-06-16 Richard Earnshaw <rearnsha@arm.com>
* config/arm/arm-protos.h (arm_build_target): Remove arch_core.

View file

@ -27,6 +27,8 @@
#include "common/common-target-def.h"
#include "opts.h"
#include "flags.h"
#include "sbitmap.h"
#include "diagnostic.h"
/* Set default optimization options. */
static const struct default_options arm_option_optimization_table[] =
@ -187,6 +189,194 @@ arm_target_thumb_only (int argc, const char **argv)
return NULL;
}
/* List the permitted CPU option names. If TARGET is a near miss for an
entry, print out the suggested alternative. */
static void
arm_print_hint_for_cpu_option (const char *target,
const cpu_option *list)
{
auto_vec<const char*> candidates;
for (; list->common.name != NULL; list++)
candidates.safe_push (list->common.name);
char *s;
const char *hint = candidates_list_and_hint (target, s, candidates);
if (hint)
inform (input_location, "valid arguments are: %s; did you mean %qs?",
s, hint);
else
inform (input_location, "valid arguments are: %s", s);
XDELETEVEC (s);
}
/* Parse the base component of a CPU selection in LIST. Return a
pointer to the entry in the architecture table. OPTNAME is the
name of the option we are parsing and can be used if a diagnostic
is needed. */
const cpu_option *
arm_parse_cpu_option_name (const cpu_option *list, const char *optname,
const char *target)
{
const cpu_option *entry;
const char *end = strchr (target, '+');
size_t len = end ? end - target : strlen (target);
for (entry = list; entry->common.name != NULL; entry++)
{
if (strncmp (entry->common.name, target, len) == 0
&& entry->common.name[len] == '\0')
return entry;
}
error_at (input_location, "unrecognized %s target: %s", optname, target);
arm_print_hint_for_cpu_option (target, list);
return NULL;
}
/* List the permitted architecture option names. If TARGET is a near
miss for an entry, print out the suggested alternative. */
static void
arm_print_hint_for_arch_option (const char *target,
const arch_option *list)
{
auto_vec<const char*> candidates;
for (; list->common.name != NULL; list++)
candidates.safe_push (list->common.name);
char *s;
const char *hint = candidates_list_and_hint (target, s, candidates);
if (hint)
inform (input_location, "valid arguments are: %s; did you mean %qs?",
s, hint);
else
inform (input_location, "valid arguments are: %s", s);
XDELETEVEC (s);
}
/* Parse the base component of a CPU or architecture selection in
LIST. Return a pointer to the entry in the architecture table.
OPTNAME is the name of the option we are parsing and can be used if
a diagnostic is needed. */
const arch_option *
arm_parse_arch_option_name (const arch_option *list, const char *optname,
const char *target)
{
const arch_option *entry;
const char *end = strchr (target, '+');
size_t len = end ? end - target : strlen (target);
for (entry = list; entry->common.name != NULL; entry++)
{
if (strncmp (entry->common.name, target, len) == 0
&& entry->common.name[len] == '\0')
return entry;
}
error_at (input_location, "unrecognized %s target: %s", optname, target);
arm_print_hint_for_arch_option (target, list);
return NULL;
}
/* Convert a static initializer array of feature bits to sbitmap
representation. */
void
arm_initialize_isa (sbitmap isa, const enum isa_feature *isa_bits)
{
bitmap_clear (isa);
while (*isa_bits != isa_nobit)
bitmap_set_bit (isa, *(isa_bits++));
}
/* OPT isn't a recognized feature. Print a suitable error message and
suggest a possible value. Always print the list of permitted
values. */
static void
arm_unrecognized_feature (const char *opt, size_t len,
const cpu_arch_option *target)
{
char *this_opt = XALLOCAVEC (char, len+1);
auto_vec<const char*> candidates;
strncpy (this_opt, opt, len);
this_opt[len] = 0;
error_at (input_location, "%qs does not support feature %qs", target->name,
this_opt);
for (const cpu_arch_extension *list = target->extensions;
list->name != NULL;
list++)
candidates.safe_push (list->name);
char *s;
const char *hint = candidates_list_and_hint (this_opt, s, candidates);
if (hint)
inform (input_location, "valid feature names are: %s; did you mean %qs?",
s, hint);
else
inform (input_location, "valid feature names are: %s", s);
XDELETEVEC (s);
}
/* Parse any feature extensions to add to (or remove from) the
permitted ISA selection. */
void
arm_parse_option_features (sbitmap isa, const cpu_arch_option *target,
const char *opts_in)
{
const char *opts = opts_in;
if (!opts)
return;
if (!target->extensions)
{
error_at (input_location, "%s does not take any feature options",
target->name);
return;
}
while (opts)
{
gcc_assert (*opts == '+');
const struct cpu_arch_extension *entry;
const char *end = strchr (++opts, '+');
size_t len = end ? end - opts : strlen (opts);
bool matched = false;
for (entry = target->extensions;
!matched && entry->name != NULL;
entry++)
{
if (strncmp (entry->name, opts, len) == 0
&& entry->name[len] == '\0')
{
if (isa)
{
const enum isa_feature *f = entry->isa_bits;
if (entry->remove)
{
while (*f != isa_nobit)
bitmap_clear_bit (isa, *(f++));
}
else
{
while (*f != isa_nobit)
bitmap_set_bit (isa, *(f++));
}
}
matched = true;
}
}
if (!matched)
arm_unrecognized_feature (opts, len, target);
opts = end;
}
}
#undef ARM_CPU_NAME_LENGTH

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -513,4 +513,16 @@ struct cpu_option
enum arch_type arch;
};
extern const arch_option all_architectures[];
extern const cpu_option all_cores[];
const cpu_option *arm_parse_cpu_option_name (const cpu_option *, const char *,
const char *);
const arch_option *arm_parse_arch_option_name (const arch_option *,
const char *, const char *);
void arm_parse_option_features (sbitmap, const cpu_arch_option *,
const char *);
void arm_initialize_isa (sbitmap, const enum isa_feature *);
#endif /* ! GCC_ARM_PROTOS_H */

View file

@ -3024,194 +3024,6 @@ arm_option_override_internal (struct gcc_options *opts,
#endif
}
/* Convert a static initializer array of feature bits to sbitmap
representation. */
static void
arm_initialize_isa (sbitmap isa, const enum isa_feature *isa_bits)
{
bitmap_clear (isa);
while (*isa_bits != isa_nobit)
bitmap_set_bit (isa, *(isa_bits++));
}
/* List the permitted CPU option names. If TARGET is a near miss for an
entry, print out the suggested alternative. */
static void
arm_print_hint_for_cpu_option (const char *target,
const cpu_option *list)
{
auto_vec<const char*> candidates;
for (; list->common.name != NULL; list++)
candidates.safe_push (list->common.name);
char *s;
const char *hint = candidates_list_and_hint (target, s, candidates);
if (hint)
inform (input_location, "valid arguments are: %s; did you mean %qs?",
s, hint);
else
inform (input_location, "valid arguments are: %s", s);
XDELETEVEC (s);
}
/* Parse the base component of a CPU selection in LIST. Return a
pointer to the entry in the architecture table. OPTNAME is the
name of the option we are parsing and can be used if a diagnostic
is needed. */
static const cpu_option *
arm_parse_cpu_option_name (const cpu_option *list, const char *optname,
const char *target)
{
const cpu_option *entry;
const char *end = strchr (target, '+');
size_t len = end ? end - target : strlen (target);
for (entry = list; entry->common.name != NULL; entry++)
{
if (strncmp (entry->common.name, target, len) == 0
&& entry->common.name[len] == '\0')
return entry;
}
error_at (input_location, "unrecognized %s target: %s", optname, target);
arm_print_hint_for_cpu_option (target, list);
return NULL;
}
/* List the permitted architecture option names. If TARGET is a near
miss for an entry, print out the suggested alternative. */
static void
arm_print_hint_for_arch_option (const char *target,
const arch_option *list)
{
auto_vec<const char*> candidates;
for (; list->common.name != NULL; list++)
candidates.safe_push (list->common.name);
char *s;
const char *hint = candidates_list_and_hint (target, s, candidates);
if (hint)
inform (input_location, "valid arguments are: %s; did you mean %qs?",
s, hint);
else
inform (input_location, "valid arguments are: %s", s);
XDELETEVEC (s);
}
/* Parse the base component of a CPU or architecture selection in
LIST. Return a pointer to the entry in the architecture table.
OPTNAME is the name of the option we are parsing and can be used if
a diagnostic is needed. */
static const arch_option *
arm_parse_arch_option_name (const arch_option *list, const char *optname,
const char *target)
{
const arch_option *entry;
const char *end = strchr (target, '+');
size_t len = end ? end - target : strlen (target);
for (entry = list; entry->common.name != NULL; entry++)
{
if (strncmp (entry->common.name, target, len) == 0
&& entry->common.name[len] == '\0')
return entry;
}
error_at (input_location, "unrecognized %s target: %s", optname, target);
arm_print_hint_for_arch_option (target, list);
return NULL;
}
/* OPT isn't a recognized feature. Print a suitable error message and
suggest a possible value. Always print the list of permitted
values. */
static void
arm_unrecognized_feature (const char *opt, size_t len,
const cpu_arch_option *target)
{
char *this_opt = XALLOCAVEC (char, len+1);
auto_vec<const char*> candidates;
strncpy (this_opt, opt, len);
this_opt[len] = 0;
error_at (input_location, "%qs does not support feature %qs", target->name,
this_opt);
for (const cpu_arch_extension *list = target->extensions;
list->name != NULL;
list++)
candidates.safe_push (list->name);
char *s;
const char *hint = candidates_list_and_hint (this_opt, s, candidates);
if (hint)
inform (input_location, "valid feature names are: %s; did you mean %qs?",
s, hint);
else
inform (input_location, "valid feature names are: %s", s);
XDELETEVEC (s);
}
/* Parse any feature extensions to add to (or remove from) the
permitted ISA selection. */
static void
arm_parse_option_features (sbitmap isa, const cpu_arch_option *target,
const char *opts_in)
{
const char *opts = opts_in;
if (!opts)
return;
if (!target->extensions)
{
error_at (input_location, "%s does not take any feature options",
target->name);
return;
}
while (opts)
{
gcc_assert (*opts == '+');
const struct cpu_arch_extension *entry;
const char *end = strchr (++opts, '+');
size_t len = end ? end - opts : strlen (opts);
bool matched = false;
for (entry = target->extensions;
!matched && entry->name != NULL;
entry++)
{
if (strncmp (entry->name, opts, len) == 0
&& entry->name[len] == '\0')
{
if (isa)
{
const enum isa_feature *f = entry->isa_bits;
if (entry->remove)
{
while (*f != isa_nobit)
bitmap_clear_bit (isa, *(f++));
}
else
{
while (*f != isa_nobit)
bitmap_set_bit (isa, *(f++));
}
}
matched = true;
}
}
if (!matched)
arm_unrecognized_feature (opts, len, target);
opts = end;
}
}
static sbitmap isa_all_fpubits;
static sbitmap isa_quirkbits;
@ -30886,7 +30698,7 @@ arm_identify_fpu_from_isa (sbitmap isa)
if (bitmap_empty_p (fpubits))
return "softvfp";
for (unsigned int i = 0; i < ARRAY_SIZE (all_fpus); i++)
for (unsigned int i = 0; i < TARGET_FPU_auto; i++)
{
arm_initialize_isa (cand_fpubits, all_fpus[i].isa_bits);
if (bitmap_equal_p (fpubits, cand_fpubits))

View file

@ -128,6 +128,39 @@ function gen_headers () {
function gen_data () {
boilerplate("C")
print "static const cpu_tune all_tunes[] ="
print "{"
ncpus = split (cpu_list, cpus)
for (n = 1; n <= ncpus; n++) {
print " { /* " cpus[n] ". */"
# scheduler
if (cpus[n] in cpu_tune_for) {
if (! (cpu_tune_for[cpus[n]] in cpu_cnames)) {
fatal("unknown \"tune for\" target " cpu_tune_for[cpus[n]] \
" for CPU " cpus[n])
}
print " TARGET_CPU_" cpu_cnames[cpu_tune_for[cpus[n]]] ","
} else {
print " TARGET_CPU_" cpu_cnames[cpus[n]] ","
}
# tune_flags
if (cpus[n] in cpu_tune_flags) {
print " (" cpu_tune_flags[cpus[n]] "),"
} else print " 0,"
# tune
print " &arm_" cpu_cost[cpus[n]] "_tune"
print " },"
}
print " {TARGET_CPU_arm_none, 0, NULL}"
print "};"
}
function gen_comm_data () {
boilerplate("C")
ncpus = split (cpu_list, cpus)
for (n = 1; n <= ncpus; n++) {
@ -147,7 +180,7 @@ function gen_data () {
}
}
print "static const cpu_option all_cores[] ="
print "const cpu_option all_cores[] ="
print "{"
for (n = 1; n <= ncpus; n++) {
@ -188,32 +221,6 @@ function gen_data () {
print " {{NULL, NULL, {isa_nobit}}, TARGET_ARCH_arm_none}"
print "};"
print "static const cpu_tune all_tunes[] ="
print "{"
for (n = 1; n <= ncpus; n++) {
print " { /* " cpus[n] ". */"
# scheduler
if (cpus[n] in cpu_tune_for) {
if (! (cpu_tune_for[cpus[n]] in cpu_cnames)) {
fatal("unknown \"tune for\" target " cpu_tune_for[cpus[n]] \
" for CPU " cpus[n])
}
print " TARGET_CPU_" cpu_cnames[cpu_tune_for[cpus[n]]] ","
} else {
print " TARGET_CPU_" cpu_cnames[cpus[n]] ","
}
# tune_flags
if (cpus[n] in cpu_tune_flags) {
print " (" cpu_tune_flags[cpus[n]] "),"
} else print " 0,"
# tune
print " &arm_" cpu_cost[cpus[n]] "_tune"
print " },"
}
print " {TARGET_CPU_arm_none, 0, NULL}"
print "};"
narchs = split (arch_list, archs)
for (n = 1; n <= narchs; n++) {
@ -233,7 +240,7 @@ function gen_data () {
}
}
print "static const struct arch_option all_architectures[] ="
print "const arch_option all_architectures[] ="
print "{"
for (n = 1; n <= narchs; n++) {
@ -265,7 +272,7 @@ function gen_data () {
print " NULL, BASE_ARCH_0, TARGET_CPU_arm_none}"
print "};\n"
print "const struct arm_fpu_desc all_fpus[] ="
print "const arm_fpu_desc all_fpus[] ="
print "{"
nfpus = split (fpu_list, fpus)
@ -281,10 +288,6 @@ function gen_data () {
}
print "};"
}
function gen_comm_data () {
boilerplate("C")
print "static const struct arm_arch_core_flag arm_arch_core_flags[] ="
print "{"