]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tm.texi (TARGET_PROMOTE_FUNCTION_MODE): Add documentation for for_return == 2.
authorPaolo Bonzini <bonzini@gnu.org>
Wed, 12 Aug 2009 16:23:12 +0000 (16:23 +0000)
committerPaolo Bonzini <bonzini@gcc.gnu.org>
Wed, 12 Aug 2009 16:23:12 +0000 (16:23 +0000)
2009-08-12  Paolo Bonzini  <bonzini@gnu.org>

* doc/tm.texi (TARGET_PROMOTE_FUNCTION_MODE): Add documentation
for for_return == 2.
* function.c (assign_parm_setup_reg): Use for_return == 2, improve
comments.
* calls.c (expand_call): Fix typo.
* explow.c (promote_decl_mode): Use for_return == 2 for RESULT_DECL
and PARM_DECL.
* stmt.c (expand_value_return): Use promote_function_mode to copy out
of pseudo.
* targhooks.c (default_promote_function_mode): Handle for_return == 2.
* config/cris/cris.c (cris_promote_function_mode): Likewise.
* config/mmix/mmix.c (mmix_promote_function_mode): Likewise.
* config/pa/pa.c (pa_promote_function_mode): Likewise.

From-SVN: r150700

gcc/ChangeLog
gcc/calls.c
gcc/config/cris/cris.c
gcc/config/mmix/mmix.c
gcc/config/pa/pa.c
gcc/doc/tm.texi
gcc/explow.c
gcc/function.c
gcc/stmt.c
gcc/targhooks.c

index 13788c3e851ac0db44d81d4c38a056394c02294c..8cea1ba72fe9ae09db226de1007c0ab723fdcbe2 100644 (file)
@@ -1,3 +1,19 @@
+2009-08-12  Paolo Bonzini  <bonzini@gnu.org>
+
+       * doc/tm.texi (TARGET_PROMOTE_FUNCTION_MODE): Add documentation
+       for for_return == 2.
+       * function.c (assign_parm_setup_reg): Use for_return == 2, improve
+       comments.
+       * calls.c (expand_call): Fix typo.
+       * explow.c (promote_decl_mode): Use for_return == 2 for RESULT_DECL
+       and PARM_DECL.
+       * stmt.c (expand_value_return): Use promote_function_mode to copy out
+       of pseudo.
+       * targhooks.c (default_promote_function_mode): Handle for_return == 2.
+       * config/cris/cris.c (cris_promote_function_mode): Likewise.
+       * config/mmix/mmix.c (mmix_promote_function_mode): Likewise.
+       * config/pa/pa.c (pa_promote_function_mode): Likewise.
+
 2009-08-11  Andrew Haley  <aph@redhat.com>
 
        * config/arm/arm.c (arm_init_libfuncs): Add __sync_synchronize.
index 7ad5b099db1f26680e73aafdbf357227236bad25..cdb934a2785a4234842701115571c07d447e5896 100644 (file)
@@ -2353,9 +2353,9 @@ expand_call (tree exp, rtx target, int ignore)
                                 &caller_unsignedp,
                                 TREE_TYPE (current_function_decl), 1);
       callee_promoted_mode
-       = promote_function_mode (TREE_TYPE (caller_res), callee_mode,
+       = promote_function_mode (TREE_TYPE (funtype), callee_mode,
                                 &callee_unsignedp,
-                                TREE_TYPE (funtype), 1);
+                                funtype, 1);
       if (caller_mode != VOIDmode
          && (caller_promoted_mode != callee_promoted_mode
              || ((caller_mode != caller_promoted_mode
index a9fe9dee52f58b95c098cc6998c9de8d8214d915..6b3fd0fcfca1523c342ea8d9cc0b1d47a35eef3f 100644 (file)
@@ -3771,7 +3771,7 @@ cris_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
   /* Defining PROMOTE_FUNCTION_RETURN in gcc-2.7.2 uncovered bug 981110 (even
      when modifying FUNCTION_VALUE to return the promoted mode).  Maybe
      pointless as of now, but let's keep the old behavior.  */
-  if (for_return)
+  if (for_return == 1)
     return mode;
   return CRIS_PROMOTED_MODE (mode, *punsignedp, type);
 } 
index 9e94279b85a0b0a2793f533f7e77fb6e979cce34..8521f374f81089c91c39c3a692de92f0744a67bb 100644 (file)
@@ -2701,7 +2701,7 @@ mmix_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
 {
   /* Apparently not doing TRT if int < register-size.  FIXME: Perhaps
      FUNCTION_VALUE and LIBCALL_VALUE needs tweaking as some ports say.  */
-  if (for_return)
+  if (for_return == 1)
     return mode;
 
   /* Promotion of modes currently generates slow code, extending before
index e60ddde05350919e2ca5b61152d08783a25fc02a..c5543ef1195991649f235eaedd5bfbd11510b79e 100644 (file)
@@ -9199,7 +9199,7 @@ pa_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
                           const_tree fntype ATTRIBUTE_UNUSED,
                           int for_return)
 {
-  if (!for_return)
+  if (for_return == 0)
     return mode;
   return promote_mode (type, mode, punsignedp);
 }
index 34c81c9e15c234f8395d85c52780d2e9a5990fe7..df4973d83686d8b69eecf9c278437bdb75918c36 100644 (file)
@@ -1046,13 +1046,17 @@ and possibly change @code{*@var{punsignedp}} if the promotion should
 change signedness.  This function is called only for scalar @emph{or
 pointer} types.
 
+@var{for_return} allows to distinguish the promotion of arguments and
+return values.  If it is @code{1}, a return value is being promoted and
+@code{TARGET_FUNCTION_VALUE} must perform the same promotions done here.
+If it is @code{2}, the returned mode should be that of the register in
+which an incoming parameter is copied, or the outgoing result is computed;
+then the hook should return the same mode as @code{promote_mode}, though
+the signedness may be different.
+
 The default is to not promote arguments and return values.  You can
 also define the hook to @code{default_promote_function_mode_always_promote}
 if you would like to apply the same rules given by @code{PROMOTE_MODE}.
-
-@var{for_return} allows to distinguish the promotion of arguments and
-return values.  If this target hook promotes return values,
-@code{TARGET_FUNCTION_VALUE} must perform the same promotions done here.
 @end deftypefn
 
 @defmac PARM_BOUNDARY
index 7388a455b1dfcfa8cf3bc15fbbbacde722125648..933eac81bb143b7c356b702573de81038a671aa0 100644 (file)
@@ -825,12 +825,10 @@ promote_decl_mode (const_tree decl, int *punsignedp)
   enum machine_mode mode = DECL_MODE (decl);
   enum machine_mode pmode;
 
-  if (TREE_CODE (decl) == RESULT_DECL)
+  if (TREE_CODE (decl) == RESULT_DECL
+      || TREE_CODE (decl) == PARM_DECL)
     pmode = promote_function_mode (type, mode, &unsignedp,
-                                   TREE_TYPE (current_function_decl), 1);
-  else if (TREE_CODE (decl) == PARM_DECL)
-    pmode = promote_function_mode (type, mode, &unsignedp,
-                                   TREE_TYPE (current_function_decl), 0);
+                                   TREE_TYPE (current_function_decl), 2);
   else
     pmode = promote_mode (type, mode, &unsignedp);
 
index 2294b971547f631ea05f5507277ab5a5fb084748..b1d467c57872f517d872c2021076eb5ec765d568 100644 (file)
@@ -2770,13 +2770,11 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm,
   bool did_conversion = false;
 
   /* Store the parm in a pseudoregister during the function, but we may
-     need to do it in a wider mode.  */
-
-  /* This is not really promoting for a call.  However we need to be
-     consistent with assign_parm_find_data_types and expand_expr_real_1.  */
+     need to do it in a wider mode.  Using 2 here makes the result
+     consistent with promote_decl_mode and thus expand_expr_real_1.  */
   promoted_nominal_mode
     = promote_function_mode (data->nominal_type, data->nominal_mode, &unsignedp,
-                            TREE_TYPE (current_function_decl), 0);
+                            TREE_TYPE (current_function_decl), 2);
 
   parmreg = gen_reg_rtx (promoted_nominal_mode);
 
@@ -2796,7 +2794,8 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm,
 
   assign_parm_remove_parallels (data);
 
-  /* Copy the value into the register.  */
+  /* Copy the value into the register, thus bridging between
+     assign_parm_find_data_types and expand_expr_real_1.  */
   if (data->nominal_mode != data->passed_mode
       || promoted_nominal_mode != data->promoted_mode)
     {
index 29bcf870fba707f338af86d81927fb6d5dfe104f..fe60ba6715058c5aa80b0cee2da10422b58af293 100644 (file)
@@ -1511,25 +1511,24 @@ expand_naked_return (void)
 static void
 expand_value_return (rtx val)
 {
-  /* Copy the value to the return location
-     unless it's already there.  */
+  /* Copy the value to the return location unless it's already there.  */
 
   tree decl = DECL_RESULT (current_function_decl);
   rtx return_reg = DECL_RTL (decl);
   if (return_reg != val)
     {
-      int unsignedp;
+      tree funtype = TREE_TYPE (current_function_decl);
+      tree type = TREE_TYPE (decl);
+      int unsignedp = TYPE_UNSIGNED (type);
       enum machine_mode old_mode = DECL_MODE (decl);
-      enum machine_mode mode = promote_decl_mode (decl, &unsignedp);
+      enum machine_mode mode = promote_function_mode (type, old_mode,
+                                                     &unsignedp, funtype, 1);
 
       if (mode != old_mode)
        val = convert_modes (mode, old_mode, val, unsignedp);
 
       if (GET_CODE (return_reg) == PARALLEL)
-       {
-          tree type = TREE_TYPE (decl);
-         emit_group_load (return_reg, val, type, int_size_in_bytes (type));
-       }
+       emit_group_load (return_reg, val, type, int_size_in_bytes (type));
       else
        emit_move_insn (return_reg, val);
     }
index 58a9aeea4031248c1c2c07350aa7e8cb7773cda0..7535bc10ab73ba2842bccc3d08b3e8aced1ed87d 100644 (file)
@@ -119,6 +119,8 @@ default_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
                               const_tree funtype ATTRIBUTE_UNUSED,
                               int for_return ATTRIBUTE_UNUSED)
 {
+  if (for_return == 2)
+    return promote_mode (type, mode, punsignedp);
   return mode;
 }