* [4.7] Avoid global state in s390_handle_option
@ 2011-03-11 2:48 Joseph S. Myers
2011-03-23 11:59 ` Andreas Krebbel
0 siblings, 1 reply; 3+ messages in thread
From: Joseph S. Myers @ 2011-03-11 2:48 UTC (permalink / raw)
To: gcc-patches; +Cc: hpenner, uweigand, Andreas.Krebbel
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 S390 handle_option hook from using global state.
S390 already had a processor enumeration, but not one suitable for
direct use with Enum in the .opt file for handling -march/-mtune
options because two processors (z9-109 and z9-ec) in
s390_handle_arch_option have a single PROCESSOR_ value but different
flags. Thus, a further enumeration is added that corresponds to the
-march/-mtune values, so that those options can use the Enum
facility.
Three options used sscanf in s390_handle_option to read integer
values; two of these are converted to use UInteger in the .opt file
because the valid values can all be represented as nonnegative int
values. In the case of the third, -mwarn-framesize=, the use of
sscanf is retained (now storing into the options structure, of
course). One format using HOST_WIDE_INT_PRINT_DEC for a value that
changed type is updated; as this was a GCC diagnostic format, not a
printf format, use of HOST_WIDE_INT_PRINT_DEC was incorrect there
anyway and %wd was the correct way of printing HOST_WIDE_INT; I fixed
the other use of HOST_WIDE_INT_PRINT_DEC in that format string, but
not some other instances of the same bug in the S390 back end. (For
some hosts, HOST_WIDE_INT_PRINT_DEC may only be understood by system
printf and not by the GCC pretty-printers at all; furthermore,
concatenation with macro expansions does not work with i18n.)
Tested building cc1 and xgcc for cross to s390-linux-gnu. Will commit
to trunk for 4.7 in the absence of target maintainer objections.
2011-03-10 Joseph Myers <joseph@codesourcery.com>
* config/s390/s390-opts.h: New.
* config/s390/s390.c (s390_tune, s390_tune_flags, s390_arch,
s390_arch_flags, s390_warn_framesize, s390_stack_size,
s390_stack_guard): Remove.
(s390_handle_arch_option): Return void. Take enum
s390_arch_option value instead of string and searching array.
(s390_handle_option): Don't assert that global structures are in
use. Access variables via opts pointer. Use error_at. Don't use
sscanf for -mstack-guard= or -mstack-size=. Update call to
s390_handle_arch_option.
(s390_option_override): Update call to s390_handle_arch_option.
(s390_emit_prologue): Use %d format for s390_stack_size in
diagnostic. Use %wd for HOST_WIDE_INT.
* config/s390/s390.h (enum processor_type): Move to s390-opts.h.
(s390_tune, s390_tune_flags, s390_arch, s390_arch_flags): Remove.
* config/s390/s390.opt (config/s390/s390-opts.h): New
HeaderInclude entry.
(s390_arch_string, s390_tune, s390_tune_flags, s390_arch,
s390_arch_flags, s390_warn_framesize): New Variable entries.
(s390_arch_option): New Enum and EnumValue entries.
(march=): Use Enum instead of Var.
(mstack-guard=, mstack-size=): Use UInteger and Var.
(mtune=): Use Enum.
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/s390/s390-opts.h gcc-mainline/gcc/config/s390/s390-opts.h
--- gcc-mainline-1/gcc/config/s390/s390-opts.h 1969-12-31 16:00:00.000000000 -0800
+++ gcc-mainline/gcc/config/s390/s390-opts.h 2011-03-10 17:45:57.000000000 -0800
@@ -0,0 +1,57 @@
+/* Definitions for option handling for IBM S/390.
+ Copyright (C) 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 S390_OPTS_H
+#define S390_OPTS_H
+
+/* Which processor to generate code or schedule for. The cpu attribute
+ defines a list that mirrors this list, so changes to s390.md must be
+ made at the same time. */
+
+enum processor_type
+{
+ PROCESSOR_9672_G5,
+ PROCESSOR_9672_G6,
+ PROCESSOR_2064_Z900,
+ PROCESSOR_2084_Z990,
+ PROCESSOR_2094_Z9_109,
+ PROCESSOR_2097_Z10,
+ PROCESSOR_2817_Z196,
+ PROCESSOR_max
+};
+
+/* This enumeration must match processor_alias_table in
+ s390_handle_arch_option. It is different from enum processor_type
+ because some processors differ for option handling but not for
+ scheduling. */
+
+enum s390_arch_option
+{
+ s390_arch_g5,
+ s390_arch_g6,
+ s390_arch_z900,
+ s390_arch_z990,
+ s390_arch_z9_109,
+ s390_arch_z9_ec,
+ s390_arch_z10,
+ s390_arch_z196
+};
+
+#endif
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/s390/s390.c gcc-mainline/gcc/config/s390/s390.c
--- gcc-mainline-1/gcc/config/s390/s390.c 2011-02-24 08:55:51.000000000 -0800
+++ gcc-mainline/gcc/config/s390/s390.c 2011-03-10 17:54:19.000000000 -0800
@@ -278,17 +278,6 @@ struct s390_address
bool literal_pool;
};
-/* Which cpu are we tuning for. */
-enum processor_type s390_tune = PROCESSOR_max;
-int s390_tune_flags;
-/* Which instruction set architecture to use. */
-enum processor_type s390_arch;
-int s390_arch_flags;
-
-HOST_WIDE_INT s390_warn_framesize = 0;
-HOST_WIDE_INT s390_stack_size = 0;
-HOST_WIDE_INT s390_stack_guard = 0;
-
/* The following structure is embedded in the machine
specific part of struct function. */
@@ -1515,88 +1504,81 @@ s390_option_init_struct (struct gcc_opti
opts->x_flag_asynchronous_unwind_tables = 1;
}
-/* Return true if ARG is the name of a processor. Set *TYPE and *FLAGS
- to the associated processor_type and processor_flags if so. */
+/* Set *TYPE and *FLAGS to the associated processor_type and
+ processor_flags for processor ARCH. */
-static bool
-s390_handle_arch_option (const char *arg,
+static void
+s390_handle_arch_option (enum s390_arch_option arch,
enum processor_type *type,
int *flags)
{
+ /* This must match enum s390_arch_option in s390-opts.h. */
static struct pta
{
- const char *const name; /* processor name or nickname. */
const enum processor_type processor;
const int flags; /* From enum processor_flags. */
}
const processor_alias_table[] =
{
- {"g5", PROCESSOR_9672_G5, PF_IEEE_FLOAT},
- {"g6", PROCESSOR_9672_G6, PF_IEEE_FLOAT},
- {"z900", PROCESSOR_2064_Z900, PF_IEEE_FLOAT | PF_ZARCH},
- {"z990", PROCESSOR_2084_Z990, PF_IEEE_FLOAT | PF_ZARCH
+ {PROCESSOR_9672_G5, PF_IEEE_FLOAT},
+ {PROCESSOR_9672_G6, PF_IEEE_FLOAT},
+ {PROCESSOR_2064_Z900, PF_IEEE_FLOAT | PF_ZARCH},
+ {PROCESSOR_2084_Z990, PF_IEEE_FLOAT | PF_ZARCH
| PF_LONG_DISPLACEMENT},
- {"z9-109", PROCESSOR_2094_Z9_109, PF_IEEE_FLOAT | PF_ZARCH
+ {PROCESSOR_2094_Z9_109, PF_IEEE_FLOAT | PF_ZARCH
| PF_LONG_DISPLACEMENT | PF_EXTIMM},
- {"z9-ec", PROCESSOR_2094_Z9_109, PF_IEEE_FLOAT | PF_ZARCH
+ {PROCESSOR_2094_Z9_109, PF_IEEE_FLOAT | PF_ZARCH
| PF_LONG_DISPLACEMENT | PF_EXTIMM | PF_DFP },
- {"z10", PROCESSOR_2097_Z10, PF_IEEE_FLOAT | PF_ZARCH
+ {PROCESSOR_2097_Z10, PF_IEEE_FLOAT | PF_ZARCH
| PF_LONG_DISPLACEMENT | PF_EXTIMM | PF_DFP | PF_Z10},
- {"z196", PROCESSOR_2817_Z196, PF_IEEE_FLOAT | PF_ZARCH
+ {PROCESSOR_2817_Z196, PF_IEEE_FLOAT | PF_ZARCH
| PF_LONG_DISPLACEMENT | PF_EXTIMM | PF_DFP | PF_Z10 | PF_Z196 },
};
- size_t i;
-
- for (i = 0; i < ARRAY_SIZE (processor_alias_table); i++)
- if (strcmp (arg, processor_alias_table[i].name) == 0)
- {
- *type = processor_alias_table[i].processor;
- *flags = processor_alias_table[i].flags;
- return true;
- }
- *type = PROCESSOR_max;
- *flags = 0;
- return false;
+ *type = processor_alias_table[(int) arch].processor;
+ *flags = processor_alias_table[(int) arch].flags;
}
/* Implement TARGET_HANDLE_OPTION. */
static bool
-s390_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
+s390_handle_option (struct gcc_options *opts,
+ struct gcc_options *opts_set ATTRIBUTE_UNUSED,
const struct cl_decoded_option *decoded,
- location_t loc ATTRIBUTE_UNUSED)
+ location_t loc)
{
size_t code = decoded->opt_index;
const char *arg = decoded->arg;
-
- gcc_assert (opts == &global_options);
- gcc_assert (opts_set == &global_options_set);
+ int value = decoded->value;
switch (code)
{
case OPT_march_:
- return s390_handle_arch_option (arg, &s390_arch, &s390_arch_flags);
+ s390_handle_arch_option ((enum s390_arch_option) value,
+ &opts->x_s390_arch,
+ &opts->x_s390_arch_flags);
+ opts->x_s390_arch_string = arg;
+ return true;
case OPT_mstack_guard_:
- if (sscanf (arg, HOST_WIDE_INT_PRINT_DEC, &s390_stack_guard) != 1)
- return false;
- if (exact_log2 (s390_stack_guard) == -1)
- error ("stack guard value must be an exact power of 2");
+ if (exact_log2 (value) == -1)
+ error_at (loc, "stack guard value must be an exact power of 2");
return true;
case OPT_mstack_size_:
- if (sscanf (arg, HOST_WIDE_INT_PRINT_DEC, &s390_stack_size) != 1)
- return false;
- if (exact_log2 (s390_stack_size) == -1)
- error ("stack size must be an exact power of 2");
+ if (exact_log2 (value) == -1)
+ error_at (loc, "stack size must be an exact power of 2");
return true;
case OPT_mtune_:
- return s390_handle_arch_option (arg, &s390_tune, &s390_tune_flags);
+ s390_handle_arch_option ((enum s390_arch_option) value,
+ &opts->x_s390_tune,
+ &opts->x_s390_tune_flags);
+ return true;
case OPT_mwarn_framesize_:
- return sscanf (arg, HOST_WIDE_INT_PRINT_DEC, &s390_warn_framesize) == 1;
+ return sscanf (arg, HOST_WIDE_INT_PRINT_DEC,
+ &opts->x_s390_warn_framesize) == 1;
default:
return true;
@@ -1622,7 +1604,8 @@ s390_option_override (void)
if (!s390_arch_string)
{
s390_arch_string = TARGET_ZARCH? "z900" : "g5";
- s390_handle_arch_option (s390_arch_string, &s390_arch, &s390_arch_flags);
+ s390_handle_arch_option ((TARGET_ZARCH ? s390_arch_z900 : s390_arch_g5),
+ &s390_arch, &s390_arch_flags);
}
/* This check is triggered when the user specified a wrong -march=
@@ -8068,10 +8051,9 @@ s390_emit_prologue (void)
if (cfun_frame_layout.frame_size >= s390_stack_size)
{
- warning (0, "frame size of function %qs is "
- HOST_WIDE_INT_PRINT_DEC
+ warning (0, "frame size of function %qs is %wd"
" bytes exceeding user provided stack limit of "
- HOST_WIDE_INT_PRINT_DEC " bytes. "
+ "%d bytes. "
"An unconditional trap is added.",
current_function_name(), cfun_frame_layout.frame_size,
s390_stack_size);
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/s390/s390.h gcc-mainline/gcc/config/s390/s390.h
--- gcc-mainline-1/gcc/config/s390/s390.h 2011-02-02 13:22:55.000000000 -0800
+++ gcc-mainline/gcc/config/s390/s390.h 2011-03-10 17:45:27.000000000 -0800
@@ -24,22 +24,6 @@ along with GCC; see the file COPYING3.
#ifndef _S390_H
#define _S390_H
-/* Which processor to generate code or schedule for. The cpu attribute
- defines a list that mirrors this list, so changes to s390.md must be
- made at the same time. */
-
-enum processor_type
-{
- PROCESSOR_9672_G5,
- PROCESSOR_9672_G6,
- PROCESSOR_2064_Z900,
- PROCESSOR_2084_Z990,
- PROCESSOR_2094_Z9_109,
- PROCESSOR_2097_Z10,
- PROCESSOR_2817_Z196,
- PROCESSOR_max
-};
-
/* Optional architectural facilities supported by the processor. */
enum processor_flags
@@ -53,16 +37,10 @@ enum processor_flags
PF_Z196 = 64
};
-extern enum processor_type s390_tune;
-extern int s390_tune_flags;
-
/* This is necessary to avoid a warning about comparing different enum
types. */
#define s390_tune_attr ((enum attr_cpu)s390_tune)
-extern enum processor_type s390_arch;
-extern int s390_arch_flags;
-
/* These flags indicate that the generated code should run on a cpu
providing the respective hardware facility regardless of the
current cpu mode (ESA or z/Architecture). */
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/s390/s390.opt gcc-mainline/gcc/config/s390/s390.opt
--- gcc-mainline-1/gcc/config/s390/s390.opt 2011-01-04 03:50:51.000000000 -0800
+++ gcc-mainline/gcc/config/s390/s390.opt 2011-03-10 17:45:08.000000000 -0800
@@ -1,6 +1,6 @@
; Options for the S/390 / zSeries port of the compiler.
-; Copyright (C) 2005, 2006, 2007, 2010 Free Software Foundation, Inc.
+; Copyright (C) 2005, 2006, 2007, 2010, 2011 Free Software Foundation, Inc.
;
; This file is part of GCC.
;
@@ -18,6 +18,30 @@
; along with GCC; see the file COPYING3. If not see
; <http://www.gnu.org/licenses/>.
+HeaderInclude
+config/s390/s390-opts.h
+
+; The architecture name to use in diagnostics.
+Variable
+const char *s390_arch_string
+
+; Which cpu are we tuning for.
+Variable
+enum processor_type s390_tune = PROCESSOR_max
+
+Variable
+int s390_tune_flags
+
+; Which instruction set architecture to use.
+Variable
+enum processor_type s390_arch
+
+Variable
+int s390_arch_flags
+
+Variable
+HOST_WIDE_INT s390_warn_framesize = 0
+
m31
Target Report RejectNegative Negative(m64) InverseMask(64BIT)
31 bit ABI
@@ -27,9 +51,36 @@ Target Report RejectNegative Negative(m3
64 bit ABI
march=
-Target RejectNegative Joined Var(s390_arch_string)
+Target RejectNegative Joined Enum(s390_arch_option)
Generate code for given CPU
+Enum
+Name(s390_arch_option) Type(enum s390_arch_option)
+
+EnumValue
+Enum(s390_arch_option) String(g5) Value(s390_arch_g5)
+
+EnumValue
+Enum(s390_arch_option) String(g6) Value(s390_arch_g6)
+
+EnumValue
+Enum(s390_arch_option) String(z900) Value(s390_arch_z900)
+
+EnumValue
+Enum(s390_arch_option) String(z990) Value(s390_arch_z990)
+
+EnumValue
+Enum(s390_arch_option) String(z9-109) Value(s390_arch_z9_109)
+
+EnumValue
+Enum(s390_arch_option) String(z9-ec) Value(s390_arch_z9_ec)
+
+EnumValue
+Enum(s390_arch_option) String(z10) Value(s390_arch_z10)
+
+EnumValue
+Enum(s390_arch_option) String(z196) Value(s390_arch_z196)
+
mbackchain
Target Report Mask(BACKCHAIN)
Maintain backchain pointer
@@ -71,15 +122,15 @@ Target Report RejectNegative Negative(mh
Disable hardware floating point
mstack-guard=
-Target RejectNegative Joined
+Target RejectNegative Joined UInteger Var(s390_stack_guard)
Set the max. number of bytes which has to be left to stack size before a trap instruction is triggered
mstack-size=
-Target RejectNegative Joined
+Target RejectNegative Joined UInteger Var(s390_stack_size)
Emit extra code in the function prologue in order to trap if the stack size exceeds the given limit
mtune=
-Target RejectNegative Joined
+Target RejectNegative Joined Enum(s390_arch_option)
Schedule code for given CPU
mmvcle
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [4.7] Avoid global state in s390_handle_option
2011-03-11 2:48 [4.7] Avoid global state in s390_handle_option Joseph S. Myers
@ 2011-03-23 11:59 ` Andreas Krebbel
2011-03-23 13:14 ` Joseph S. Myers
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Krebbel @ 2011-03-23 11:59 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: gcc-patches
Hi Joseph,
sorry for the late reply to your patch. I would like to propose a few
changes as implemented with the attached patch:
- The options mapped to an enum type seem to always need an
initialization value. Otherwise there is a warning when compiling
options.c:
error: enum conversion in initialization is invalid in C++ [-Werror=c++-compat]
- I've merged s390_arch_option and processor_type enums. Both only
differ for z9-ec which in turn is only relevant for the pipeline
description. The patch adjusts the pipeline description accordingly.
With that change several other things could be simplified.
- I've also fixed two more warning statements using
HOST_WIDE_INT_PRINT_DEC.
Tested on s390x.
What do you think?
Bye,
-Andreas-
2011-03-23 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* config/s390/2084.md: Enable all insn reservations also for z9_ec
cpu attribute value.
* config/s390/s390-opts.h (enum s390_arch_option): Remove.
(enum processor_type): Add PROCESSOR_2094_Z9_EC.
* config/s390/s390.c (processor_flags_table): New constant array.
(s390_handle_arch_option): Remove.
(s390_handle_option): Remove s390_handle_arch_option invocations
and OPT_mwarn_framesize_ handling.
(s390_option_override): Remove s390_handle_arch_option invocation.
(s390_emit_prologue): Remove use of HOST_WIDE_INT_PRINT_DEC in
warnings.
* config/s390/s390.md (cpu attribute): Add z9_ec value.
* config/s390/s390.opt (s390_tune, s390_arch)
(march=): Replace s390_arch_option enum and values with
processor_type. Set variable name to s390_arch. Set
initialization value.
(mtune=): Replace s390_arch_option with processor_type. Set
variable name to s390_tune. Set initialization value.
Index: gcc/config/s390/2084.md
===================================================================
*** gcc/config/s390/2084.md.orig
--- gcc/config/s390/2084.md
***************
*** 62,130 ****
;;
(define_insn_reservation "x_int" 1
! (and (eq_attr "cpu" "z990,z9_109")
(and (eq_attr "type" "integer")
(eq_attr "atype" "reg")))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_agen" 1
! (and (eq_attr "cpu" "z990,z9_109")
(and (eq_attr "type" "integer")
(eq_attr "atype" "agen")))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_lr" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "lr"))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_la" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "la"))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_larl" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "larl"))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_load" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "load"))
"x-e1-st+x-mem,x-wr-st")
(define_insn_reservation "x_store" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "store"))
"x-e1-st+x_store_tok,x-wr-st")
(define_insn_reservation "x_branch" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "branch"))
"x_e1_r,x_wr_r")
(define_insn_reservation "x_call" 5
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "jsr"))
"x-e1-np*5,x-wr-np")
(define_insn_reservation "x_mul_hi" 2
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "imulhi"))
"x-e1-np*2,x-wr-np")
(define_insn_reservation "x_mul_sidi" 4
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "imulsi,imuldi"))
"x-e1-np*4,x-wr-np")
(define_insn_reservation "x_div" 10
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "idiv"))
"x-e1-np*10,x-wr-np")
(define_insn_reservation "x_sem" 17
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "sem"))
"x-e1-np+x-mem,x-e1-np*16,x-wr-st")
--- 62,130 ----
;;
(define_insn_reservation "x_int" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(and (eq_attr "type" "integer")
(eq_attr "atype" "reg")))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_agen" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(and (eq_attr "type" "integer")
(eq_attr "atype" "agen")))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_lr" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "lr"))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_la" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "la"))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_larl" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "larl"))
"x-e1-st,x-wr-st")
(define_insn_reservation "x_load" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "load"))
"x-e1-st+x-mem,x-wr-st")
(define_insn_reservation "x_store" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "store"))
"x-e1-st+x_store_tok,x-wr-st")
(define_insn_reservation "x_branch" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "branch"))
"x_e1_r,x_wr_r")
(define_insn_reservation "x_call" 5
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "jsr"))
"x-e1-np*5,x-wr-np")
(define_insn_reservation "x_mul_hi" 2
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "imulhi"))
"x-e1-np*2,x-wr-np")
(define_insn_reservation "x_mul_sidi" 4
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "imulsi,imuldi"))
"x-e1-np*4,x-wr-np")
(define_insn_reservation "x_div" 10
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "idiv"))
"x-e1-np*10,x-wr-np")
(define_insn_reservation "x_sem" 17
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "sem"))
"x-e1-np+x-mem,x-e1-np*16,x-wr-st")
***************
*** 133,159 ****
;;
(define_insn_reservation "x_cs" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "cs"))
"x-e1-np,x-wr-np")
(define_insn_reservation "x_vs" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "vs"))
"x-e1-np*10,x-wr-np")
(define_insn_reservation "x_stm" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "stm"))
"(x-e1-np+x_store_tok)*10,x-wr-np")
(define_insn_reservation "x_lm" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "lm"))
"x-e1-np*10,x-wr-np")
(define_insn_reservation "x_other" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "other"))
"x-e1-np,x-wr-np")
--- 133,159 ----
;;
(define_insn_reservation "x_cs" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "cs"))
"x-e1-np,x-wr-np")
(define_insn_reservation "x_vs" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "vs"))
"x-e1-np*10,x-wr-np")
(define_insn_reservation "x_stm" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "stm"))
"(x-e1-np+x_store_tok)*10,x-wr-np")
(define_insn_reservation "x_lm" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "lm"))
"x-e1-np*10,x-wr-np")
(define_insn_reservation "x_other" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "other"))
"x-e1-np,x-wr-np")
***************
*** 162,249 ****
;;
(define_insn_reservation "x_fsimptf" 7
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "fsimptf,fhex"))
"x_e1_t*2,x-wr-fp")
(define_insn_reservation "x_fsimpdf" 6
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "fsimpdf,fmuldf,fmadddf,fhex"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_fsimpsf" 6
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "fsimpsf,fmulsf,fmaddsf,fhex"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_fmultf" 33
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "fmultf"))
"x_e1_t*27,x-wr-fp")
(define_insn_reservation "x_fdivtf" 82
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "fdivtf,fsqrttf"))
"x_e1_t*76,x-wr-fp")
(define_insn_reservation "x_fdivdf" 36
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "fdivdf,fsqrtdf"))
"x_e1_t*30,x-wr-fp")
(define_insn_reservation "x_fdivsf" 36
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "fdivsf,fsqrtsf"))
"x_e1_t*30,x-wr-fp")
(define_insn_reservation "x_floadtf" 6
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "floadtf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_floaddf" 6
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "floaddf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_floadsf" 6
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "floadsf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_fstoredf" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "fstoredf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_fstoresf" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "fstoresf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_ftrunctf" 16
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "ftrunctf"))
"x_e1_t*10,x-wr-fp")
(define_insn_reservation "x_ftruncdf" 11
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "ftruncdf"))
"x_e1_t*5,x-wr-fp")
(define_insn_reservation "x_ftoi" 1
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "ftoi"))
"x_e1_t*3,x-wr-fp")
(define_insn_reservation "x_itof" 7
! (and (eq_attr "cpu" "z990,z9_109")
(eq_attr "type" "itoftf,itofdf,itofsf"))
"x_e1_t*3,x-wr-fp")
--- 162,249 ----
;;
(define_insn_reservation "x_fsimptf" 7
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "fsimptf,fhex"))
"x_e1_t*2,x-wr-fp")
(define_insn_reservation "x_fsimpdf" 6
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "fsimpdf,fmuldf,fmadddf,fhex"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_fsimpsf" 6
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "fsimpsf,fmulsf,fmaddsf,fhex"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_fmultf" 33
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "fmultf"))
"x_e1_t*27,x-wr-fp")
(define_insn_reservation "x_fdivtf" 82
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "fdivtf,fsqrttf"))
"x_e1_t*76,x-wr-fp")
(define_insn_reservation "x_fdivdf" 36
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "fdivdf,fsqrtdf"))
"x_e1_t*30,x-wr-fp")
(define_insn_reservation "x_fdivsf" 36
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "fdivsf,fsqrtsf"))
"x_e1_t*30,x-wr-fp")
(define_insn_reservation "x_floadtf" 6
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "floadtf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_floaddf" 6
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "floaddf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_floadsf" 6
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "floadsf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_fstoredf" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "fstoredf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_fstoresf" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "fstoresf"))
"x_e1_t,x-wr-fp")
(define_insn_reservation "x_ftrunctf" 16
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "ftrunctf"))
"x_e1_t*10,x-wr-fp")
(define_insn_reservation "x_ftruncdf" 11
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "ftruncdf"))
"x_e1_t*5,x-wr-fp")
(define_insn_reservation "x_ftoi" 1
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "ftoi"))
"x_e1_t*3,x-wr-fp")
(define_insn_reservation "x_itof" 7
! (and (eq_attr "cpu" "z990,z9_109,z9_ec")
(eq_attr "type" "itoftf,itofdf,itofsf"))
"x_e1_t*3,x-wr-fp")
Index: gcc/config/s390/s390-opts.h
===================================================================
*** gcc/config/s390/s390-opts.h.orig
--- gcc/config/s390/s390-opts.h
*************** enum processor_type
*** 32,57 ****
PROCESSOR_2064_Z900,
PROCESSOR_2084_Z990,
PROCESSOR_2094_Z9_109,
PROCESSOR_2097_Z10,
PROCESSOR_2817_Z196,
PROCESSOR_max
};
- /* This enumeration must match processor_alias_table in
- s390_handle_arch_option. It is different from enum processor_type
- because some processors differ for option handling but not for
- scheduling. */
-
- enum s390_arch_option
- {
- s390_arch_g5,
- s390_arch_g6,
- s390_arch_z900,
- s390_arch_z990,
- s390_arch_z9_109,
- s390_arch_z9_ec,
- s390_arch_z10,
- s390_arch_z196
- };
-
#endif
--- 32,41 ----
PROCESSOR_2064_Z900,
PROCESSOR_2084_Z990,
PROCESSOR_2094_Z9_109,
+ PROCESSOR_2094_Z9_EC,
PROCESSOR_2097_Z10,
PROCESSOR_2817_Z196,
PROCESSOR_max
};
#endif
Index: gcc/config/s390/s390.c
===================================================================
*** gcc/config/s390/s390.c.orig
--- gcc/config/s390/s390.c
*************** along with GCC; see the file COPYING3.
*** 55,60 ****
--- 55,75 ----
#include "cfgloop.h"
#include "opts.h"
+ static const int processor_flags_table[] =
+ {
+ /* g5 */ PF_IEEE_FLOAT,
+ /* g6 */ PF_IEEE_FLOAT,
+ /* z900 */ PF_IEEE_FLOAT | PF_ZARCH,
+ /* z990 */ PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT,
+ /* z9-109 */ PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
+ | PF_EXTIMM,
+ /* z9-ec */ PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
+ | PF_EXTIMM | PF_DFP,
+ /* z10 */ PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
+ | PF_EXTIMM | PF_DFP | PF_Z10,
+ /* z196 */ PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
+ | PF_EXTIMM | PF_DFP | PF_Z10 | PF_Z196
+ };
/* Define the specific costs for a given cpu. */
*************** s390_option_init_struct (struct gcc_opti
*** 1530,1576 ****
opts->x_flag_asynchronous_unwind_tables = 1;
}
- /* Set *TYPE and *FLAGS to the associated processor_type and
- processor_flags for processor ARCH. */
-
- static void
- s390_handle_arch_option (enum s390_arch_option arch,
- enum processor_type *type,
- int *flags)
- {
- /* This must match enum s390_arch_option in s390-opts.h. */
- static struct pta
- {
- const enum processor_type processor;
- const int flags; /* From enum processor_flags. */
- }
- const processor_alias_table[] =
- {
- {PROCESSOR_9672_G5, PF_IEEE_FLOAT},
- {PROCESSOR_9672_G6, PF_IEEE_FLOAT},
- {PROCESSOR_2064_Z900, PF_IEEE_FLOAT | PF_ZARCH},
- {PROCESSOR_2084_Z990, PF_IEEE_FLOAT | PF_ZARCH
- | PF_LONG_DISPLACEMENT},
- {PROCESSOR_2094_Z9_109, PF_IEEE_FLOAT | PF_ZARCH
- | PF_LONG_DISPLACEMENT | PF_EXTIMM},
- {PROCESSOR_2094_Z9_109, PF_IEEE_FLOAT | PF_ZARCH
- | PF_LONG_DISPLACEMENT | PF_EXTIMM | PF_DFP },
- {PROCESSOR_2097_Z10, PF_IEEE_FLOAT | PF_ZARCH
- | PF_LONG_DISPLACEMENT | PF_EXTIMM | PF_DFP | PF_Z10},
- {PROCESSOR_2817_Z196, PF_IEEE_FLOAT | PF_ZARCH
- | PF_LONG_DISPLACEMENT | PF_EXTIMM | PF_DFP | PF_Z10 | PF_Z196 },
- };
-
- *type = processor_alias_table[(int) arch].processor;
- *flags = processor_alias_table[(int) arch].flags;
- }
-
/* Implement TARGET_HANDLE_OPTION. */
static bool
s390_handle_option (struct gcc_options *opts,
struct gcc_options *opts_set ATTRIBUTE_UNUSED,
! const struct cl_decoded_option *decoded,
location_t loc)
{
size_t code = decoded->opt_index;
--- 1545,1556 ----
opts->x_flag_asynchronous_unwind_tables = 1;
}
/* Implement TARGET_HANDLE_OPTION. */
static bool
s390_handle_option (struct gcc_options *opts,
struct gcc_options *opts_set ATTRIBUTE_UNUSED,
! const struct cl_decoded_option *decoded,
location_t loc)
{
size_t code = decoded->opt_index;
*************** s390_handle_option (struct gcc_options *
*** 1580,1588 ****
switch (code)
{
case OPT_march_:
! s390_handle_arch_option ((enum s390_arch_option) value,
! &opts->x_s390_arch,
! &opts->x_s390_arch_flags);
opts->x_s390_arch_string = arg;
return true;
--- 1560,1566 ----
switch (code)
{
case OPT_march_:
! opts->x_s390_arch_flags = processor_flags_table[value];
opts->x_s390_arch_string = arg;
return true;
*************** s390_handle_option (struct gcc_options *
*** 1597,1605 ****
return true;
case OPT_mtune_:
! s390_handle_arch_option ((enum s390_arch_option) value,
! &opts->x_s390_tune,
! &opts->x_s390_tune_flags);
return true;
case OPT_mwarn_framesize_:
--- 1575,1581 ----
return true;
case OPT_mtune_:
! opts->x_s390_tune_flags = processor_flags_table[value];
return true;
case OPT_mwarn_framesize_:
*************** s390_option_override (void)
*** 1626,1645 ****
target_flags &= ~MASK_ZARCH;
}
! /* Determine processor architectural level. */
! if (!s390_arch_string)
{
s390_arch_string = TARGET_ZARCH? "z900" : "g5";
! s390_handle_arch_option ((TARGET_ZARCH ? s390_arch_z900 : s390_arch_g5),
! &s390_arch, &s390_arch_flags);
}
- /* This check is triggered when the user specified a wrong -march=
- string and prevents subsequent error messages from being
- issued. */
- if (s390_arch == PROCESSOR_max)
- return;
-
/* Determine processor to tune for. */
if (s390_tune == PROCESSOR_max)
{
--- 1602,1616 ----
target_flags &= ~MASK_ZARCH;
}
! /* Set the march default in case it hasn't been specified on
! cmdline. */
! if (s390_arch == PROCESSOR_max)
{
s390_arch_string = TARGET_ZARCH? "z900" : "g5";
! s390_arch = TARGET_ZARCH ? PROCESSOR_2064_Z900 : PROCESSOR_9672_G5;
! s390_arch_flags = processor_flags_table[(int)s390_arch];
}
/* Determine processor to tune for. */
if (s390_tune == PROCESSOR_max)
{
*************** s390_emit_prologue (void)
*** 8160,8167 ****
not match the test under mask pattern. */
if (stack_guard >= s390_stack_size)
{
! warning (0, "frame size of function %qs is "
! HOST_WIDE_INT_PRINT_DEC
" bytes which is more than half the stack size. "
"The dynamic check would not be reliable. "
"No check emitted for this function.",
--- 8131,8137 ----
not match the test under mask pattern. */
if (stack_guard >= s390_stack_size)
{
! warning (0, "frame size of function %qs is %wd"
" bytes which is more than half the stack size. "
"The dynamic check would not be reliable. "
"No check emitted for this function.",
*************** s390_emit_prologue (void)
*** 8189,8195 ****
if (s390_warn_framesize > 0
&& cfun_frame_layout.frame_size >= s390_warn_framesize)
! warning (0, "frame size of %qs is " HOST_WIDE_INT_PRINT_DEC " bytes",
current_function_name (), cfun_frame_layout.frame_size);
if (s390_warn_dynamicstack_p && cfun->calls_alloca)
--- 8159,8165 ----
if (s390_warn_framesize > 0
&& cfun_frame_layout.frame_size >= s390_warn_framesize)
! warning (0, "frame size of %qs is %wd bytes",
current_function_name (), cfun_frame_layout.frame_size);
if (s390_warn_dynamicstack_p && cfun->calls_alloca)
Index: gcc/config/s390/s390.md
===================================================================
*** gcc/config/s390/s390.md.orig
--- gcc/config/s390/s390.md
***************
*** 272,278 ****
;; distinguish between g5 and g6, but there are differences between the two
;; CPUs could in theory be modeled.
! (define_attr "cpu" "g5,g6,z900,z990,z9_109,z10,z196"
(const (symbol_ref "s390_tune_attr")))
(define_attr "cpu_facility" "standard,ieee,zarch,longdisp,extimm,dfp,z10,z196"
--- 272,278 ----
;; distinguish between g5 and g6, but there are differences between the two
;; CPUs could in theory be modeled.
! (define_attr "cpu" "g5,g6,z900,z990,z9_109,z9_ec,z10,z196"
(const (symbol_ref "s390_tune_attr")))
(define_attr "cpu_facility" "standard,ieee,zarch,longdisp,extimm,dfp,z10,z196"
Index: gcc/config/s390/s390.opt
===================================================================
*** gcc/config/s390/s390.opt.orig
--- gcc/config/s390/s390.opt
*************** config/s390/s390-opts.h
*** 25,41 ****
Variable
const char *s390_arch_string
- ; Which cpu are we tuning for.
- Variable
- enum processor_type s390_tune = PROCESSOR_max
-
Variable
int s390_tune_flags
- ; Which instruction set architecture to use.
- Variable
- enum processor_type s390_arch
-
Variable
int s390_arch_flags
--- 25,33 ----
*************** Target Report RejectNegative Negative(m3
*** 51,85 ****
64 bit ABI
march=
! Target RejectNegative Joined Enum(s390_arch_option)
Generate code for given CPU
Enum
! Name(s390_arch_option) Type(enum s390_arch_option)
EnumValue
! Enum(s390_arch_option) String(g5) Value(s390_arch_g5)
EnumValue
! Enum(s390_arch_option) String(g6) Value(s390_arch_g6)
EnumValue
! Enum(s390_arch_option) String(z900) Value(s390_arch_z900)
EnumValue
! Enum(s390_arch_option) String(z990) Value(s390_arch_z990)
EnumValue
! Enum(s390_arch_option) String(z9-109) Value(s390_arch_z9_109)
EnumValue
! Enum(s390_arch_option) String(z9-ec) Value(s390_arch_z9_ec)
EnumValue
! Enum(s390_arch_option) String(z10) Value(s390_arch_z10)
EnumValue
! Enum(s390_arch_option) String(z196) Value(s390_arch_z196)
mbackchain
Target Report Mask(BACKCHAIN)
--- 43,77 ----
64 bit ABI
march=
! Target RejectNegative Joined Enum(processor_type) Var(s390_arch) Init(PROCESSOR_max)
Generate code for given CPU
Enum
! Name(processor_type) Type(enum processor_type)
EnumValue
! Enum(processor_type) String(g5) Value(PROCESSOR_9672_G5)
EnumValue
! Enum(processor_type) String(g6) Value(PROCESSOR_9672_G6)
EnumValue
! Enum(processor_type) String(z900) Value(PROCESSOR_2064_Z900)
EnumValue
! Enum(processor_type) String(z990) Value(PROCESSOR_2084_Z990)
EnumValue
! Enum(processor_type) String(z9-109) Value(PROCESSOR_2094_Z9_109)
EnumValue
! Enum(processor_type) String(z9-ec) Value(PROCESSOR_2094_Z9_EC)
EnumValue
! Enum(processor_type) String(z10) Value(PROCESSOR_2097_Z10)
EnumValue
! Enum(processor_type) String(z196) Value(PROCESSOR_2817_Z196)
mbackchain
Target Report Mask(BACKCHAIN)
*************** Target RejectNegative Joined UInteger Va
*** 130,136 ****
Emit extra code in the function prologue in order to trap if the stack size exceeds the given limit
mtune=
! Target RejectNegative Joined Enum(s390_arch_option)
Schedule code for given CPU
mmvcle
--- 122,128 ----
Emit extra code in the function prologue in order to trap if the stack size exceeds the given limit
mtune=
! Target RejectNegative Joined Enum(processor_type) Var(s390_tune) Init(PROCESSOR_max)
Schedule code for given CPU
mmvcle
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [4.7] Avoid global state in s390_handle_option
2011-03-23 11:59 ` Andreas Krebbel
@ 2011-03-23 13:14 ` Joseph S. Myers
0 siblings, 0 replies; 3+ messages in thread
From: Joseph S. Myers @ 2011-03-23 13:14 UTC (permalink / raw)
To: Andreas Krebbel; +Cc: gcc-patches
On Wed, 23 Mar 2011, Andreas Krebbel wrote:
> Hi Joseph,
>
> sorry for the late reply to your patch. I would like to propose a few
> changes as implemented with the attached patch:
These seem reasonable to me.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-23 13:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-11 2:48 [4.7] Avoid global state in s390_handle_option Joseph S. Myers
2011-03-23 11:59 ` Andreas Krebbel
2011-03-23 13:14 ` Joseph S. Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).