]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
target.h (struct calls): Add function_value_regno_p field.
authorAnatoly Sokolov <aesok@post.ru>
Sun, 2 May 2010 10:49:10 +0000 (14:49 +0400)
committerAnatoly Sokolov <aesok@gcc.gnu.org>
Sun, 2 May 2010 10:49:10 +0000 (14:49 +0400)
* target.h (struct calls): Add function_value_regno_p field.
* target-def.h (TARGET_FUNCTION_VALUE_REGNO_P): Define.
(TARGET_INITIALIZER): Use TARGET_FUNCTION_VALUE_REGNO_P.
* targhooks.c (default_function_value_regno_p): New function.
* targhooks.h (default_function_value_regno_p): Declare function.
* rtlanal.c (keep_with_call_p): Use function_value_regno_p hook.
* builtins.c. (apply_result_size): (Ditto.).
* combine.c. (likely_spilled_retval_p): (Ditto.).
* mode-switching.c. Include 'target.h'.
(create_pre_exit): Use function_value_regno_p hook.
* Makefile.in (mode-switching.o): Add dependency on TARGET_H.
* doc/tm.texi (FUNCTION_VALUE_REGNO_P,
TARGET_FUNCTION_VALUE_REGNO_P): Revise documentation.

* config/i386/i386.h (TARGET_FUNCTION_VALUE_REGNO_P): Remove macro.
* config/i386/i386.c (TARGET_FUNCTION_VALUE_REGNO_P): Define macro.
(ix86_function_value_regno_p): Declare as static, change argument
type to const unsigned int.
* config/i386/i386-protos.h (ix86_function_value_regno_p): Remove.

From-SVN: r158970

14 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/builtins.c
gcc/combine.c
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/doc/tm.texi
gcc/mode-switching.c
gcc/rtlanal.c
gcc/target-def.h
gcc/target.h
gcc/targhooks.c
gcc/targhooks.h

index 7f636b3c90833e2884c239474f19032d46570eaa..d0122024500e71d5cbf91a3091b9f6bb91285907 100644 (file)
@@ -1,3 +1,25 @@
+2010-05-01  Anatoly Sokolov  <aesok@post.ru>
+
+       * target.h (struct calls): Add function_value_regno_p field.
+       * target-def.h (TARGET_FUNCTION_VALUE_REGNO_P): Define.
+       (TARGET_INITIALIZER): Use TARGET_FUNCTION_VALUE_REGNO_P.
+       * targhooks.c (default_function_value_regno_p): New function.
+       * targhooks.h (default_function_value_regno_p): Declare function.
+       * rtlanal.c (keep_with_call_p): Use function_value_regno_p hook.
+       * builtins.c. (apply_result_size): (Ditto.).
+       * combine.c. (likely_spilled_retval_p): (Ditto.).
+       * mode-switching.c. Include 'target.h'.
+       (create_pre_exit): Use function_value_regno_p hook.
+       * Makefile.in (mode-switching.o): Add dependency on TARGET_H.
+       * doc/tm.texi (FUNCTION_VALUE_REGNO_P,
+       TARGET_FUNCTION_VALUE_REGNO_P): Revise documentation.
+
+       * config/i386/i386.h (TARGET_FUNCTION_VALUE_REGNO_P): Remove macro.
+       * config/i386/i386.c (TARGET_FUNCTION_VALUE_REGNO_P): Define macro.
+       (ix86_function_value_regno_p): Declare as static, change argument
+       type to const unsigned int.
+       * config/i386/i386-protos.h (ix86_function_value_regno_p): Remove.
+
 2010-05-01  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/43949
index 48f2c618ea598d91cbee605243abb3b1b4ffb62f..95185da535424ad00513aafcc3caeb588f1a6bd8 100644 (file)
@@ -2991,7 +2991,7 @@ lcm.o : lcm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
 mode-switching.o : mode-switching.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) insn-config.h \
    $(INSN_ATTR_H) $(RECOG_H) $(BASIC_BLOCK_H) $(TM_P_H) $(FUNCTION_H) \
-   output.h $(TREE_PASS_H) $(TIMEVAR_H) $(REAL_H) $(DF_H)
+   output.h $(TREE_PASS_H) $(TIMEVAR_H) $(REAL_H) $(DF_H) $(TARGET_H)
 tree-ssa-dce.o : tree-ssa-dce.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
     $(RTL_H) $(TM_P_H) $(TREE_FLOW_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) $(TM_H) \
     coretypes.h $(TREE_DUMP_H) $(TREE_PASS_H) $(FLAGS_H) $(BASIC_BLOCK_H) \
index b514ae03b41be438f1e6e5d2c01252dad75265e6..5f4b7176155485cd53604361eee28baa924543fa 100644 (file)
@@ -1322,7 +1322,7 @@ apply_result_size (void)
       size = 0;
 
       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
-       if (FUNCTION_VALUE_REGNO_P (regno))
+       if (targetm.calls.function_value_regno_p (regno))
          {
            mode = reg_raw_mode[regno];
 
index 0c934457d260d532f906cde972e3c556477fecb5..303f180f790c8216222e02075e9f75ed4e38c1bd 100644 (file)
@@ -2076,14 +2076,14 @@ likely_spilled_retval_p (rtx insn)
   unsigned regno, nregs;
   /* We assume here that no machine mode needs more than
      32 hard registers when the value overlaps with a register
-     for which FUNCTION_VALUE_REGNO_P is true.  */
+     for which TARGET_FUNCTION_VALUE_REGNO_P is true.  */
   unsigned mask;
   struct likely_spilled_retval_info info;
 
   if (!NONJUMP_INSN_P (use) || GET_CODE (PATTERN (use)) != USE || insn == use)
     return 0;
   reg = XEXP (PATTERN (use), 0);
-  if (!REG_P (reg) || !FUNCTION_VALUE_REGNO_P (REGNO (reg)))
+  if (!REG_P (reg) || !targetm.calls.function_value_regno_p (REGNO (reg)))
     return 0;
   regno = REGNO (reg);
   nregs = hard_regno_nregs[regno][GET_MODE (reg)];
index 5c6140d88a0ba33212f3ce40eb47ac56945607c4..48695c080b1578c1e9d13d0a77e75ae0534fa5f5 100644 (file)
@@ -136,7 +136,6 @@ extern int ix86_attr_length_vex_default (rtx, int, int);
 extern enum machine_mode ix86_fp_compare_mode (enum rtx_code);
 
 extern rtx ix86_libcall_value (enum machine_mode);
-extern bool ix86_function_value_regno_p (int);
 extern bool ix86_function_arg_regno_p (int);
 extern int ix86_function_arg_boundary (enum machine_mode, tree);
 extern bool ix86_sol10_return_in_memory (const_tree,const_tree);
index 63545c807c8a1b3b6bcab32e468c916004f8cfed..61a619bed2a7f1d91a320f4a1b889f30a49c150b 100644 (file)
@@ -1880,6 +1880,7 @@ static bool ext_80387_constants_init = 0;
 \f
 static struct machine_function * ix86_init_machine_status (void);
 static rtx ix86_function_value (const_tree, const_tree, bool);
+static bool ix86_function_value_regno_p (const unsigned int);
 static rtx ix86_static_chain (const_tree, bool);
 static int ix86_function_regparm (const_tree, const_tree);
 static void ix86_compute_frame_layout (struct ix86_frame *);
@@ -6331,8 +6332,8 @@ ix86_function_arg_boundary (enum machine_mode mode, tree type)
 
 /* Return true if N is a possible register number of function value.  */
 
-bool
-ix86_function_value_regno_p (int regno)
+static bool
+ix86_function_value_regno_p (const unsigned int regno)
 {
   switch (regno)
     {
@@ -30656,6 +30657,9 @@ ix86_enum_va_list (int idx, const char **pname, tree *ptree)
 #undef TARGET_FUNCTION_VALUE
 #define TARGET_FUNCTION_VALUE ix86_function_value
 
+#undef TARGET_FUNCTION_VALUE_REGNO_P
+#define TARGET_FUNCTION_VALUE_REGNO_P ix86_function_value_regno_p
+
 #undef TARGET_SECONDARY_RELOAD
 #define TARGET_SECONDARY_RELOAD ix86_secondary_reload
 
index 9be3eb8cae8c604a3fc0cb819bdfbafd970f38fb..ebe32388d804d72cdf8d50214099b1fe12c6f27f 100644 (file)
@@ -1554,8 +1554,6 @@ enum reg_class
 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) \
   ix86_return_pops_args ((FUNDECL), (FUNTYPE), (SIZE))
 
-#define FUNCTION_VALUE_REGNO_P(N) ix86_function_value_regno_p (N)
-
 /* Define how to find the value returned by a library function
    assuming the value has mode MODE.  */
 
index 6582ab1cd91aa7636bcf84729d36d77496e088f5..a20d48c9f9cfa0d73659110c8035b1c190210422 100644 (file)
@@ -4461,8 +4461,26 @@ suffices:
 If the machine has register windows, so that the caller and the called
 function use different registers for the return value, this macro
 should recognize only the caller's register numbers.
+
+This macro has been deprecated.  Use @code{TARGET_FUNCTION_VALUE_REGNO_P}
+for a new target instead.
 @end defmac
 
+@deftypefn {Target Hook} bool TARGET_FUNCTION_VALUE_REGNO_P (const unsigned int @var{regno})
+A target hook that return @code{true} if @var{regno} is the number of a hard
+register in which the values of called function may come back.
+
+A register whose use for returning values is limited to serving as the
+second of a pair (for a value of type @code{double}, say) need not be
+recognized by this target hook.
+
+If the machine has register windows, so that the caller and the called
+function use different registers for the return value, this target hook
+should recognize only the caller's register numbers.
+
+If this hook is not defined, then FUNCTION_VALUE_REGNO_P will be used.
+@end deftypefn
+
 @defmac TARGET_ENUM_VA_LIST (@var{idx}, @var{pname}, @var{ptype})
 This target macro is used in function @code{c_common_nodes_and_builtins}
 to iterate through the target specific builtin types for va_list. The
index 140c513918e0b55dfcdcb6529f232c60d288aa2f..30051c6ea24f1cb1f7f45f15e07fdf91c9cb12d2 100644 (file)
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
+#include "target.h"
 #include "rtl.h"
 #include "regs.h"
 #include "hard-reg-set.h"
@@ -262,7 +263,7 @@ create_pre_exit (int n_entities, int *entity_map, const int *num_modes)
                      case USE:
                        /* Skip __builtin_apply pattern.  */
                        if (GET_CODE (XEXP (return_copy_pat, 0)) == REG
-                           && (FUNCTION_VALUE_REGNO_P
+                           && (targetm.calls.function_value_regno_p
                                (REGNO (XEXP (return_copy_pat, 0)))))
                          {
                            maybe_builtin_apply = 1;
@@ -359,7 +360,8 @@ create_pre_exit (int n_entities, int *entity_map, const int *num_modes)
                        && copy_start + copy_num <= ret_end)
                      nregs -= copy_num;
                    else if (!maybe_builtin_apply
-                            || !FUNCTION_VALUE_REGNO_P (copy_start))
+                            || !targetm.calls.function_value_regno_p
+                                (copy_start))
                      break;
                    last_insn = return_copy;
                  }
index 0e3b77bc0c9f1fbf7df79ddc86ffcb9d139ceabb..8a5df24632d324033a52967de5f24df4ad63b4af 100644 (file)
@@ -3474,7 +3474,7 @@ keep_with_call_p (const_rtx insn)
          && general_operand (SET_SRC (set), VOIDmode))
        return true;
       if (REG_P (SET_SRC (set))
-         && FUNCTION_VALUE_REGNO_P (REGNO (SET_SRC (set)))
+         && targetm.calls.function_value_regno_p (REGNO (SET_SRC (set)))
          && REG_P (SET_DEST (set))
          && REGNO (SET_DEST (set)) >= FIRST_PSEUDO_REGISTER)
        return true;
index d0566650cf78090685c89f9e05efd36267fb4692..feca6c5270c22ca3c47599227f1850cdeafa38c8 100644 (file)
 
 #define TARGET_FUNCTION_VALUE default_function_value
 #define TARGET_LIBCALL_VALUE default_libcall_value
+#define TARGET_FUNCTION_VALUE_REGNO_P default_function_value_regno_p
 #define TARGET_INTERNAL_ARG_POINTER default_internal_arg_pointer
 #define TARGET_UPDATE_STACK_BOUNDARY NULL
 #define TARGET_GET_DRAP_RTX NULL
    TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN,                     \
    TARGET_FUNCTION_VALUE,                                      \
    TARGET_LIBCALL_VALUE,                                       \
+   TARGET_FUNCTION_VALUE_REGNO_P,                              \
    TARGET_INTERNAL_ARG_POINTER,                                        \
    TARGET_UPDATE_STACK_BOUNDARY,                               \
    TARGET_GET_DRAP_RTX,                                                \
index 7729525512df890dc428ea56e1bef650a5423f68..62a1bcc3d7e3a04d37e4699451fc68894c5c7b56 100644 (file)
@@ -968,6 +968,10 @@ struct gcc_target
        calling the function FN_NAME.  */
     rtx (*libcall_value) (enum machine_mode, const_rtx);
 
+    /* Return true if REGNO is a possible register number for
+       a function value as seen by the caller.  */
+    bool (*function_value_regno_p) (const unsigned int);
+
     /* Return an rtx for the argument pointer incoming to the
        current function.  */
     rtx (*internal_arg_pointer) (void);
index 00fa5024fa1a58f9ac5805765c962292ed9f817a..8df0de421f818e69c9b9c3d86f1eb9c223b462b8 100644 (file)
@@ -619,6 +619,18 @@ default_libcall_value (enum machine_mode mode ATTRIBUTE_UNUSED,
 #endif
 }
 
+/* The default hook for TARGET_FUNCTION_VALUE_REGNO_P.  */
+
+bool
+default_function_value_regno_p (const unsigned int regno ATTRIBUTE_UNUSED)
+{
+#ifdef FUNCTION_VALUE_REGNO_P
+  return FUNCTION_VALUE_REGNO_P (regno);
+#else
+  gcc_unreachable ();
+#endif
+}
+
 rtx
 default_internal_arg_pointer (void)
 {
index 209ed79b0c8af1ac4cf6f528ab76675237a0839d..e70eef4d555ce32871dcf06233edfd0a0c46a3b8 100644 (file)
@@ -99,6 +99,7 @@ extern const char *hook_invalid_arg_for_unprototyped_fn
 extern bool hook_bool_const_rtx_commutative_p (const_rtx, int);
 extern rtx default_function_value (const_tree, const_tree, bool);
 extern rtx default_libcall_value (enum machine_mode, const_rtx);
+extern bool default_function_value_regno_p (const unsigned int);
 extern rtx default_internal_arg_pointer (void);
 extern rtx default_static_chain (const_tree, bool);
 extern void default_trampoline_init (rtx, tree, rtx);