This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

altivec: switch to disable VRSAVE generation


both linux and eabi altivec do not need vrsave instructions to
be generated, so their generation just bloats both code and the
stack frame.

this patch adds a switch to disable its generation.  the default
is still on, but i could default it to NO if there is no objection.

it's probably best we apply this patch only to the trunk.

ok for trunk?

2002-04-30  Aldy Hernandez  <aldyh@redhat.com>

	* doc/invoke.texi (Option Summary): Add -mvrsave=.
	(RS/6000 and PowerPC Options): Document -mvrsave=.

	* config/rs6000/rs6000.c (rs6000_altivec_vrsave): New global.
	(rs6000_altivec_vrsave_string): Same.
	(rs6000_override_options): Call rs6000_parse_vrsave_option.
	(rs6000_parse_vrsave_option): New.
	(rs6000_stack_info): Only generate vrsave instructions when
	TARGET_ALTIVEC_VRSAVE.

	* config/rs6000/rs6000.h (TARGET_OPTIONS): Add -mvrsave= option.
	(rs6000_altivec_vrsave_string): Define extern.
	(rs6000_altivec_vrsave): Same.
	(TARGET_ALTIVEC_VRSAVE): New.


Index: doc/invoke.texi
===================================================================
RCS file: /cvs/uberbaum/gcc/doc/invoke.texi,v
retrieving revision 1.137
diff -c -p -r1.137 invoke.texi
*** doc/invoke.texi	31 Mar 2002 03:11:19 -0000	1.137
--- doc/invoke.texi	30 Apr 2002 04:56:13 -0000
*************** in the following sections.
*** 447,452 ****
--- 447,453 ----
  -mcall-aix -mcall-sysv -mcall-netbsd @gol
  -maix-struct-return -msvr4-struct-return
  -mabi=altivec -mabi=no-altivec @gol
+ -mvrsave=yes -mvrsave=no @gol
  -mprototype  -mno-prototype @gol
  -msim  -mmvme  -mads  -myellowknife  -memb -msdata @gol
  -msdata=@var{opt}  -mvxworks -G @var{num} -pthread}
*************** These switches enable or disable the use
*** 6428,6433 ****
--- 6429,6441 ----
  allow access to the AltiVec instruction set.  You may also need to set
  @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
  enhancements.
+ 
+ @item -mvrsave=@var{yes/no}
+ @itemx -mvrsave
+ @opindex mvrsave
+ This switch enables or disables the generation of VRSAVE save and
+ restore instructions when using the AltiVec instruction set.  If this
+ switch is unspecified, the default is to generate VRSAVE instructions.
  
  @item -mfull-toc
  @itemx -mno-fp-in-toc
Index: config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.199
diff -c -p -r1.199 rs6000.h
*** config/rs6000/rs6000.h	12 Apr 2002 16:57:47 -0000	1.199
--- config/rs6000/rs6000.h	30 Apr 2002 04:56:16 -0000
*************** extern enum processor_type rs6000_cpu;
*** 430,435 ****
--- 430,437 ----
     {"abi=", &rs6000_abi_string, N_("Specify ABI to use") },		\
     {"long-double-", &rs6000_long_double_size_string,			\
      N_("Specify size of long double (64 or 128 bits)") },		\
+    {"vrsave=", &rs6000_altivec_vrsave_string,                         \
+     N_("Specify yes/no if VRSAVE instructions should be generated for AltiVec") }, \
     SUBTARGET_OPTIONS							\
  }
  
*************** extern int rs6000_debug_arg;		/* debug a
*** 458,466 ****
--- 460,471 ----
  extern const char *rs6000_long_double_size_string;
  extern int rs6000_long_double_type_size;
  extern int rs6000_altivec_abi;
+ extern const char *rs6000_altivec_vrsave_string;
+ extern int rs6000_altivec_vrsave;
  
  #define TARGET_LONG_DOUBLE_128 (rs6000_long_double_type_size == 128)
  #define TARGET_ALTIVEC_ABI rs6000_altivec_abi
+ #define TARGET_ALTIVEC_VRSAVE rs6000_altivec_vrsave
  
  /* Sometimes certain combinations of command options do not make sense
     on a particular target machine.  You can define a macro
*************** extern int rs6000_altivec_abi;
*** 518,523 ****
--- 523,534 ----
     For RS/6000 we can decide arbitrarily since there are no machine
     instructions for them.  Might as well be consistent with bits and bytes.  */
  #define WORDS_BIG_ENDIAN 1
+ 
+ /* Define to TRUE on a big-endian system when structure arguments
+    passed (and returned) in registers are passed in a little-endian
+    manner instead of a big-endian manner.  */
+ 
+ #define FUNCTION_ARG_REG_LITTLE_ENDIAN 1
  
  #define MAX_BITS_PER_WORD 64
  
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.306
diff -c -p -r1.306 rs6000.c
*** config/rs6000/rs6000.c	15 Apr 2002 22:39:09 -0000	1.306
--- config/rs6000/rs6000.c	30 Apr 2002 04:56:21 -0000
*************** int rs6000_long_double_type_size;
*** 74,79 ****
--- 74,85 ----
  /* Whether -mabi=altivec has appeared */
  int rs6000_altivec_abi;
  
+ /* Whether VRSAVE instructions should be generated.  */
+ int rs6000_altivec_vrsave;
+ 
+ /* String from -mvrsave= option.  */
+ const char *rs6000_altivec_vrsave_string;
+ 
  /* Set to non-zero once AIX common-mode calls have been defined.  */
  static int common_mode_defined;
  
*************** static rtx altivec_expand_predicate_buil
*** 168,173 ****
--- 174,180 ----
  static rtx altivec_expand_ternop_builtin PARAMS ((enum insn_code, tree, rtx));
  static rtx altivec_expand_stv_builtin PARAMS ((enum insn_code, tree));
  static void rs6000_parse_abi_options PARAMS ((void));
+ static void rs6000_parse_vrsave_option PARAMS ((void));
  static int first_altivec_reg_to_save PARAMS ((void));
  static unsigned int compute_vrsave_mask PARAMS ((void));
  static void is_altivec_return_reg PARAMS ((rtx, void *));
*************** rs6000_override_options (default_cpu)
*** 534,539 ****
--- 541,549 ----
    /* Handle -mabi= options.  */
    rs6000_parse_abi_options ();
  
+   /* Handle -mvrsave= option.  */
+   rs6000_parse_vrsave_option ();
+ 
  #ifdef TARGET_REGNAMES
    /* If the user desires alternate register names, copy in the
       alternate names now.  */
*************** rs6000_override_options (default_cpu)
*** 581,586 ****
--- 591,611 ----
    free_machine_status = rs6000_free_machine_status;
  }
  
+ /* Handle -mvrsave= options.  */
+ static void
+ rs6000_parse_vrsave_option ()
+ {
+   /* Generate VRSAVE instructions by default.  */
+   if (rs6000_altivec_vrsave_string == 0
+       || ! strcmp (rs6000_altivec_vrsave_string, "yes"))
+     rs6000_altivec_vrsave = 1;
+   else if (! strcmp (rs6000_altivec_vrsave_string, "no"))
+     rs6000_altivec_vrsave = 0;
+   else
+     error ("unknown -mvrsave= option specified: '%s'",
+ 	   rs6000_altivec_vrsave_string);
+ }
+ 
  /* Handle -mabi= options.  */
  static void
  rs6000_parse_abi_options ()
*************** rs6000_stack_info ()
*** 7759,7765 ****
    info_ptr->parm_size    = RS6000_ALIGN (current_function_outgoing_args_size,
  					 8);
  
!   if (TARGET_ALTIVEC_ABI)
      {
        info_ptr->vrsave_mask = compute_vrsave_mask ();
        info_ptr->vrsave_size  = info_ptr->vrsave_mask ? 4 : 0;
--- 7784,7790 ----
    info_ptr->parm_size    = RS6000_ALIGN (current_function_outgoing_args_size,
  					 8);
  
!   if (TARGET_ALTIVEC_ABI && TARGET_ALTIVEC_VRSAVE)
      {
        info_ptr->vrsave_mask = compute_vrsave_mask ();
        info_ptr->vrsave_size  = info_ptr->vrsave_mask ? 4 : 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]