Re: [s390] Split out pre-prologue rewrite into separate pass

2014-02-07 Thread Andreas Krebbel
On 04/02/14 12:14, Richard Sandiford wrote:
 s390_emit_prologue performs some optimisations on the function before
 emitting the prologue.  It also rewrites constant pool accesses to make
 the base register explicit.
 
 Doing this in the prologue pattern makes the interaction with direct
 returns and simple_returns less obvious, so this patch splits the code
 out into a new target-specific pre-prologue pass.  I've called it
 early_mach for want of a better name.
 
 I also moved s390_option_override to the end of the file in order
 to avoid some forward declarations that would have been needed otherwise.
 The only change is at the very end of the function.
 
 Tested on s390-linux-gnu and s390x-linux-gnu, using
 unix{,-m31,-march=z10/-m31,-march=z10,-march=z196,-march=zEC12}
 for the latter.  OK to install?
 
 Thanks,
 Richard
 
 
 gcc/
   * config/s390/s390.c: Include tree-pass.h and context.h.
   (s390_early_mach): New function, split out from...
   (s390_emit_prologue): ...here.
   (pass_data_s390_early_mach): New pass structure.
   (pass_s390_early_mach): New class.
   (s390_option_override): Create and register early_mach pass.
   Move to end of file.

Ok to apply.  Thanks a lot for doing this work!

-Andreas-



[s390] Split out pre-prologue rewrite into separate pass

2014-02-04 Thread Richard Sandiford
s390_emit_prologue performs some optimisations on the function before
emitting the prologue.  It also rewrites constant pool accesses to make
the base register explicit.

Doing this in the prologue pattern makes the interaction with direct
returns and simple_returns less obvious, so this patch splits the code
out into a new target-specific pre-prologue pass.  I've called it
early_mach for want of a better name.

I also moved s390_option_override to the end of the file in order
to avoid some forward declarations that would have been needed otherwise.
The only change is at the very end of the function.

Tested on s390-linux-gnu and s390x-linux-gnu, using
unix{,-m31,-march=z10/-m31,-march=z10,-march=z196,-march=zEC12}
for the latter.  OK to install?

Thanks,
Richard


gcc/
* config/s390/s390.c: Include tree-pass.h and context.h.
(s390_early_mach): New function, split out from...
(s390_emit_prologue): ...here.
(pass_data_s390_early_mach): New pass structure.
(pass_s390_early_mach): New class.
(s390_option_override): Create and register early_mach pass.
Move to end of file.

Index: gcc/config/s390/s390.c
===
--- gcc/config/s390/s390.c  2014-01-31 17:13:43.803357694 +
+++ gcc/config/s390/s390.c  2014-01-31 17:20:31.582196663 +
@@ -68,6 +68,8 @@ Software Foundation; either version 3, o
 #include params.h
 #include cfgloop.h
 #include opts.h
+#include tree-pass.h
+#include context.h
 
 /* Define the specific costs for a given cpu.  */
 
@@ -1678,220 +1680,6 @@ s390_init_machine_status (void)
   return ggc_alloc_cleared_machine_function ();
 }
 
-static void
-s390_option_override (void)
-{
-  unsigned int i;
-  cl_deferred_option *opt;
-  veccl_deferred_option *v =
-(veccl_deferred_option *) s390_deferred_options;
-
-  if (v)
-FOR_EACH_VEC_ELT (*v, i, opt)
-  {
-   switch (opt-opt_index)
- {
- case OPT_mhotpatch:
-   s390_hotpatch_trampoline_halfwords = (opt-value) ?
- s390_hotpatch_trampoline_halfwords_default : -1;
-   break;
- case OPT_mhotpatch_:
-   {
- int val;
-
- val = integral_argument (opt-arg);
- if (val == -1)
-   {
- /* argument is not a plain number */
- error (argument to %qs should be a non-negative integer,
--mhotpatch=);
- break;
-   }
- else if (val  s390_hotpatch_trampoline_halfwords_max)
-   {
- error (argument to %qs is too large (max. %d),
--mhotpatch=, s390_hotpatch_trampoline_halfwords_max);
- break;
-   }
- s390_hotpatch_trampoline_halfwords = val;
- break;
-   }
- default:
-   gcc_unreachable ();
- }
-  }
-
-  /* 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;
-}
-
-  /* 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_tune = s390_arch;
-  s390_tune_flags = s390_arch_flags;
-}
-
-  /* Sanity checks.  */
-  if (TARGET_ZARCH  !TARGET_CPU_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);
-
-  /* Use hardware DFP if available and not explicitly disabled by
- user. E.g. with -m31 -march=z10 -mzarch   */
-  if (!(target_flags_explicit  MASK_HARD_DFP)  TARGET_DFP)
-target_flags |= MASK_HARD_DFP;
-
-  /* Enable hardware transactions if available and not explicitly
- disabled by user.  E.g. with -m31 -march=zEC12 -mzarch */
-  if (!(target_flags_explicit  MASK_OPT_HTM)  TARGET_CPU_HTM  
TARGET_ZARCH)
-target_flags |= MASK_OPT_HTM;
-
-  if (TARGET_HARD_DFP  !TARGET_DFP)
-{
-  if (target_flags_explicit  MASK_HARD_DFP)
-   {
- if (!TARGET_CPU_DFP)
-   error (hardware decimal floating point instructions
-   not available on %s, s390_arch_string);
- if (!TARGET_ZARCH)
-   error (hardware decimal floating point instructions
-   not available in ESA/390 mode);
-   }
-  else
-   target_flags = ~MASK_HARD_DFP;
-}
-
-  if ((target_flags_explicit  MASK_SOFT_FLOAT)  TARGET_SOFT_FLOAT)