This patch, for 4.7 and relative to a tree with <http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01709.html> applied, stops the MN10300 handle_option hook from using global state. The -mtune= option, taking a string argument and storing it in a string variable, is made to use Var to store the string rather than ad hoc handler code. (This option actually takes enumerated arguments, but they are handled in mn10300_option_override, and conversion of TARGET_OPTION_OVERRIDE hooks will be a later patch series. These particular enumerated arguments, like some for MIPS and RX, are case-insensitive, which will require a new target-independent .opt feature to handle such enumerated arguments through .opt files.)
Tested building cc1 and xgcc for cross to mn10300-elf. Will commit to trunk for 4.7 in the absence of target maintainer objections. 2011-03-06 Joseph Myers <jos...@codesourcery.com> * config/mn10300/mn10300-opts.h: New. * config/mn10300/mn10300.c (mn10300_processor, mn10300_tune_string): Remove. (mn10300_handle_option): Don't assert that global structures are in use. Access mn10300_processor via opts pointer. Don't handle OPT_mtune_ here. * config/mn10300/mn10300.h (enum processor_type): Move to mn10300-opts.h. (mn10300_processor): Remove. * config/mn10300/mn10300.opt (config/mn10300/mn10300-opts.h): New HeaderInclude entry. (mn10300_processor): New Variable entry. (mtune=): Use Var. diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/mn10300/mn10300-opts.h gcc-mainline/gcc/config/mn10300/mn10300-opts.h --- gcc-mainline-1/gcc/config/mn10300/mn10300-opts.h 1969-12-31 16:00:00.000000000 -0800 +++ gcc-mainline/gcc/config/mn10300/mn10300-opts.h 2011-03-06 09:08:22.000000000 -0800 @@ -0,0 +1,32 @@ +/* Definitions for option handling for Matsushita MN10300 series. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + <http://www.gnu.org/licenses/>. */ + +#ifndef MN10300_OPTS_H +#define MN10300_OPTS_H + +enum processor_type +{ + PROCESSOR_MN10300, + PROCESSOR_AM33, + PROCESSOR_AM33_2, + PROCESSOR_AM34 +}; + +#endif diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/mn10300/mn10300.c gcc-mainline/gcc/config/mn10300/mn10300.c --- gcc-mainline-1/gcc/config/mn10300/mn10300.c 2011-02-23 18:41:54.000000000 -0800 +++ gcc-mainline/gcc/config/mn10300/mn10300.c 2011-03-06 09:09:40.000000000 -0800 @@ -52,12 +52,6 @@ symbol names from register names. */ int mn10300_protect_label; -/* The selected processor. */ -enum processor_type mn10300_processor = PROCESSOR_DEFAULT; - -/* Processor type to select for tuning. */ -static const char * mn10300_tune_string = NULL; - /* Selected processor type for tuning. */ enum processor_type mn10300_tune_cpu = PROCESSOR_DEFAULT; @@ -91,35 +85,28 @@ static int cc_flags_for_code(enum rtx_co /* Implement TARGET_HANDLE_OPTION. */ static bool -mn10300_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, +mn10300_handle_option (struct gcc_options *opts, + struct gcc_options *opts_set ATTRIBUTE_UNUSED, const struct cl_decoded_option *decoded, location_t loc ATTRIBUTE_UNUSED) { size_t code = decoded->opt_index; - const char *arg = decoded->arg; int value = decoded->value; - gcc_assert (opts == &global_options); - gcc_assert (opts_set == &global_options_set); - switch (code) { case OPT_mam33: - mn10300_processor = value ? PROCESSOR_AM33 : PROCESSOR_MN10300; + opts->x_mn10300_processor = value ? PROCESSOR_AM33 : PROCESSOR_MN10300; return true; case OPT_mam33_2: - mn10300_processor = (value - ? PROCESSOR_AM33_2 - : MIN (PROCESSOR_AM33, PROCESSOR_DEFAULT)); + opts->x_mn10300_processor = (value + ? PROCESSOR_AM33_2 + : MIN (PROCESSOR_AM33, PROCESSOR_DEFAULT)); return true; case OPT_mam34: - mn10300_processor = (value ? PROCESSOR_AM34 : PROCESSOR_DEFAULT); - return true; - - case OPT_mtune_: - mn10300_tune_string = arg; + opts->x_mn10300_processor = (value ? PROCESSOR_AM34 : PROCESSOR_DEFAULT); return true; default: diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/mn10300/mn10300.h gcc-mainline/gcc/config/mn10300/mn10300.h --- gcc-mainline-1/gcc/config/mn10300/mn10300.h 2011-02-08 12:45:22.000000000 -0800 +++ gcc-mainline/gcc/config/mn10300/mn10300.h 2011-03-06 09:09:08.000000000 -0800 @@ -1,7 +1,7 @@ /* Definitions of target machine for GNU compiler. Matsushita MN10300 series Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Jeff Law (l...@cygnus.com). This file is part of GCC. @@ -57,15 +57,10 @@ } \ while (0) -enum processor_type -{ - PROCESSOR_MN10300, - PROCESSOR_AM33, - PROCESSOR_AM33_2, - PROCESSOR_AM34 -}; +#ifndef MN10300_OPTS_H +#include "config/mn10300/mn10300-opts.h" +#endif -extern enum processor_type mn10300_processor; extern enum processor_type mn10300_tune_cpu; #define TARGET_AM33 (mn10300_processor >= PROCESSOR_AM33) diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/mn10300/mn10300.opt gcc-mainline/gcc/config/mn10300/mn10300.opt --- gcc-mainline-1/gcc/config/mn10300/mn10300.opt 2011-02-16 15:05:30.000000000 -0800 +++ gcc-mainline/gcc/config/mn10300/mn10300.opt 2011-03-06 09:10:15.000000000 -0800 @@ -18,6 +18,13 @@ ; along with GCC; see the file COPYING3. If not see ; <http://www.gnu.org/licenses/>. +HeaderInclude +config/mn10300/mn10300-opts.h + +; The selected processor. +Variable +enum processor_type mn10300_processor = PROCESSOR_DEFAULT + mam33 Target Target the AM33 processor @@ -31,7 +38,7 @@ Target Report Target the AM34 processor mtune= -Target RejectNegative Joined +Target RejectNegative Joined Var(mn10300_tune_string) Tune code for the given processor mmult-bug -- Joseph S. Myers jos...@codesourcery.com