diff mbox

Patch for gcc.dg/builtin-apply4.c, looking for sh port help

Message ID 1288125140.496977.31167.nullmailer@hpsje.cup.hp.com
State New
Headers show

Commit Message

Steve Ellcey Oct. 26, 2010, 8:32 p.m. UTC
Here is a patch to fix gcc.dg/builtin-apply4.c and
gcc.dg/torture/stackalign/builtin-apply-4.c on IA64.  This is based on
Joern's patch from several years ago:

http://gcc.gnu.org/ml/gcc-patches/2005-08/msg00129.html

I didn't include the 'sh' specific changes or the changes to
mode-switching.c because I didn't understand them and they didn't seem
necessary to make things work on IA64.  I also added a target function
for argument modes in addtion to return modes, because that was needed
for IA64.  The default (and IA64 specific) functions for these two target
functions are the same but since the sh target might need one but not
the other, I created two seperate target functions.  I did some testing
with complex double and complex long double types on IA64 and those seem
to work with this patch too.

Are either of the sh port maintainers willing to test this on sh and
extend it if necessary to fix that port?  Otherwise I will see if I
can get this checked in as it is to fix these test failures on IA64.

Steve Ellcey
sje@cup.hp.com


2010-10-26  Steve Ellcey  <sje@cup.hp.com>

	* doc/tm.texi.in (TARGET_GET_RAW_RESULT_MODE): New.
	(TARGET_GET_RAW_ARG_MODE): New.
	* doc/tm.texi: Regenerate.
	* target.def (get_raw_result_mode): New.
	(get_raw_arg_mode): New.
	* targhooks.c (default_get_reg_raw_mode): New.
	* targhooks.h (default_get_reg_raw_mode): New.
	* builtins.c (apply_args_size): Use targetm.calls.get_raw_arg_mode.
	(apply_result_size): Ditto.
	* config/ia64/ia64.c (ia64_get_reg_raw_mode): New.
	(TARGET_GET_RAW_RESULT_MODE): Define.
	(TARGET_GET_RAW_ARG_MODE): Ditto.

Comments

Paolo Bonzini Oct. 26, 2010, 9:23 p.m. UTC | #1
On 10/26/2010 10:32 PM, Steve Ellcey wrote:
> Here is a patch to fix gcc.dg/builtin-apply4.c and
> gcc.dg/torture/stackalign/builtin-apply-4.c on IA64.  This is based on
> Joern's patch from several years ago:
>
> http://gcc.gnu.org/ml/gcc-patches/2005-08/msg00129.html
>
> I didn't include the 'sh' specific changes or the changes to
> mode-switching.c because I didn't understand them and they didn't seem
> necessary to make things work on IA64.  I also added a target function
> for argument modes in addtion to return modes, because that was needed
> for IA64.  The default (and IA64 specific) functions for these two target
> functions are the same but since the sh target might need one but not
> the other, I created two seperate target functions.  I did some testing
> with complex double and complex long double types on IA64 and those seem
> to work with this patch too.
>
> Are either of the sh port maintainers willing to test this on sh and
> extend it if necessary to fix that port?  Otherwise I will see if I
> can get this checked in as it is to fix these test failures on IA64.

Do we care about __builtin_apply at all?  I'd rather hope Nicola would 
finally switch libobjc to libffi...

Paolo
Steve Ellcey Oct. 26, 2010, 9:43 p.m. UTC | #2
On Tue, 2010-10-26 at 23:23 +0200, Paolo Bonzini wrote:

> Do we care about __builtin_apply at all?  I'd rather hope Nicola would 
> finally switch libobjc to libffi...
> 
> Paolo

See: http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01373.html

Steve Ellcey
sje@cup.hp.com
Kaz Kojima Oct. 26, 2010, 10:47 p.m. UTC | #3
Steve Ellcey <sje@cup.hp.com> wrote:
> Are either of the sh port maintainers willing to test this on sh and
> extend it if necessary to fix that port?  Otherwise I will see if I
> can get this checked in as it is to fix these test failures on IA64.

I've fired a build&test script with your patch.  I'll report
back the result.
I'm also trying the SH specific change, though it'll take
some time.

Regards,
	kaz
Joseph Myers Oct. 26, 2010, 11:28 p.m. UTC | #4
On Tue, 26 Oct 2010, Steve Ellcey wrote:

> +@hook TARGET_GET_RAW_RESULT_MODE
> +This target hook returns the mode to be used when accessing raw argument
> +registers in __builtin_apply_args.  Define this macro if the value
> +in reg_raw_mode is not correct.

@code{__builtin_apply_args}, @var{reg_raw_mode}.  Also, documentation for 
new hooks (not based on pre-existing GFDL-only documentation) should go 
directly in target.def rather than in tm.texi.in - or is your problem here 
that it *is* based on pre-existing GFDL-only documentation?

> +This target hook returns the mode to be used when accessing raw return
> +registers in __builtin_return.  Define this macro if the value
> +in reg_raw_mode is not correct.

Likewise.
Kaz Kojima Oct. 27, 2010, 1:29 p.m. UTC | #5
> Steve Ellcey <sje@cup.hp.com> wrote:
>> Are either of the sh port maintainers willing to test this on sh and
>> extend it if necessary to fix that port?  Otherwise I will see if I
>> can get this checked in as it is to fix these test failures on IA64.
> 
> I've fired a build&test script with your patch.  I'll report
> back the result.

I've confirmed that it passes without regressions on
sh4-unknown-linux-gnu.

Regards,
	kaz
Richard Henderson Oct. 27, 2010, 2:16 p.m. UTC | #6
On 10/26/2010 04:32 PM, Steve Ellcey wrote:
> 2010-10-26  Steve Ellcey  <sje@cup.hp.com>
> 
> 	* doc/tm.texi.in (TARGET_GET_RAW_RESULT_MODE): New.
> 	(TARGET_GET_RAW_ARG_MODE): New.
> 	* doc/tm.texi: Regenerate.
> 	* target.def (get_raw_result_mode): New.
> 	(get_raw_arg_mode): New.
> 	* targhooks.c (default_get_reg_raw_mode): New.
> 	* targhooks.h (default_get_reg_raw_mode): New.
> 	* builtins.c (apply_args_size): Use targetm.calls.get_raw_arg_mode.
> 	(apply_result_size): Ditto.
> 	* config/ia64/ia64.c (ia64_get_reg_raw_mode): New.
> 	(TARGET_GET_RAW_RESULT_MODE): Define.
> 	(TARGET_GET_RAW_ARG_MODE): Ditto.

The patch is fine once you've addressed Joseph's comments
re documentation placement.


r~
diff mbox

Patch

Index: doc/tm.texi
===================================================================
--- doc/tm.texi	(revision 165928)
+++ doc/tm.texi	(working copy)
@@ -3964,6 +3964,18 @@  suppresses this behavior and causes the 
 stack in its natural location.
 @end defmac
 
+@deftypefn {Target Hook} {enum machine_mode} TARGET_GET_RAW_RESULT_MODE (int @var{regno})
+This target hook returns the mode to be used when accessing raw argument
+registers in __builtin_apply_args.  Define this macro if the value
+in reg_raw_mode is not correct.
+@end deftypefn
+
+@deftypefn {Target Hook} {enum machine_mode} TARGET_GET_RAW_ARG_MODE (int @var{regno})
+This target hook returns the mode to be used when accessing raw return
+registers in __builtin_return.  Define this macro if the value
+in reg_raw_mode is not correct.
+@end deftypefn
+
 @deftypefn {Target Hook} int TARGET_RETURN_POPS_ARGS (tree @var{fundecl}, tree @var{funtype}, int @var{size})
 This target hook returns the number of bytes of its own arguments that
 a function pops on returning, or 0 if the function pops no arguments
Index: doc/tm.texi.in
===================================================================
--- doc/tm.texi.in	(revision 165928)
+++ doc/tm.texi.in	(working copy)
@@ -3958,6 +3958,18 @@  suppresses this behavior and causes the 
 stack in its natural location.
 @end defmac
 
+@hook TARGET_GET_RAW_RESULT_MODE
+This target hook returns the mode to be used when accessing raw argument
+registers in __builtin_apply_args.  Define this macro if the value
+in reg_raw_mode is not correct.
+@end deftypefn
+
+@hook TARGET_GET_RAW_ARG_MODE
+This target hook returns the mode to be used when accessing raw return
+registers in __builtin_return.  Define this macro if the value
+in reg_raw_mode is not correct.
+@end deftypefn
+
 @hook TARGET_RETURN_POPS_ARGS
 This target hook returns the number of bytes of its own arguments that
 a function pops on returning, or 0 if the function pops no arguments
Index: targhooks.c
===================================================================
--- targhooks.c	(revision 165928)
+++ targhooks.c	(working copy)
@@ -64,6 +64,7 @@  along with GCC; see the file COPYING3.  
 #include "target-def.h"
 #include "ggc.h"
 #include "hard-reg-set.h"
+#include "regs.h"
 #include "reload.h"
 #include "optabs.h"
 #include "recog.h"
@@ -1333,6 +1334,15 @@  sjlj_except_unwind_info (void)
   return UI_SJLJ;
 }
 
+/* To be used by targets where reg_raw_mode doesn't return the right
+   mode for registers used in apply_builtin_return and apply_builtin_arg.  */
+
+enum machine_mode
+default_get_reg_raw_mode(int regno)
+{
+  return reg_raw_mode[regno];
+}
+
 const struct default_options empty_optimization_table[] =
   {
     { OPT_LEVELS_NONE, 0, NULL, 0 }
Index: targhooks.h
===================================================================
--- targhooks.h	(revision 165928)
+++ targhooks.h	(working copy)
@@ -168,4 +168,6 @@  extern int default_loop_align_max_skip (
 extern int default_label_align_max_skip (rtx);
 extern int default_jump_align_max_skip (rtx);
 
+extern enum machine_mode default_get_reg_raw_mode(int);
+
 extern const struct default_options empty_optimization_table[];
Index: target.def
===================================================================
--- target.def	(revision 165928)
+++ target.def	(working copy)
@@ -1982,6 +1982,22 @@  DEFHOOK
  int, (tree fundecl, tree funtype, int size),
  default_return_pops_args)
 
+/* Return a mode wide enough to copy any function value that might be
+   returned.  */
+DEFHOOK
+(get_raw_result_mode,
+ "",
+ enum machine_mode, (int regno),
+ default_get_reg_raw_mode)
+
+/* Return a mode wide enough to copy any argument value that might be
+   passed.  */
+DEFHOOK
+(get_raw_arg_mode,
+ "",
+ enum machine_mode, (int regno),
+ default_get_reg_raw_mode)
+
 HOOK_VECTOR_END (calls)
 
 /* Return the diagnostic message string if conversion from FROMTYPE
Index: builtins.c
===================================================================
--- builtins.c	(revision 165928)
+++ builtins.c	(working copy)
@@ -1334,7 +1334,7 @@  apply_args_size (void)
       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
 	if (FUNCTION_ARG_REGNO_P (regno))
 	  {
-	    mode = reg_raw_mode[regno];
+	    mode = targetm.calls.get_raw_arg_mode (regno);
 
 	    gcc_assert (mode != VOIDmode);
 
@@ -1370,7 +1370,7 @@  apply_result_size (void)
       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
 	if (targetm.calls.function_value_regno_p (regno))
 	  {
-	    mode = reg_raw_mode[regno];
+	    mode = targetm.calls.get_raw_result_mode (regno);
 
 	    gcc_assert (mode != VOIDmode);
 
Index: config/ia64/ia64.c
===================================================================
--- config/ia64/ia64.c	(revision 165928)
+++ config/ia64/ia64.c	(working copy)
@@ -325,6 +325,7 @@  static void ia64_dwarf_handle_frame_unsp
 static tree ia64_builtin_decl (unsigned, bool);
 
 static reg_class_t ia64_preferred_reload_class (rtx, reg_class_t);
+static enum machine_mode ia64_get_reg_raw_mode (int regno);
 
 /* Table of valid machine attributes.  */
 static const struct attribute_spec ia64_attribute_table[] =
@@ -545,6 +546,10 @@  static const struct default_options ia64
 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
 #undef TARGET_MUST_PASS_IN_STACK
 #define TARGET_MUST_PASS_IN_STACK must_pass_in_stack_var_size
+#undef TARGET_GET_RAW_RESULT_MODE
+#define TARGET_GET_RAW_RESULT_MODE ia64_get_reg_raw_mode
+#undef TARGET_GET_RAW_ARG_MODE
+#define TARGET_GET_RAW_ARG_MODE ia64_get_reg_raw_mode
 
 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
 #define TARGET_GIMPLIFY_VA_ARG_EXPR ia64_gimplify_va_arg
@@ -10959,5 +10964,12 @@  ia64_dconst_0_375 (void)
   return ia64_dconst_0_375_rtx;
 }
 
+static enum machine_mode
+ia64_get_reg_raw_mode (int regno)
+{
+  if (FR_REGNO_P (regno))
+    return XFmode;
+  return default_get_reg_raw_mode(regno);
+}
 
 #include "gt-ia64.h"