This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
S/390: Rework processor type selection
- From: Ulrich Weigand <weigand at i1 dot informatik dot uni-erlangen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 30 Jun 2003 21:52:19 +0200 (MET DST)
- Subject: S/390: Rework processor type selection
Hello,
this patch reworks the way processor type selection is done by the
s390 backend. The relevant changes are:
- More reasonable default rules if only some of -m31/-m64, -mesa/-mzarch,
-march, and -mtune are specified. Compute defaults at one place
(DRIVER_SELF_SPECS) instead of spread out through different passes.
- Pass processor type and architecture mode to the assembler to allow
instruction set verification. (Requires recent binutils.)
- Implement configure options --with-arch, --with-tune, and --with-mode
to allow presetting all aspects of processor selection.
- Internal cleanup to make processor facility tests simpler.
In addition, the new "z990" processor is allowed as -march/-mtune value.
Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux.
Bye,
Ulrich
ChangeLog:
* config.gcc [s390*-*-*]: Support --with-arch, --with-tune, and
--with-mode configure options.
* config/s390/s390.h (OPTION_DEFAULT_SPECS): Define.
(DRIVER_SELF_SPECS): Define.
* config/s390/linux.h (ASM_SPEC): Pass architecture mode and cpu
architecture to assembler.
(LINK_SPEC): Merge 31-bit and 64-bit variants.
(LINK_ARCH31_SPEC, LINK_ARCH64_SPEC, EXTRA_SPECS): Remove.
* config/s390/s390.c (override_options): New default rules for
architecture mode and cpu architecture selection.
* doc/invoke.texi (-mesa, -mzarch, -march, -mtune): Document
new default rules.
* config/s390/s390.h (enum processor_type): Add PROCESSOR_2084_Z990.
* config/s390/s390.md (attr "cpu"): Add "z990" processor type.
* config/s390/s390.c (override_options): Add "z990" to
processor_alias_table.
* doc/invoke.texi (-march): Document "z990" processor type.
* config/s390/s390.c (s390_tune_flags, s390_arch_flags): New variables.
* config/s390/s390.h (s390_tune_flags, s390_arch_flags): Declare.
(enum processor_flags, TARGET_CPU_IEEE_FLOAT, TARGET_CPU_ZARCH,
TARGET_CPU_LONG_DISPLACEMENT, TARGET_LONG_DISPLACEMENT): New.
* config/s390/s390.c (override_options): Replace enum pta_flags by
enum processor_flags. Fill in s390_tune_flags and s390_arch_flags.
* config/s390/s390.c (s390_cpu): Rename to ...
(s390_tune): ... this.
* config/s390/s390.h (s390_cpu, s390_tune): Likewise.
* config/s390/s390.c (s390_issue_rate, override_options): Likewise.
* config/s390/s390.md (attr "cpu"): Likewise.
Index: gcc/config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.327
diff -c -p -r1.327 config.gcc
*** gcc/config.gcc 26 Jun 2003 16:34:27 -0000 1.327
--- gcc/config.gcc 29 Jun 2003 16:56:39 -0000
*************** then
*** 2442,2447 ****
--- 2442,2476 ----
done
;;
+ s390*-*-*)
+ supported_defaults="arch mode tune"
+
+ for which in arch tune; do
+ eval "val=\$with_$which"
+ case x$val in
+ x \
+ | xg5 | xg6 | xz900 | xz990)
+ # OK
+ ;;
+ *)
+ echo "Unknown cpu used in --with-$which=$val." 1>&2
+ exit 1
+ ;;
+ esac
+ done
+
+ case "x$with_mode" in
+ x \
+ | xesa | xzarch)
+ # OK
+ ;;
+ *)
+ echo "Unknown architecture mode used in --with-mode=$with_mode." 1>&2
+ exit 1
+ ;;
+ esac
+ ;;
+
sparc*-*-*)
supported_defaults="cpu float tune"
*************** then
*** 2606,2612 ****
esac
t=
! all_defaults="abi cpu arch tune schedule float"
for option in $all_defaults
do
eval "val=\$with_$option"
--- 2635,2641 ----
esac
t=
! all_defaults="abi cpu arch tune schedule float mode"
for option in $all_defaults
do
eval "val=\$with_$option"
Index: gcc/config/s390/linux.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/linux.h,v
retrieving revision 1.31
diff -c -p -r1.31 linux.h
*** gcc/config/s390/linux.h 7 Jun 2003 17:11:48 -0000 1.31
--- gcc/config/s390/linux.h 29 Jun 2003 16:57:13 -0000
*************** Boston, MA 02111-1307, USA. */
*** 69,81 ****
/* Target specific assembler settings. */
- #ifdef DEFAULT_TARGET_64BIT
- #undef ASM_SPEC
- #define ASM_SPEC "%{m31:-m31 -Aesa}"
- #else
#undef ASM_SPEC
! #define ASM_SPEC "%{m64:-m64 -Aesame}"
! #endif
/* Target specific linker settings. */
--- 69,76 ----
/* Target specific assembler settings. */
#undef ASM_SPEC
! #define ASM_SPEC "%{m31&m64}%{mesa&mzarch}%{march=*}"
/* Target specific linker settings. */
*************** Boston, MA 02111-1307, USA. */
*** 86,125 ****
#define MULTILIB_DEFAULTS { "m31" }
#endif
! #define LINK_ARCH31_SPEC \
! "-m elf_s390 \
! %{shared:-shared} \
! %{!shared: \
! %{static:-static} \
! %{!static: \
! %{rdynamic:-export-dynamic} \
! %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
!
! #define LINK_ARCH64_SPEC \
! "-m elf64_s390 \
%{shared:-shared} \
%{!shared: \
%{static:-static} \
%{!static: \
%{rdynamic:-export-dynamic} \
! %{!dynamic-linker:-dynamic-linker /lib/ld64.so.1}}}"
!
! #ifdef DEFAULT_TARGET_64BIT
! #undef LINK_SPEC
! #define LINK_SPEC "%{m31:%(link_arch31)} %{!m31:%(link_arch64)}"
! #else
! #undef LINK_SPEC
! #define LINK_SPEC "%{m64:%(link_arch64)} %{!m64:%(link_arch31)}"
! #endif
!
!
! /* This macro defines names of additional specifications to put in the specs
! that can be used in various specifications like CC1_SPEC. Its definition
! is an initializer with a subgrouping for each command option. */
- #define EXTRA_SPECS \
- { "link_arch31", LINK_ARCH31_SPEC }, \
- { "link_arch64", LINK_ARCH64_SPEC }, \
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
--- 81,98 ----
#define MULTILIB_DEFAULTS { "m31" }
#endif
! #undef LINK_SPEC
! #define LINK_SPEC \
! "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
%{shared:-shared} \
%{!shared: \
%{static:-static} \
%{!static: \
%{rdynamic:-export-dynamic} \
! %{!dynamic-linker: \
! %{m31:-dynamic-linker /lib/ld.so.1} \
! %{m64:-dynamic-linker /lib/ld64.so.1}}}}"
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.97
diff -c -p -r1.97 s390.c
*** gcc/config/s390/s390.c 27 Jun 2003 21:10:13 -0000 1.97
--- gcc/config/s390/s390.c 29 Jun 2003 16:57:15 -0000
*************** struct s390_address
*** 157,165 ****
};
/* Which cpu are we tuning for. */
! enum processor_type s390_cpu;
/* Which instruction set architecture to use. */
enum processor_type s390_arch;
/* Strings to hold which cpu and instruction set architecture to use. */
const char *s390_tune_string; /* for -mtune=<xxx> */
--- 157,167 ----
};
/* Which cpu are we tuning for. */
! enum processor_type s390_tune;
! enum processor_flags s390_tune_flags;
/* Which instruction set architecture to use. */
enum processor_type s390_arch;
+ enum processor_flags s390_arch_flags;
/* Strings to hold which cpu and instruction set architecture to use. */
const char *s390_tune_string; /* for -mtune=<xxx> */
*************** void
*** 925,946 ****
override_options ()
{
int i;
- static const char * const cpu_names[] = TARGET_CPU_DEFAULT_NAMES;
static struct pta
{
const char *const name; /* processor name or nickname. */
const enum processor_type processor;
! const enum pta_flags
! {
! PTA_IEEE_FLOAT = 1,
! PTA_ZARCH = 2
! } flags;
}
const processor_alias_table[] =
{
! {"g5", PROCESSOR_9672_G5, PTA_IEEE_FLOAT},
! {"g6", PROCESSOR_9672_G6, PTA_IEEE_FLOAT},
! {"z900", PROCESSOR_2064_Z900, PTA_IEEE_FLOAT | PTA_ZARCH},
};
int const pta_size = ARRAY_SIZE (processor_alias_table);
--- 927,945 ----
override_options ()
{
int i;
static struct pta
{
const char *const name; /* processor name or nickname. */
const enum processor_type processor;
! const enum processor_flags 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
! | PF_LONG_DISPLACEMENT},
};
int const pta_size = ARRAY_SIZE (processor_alias_table);
*************** override_options ()
*** 950,1008 ****
/* Set up function hooks. */
init_machine_status = s390_init_machine_status;
!
! /* Set cpu and arch, if only partially given. */
! if (!s390_tune_string && s390_arch_string)
! s390_tune_string = s390_arch_string;
! if (!s390_tune_string)
! s390_tune_string = cpu_names [TARGET_64BIT ? TARGET_CPU_DEFAULT_2064
! : TARGET_CPU_DEFAULT_9672];
if (!s390_arch_string)
! #ifdef DEFAULT_TARGET_64BIT
! s390_arch_string = "z900";
! #else
! s390_arch_string = "g5";
! #endif
for (i = 0; i < pta_size; i++)
if (! strcmp (s390_arch_string, processor_alias_table[i].name))
{
s390_arch = processor_alias_table[i].processor;
! /* Default cpu tuning to the architecture. */
! s390_cpu = s390_arch;
!
! if (!(processor_alias_table[i].flags & PTA_ZARCH)
! && TARGET_64BIT)
! error ("64-bit ABI not supported on %s", s390_arch_string);
!
! if (!(processor_alias_table[i].flags & PTA_ZARCH)
! && TARGET_ZARCH)
! error ("z/Architecture not supported on %s", s390_arch_string);
!
break;
}
-
if (i == pta_size)
! error ("bad value (%s) for -march= switch", s390_arch_string);
! /* ESA implies 31 bit mode. */
! if ((target_flags_explicit & MASK_ZARCH) && !TARGET_ZARCH)
{
! if ((target_flags_explicit & MASK_64BIT) && TARGET_64BIT)
! error ("64-bit ABI not possible in ESA/390 mode");
! else
! target_flags &= ~MASK_64BIT;
}
! for (i = 0; i < pta_size; i++)
! if (! strcmp (s390_tune_string, processor_alias_table[i].name))
! {
! s390_cpu = processor_alias_table[i].processor;
! break;
! }
!
! if (i == pta_size)
! error ("bad value (%s) for -mtune= switch", s390_tune_string);
}
/* Map for smallest class containing reg regno. */
--- 949,1003 ----
/* Set up function hooks. */
init_machine_status = s390_init_machine_status;
!
! /* Architecture mode defaults according to ABI. */
! if (!(target_flags_explicit & MASK_ZARCH))
! {
! if (TARGET_64BIT)
! target_flags |= MASK_ZARCH;
! else
! target_flags &= ~MASK_ZARCH;
! }
!
! /* Determine processor architectural level. */
if (!s390_arch_string)
! s390_arch_string = TARGET_ZARCH? "z900" : "g5";
for (i = 0; i < pta_size; i++)
if (! strcmp (s390_arch_string, processor_alias_table[i].name))
{
s390_arch = processor_alias_table[i].processor;
! s390_arch_flags = processor_alias_table[i].flags;
break;
}
if (i == pta_size)
! error ("Unknown cpu used in -march=%s.", s390_arch_string);
! /* Determine processor to tune for. */
! if (!s390_tune_string)
{
! s390_tune = s390_arch;
! s390_tune_flags = s390_arch_flags;
! s390_tune_string = s390_arch_string;
! }
! else
! {
! for (i = 0; i < pta_size; i++)
! if (! strcmp (s390_tune_string, processor_alias_table[i].name))
! {
! s390_tune = processor_alias_table[i].processor;
! s390_tune_flags = processor_alias_table[i].flags;
! break;
! }
! if (i == pta_size)
! error ("Unknown cpu used in -mtune=%s.", s390_tune_string);
}
! /* Sanity checks. */
! if (TARGET_ZARCH && !(s390_arch_flags & PF_ZARCH))
! error ("z/Architecture mode not supported on %s.", s390_arch_string);
! if (TARGET_64BIT && !TARGET_ZARCH)
! error ("64-bit ABI not supported in ESA/390 mode.");
}
/* Map for smallest class containing reg regno. */
*************** s390_issue_rate ()
*** 3707,3713 ****
static int
s390_use_dfa_pipeline_interface ()
{
! if (s390_cpu == PROCESSOR_2064_Z900)
return 1;
return 0;
--- 3702,3708 ----
static int
s390_use_dfa_pipeline_interface ()
{
! if (s390_tune == PROCESSOR_2064_Z900)
return 1;
return 0;
Index: gcc/config/s390/s390.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.h,v
retrieving revision 1.75
diff -c -p -r1.75 s390.h
*** gcc/config/s390/s390.h 27 Jun 2003 21:10:15 -0000 1.75
--- gcc/config/s390/s390.h 29 Jun 2003 16:57:15 -0000
*************** enum processor_type
*** 37,55 ****
PROCESSOR_9672_G5,
PROCESSOR_9672_G6,
PROCESSOR_2064_Z900,
PROCESSOR_max
};
! extern enum processor_type s390_cpu;
extern const char *s390_tune_string;
extern enum processor_type s390_arch;
extern const char *s390_arch_string;
! #define TARGET_CPU_DEFAULT_9672 0
! #define TARGET_CPU_DEFAULT_2064 2
- #define TARGET_CPU_DEFAULT_NAMES {"g5", "g6", "z900"}
/* Run-time target specification. */
--- 37,73 ----
PROCESSOR_9672_G5,
PROCESSOR_9672_G6,
PROCESSOR_2064_Z900,
+ PROCESSOR_2084_Z990,
PROCESSOR_max
};
! /* Optional architectural facilities supported by the processor. */
!
! enum processor_flags
! {
! PF_IEEE_FLOAT = 1,
! PF_ZARCH = 2,
! PF_LONG_DISPLACEMENT = 4
! };
!
! extern enum processor_type s390_tune;
! extern enum processor_flags s390_tune_flags;
extern const char *s390_tune_string;
extern enum processor_type s390_arch;
+ extern enum processor_flags s390_arch_flags;
extern const char *s390_arch_string;
! #define TARGET_CPU_IEEE_FLOAT \
! (s390_arch_flags & PF_IEEE_FLOAT)
! #define TARGET_CPU_ZARCH \
! (s390_arch_flags & PF_ZARCH)
! #define TARGET_CPU_LONG_DISPLACEMENT \
! (s390_arch_flags & PF_LONG_DISPLACEMENT)
!
! #define TARGET_LONG_DISPLACEMENT \
! (TARGET_ZARCH && TARGET_CPU_LONG_DISPLACEMENT)
/* Run-time target specification. */
*************** extern int target_flags;
*** 118,123 ****
--- 136,160 ----
{ "arch=", &s390_arch_string, \
N_("Generate code for given CPU"), 0}, \
}
+
+ /* Support for configure-time defaults. */
+ #define OPTION_DEFAULT_SPECS \
+ { "mode", "%{!mesa:%{!mzarch:-m%(VALUE)}}" }, \
+ { "arch", "%{!march=*:-march=%(VALUE)}" }, \
+ { "tune", "%{!mtune=*:-mtune=%(VALUE)}" }
+
+ /* Defaulting rules. */
+ #ifdef DEFAULT_TARGET_64BIT
+ #define DRIVER_SELF_SPECS \
+ "%{!m31:%{!m64:-m64}}", \
+ "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \
+ "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
+ #else
+ #define DRIVER_SELF_SPECS \
+ "%{!m31:%{!m64:-m31}}", \
+ "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \
+ "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
+ #endif
/* Target version string. Overridden by the OS header. */
#ifdef DEFAULT_TARGET_64BIT
Index: gcc/config/s390/s390.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.md,v
retrieving revision 1.56
diff -c -p -r1.56 s390.md
*** gcc/config/s390/s390.md 27 Jun 2003 21:10:16 -0000 1.56
--- gcc/config/s390/s390.md 29 Jun 2003 16:57:17 -0000
***************
*** 76,83 ****
;; Processor type. This attribute must exactly match the processor_type
;; enumeration in s390.h.
! (define_attr "cpu" "g5,g6,z900"
! (const (symbol_ref "s390_cpu")))
;; Define an insn type attribute. This is used in function unit delay
;; computations.
--- 76,83 ----
;; Processor type. This attribute must exactly match the processor_type
;; enumeration in s390.h.
! (define_attr "cpu" "g5,g6,z900,z990"
! (const (symbol_ref "s390_tune")))
;; Define an insn type attribute. This is used in function unit delay
;; computations.
Index: gcc/doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.305
diff -c -p -r1.305 invoke.texi
*** gcc/doc/invoke.texi 27 Jun 2003 03:04:40 -0000 1.305
--- gcc/doc/invoke.texi 29 Jun 2003 16:57:22 -0000
*************** instructions available on z/Architecture
*** 10134,10141 ****
When @option{-mesa} is specified, generate code using the
instructions available on ESA/390. Note that @option{-mesa} is
not possible with @option{-m64}.
! For the @samp{s390} targets, the default is @option{-mesa},
! while the @samp{s390x} targets default to @option{-mzarch}.
@item -mmvcle
@itemx -mno-mvcle
--- 10134,10142 ----
When @option{-mesa} is specified, generate code using the
instructions available on ESA/390. Note that @option{-mesa} is
not possible with @option{-m64}.
! When generating code compliant to the Linux for S/390 ABI,
! the default is @option{-mesa}. When generating code compliant
! to the Linux for zSeries ABI, the default is @option{-mzarch}.
@item -mmvcle
@itemx -mno-mvcle
*************** use a @code{mvc} loop instead. This is
*** 10152,10168 ****
Print (or do not print) additional debug information when compiling.
The default is to not print debug information.
! @item -march=@var{arch}
@opindex march
! Generate code that will run on @var{arch}, which is the name of system
representing a certain processor type. Possible values for
! @var{cpu-type} are @samp{g5}, @samp{g6} and @samp{z900}.
! @item -mtune=@var{arch}
@opindex mtune
Tune to @var{cpu-type} everything applicable about the generated code,
! except for the ABI and the set of available instructions.
! The list of @var{arch} values is the same as for @option{-march}.
@end table
--- 10153,10173 ----
Print (or do not print) additional debug information when compiling.
The default is to not print debug information.
! @item -march=@var{cpu-type}
@opindex march
! Generate code that will run on @var{cpu-type}, which is the name of a system
representing a certain processor type. Possible values for
! @var{cpu-type} are @samp{g5}, @samp{g6}, @samp{z900}, and @samp{z990}.
! When generating code using the instructions available on z/Architecture,
! the default is @option{-march=z900}. Otherwise, the default is
! @option{-march=g5}.
! @item -mtune=@var{cpu-type}
@opindex mtune
Tune to @var{cpu-type} everything applicable about the generated code,
! except for the ABI and the set of available instructions.
! The list of @var{cpu-type} values is the same as for @option{-march}.
! The default is the value used for @option{-march}.
@end table
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de