[arm] Use standard option parsing code for detecting
Now that the standard CPU and architecture option parsing code is available in the driver we can use the main CPU and architecture data tables for driving the automatic enabling of Thumb code. Doing this requires that the driver script tell the parser whether or not the target string is a CPU name or an architecture, but beyond that it is just standard use of the new capabilities. We do, however, now get some error checking if the target isn't recognized, when previously we just ignored unknown targets and hoped that a later pass would pick up on this. * config/arm/arm.h (TARGET_MODE_SPECS): Add additional parameter to call to target_mode_check describing the type of option passed. * common/config/arm/arm-common.c (arm_arch_core_flag): Delete. (arm_target_thumb_only): Use arm_parse_arch_option_name or arm_parse_cpu_option_name to match parameters against list of available targets. * config/arm/parsecpu.awk (gen_comm_data): Don't generate arm_arch_core_flags data structure. * config/arm/arm-cpu_cdata.h: Regenerated. From-SVN: r249288
This commit is contained in:
parent
435d12725b
commit
e53993efae
5 changed files with 61 additions and 1137 deletions
|
@ -1,3 +1,15 @@
|
|||
2017-06-16 Richard Earnshaw <rearnsha@arm.com>
|
||||
|
||||
* config/arm/arm.h (TARGET_MODE_SPECS): Add additional parameter to
|
||||
call to target_mode_check describing the type of option passed.
|
||||
* common/config/arm/arm-common.c (arm_arch_core_flag): Delete.
|
||||
(arm_target_thumb_only): Use arm_parse_arch_option_name or
|
||||
arm_parse_cpu_option_name to match parameters against list of
|
||||
available targets.
|
||||
* config/arm/parsecpu.awk (gen_comm_data): Don't generate
|
||||
arm_arch_core_flags data structure.
|
||||
* config/arm/arm-cpu_cdata.h: Regenerated.
|
||||
|
||||
2017-06-16 Richard Earnshaw <rearnsha@arm.com>
|
||||
|
||||
* common/config/arm/arm-common.c (arm_initialize_isa): Moved here from
|
||||
|
|
|
@ -143,12 +143,6 @@ arm_rewrite_march (int argc, const char **argv)
|
|||
return arm_rewrite_selected_arch (argv[argc - 1]);
|
||||
}
|
||||
|
||||
struct arm_arch_core_flag
|
||||
{
|
||||
const char *const name;
|
||||
const enum isa_feature isa_bits[isa_num_bits];
|
||||
};
|
||||
|
||||
#include "config/arm/arm-cpu-cdata.h"
|
||||
|
||||
/* Scan over a raw feature array BITS checking for BIT being present.
|
||||
|
@ -167,26 +161,60 @@ check_isa_bits_for (const enum isa_feature* bits, enum isa_feature bit)
|
|||
|
||||
/* Called by the driver to check whether the target denoted by current
|
||||
command line options is a Thumb-only target. ARGV is an array of
|
||||
-march and -mcpu values (ie. it contains the rhs after the equal
|
||||
sign) and we use the last one of them to make a decision. The
|
||||
number of elements in ARGV is given in ARGC. */
|
||||
tupples (normally only one) where the first element of the tupple
|
||||
is 'cpu' or 'arch' and the second is the option passed to the
|
||||
compiler for that. An architecture tupple is always taken in
|
||||
preference to a cpu tupple and the last of each type always
|
||||
overrides any earlier setting. */
|
||||
|
||||
const char *
|
||||
arm_target_thumb_only (int argc, const char **argv)
|
||||
{
|
||||
unsigned int opt;
|
||||
const char *arch = NULL;
|
||||
const char *cpu = NULL;
|
||||
|
||||
if (argc)
|
||||
if (argc % 2 != 0)
|
||||
fatal_error (input_location,
|
||||
"%%:target_mode_check takes an even number of parameters");
|
||||
|
||||
while (argc)
|
||||
{
|
||||
for (opt = 0; opt < (ARRAY_SIZE (arm_arch_core_flags)); opt++)
|
||||
if ((strcmp (argv[argc - 1], arm_arch_core_flags[opt].name) == 0)
|
||||
&& !check_isa_bits_for (arm_arch_core_flags[opt].isa_bits,
|
||||
isa_bit_notm))
|
||||
return "-mthumb";
|
||||
|
||||
return NULL;
|
||||
if (strcmp (argv[0], "arch") == 0)
|
||||
arch = argv[1];
|
||||
else if (strcmp (argv[0], "cpu") == 0)
|
||||
cpu = argv[1];
|
||||
else
|
||||
fatal_error (input_location,
|
||||
"unrecognized option passed to %%:target_mode_check");
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
/* No architecture, or CPU, has option extensions that change
|
||||
whether or not we have a Thumb-only device, so there is no need
|
||||
to scan any option extensions specified. */
|
||||
|
||||
/* If the architecture is specified, that overrides any CPU setting. */
|
||||
if (arch)
|
||||
{
|
||||
const arch_option *arch_opt
|
||||
= arm_parse_arch_option_name (all_architectures, "-march", arch);
|
||||
|
||||
if (arch_opt && !check_isa_bits_for (arch_opt->common.isa_bits,
|
||||
isa_bit_notm))
|
||||
return "-mthumb";
|
||||
}
|
||||
else if (cpu)
|
||||
{
|
||||
const cpu_option *cpu_opt
|
||||
= arm_parse_cpu_option_name (all_cores, "-mcpu", cpu);
|
||||
|
||||
if (cpu_opt && !check_isa_bits_for (cpu_opt->common.isa_bits,
|
||||
isa_bit_notm))
|
||||
return "-mthumb";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* List the permitted CPU option names. If TARGET is a near miss for an
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2262,7 +2262,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
|
|||
- an array of -mcpu values if any is given;
|
||||
- an empty array. */
|
||||
#define TARGET_MODE_SPECS \
|
||||
" %{!marm:%{!mthumb:%:target_mode_check(%{march=*:%*;mcpu=*:%*;:})}}"
|
||||
" %{!marm:%{!mthumb:%:target_mode_check(%{march=*:arch %*;mcpu=*:cpu %*;:})}}"
|
||||
|
||||
#define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS TARGET_MODE_SPECS
|
||||
#define TARGET_SUPPORTS_WIDE_INT 1
|
||||
|
|
|
@ -288,44 +288,6 @@ function gen_comm_data () {
|
|||
}
|
||||
|
||||
print "};"
|
||||
|
||||
print "static const struct arm_arch_core_flag arm_arch_core_flags[] ="
|
||||
print "{"
|
||||
|
||||
ncpus = split (cpu_list, cpus)
|
||||
|
||||
for (n = 1; n <= ncpus; n++) {
|
||||
print " {"
|
||||
print " \"" cpus[n] "\","
|
||||
# Just truncate the architecture name at the beginning of the
|
||||
# extensions. We don't need any of those here (at present).
|
||||
arch_name = cpu_arch[cpus[n]];
|
||||
sub("+.*", "", arch_name)
|
||||
if (! (arch_name in arch_isa)) {
|
||||
fatal("unknown arch " arch_name " for cpu " cpus[n])
|
||||
}
|
||||
print " {"
|
||||
print " " arch_isa[arch_name] ","
|
||||
if (cpus[n] in cpu_fpu) print " " fpu_isa[cpu_fpu[cpus[n]]] ","
|
||||
if (cpus[n] in cpu_isa) print " " cpu_isa[cpus[n]] ","
|
||||
print " isa_nobit"
|
||||
print " },"
|
||||
print " },"
|
||||
}
|
||||
|
||||
narchs = split (arch_list, archs)
|
||||
|
||||
for (n = 1; n <= narchs; n++) {
|
||||
print " {"
|
||||
print " \"" archs[n] "\","
|
||||
print " {"
|
||||
print " " arch_isa[archs[n]] ","
|
||||
print " isa_nobit"
|
||||
print " },"
|
||||
print " },"
|
||||
}
|
||||
|
||||
print "};\n"
|
||||
}
|
||||
|
||||
function gen_md () {
|
||||
|
|
Loading…
Add table
Reference in a new issue