system.h (TARGET_OPTIONS, [...]): Poison.

* system.h (TARGET_OPTIONS, TARGET_SWITCHES): Poison.
	* opts.h (print_filtered_help): Delete.
	* opts.c (handle_option, decode_options): Remove calls to
	set_target_switch.
	(print_target_help): New function.
	(common_option, print_help): Call print_target_help instead of
	display_target_options.
	(print_filtered_help): Make static.
	* toplev.h (display_target_options, set_target_switch): Delete.
	* toplev.c (target_switches, target_options, display_target_options)
	(set_target_switch): Delete.
	(print_switch_values): Remove handling of TARGET_SWITCHES and
	TARGET_OPTIONS.
	(default_get_pch_validity): Likewise.  Only treat target_flags
	specially if targetm.check_pch_target_flags is nonnull.
	(pch_option_mismatch): New function.
	(default_pch_valid_p): Use it.  Remove handling of TARGET_SWITCHES
	and TARGET_OPTIONS.  Only treat target_flags specially if
	targetm.check_pch_target_flags is nonnull.
	* config/ia64/ia64.c (ia64_override_options): Don't mention
	TARGET_OPTIONS in comment.
	* config/m68k/m68k-none.h (CC1_SPEC): Likewise.
	* doc/invoke.texi: Remove a reference to TARGET_SWITCHES.
	* doc/tm.texi (TARGET_DEFAULT_TARGET_FLAGS): Don't mention the
	interaction with TARGET_SWITCHES.
	(TARGET_@var{featurename}, TARGET_SWITCHES, TARGET_OPTIONS): Delete.

From-SVN: r100432
This commit is contained in:
Richard Sandiford 2005-06-01 07:02:36 +00:00 committed by Richard Sandiford
parent 7dd2f19b2f
commit bacf5b96ed
10 changed files with 93 additions and 454 deletions

View File

@ -1,3 +1,32 @@
2005-06-01 Richard Sandiford <rsandifo@redhat.com>
* system.h (TARGET_OPTIONS, TARGET_SWITCHES): Poison.
* opts.h (print_filtered_help): Delete.
* opts.c (handle_option, decode_options): Remove calls to
set_target_switch.
(print_target_help): New function.
(common_option, print_help): Call print_target_help instead of
display_target_options.
(print_filtered_help): Make static.
* toplev.h (display_target_options, set_target_switch): Delete.
* toplev.c (target_switches, target_options, display_target_options)
(set_target_switch): Delete.
(print_switch_values): Remove handling of TARGET_SWITCHES and
TARGET_OPTIONS.
(default_get_pch_validity): Likewise. Only treat target_flags
specially if targetm.check_pch_target_flags is nonnull.
(pch_option_mismatch): New function.
(default_pch_valid_p): Use it. Remove handling of TARGET_SWITCHES
and TARGET_OPTIONS. Only treat target_flags specially if
targetm.check_pch_target_flags is nonnull.
* config/ia64/ia64.c (ia64_override_options): Don't mention
TARGET_OPTIONS in comment.
* config/m68k/m68k-none.h (CC1_SPEC): Likewise.
* doc/invoke.texi: Remove a reference to TARGET_SWITCHES.
* doc/tm.texi (TARGET_DEFAULT_TARGET_FLAGS): Don't mention the
interaction with TARGET_SWITCHES.
(TARGET_@var{featurename}, TARGET_SWITCHES, TARGET_OPTIONS): Delete.
2005-06-01 Richard Sandiford <rsandifo@redhat.com> 2005-06-01 Richard Sandiford <rsandifo@redhat.com>
* config/sh/sh.c (multcosts): Check sh_multcost rather than * config/sh/sh.c (multcosts): Check sh_multcost rather than

View File

@ -4865,7 +4865,7 @@ ia64_handle_option (size_t code, const char *arg, int value)
} }
} }
/* Handle TARGET_OPTIONS switches. */ /* Implement OVERRIDE_OPTIONS. */
void void
ia64_override_options (void) ia64_override_options (void)

View File

@ -86,8 +86,8 @@ Unrecognized value in TARGET_CPU_DEFAULT.
" "
/* cc1/cc1plus always receives all the -m flags. If the specs strings above /* cc1/cc1plus always receives all the -m flags. If the specs strings above
are consistent with the TARGET_OPTIONS flags in m68k.h, there should be no are consistent with the flags in m68k.opt, there should be no need for
need for any further cc1/cc1plus specs. */ any further cc1/cc1plus specs. */
#undef CC1_SPEC #undef CC1_SPEC
#define CC1_SPEC "" #define CC1_SPEC ""

View File

@ -6883,10 +6883,6 @@ Some configurations of the compiler also support additional special
options, usually for compatibility with other compilers on the same options, usually for compatibility with other compilers on the same
platform. platform.
These options are defined by the macro @code{TARGET_SWITCHES} in the
machine description. The default for the options is also defined by
that macro, which enables you to change the defaults.
@c This list is ordered alphanumerically by subsection name. @c This list is ordered alphanumerically by subsection name.
@c It should be the same order and spelling as these options are listed @c It should be the same order and spelling as these options are listed
@c in Machine Dependent Options @c in Machine Dependent Options

View File

@ -728,11 +728,11 @@ any target-specific headers.
@deftypevar {Target Hook} int TARGET_DEFAULT_TARGET_FLAGS @deftypevar {Target Hook} int TARGET_DEFAULT_TARGET_FLAGS
This variable specifies the initial value of @code{target_flags}. This variable specifies the initial value of @code{target_flags}.
Its default setting is 0. Its default setting is 0.
If the target defines @code{TARGET_SWITCHES}, the null
@code{TARGET_SWITCHES} entry will override this value.
@end deftypevar @end deftypevar
@cindex optional hardware or system features
@cindex features, optional, in system conventions
@deftypefn {Target Hook} bool TARGET_HANDLE_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value}) @deftypefn {Target Hook} bool TARGET_HANDLE_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value})
This hook is called whenever the user specifies one of the This hook is called whenever the user specifies one of the
target-specific options described by the @file{.opt} definition files target-specific options described by the @file{.opt} definition files
@ -750,153 +750,6 @@ argument. Otherwise @var{value} is 1 if the positive form of the
option was used and 0 if the ``no-'' form was. option was used and 0 if the ``no-'' form was.
@end deftypefn @end deftypefn
@cindex optional hardware or system features
@cindex features, optional, in system conventions
@defmac TARGET_@var{featurename}
This series of macros is to allow compiler command arguments to
enable or disable the use of optional features of the target machine.
For example, one machine description serves both the 68000 and
the 68020; a command argument tells the compiler whether it should
use 68020-only instructions or not. This command argument works
by means of a macro @code{TARGET_68020} that tests a bit in
@code{target_flags}.
Define a macro @code{TARGET_@var{featurename}} for each such option.
Its definition should test a bit in @code{target_flags}. It is
recommended that a helper macro @code{MASK_@var{featurename}}
is defined for each bit-value to test, and used in
@code{TARGET_@var{featurename}} and @code{TARGET_SWITCHES}. For
example:
@smallexample
#define TARGET_MASK_68020 1
#define TARGET_68020 (target_flags & MASK_68020)
@end smallexample
One place where these macros are used is in the condition-expressions
of instruction patterns. Note how @code{TARGET_68020} appears
frequently in the 68000 machine description file, @file{m68k.md}.
Another place they are used is in the definitions of the other
macros in the @file{@var{machine}.h} file.
@end defmac
@defmac TARGET_SWITCHES
This macro defines names of command options to set and clear
bits in @code{target_flags}. Its definition is an initializer
with a subgrouping for each command option.
Each subgrouping contains a string constant, that defines the option
name, a number, which contains the bits to set in
@code{target_flags}, and a second string which is the description
displayed by @option{--help}. If the number is negative then the bits specified
by the number are cleared instead of being set. If the description
string is present but empty, then no help information will be displayed
for that option, but it will not count as an undocumented option. The
actual option name is made by appending @samp{-m} to the specified name.
Non-empty description strings should be marked with @code{N_(@dots{})} for
@command{xgettext}. Please do not mark empty strings because the empty
string is reserved by GNU gettext. @code{gettext("")} returns the header entry
of the message catalog with meta information, not the empty string.
In addition to the description for @option{--help},
more detailed documentation for each option should be added to
@file{invoke.texi}.
One of the subgroupings should have a null string. The number in
this grouping is the default value for @code{target_flags}. Any
target options act starting with that value.
Here is an example which defines @option{-m68000} and @option{-m68020}
with opposite meanings, and picks the latter as the default:
@smallexample
#define TARGET_SWITCHES \
@{ @{ "68020", MASK_68020, "" @}, \
@{ "68000", -MASK_68020, \
N_("Compile for the 68000") @}, \
@{ "", MASK_68020, "" @}, \
@}
@end smallexample
This macro is being kept for compatibility with older backends.
New targets should use option definition files instead.
@xref{Back End}.
@end defmac
@defmac TARGET_OPTIONS
This macro is similar to @code{TARGET_SWITCHES} but defines names of command
options that have values. Its definition is an initializer with a
subgrouping for each command option.
Each subgrouping contains a string constant, that defines the option
name, the address of a variable, a description string, and a value.
Non-empty description strings should be marked with @code{N_(@dots{})}
for @command{xgettext}. Please do not mark empty strings because the
empty string is reserved by GNU gettext. @code{gettext("")} returns the
header entry of the message catalog with meta information, not the empty
string.
If the value listed in the table is @code{NULL}, then the variable, type
@code{char *}, is set to the variable part of the given option if the
fixed part matches. In other words, if the first part of the option
matches what's in the table, the variable will be set to point to the
rest of the option. This allows the user to specify a value for that
option. The actual option name is made by appending @samp{-m} to the
specified name. Again, each option should also be documented in
@file{invoke.texi}.
If the value listed in the table is non-@code{NULL}, then the option
must match the option in the table exactly (with @samp{-m}), and the
variable is set to point to the value listed in the table.
Here is an example which defines @option{-mshort-data-@var{number}}. If the
given option is @option{-mshort-data-512}, the variable @code{m88k_short_data}
will be set to the string @code{"512"}.
@smallexample
extern char *m88k_short_data;
#define TARGET_OPTIONS \
@{ @{ "short-data-", &m88k_short_data, \
N_("Specify the size of the short data section"), 0 @} @}
@end smallexample
Here is a variant of the above that allows the user to also specify
just @option{-mshort-data} where a default of @code{"64"} is used.
@smallexample
extern char *m88k_short_data;
#define TARGET_OPTIONS \
@{ @{ "short-data-", &m88k_short_data, \
N_("Specify the size of the short data section"), 0 @} \
@{ "short-data", &m88k_short_data, "", "64" @},
@}
@end smallexample
Here is an example which defines @option{-mno-alu}, @option{-malu1}, and
@option{-malu2} as a three-state switch, along with suitable macros for
checking the state of the option (documentation is elided for brevity).
@smallexample
[chip.c]
char *chip_alu = ""; /* @r{Specify default here.} */
[chip.h]
extern char *chip_alu;
#define TARGET_OPTIONS \
@{ @{ "no-alu", &chip_alu, "", "" @}, \
@{ "alu1", &chip_alu, "", "1" @}, \
@{ "alu2", &chip_alu, "", "2" @}, @}
#define TARGET_ALU (chip_alu[0] != '\0')
#define TARGET_ALU1 (chip_alu[0] == '1')
#define TARGET_ALU2 (chip_alu[0] == '2')
@end smallexample
This macro is being kept for compatibility with older backends.
New targets should use option definition files instead.
@xref{Back End}.
@end defmac
@defmac TARGET_VERSION @defmac TARGET_VERSION
This macro is a C statement to print on @code{stderr} a string This macro is a C statement to print on @code{stderr} a string
describing the particular machine description choice. Every machine describing the particular machine description choice. Every machine

View File

@ -110,8 +110,10 @@ static void complain_wrong_lang (const char *, const struct cl_option *,
unsigned int lang_mask); unsigned int lang_mask);
static void handle_options (unsigned int, const char **, unsigned int); static void handle_options (unsigned int, const char **, unsigned int);
static void wrap_help (const char *help, const char *item, unsigned int); static void wrap_help (const char *help, const char *item, unsigned int);
static void print_target_help (void);
static void print_help (void); static void print_help (void);
static void print_param_help (void); static void print_param_help (void);
static void print_filtered_help (unsigned int);
static unsigned int print_switch (const char *text, unsigned int indent); static unsigned int print_switch (const char *text, unsigned int indent);
static void set_debug_level (enum debug_info_type type, int extended, static void set_debug_level (enum debug_info_type type, int extended,
const char *arg); const char *arg);
@ -294,16 +296,7 @@ handle_option (const char **argv, unsigned int lang_mask)
} }
if (opt_index == cl_options_count) if (opt_index == cl_options_count)
{
#if defined (TARGET_OPTIONS) || defined (TARGET_SWITCHES)
if (opt[1] == 'm')
{
set_target_switch (argv[0] + 2);
result = 1;
}
#endif
goto done; goto done;
}
option = &cl_options[opt_index]; option = &cl_options[opt_index];
@ -633,7 +626,6 @@ decode_options (unsigned int argc, const char **argv)
/* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
modify it. */ modify it. */
target_flags = targetm.default_target_flags; target_flags = targetm.default_target_flags;
set_target_switch ("");
/* Unwind tables are always present when a target has ABI-specified unwind /* Unwind tables are always present when a target has ABI-specified unwind
tables, so the default should be ON. */ tables, so the default should be ON. */
@ -726,7 +718,7 @@ common_handle_option (size_t scode, const char *arg, int value)
break; break;
case OPT__target_help: case OPT__target_help:
display_target_options (); print_target_help ();
exit_after_options = true; exit_after_options = true;
break; break;
@ -1203,6 +1195,27 @@ set_debug_level (enum debug_info_type type, int extended, const char *arg)
} }
} }
/* Display help for target options. */
static void
print_target_help (void)
{
unsigned int i;
static bool displayed = false;
/* Avoid double printing for --help --target-help. */
if (displayed)
return;
displayed = true;
for (i = 0; i < cl_options_count; i++)
if ((cl_options[i].flags & (CL_TARGET | CL_UNDOCUMENTED)) == CL_TARGET)
{
printf (_("\nTarget specific options:\n"));
print_filtered_help (CL_TARGET);
break;
}
}
/* Output --help text. */ /* Output --help text. */
static void static void
print_help (void) print_help (void)
@ -1229,8 +1242,7 @@ print_help (void)
lang_names[i]); lang_names[i]);
print_filtered_help (1U << i); print_filtered_help (1U << i);
} }
print_target_help ();
display_target_options ();
} }
/* Print the help for --param. */ /* Print the help for --param. */
@ -1259,7 +1271,7 @@ print_param_help (void)
} }
/* Print help for a specific front-end, etc. */ /* Print help for a specific front-end, etc. */
void static void
print_filtered_help (unsigned int flag) print_filtered_help (unsigned int flag)
{ {
unsigned int i, len, filter, indent = 0; unsigned int i, len, filter, indent = 0;

View File

@ -86,6 +86,5 @@ extern unsigned num_in_fnames;
extern void decode_options (unsigned int argc, const char **argv); extern void decode_options (unsigned int argc, const char **argv);
extern int option_enabled (int opt_idx); extern int option_enabled (int opt_idx);
extern bool get_option_state (int, struct cl_option_state *); extern bool get_option_state (int, struct cl_option_state *);
extern void print_filtered_help (unsigned int);
#endif #endif

View File

@ -738,7 +738,8 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
NON_SAVING_SETJMP TARGET_LATE_RTL_PROLOGUE_EPILOGUE \ NON_SAVING_SETJMP TARGET_LATE_RTL_PROLOGUE_EPILOGUE \
CASE_DROPS_THROUGH TARGET_BELL TARGET_BS TARGET_CR TARGET_DIGIT0 \ CASE_DROPS_THROUGH TARGET_BELL TARGET_BS TARGET_CR TARGET_DIGIT0 \
TARGET_ESC TARGET_FF TARGET_NEWLINE TARGET_TAB TARGET_VT \ TARGET_ESC TARGET_FF TARGET_NEWLINE TARGET_TAB TARGET_VT \
LINK_LIBGCC_SPECIAL DONT_ACCESS_GBLS_AFTER_EPILOGUE LINK_LIBGCC_SPECIAL DONT_ACCESS_GBLS_AFTER_EPILOGUE \
TARGET_OPTIONS TARGET_SWITCHES
/* Hooks that are no longer used. */ /* Hooks that are no longer used. */
#pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \ #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \

View File

@ -374,35 +374,6 @@ static const param_info lang_independent_params[] = {
{ NULL, 0, 0, 0, NULL } { NULL, 0, 0, 0, NULL }
}; };
#ifdef TARGET_SWITCHES
/* Here is a table, controlled by the tm.h file, listing each -m switch
and which bits in `target_switches' it should set or clear.
If VALUE is positive, it is bits to set.
If VALUE is negative, -VALUE is bits to clear.
(The sign bit is not used so there is no confusion.) */
static const struct
{
const char *const name;
const int value;
const char *const description;
}
target_switches[] = TARGET_SWITCHES;
#endif
/* This table is similar, but allows the switch to have a value. */
#ifdef TARGET_OPTIONS
static const struct
{
const char *const prefix;
const char **const variable;
const char *const description;
const char *const value;
}
target_options[] = TARGET_OPTIONS;
#endif
/* Output files for assembler code (real compiler output) /* Output files for assembler code (real compiler output)
and debugging dumps. */ and debugging dumps. */
@ -1057,92 +1028,6 @@ compile_file (void)
targetm.asm_out.file_end (); targetm.asm_out.file_end ();
} }
/* Display help for target options. */
void
display_target_options (void)
{
int undoc;
#if defined (TARGET_SWITCHES) || defined (TARGET_OPTIONS)
int i;
#endif
unsigned int cli;
static bool displayed = false;
/* Avoid double printing for --help --target-help. */
if (displayed)
return;
displayed = true;
for (cli = 0; cli < cl_options_count; cli++)
if ((cl_options[cli].flags & (CL_TARGET | CL_UNDOCUMENTED)) == CL_TARGET)
break;
if (cli < cl_options_count
#ifdef TARGET_SWITCHES
|| ARRAY_SIZE (target_switches) > 1
#endif
#ifdef TARGET_OPTIONS
|| ARRAY_SIZE (target_options) > 1
#endif
)
{
int doc = cli < cl_options_count;
undoc = 0;
printf (_("\nTarget specific options:\n"));
#ifdef TARGET_SWITCHES
for (i = ARRAY_SIZE (target_switches); i--;)
{
const char *option = target_switches[i].name;
const char *description = target_switches[i].description;
if (option == NULL || *option == 0)
continue;
else if (description == NULL)
{
undoc = 1;
if (extra_warnings)
printf (_(" -m%-23s [undocumented]\n"), option);
}
else if (*description != 0)
doc += printf (" -m%-23s %s\n", option, _(description));
}
#endif
#ifdef TARGET_OPTIONS
for (i = ARRAY_SIZE (target_options); i--;)
{
const char *option = target_options[i].prefix;
const char *description = target_options[i].description;
if (option == NULL || *option == 0)
continue;
else if (description == NULL)
{
undoc = 1;
if (extra_warnings)
printf (_(" -m%-23s [undocumented]\n"), option);
}
else if (*description != 0)
doc += printf (" -m%-23s %s\n", option, _(description));
}
#endif
print_filtered_help (CL_TARGET);
if (undoc)
{
if (doc)
printf (_("\nThere are undocumented target specific options as well.\n"));
else
printf (_(" They exist, but they are not documented.\n"));
}
}
}
/* Parse a -d... command line switch. */ /* Parse a -d... command line switch. */
void void
@ -1193,64 +1078,6 @@ const char *const debug_type_names[] =
"none", "stabs", "coff", "dwarf-2", "xcoff", "vms" "none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
}; };
/* Decode -m switches. */
/* Decode the switch -mNAME. */
void
set_target_switch (const char *name)
{
#if defined (TARGET_SWITCHES) || defined (TARGET_OPTIONS)
size_t j;
#endif
int valid_target_option = 0;
#ifdef TARGET_SWITCHES
for (j = 0; j < ARRAY_SIZE (target_switches); j++)
if (!strcmp (target_switches[j].name, name))
{
if (target_switches[j].value < 0)
target_flags &= ~-target_switches[j].value;
else
target_flags |= target_switches[j].value;
if (name[0] != 0)
{
if (target_switches[j].value < 0)
target_flags_explicit |= -target_switches[j].value;
else
target_flags_explicit |= target_switches[j].value;
}
valid_target_option = 1;
}
#endif
#ifdef TARGET_OPTIONS
if (!valid_target_option)
for (j = 0; j < ARRAY_SIZE (target_options); j++)
{
int len = strlen (target_options[j].prefix);
if (target_options[j].value)
{
if (!strcmp (target_options[j].prefix, name))
{
*target_options[j].variable = target_options[j].value;
valid_target_option = 1;
}
}
else
{
if (!strncmp (target_options[j].prefix, name, len))
{
*target_options[j].variable = name + len;
valid_target_option = 1;
}
}
}
#endif
if (name[0] != 0 && !valid_target_option)
error ("invalid option %qs", name);
}
/* Print version information to FILE. /* Print version information to FILE.
Each line begins with INDENT (for the case where FILE is the Each line begins with INDENT (for the case where FILE is the
assembler output file). */ assembler output file). */
@ -1359,31 +1186,6 @@ print_switch_values (FILE *file, int pos, int max,
pos = print_single_switch (file, pos, max, indent, sep, term, pos = print_single_switch (file, pos, max, indent, sep, term,
"", cl_options[j].opt_text); "", cl_options[j].opt_text);
/* Print target specific options. */
#ifdef TARGET_SWITCHES
for (j = 0; j < ARRAY_SIZE (target_switches); j++)
if (target_switches[j].name[0] != '\0'
&& target_switches[j].value > 0
&& ((target_switches[j].value & target_flags)
== target_switches[j].value))
{
pos = print_single_switch (file, pos, max, indent, sep, term,
"-m", target_switches[j].name);
}
#endif
#ifdef TARGET_OPTIONS
for (j = 0; j < ARRAY_SIZE (target_options); j++)
if (*target_options[j].variable != NULL)
{
char prefix[256];
sprintf (prefix, "-m%s", target_options[j].prefix);
pos = print_single_switch (file, pos, max, indent, sep, term,
prefix, *target_options[j].variable);
}
#endif
fprintf (file, "%s", term); fprintf (file, "%s", term);
} }
@ -1460,15 +1262,9 @@ default_get_pch_validity (size_t *len)
size_t i; size_t i;
char *result, *r; char *result, *r;
*len = sizeof (target_flags) + 2; *len = 2;
#ifdef TARGET_OPTIONS if (targetm.check_pch_target_flags)
for (i = 0; i < ARRAY_SIZE (target_options); i++) *len += sizeof (target_flags);
{
*len += 1;
if (*target_options[i].variable)
*len += strlen (*target_options[i].variable);
}
#endif
for (i = 0; i < cl_options_count; i++) for (i = 0; i < cl_options_count; i++)
if (option_affects_pch_p (i, &state)) if (option_affects_pch_p (i, &state))
*len += state.size; *len += state.size;
@ -1477,21 +1273,12 @@ default_get_pch_validity (size_t *len)
r[0] = flag_pic; r[0] = flag_pic;
r[1] = flag_pie; r[1] = flag_pie;
r += 2; r += 2;
if (targetm.check_pch_target_flags)
{
memcpy (r, &target_flags, sizeof (target_flags)); memcpy (r, &target_flags, sizeof (target_flags));
r += sizeof (target_flags); r += sizeof (target_flags);
#ifdef TARGET_OPTIONS
for (i = 0; i < ARRAY_SIZE (target_options); i++)
{
const char *str = *target_options[i].variable;
size_t l;
if (! str)
str = "";
l = strlen (str) + 1;
memcpy (r, str, l);
r += l;
} }
#endif
for (i = 0; i < cl_options_count; i++) for (i = 0; i < cl_options_count; i++)
if (option_affects_pch_p (i, &state)) if (option_affects_pch_p (i, &state))
{ {
@ -1502,6 +1289,20 @@ default_get_pch_validity (size_t *len)
return result; return result;
} }
/* Return a message which says that a PCH file was created with a different
setting of OPTION. */
static const char *
pch_option_mismatch (const char *option)
{
char *r;
asprintf (&r, _("created and used with differing settings of '%s'"), option);
if (r == NULL)
return _("out of memory");
return r;
}
/* Default version of pch_valid_p. */ /* Default version of pch_valid_p. */
const char * const char *
@ -1509,9 +1310,7 @@ default_pch_valid_p (const void *data_p, size_t len)
{ {
struct cl_option_state state; struct cl_option_state state;
const char *data = (const char *)data_p; const char *data = (const char *)data_p;
const char *flag_that_differs = NULL;
size_t i; size_t i;
int tf;
/* -fpic and -fpie also usually make a PCH invalid. */ /* -fpic and -fpie also usually make a PCH invalid. */
if (data[0] != flag_pic) if (data[0] != flag_pic)
@ -1521,77 +1320,29 @@ default_pch_valid_p (const void *data_p, size_t len)
data += 2; data += 2;
/* Check target_flags. */ /* Check target_flags. */
memcpy (&tf, data, sizeof (target_flags));
if (targetm.check_pch_target_flags) if (targetm.check_pch_target_flags)
{ {
const char *r = targetm.check_pch_target_flags (tf); int tf;
const char *r;
memcpy (&tf, data, sizeof (target_flags));
data += sizeof (target_flags);
len -= sizeof (target_flags);
r = targetm.check_pch_target_flags (tf);
if (r != NULL) if (r != NULL)
return r; return r;
} }
#ifdef TARGET_SWITCHES
else if (tf != target_flags)
{
for (i = 0; i < ARRAY_SIZE (target_switches); i++)
{
int bits;
bits = target_switches[i].value;
if (bits < 0)
bits = -bits;
if ((target_flags & bits) != (tf & bits))
{
flag_that_differs = target_switches[i].name;
goto make_message;
}
}
gcc_unreachable ();
}
#endif
data += sizeof (target_flags);
len -= sizeof (target_flags);
/* Check string options. */
#ifdef TARGET_OPTIONS
for (i = 0; i < ARRAY_SIZE (target_options); i++)
{
const char *str = *target_options[i].variable;
size_t l;
if (! str)
str = "";
l = strlen (str) + 1;
if (len < l || memcmp (data, str, l) != 0)
{
flag_that_differs = target_options[i].prefix;
goto make_message;
}
data += l;
len -= l;
}
#endif
for (i = 0; i < cl_options_count; i++) for (i = 0; i < cl_options_count; i++)
if (option_affects_pch_p (i, &state)) if (option_affects_pch_p (i, &state))
{ {
if (memcmp (data, state.data, state.size) != 0) if (memcmp (data, state.data, state.size) != 0)
{ return pch_option_mismatch (cl_options[i].opt_text);
flag_that_differs = cl_options[i].opt_text + 2;
goto make_message;
}
data += state.size; data += state.size;
len -= state.size; len -= state.size;
} }
return NULL; return NULL;
make_message:
{
char *r;
asprintf (&r, _("created and used with differing settings of '-m%s'"),
flag_that_differs);
if (r == NULL)
return _("out of memory");
return r;
}
} }
/* Default tree printer. Handles declarations only. */ /* Default tree printer. Handles declarations only. */

View File

@ -138,9 +138,7 @@ extern int time_report;
extern int flag_tree_based_profiling; extern int flag_tree_based_profiling;
/* Things to do with target switches. */ /* Things to do with target switches. */
extern void display_target_options (void);
extern void print_version (FILE *, const char *); extern void print_version (FILE *, const char *);
extern void set_target_switch (const char *);
extern void * default_get_pch_validity (size_t *); extern void * default_get_pch_validity (size_t *);
extern const char * default_pch_valid_p (const void *, size_t); extern const char * default_pch_valid_p (const void *, size_t);