From patchwork Tue Oct 26 20:32:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 69291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E9D2DB70AF for ; Wed, 27 Oct 2010 07:32:59 +1100 (EST) Received: (qmail 5088 invoked by alias); 26 Oct 2010 20:32:41 -0000 Received: (qmail 5063 invoked by uid 22791); 26 Oct 2010 20:32:31 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from g5t0007.atlanta.hp.com (HELO g5t0007.atlanta.hp.com) (15.192.0.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Oct 2010 20:32:23 +0000 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g5t0007.atlanta.hp.com (Postfix) with ESMTP id 8C5BD142F7; Tue, 26 Oct 2010 20:32:21 +0000 (UTC) Received: from hpsje.cup.hp.com (hpsje.cup.hp.com [16.89.92.85]) by g5t0030.atlanta.hp.com (Postfix) with SMTP id E018614142; Tue, 26 Oct 2010 20:32:20 +0000 (UTC) Received: (nullmailer pid 31168 invoked by uid 437); Tue, 26 Oct 2010 20:32:20 -0000 From: Steve Ellcey To: gcc-patches@gcc.gnu.org Cc: aoliva@redhat.com, kkojima@gcc.gnu.org, rth@redhat.com Subject: Patch for gcc.dg/builtin-apply4.c, looking for sh port help In-Reply-To: Date: Tue, 26 Oct 2010 13:32:20 -0700 Message-Id: <1288125140.496977.31167.nullmailer@hpsje.cup.hp.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * 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. 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"