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 PA handle_option hook from using global state. The -munix= options are converted to use Var in the .opt files, -mschedule= is made to use the Enum facility, and -mfixed-range= is deferred to pa_option_override as in the IA64 patch.
Tested building cc1 and xgcc for cross to hppa2.0w-hp-hpux11.23. Will commit to trunk for 4.7 in the absence of target maintainer objections. 2011-03-06 Joseph Myers <jos...@codesourcery.com> * config/pa/pa-hpux.opt (flag_pa_unix): New Variable entry. (munix=93): Use Var. * config/pa/pa-hpux1010.opt (munix=95): Use Var. * config/pa/pa-hpux1111.opt (munix=98): Use Var. * config/pa/pa-opts.h: New. * config/pa/pa.c (pa_cpu, flag_pa_unix): Remove. (pa_handle_option): Don't assert that global structures are in use. Access target_flags via opts pointer. Don't handle OPT_mschedule_, OPT_mfixed_range_, OPT_munix_93, OPT_munix_95 or OPT_munix_98 here. (pa_option_override): Handle deferred OPT_mfixed_range_. diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa-hpux.opt gcc-mainline/gcc/config/pa/pa-hpux.opt --- gcc-mainline-1/gcc/config/pa/pa-hpux.opt 2011-02-04 15:18:52.000000000 -0800 +++ gcc-mainline/gcc/config/pa/pa-hpux.opt 2011-03-06 09:37:23.000000000 -0800 @@ -18,12 +18,16 @@ ; along with GCC; see the file COPYING3. If not see ; <http://www.gnu.org/licenses/>. +; The UNIX standard to use for predefines and linking. +Variable +int flag_pa_unix = TARGET_HPUX_11_11 ? 1998 : TARGET_HPUX_10_10 ? 1995 : 1993 + msio Target RejectNegative Mask(SIO) MaskExists Generate cpp defines for server IO munix=93 -Target RejectNegative +Target RejectNegative Var(flag_pa_unix, 1993) Specify UNIX standard for predefines and linking mwsio diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa-hpux1010.opt gcc-mainline/gcc/config/pa/pa-hpux1010.opt --- gcc-mainline-1/gcc/config/pa/pa-hpux1010.opt 2009-03-28 00:38:47.000000000 -0700 +++ gcc-mainline/gcc/config/pa/pa-hpux1010.opt 2011-03-06 09:38:04.000000000 -0800 @@ -1,6 +1,6 @@ ; Options for the HP PA-RISC port of the compiler. -; Copyright (C) 2005, 2007 Free Software Foundation, Inc. +; Copyright (C) 2005, 2007, 2011 Free Software Foundation, Inc. ; ; This file is part of GCC. ; @@ -19,5 +19,5 @@ ; <http://www.gnu.org/licenses/>. munix=95 -Target RejectNegative +Target RejectNegative Var(flag_pa_unix, 1995) Specify UNIX standard for predefines and linking diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa-hpux1111.opt gcc-mainline/gcc/config/pa/pa-hpux1111.opt --- gcc-mainline-1/gcc/config/pa/pa-hpux1111.opt 2009-03-28 00:38:47.000000000 -0700 +++ gcc-mainline/gcc/config/pa/pa-hpux1111.opt 2011-03-06 09:38:24.000000000 -0800 @@ -1,6 +1,6 @@ ; Options for the HP PA-RISC port of the compiler. -; Copyright (C) 2005, 2007 Free Software Foundation, Inc. +; Copyright (C) 2005, 2007, 2011 Free Software Foundation, Inc. ; ; This file is part of GCC. ; @@ -19,5 +19,5 @@ ; <http://www.gnu.org/licenses/>. munix=98 -Target RejectNegative +Target RejectNegative Var(flag_pa_unix, 1998) Specify UNIX standard for predefines and linking diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa-opts.h gcc-mainline/gcc/config/pa/pa-opts.h --- gcc-mainline-1/gcc/config/pa/pa-opts.h 1969-12-31 16:00:00.000000000 -0800 +++ gcc-mainline/gcc/config/pa/pa-opts.h 2011-03-06 10:05:13.000000000 -0800 @@ -0,0 +1,37 @@ +/* Definitions for option handling for HP PA. + Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, + 2002, 2003, 2004, 2005, 2006, 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 PA_OPTS_H +#define PA_OPTS_H + +/* Which processor to schedule for. */ + +enum processor_type +{ + PROCESSOR_700, + PROCESSOR_7100, + PROCESSOR_7100LC, + PROCESSOR_7200, + PROCESSOR_7300, + PROCESSOR_8000 +}; + +#endif diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa.c gcc-mainline/gcc/config/pa/pa.c --- gcc-mainline-1/gcc/config/pa/pa.c 2011-02-24 07:39:41.000000000 -0800 +++ gcc-mainline/gcc/config/pa/pa.c 2011-03-06 10:34:36.000000000 -0800 @@ -193,12 +193,6 @@ static GTY(()) section *som_readonly_dat static GTY(()) section *som_one_only_readonly_data_section; static GTY(()) section *som_one_only_data_section; -/* Which cpu we are scheduling for. */ -enum processor_type pa_cpu = TARGET_SCHED_DEFAULT; - -/* The UNIX standard to use for predefines and linking. */ -int flag_pa_unix = TARGET_HPUX_11_11 ? 1998 : TARGET_HPUX_10_10 ? 1995 : 1993; - /* Counts for the number of callee-saved general and floating point registers which were saved by the current function's prologue. */ static int gr_saved, fr_saved; @@ -480,74 +474,32 @@ fix_range (const char *const_str) /* Implement TARGET_HANDLE_OPTION. */ static bool -pa_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, +pa_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; - - gcc_assert (opts == &global_options); - gcc_assert (opts_set == &global_options_set); switch (code) { case OPT_mnosnake: case OPT_mpa_risc_1_0: case OPT_march_1_0: - target_flags &= ~(MASK_PA_11 | MASK_PA_20); + opts->x_target_flags &= ~(MASK_PA_11 | MASK_PA_20); return true; case OPT_msnake: case OPT_mpa_risc_1_1: case OPT_march_1_1: - target_flags &= ~MASK_PA_20; - target_flags |= MASK_PA_11; + opts->x_target_flags &= ~MASK_PA_20; + opts->x_target_flags |= MASK_PA_11; return true; case OPT_mpa_risc_2_0: case OPT_march_2_0: - target_flags |= MASK_PA_11 | MASK_PA_20; - return true; - - case OPT_mschedule_: - if (strcmp (arg, "8000") == 0) - pa_cpu = PROCESSOR_8000; - else if (strcmp (arg, "7100") == 0) - pa_cpu = PROCESSOR_7100; - else if (strcmp (arg, "700") == 0) - pa_cpu = PROCESSOR_700; - else if (strcmp (arg, "7100LC") == 0) - pa_cpu = PROCESSOR_7100LC; - else if (strcmp (arg, "7200") == 0) - pa_cpu = PROCESSOR_7200; - else if (strcmp (arg, "7300") == 0) - pa_cpu = PROCESSOR_7300; - else - return false; - return true; - - case OPT_mfixed_range_: - fix_range (arg); - return true; - -#if TARGET_HPUX - case OPT_munix_93: - flag_pa_unix = 1993; - return true; -#endif - -#if TARGET_HPUX_10_10 - case OPT_munix_95: - flag_pa_unix = 1995; - return true; -#endif - -#if TARGET_HPUX_11_11 - case OPT_munix_98: - flag_pa_unix = 1998; + opts->x_target_flags |= MASK_PA_11 | MASK_PA_20; return true; -#endif default: return true; @@ -559,6 +511,24 @@ pa_handle_option (struct gcc_options *op static void pa_option_override (void) { + unsigned int i; + cl_deferred_option *opt; + VEC(cl_deferred_option,heap) *vec + = (VEC(cl_deferred_option,heap) *) pa_deferred_options; + + FOR_EACH_VEC_ELT (cl_deferred_option, vec, i, opt) + { + switch (opt->opt_index) + { + case OPT_mfixed_range_: + fix_range (opt->arg); + break; + + default: + gcc_unreachable (); + } + } + /* Unconditional branches in the delay slot are not compatible with dwarf2 call frame information. There is no benefit in using this optimization on PA8000 and later processors. */ diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa.h gcc-mainline/gcc/config/pa/pa.h --- gcc-mainline-1/gcc/config/pa/pa.h 2011-01-26 16:28:20.000000000 -0800 +++ gcc-mainline/gcc/config/pa/pa.h 2011-03-06 10:05:07.000000000 -0800 @@ -1,6 +1,6 @@ /* Definitions of target machine for GNU compiler, for the HP Spectrum. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiem...@cygnus.com) of Cygnus Support and Tim Moore (mo...@defmacro.cs.utah.edu) of the Center for @@ -25,24 +25,6 @@ along with GCC; see the file COPYING3. /* For long call handling. */ extern unsigned long total_code_bytes; -/* Which processor to schedule for. */ - -enum processor_type -{ - PROCESSOR_700, - PROCESSOR_7100, - PROCESSOR_7100LC, - PROCESSOR_7200, - PROCESSOR_7300, - PROCESSOR_8000 -}; - -/* For -mschedule= option. */ -extern enum processor_type pa_cpu; - -/* For -munix= option. */ -extern int flag_pa_unix; - #define pa_cpu_attr ((enum attr_cpu)pa_cpu) /* Print subsidiary information on the compiler version in use. */ diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa.opt gcc-mainline/gcc/config/pa/pa.opt --- gcc-mainline-1/gcc/config/pa/pa.opt 2009-03-28 00:38:47.000000000 -0700 +++ gcc-mainline/gcc/config/pa/pa.opt 2011-03-06 10:33:06.000000000 -0800 @@ -1,6 +1,6 @@ ; Options for the HP PA-RISC port of the compiler. -; Copyright (C) 2005, 2007 Free Software Foundation, Inc. +; Copyright (C) 2005, 2007, 2011 Free Software Foundation, Inc. ; ; This file is part of GCC. ; @@ -18,6 +18,13 @@ ; along with GCC; see the file COPYING3. If not see ; <http://www.gnu.org/licenses/>. +HeaderInclude +config/pa/pa-opts.h + +; Which cpu we are scheduling for. +Variable +enum processor_type pa_cpu = TARGET_SCHED_DEFAULT + march=1.0 Target RejectNegative Generate PA1.0 code @@ -47,7 +54,7 @@ Target Report Mask(FAST_INDIRECT_CALLS) Generate fast indirect calls mfixed-range= -Target RejectNegative Joined +Target RejectNegative Joined Var(pa_deferred_options) Defer Specify range of registers to make fixed mgas @@ -96,9 +103,30 @@ Target Report Mask(PORTABLE_RUNTIME) Use portable calling conventions mschedule= -Target RejectNegative Joined +Target RejectNegative Joined Enum(pa_schedule) Var(pa_cpu) Specify CPU for scheduling purposes. Valid arguments are 700, 7100, 7100LC, 7200, 7300, and 8000 +Enum +Name(pa_schedule) Type(enum processor_type) + +EnumValue +Enum(pa_schedule) String(8000) Value(PROCESSOR_8000) + +EnumValue +Enum(pa_schedule) String(7100) Value(PROCESSOR_7100) + +EnumValue +Enum(pa_schedule) String(700) Value(PROCESSOR_700) + +EnumValue +Enum(pa_schedule) String(7100LC) Value(PROCESSOR_7100LC) + +EnumValue +Enum(pa_schedule) String(7200) Value(PROCESSOR_7200) + +EnumValue +Enum(pa_schedule) String(7300) Value(PROCESSOR_7300) + msoft-float Target Report Mask(SOFT_FLOAT) Use software floating point -- Joseph S. Myers jos...@codesourcery.com