* gcc.c (TARGET_OPTION_TRANSLATE_TABLE): New.
(translate_options): If the above is defined, use it to map
given options to new options.
* doc/tm.texi: Document it.
From-SVN: r43787
+2001-07-05 DJ Delorie <dj@redhat.com>
+
+ * gcc.c (TARGET_OPTION_TRANSLATE_TABLE): New.
+ (translate_options): If the above is defined, use it to map
+ given options to new options.
+ * doc/tm.texi: Document it.
+
2001-07-05 Brad Lucier <lucier@math.purdue.edu>
Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
If this macro is not defined, the default value is @code{""}.
+@findex TARGET_OPTION_TRANSLATE_TABLE
+@item TARGET_OPTION_TRANSLATE_TABLE
+If defined, a list of pairs of strings, the first of which is a
+potential command line target to the @file{gcc} driver program, and the
+second of which is a space-separated (tabs and other whitespace are not
+supported) list of options with which to replace the first option. The
+target defining this list is responsible for assuring that the results
+are valid. Replacement options may not be the @code{--opt} style, they
+must be the @code{-opt} style. It is the intention of this macro to
+provide a mechanism for substitution that affects the multilibs chosen,
+such as one option that enables many options, some of which select
+multilibs. Example nonsensical definition, where @code{-malt-abi},
+@code{-EB}, and @code{-mspoo} cause different multilibs to be chosen:
+
+@example
+#define TARGET_OPTION_TRANSLATE_TABLE \
+@{ "-fast", "-march=fast-foo -malt-abi -I/usr/fast-foo" @}, \
+@{ "-compat", "-EB -malign=4 -mspoo" @}
+@end example
+
@findex CPP_SPEC
@item CPP_SPEC
A C string constant that tells the GCC driver program options to
{"--", "-f", "*j"}
};
\f
+
+#ifdef TARGET_OPTION_TRANSLATE_TABLE
+static struct {
+ const char *option_found;
+ const char *replacements;
+} target_option_translations[] =
+{
+ TARGET_OPTION_TRANSLATE_TABLE,
+ { 0, 0 }
+};
+#endif
+
/* Translate the options described by *ARGCP and *ARGVP.
Make a new vector and store it back in *ARGVP,
and store its length in *ARGVC. */
int i;
int argc = *argcp;
const char *const *argv = *argvp;
+ int newvsize = (argc + 2) * 2 * sizeof (const char *);
const char **newv =
- (const char **) xmalloc ((argc + 2) * 2 * sizeof (const char *));
+ (const char **) xmalloc (newvsize);
int newindex = 0;
i = 0;
while (i < argc)
{
+#ifdef TARGET_OPTION_TRANSLATE_TABLE
+ int tott_idx;
+
+ for (tott_idx = 0;
+ target_option_translations[tott_idx].option_found;
+ tott_idx++)
+ {
+ if (strcmp (target_option_translations[tott_idx].option_found,
+ argv[i]) == 0)
+ {
+ int spaces = 1;
+ const char *sp;
+ char *np;
+
+ for (sp = target_option_translations[tott_idx].replacements;
+ *sp; sp++)
+ {
+ if (*sp == ' ')
+ spaces ++;
+ }
+
+ newvsize += spaces * sizeof (const char *);
+ newv = (const char **) xrealloc (newv, newvsize);
+
+ sp = target_option_translations[tott_idx].replacements;
+ np = (char *) xmalloc (strlen (sp) + 1);
+ strcpy (np, sp);
+
+ while (1)
+ {
+ while (*np == ' ')
+ np++;
+ if (*np == 0)
+ break;
+ newv[newindex++] = np;
+ while (*np != ' ' && *np)
+ np++;
+ if (*np == 0)
+ break;
+ *np++ = 0;
+ }
+
+ i ++;
+ break;
+ }
+ }
+ if (target_option_translations[tott_idx].option_found)
+ continue;
+#endif
+
/* Translate -- options. */
if (argv[i][0] == '-' && argv[i][1] == '-')
{