#include "sbitmap.h"
#include "diagnostic.h"
+#include "configargs.h"
+
/* Set default optimization options. */
static const struct default_options arm_option_optimization_table[] =
{
return false;
}
+/* Look up NAME in the configuration defaults for this build of the
+ the compiler. Return the value associated with that name, or NULL
+ if no value is found. */
+static const char *
+arm_config_default (const char *name)
+{
+ int i;
+
+ if (configure_default_options[0].name == NULL)
+ return NULL;
+
+ for (i = 0; i < ARRAY_SIZE (configure_default_options); i++)
+ if (strcmp (configure_default_options[i].name, name) == 0)
+ return configure_default_options[i].value;
+
+ return NULL;
+}
+
/* 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
- 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
+ command line options is a Thumb-only, or ARM-only, target. ARGV is
+ an array of 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)
+arm_target_mode (int argc, const char **argv)
{
const char *arch = NULL;
const char *cpu = NULL;
if (arch_opt && !check_isa_bits_for (arch_opt->common.isa_bits,
isa_bit_notm))
return "-mthumb";
+ if (arch_opt && !check_isa_bits_for (arch_opt->common.isa_bits,
+ isa_bit_thumb))
+ return "-marm";
}
else if (cpu)
{
if (cpu_opt && !check_isa_bits_for (cpu_opt->common.isa_bits,
isa_bit_notm))
return "-mthumb";
+ if (cpu_opt && !check_isa_bits_for (cpu_opt->common.isa_bits,
+ isa_bit_thumb))
+ return "-marm";
+ }
+
+ const char *default_mode = arm_config_default ("mode");
+ if (default_mode)
+ {
+ if (strcmp (default_mode, "thumb") == 0)
+ return "-mthumb";
+ else if (strcmp (default_mode, "arm") == 0)
+ return "-marm";
+ else
+ gcc_unreachable ();
}
/* Compiler hasn't been configured with a default, and the CPU
--with-float is ignored if -mfloat-abi is specified.
--with-fpu is ignored if -mfpu is specified.
--with-abi is ignored if -mabi is specified.
- --with-tls is ignored if -mtls-dialect is specified. */
+ --with-tls is ignored if -mtls-dialect is specified.
+ Note: --with-mode is not handled here, that has a special rule
+ TARGET_MODE_CHECK that also takes into account the selected CPU and
+ architecture. */
#define OPTION_DEFAULT_SPECS \
{"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \
{"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
{"float", "%{!mfloat-abi=*:-mfloat-abi=%(VALUE)}" }, \
{"fpu", "%{!mfpu=*:-mfpu=%(VALUE)}"}, \
{"abi", "%{!mabi=*:-mabi=%(VALUE)}"}, \
- {"mode", "%{!marm:%{!mthumb:-m%(VALUE)}}"}, \
{"tls", "%{!mtls-dialect=*:-mtls-dialect=%(VALUE)}"},
extern const struct arm_fpu_desc
" mcpu=*:-mcpu=%:rewrite_mcpu(%{mcpu=*:%*})" \
" }"
-extern const char *arm_target_thumb_only (int argc, const char **argv);
+extern const char *arm_target_mode (int argc, const char **argv);
#define TARGET_MODE_SPEC_FUNCTIONS \
- { "target_mode_check", arm_target_thumb_only },
+ { "target_mode_check", arm_target_mode },
/* -mcpu=native handling only makes sense with compiler running on
an ARM chip. */