Message ID | 4D651030.7070003@gjlay.de |
---|---|
State | New |
Headers | show |
Georg-Johann Lay schrieb: http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01530.html > The patch fixes PR45261 by using error instead of fprintf. > > In addition, if an unsupported MCU is specified, gcc informs on how to > get a list of supported MCUs. So see the list of MCUs supported by the > compiler proper, I implemented TARGET_HELP target hook. > > Please let me know if introducing TARGET_HELP is not ok before next > stage1 and what a backport of this patch should/should not include. > > Johann > > > 2011-02-23 Georg-Johann Lay <avr@gjlay.de> > > PR target/45261 > * config/avr/avr.c (avr_option_override): Use error on bad options. > (avr_help): New function. > (TARGET_HELP): Define. > > > ------------------------------------------------------------------------ > > Index: config/avr/avr.c > =================================================================== > --- config/avr/avr.c (revision 170329) > +++ config/avr/avr.c (working copy) > @@ -96,6 +96,7 @@ static rtx avr_function_arg (CUMULATIVE_ > const_tree, bool); > static void avr_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, > const_tree, bool); > +static void avr_help (void); > > /* Allocate registers from r25 to r8 for parameters for function calls. */ > #define FIRST_CUM_REG 26 > @@ -217,6 +218,9 @@ static const struct default_options avr_ > #undef TARGET_OPTION_OPTIMIZATION_TABLE > #define TARGET_OPTION_OPTIMIZATION_TABLE avr_option_optimization_table > > +#undef TARGET_HELP > +#define TARGET_HELP avr_help > + > struct gcc_target targetm = TARGET_INITIALIZER; > > static void > @@ -232,10 +236,8 @@ avr_option_override (void) > > if (!t->name) > { > - fprintf (stderr, "unknown MCU '%s' specified\nKnown MCU names:\n", > - avr_mcu_name); > - for (t = avr_mcu_types; t->name; t++) > - fprintf (stderr," %s\n", t->name); > + error ("unrecognized argument to -mmcu= option: %qs", avr_mcu_name); > + inform (input_location, "See --target-help for supported MCUs"); > } > > avr_current_device = t; > @@ -248,6 +250,42 @@ avr_option_override (void) > init_machine_status = avr_init_machine_status; > } > > +/* Implement TARGET_HELP */ > +/* Report extra information for --target-help */ > + > +static void > +avr_help (void) > +{ > + const struct mcu_type_s *t; > + const char * const indent = " "; > + int len; > + > + /* Give a list of MCUs that are accepted by -mmcu=* . > + Note that MCUs supported by the compiler might differ from > + MCUs supported by binutils. */ > + > + len = strlen (indent); > + printf ("Known MCU names:\n%s", indent); > + > + /* Print a blank-separated list of all supported MCUs */ > + > + for (t = avr_mcu_types; t->name; t++) > + { > + printf ("%s ", t->name); > + len += 1 + strlen (t->name); > + > + /* Break long lines */ > + > + if (len > 66 && (t+1)->name) > + { > + printf ("\n%s", indent); > + len = strlen (indent); > + } > + } > + > + printf ("\n\n"); > +} > + > /* return register class from register number. */ > > static const enum reg_class reg_class_tab[]={
2011/2/27 Georg-Johann Lay <avr@gjlay.de> > > Georg-Johann Lay schrieb: > > http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01530.html > >> The patch fixes PR45261 by using error instead of fprintf. >> >> In addition, if an unsupported MCU is specified, gcc informs on how to >> get a list of supported MCUs. So see the list of MCUs supported by the >> compiler proper, I implemented TARGET_HELP target hook. >> >> Please let me know if introducing TARGET_HELP is not ok before next >> stage1 and what a backport of this patch should/should not include. >> >> Johann >> >> >> 2011-02-23 Georg-Johann Lay <avr@gjlay.de> >> >> PR target/45261 >> * config/avr/avr.c (avr_option_override): Use error on bad options. >> (avr_help): New function. >> (TARGET_HELP): Define. Applied. Denis.
Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (revision 170329) +++ config/avr/avr.c (working copy) @@ -96,6 +96,7 @@ static rtx avr_function_arg (CUMULATIVE_ const_tree, bool); static void avr_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool); +static void avr_help (void); /* Allocate registers from r25 to r8 for parameters for function calls. */ #define FIRST_CUM_REG 26 @@ -217,6 +218,9 @@ static const struct default_options avr_ #undef TARGET_OPTION_OPTIMIZATION_TABLE #define TARGET_OPTION_OPTIMIZATION_TABLE avr_option_optimization_table +#undef TARGET_HELP +#define TARGET_HELP avr_help + struct gcc_target targetm = TARGET_INITIALIZER; static void @@ -232,10 +236,8 @@ avr_option_override (void) if (!t->name) { - fprintf (stderr, "unknown MCU '%s' specified\nKnown MCU names:\n", - avr_mcu_name); - for (t = avr_mcu_types; t->name; t++) - fprintf (stderr," %s\n", t->name); + error ("unrecognized argument to -mmcu= option: %qs", avr_mcu_name); + inform (input_location, "See --target-help for supported MCUs"); } avr_current_device = t; @@ -248,6 +250,42 @@ avr_option_override (void) init_machine_status = avr_init_machine_status; } +/* Implement TARGET_HELP */ +/* Report extra information for --target-help */ + +static void +avr_help (void) +{ + const struct mcu_type_s *t; + const char * const indent = " "; + int len; + + /* Give a list of MCUs that are accepted by -mmcu=* . + Note that MCUs supported by the compiler might differ from + MCUs supported by binutils. */ + + len = strlen (indent); + printf ("Known MCU names:\n%s", indent); + + /* Print a blank-separated list of all supported MCUs */ + + for (t = avr_mcu_types; t->name; t++) + { + printf ("%s ", t->name); + len += 1 + strlen (t->name); + + /* Break long lines */ + + if (len > 66 && (t+1)->name) + { + printf ("\n%s", indent); + len = strlen (indent); + } + } + + printf ("\n\n"); +} + /* return register class from register number. */ static const enum reg_class reg_class_tab[]={