OSDN Git Service

2011-05-04 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
authorkrebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 May 2011 12:01:21 +0000 (12:01 +0000)
committerkrebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 May 2011 12:01:21 +0000 (12:01 +0000)
* calls.c (emit_library_call_value_1): Invoke
promote_function_mode hook on libcall arguments.
* explow.c (promote_function_mode, promote_mode): Handle TYPE
argument being NULL.
* targhooks.c (default_promote_function_mode): Lisewise.
* config/s390/s390.c (s390_promote_function_mode): Likewise.
* config/sparc/sparc.c (sparc_promote_function_mode): Likewise.

* doc/tm.texi: Document that TYPE argument might be NULL.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@173371 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/calls.c
gcc/config/s390/s390.c
gcc/config/sparc/sparc.c
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/explow.c
gcc/targhooks.c

index c77c139..1f6d535 100644 (file)
@@ -1,3 +1,15 @@
+2011-05-04  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
+
+       * calls.c (emit_library_call_value_1): Invoke
+       promote_function_mode hook on libcall arguments.
+       * explow.c (promote_function_mode, promote_mode): Handle TYPE
+       argument being NULL.
+       * targhooks.c (default_promote_function_mode): Lisewise.
+       * config/s390/s390.c (s390_promote_function_mode): Likewise.
+       * config/sparc/sparc.c (sparc_promote_function_mode): Likewise.
+
+       * doc/tm.texi: Document that TYPE argument might be NULL.
+
 2011-05-04  Stuart Henderson  <shenders@gcc.gnu.org>
 
        * config/bfin/bfin.c (bfin_cpus): Update silicon revisions.
index 98f3009..44a16ff 100644 (file)
@@ -3477,6 +3477,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
     {
       rtx val = va_arg (p, rtx);
       enum machine_mode mode = (enum machine_mode) va_arg (p, int);
+      int unsigned_p = 0;
 
       /* We cannot convert the arg value to the mode the library wants here;
         must do it earlier where we know the signedness of the arg.  */
@@ -3524,9 +3525,9 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
          val = force_operand (XEXP (slot, 0), NULL_RTX);
        }
 
-      argvec[count].value = val;
+      mode = promote_function_mode (NULL_TREE, mode, &unsigned_p, NULL_TREE, 0);
       argvec[count].mode = mode;
-
+      argvec[count].value = convert_modes (mode, GET_MODE (val), val, unsigned_p);
       argvec[count].reg = targetm.calls.function_arg (&args_so_far, mode,
                                                      NULL_TREE, true);
 
index e0f98e6..932ad31 100644 (file)
@@ -8742,7 +8742,7 @@ s390_promote_function_mode (const_tree type, enum machine_mode mode,
   if (INTEGRAL_MODE_P (mode)
       && GET_MODE_SIZE (mode) < UNITS_PER_LONG)
     {
-      if (POINTER_TYPE_P (type))
+      if (type != NULL_TREE && POINTER_TYPE_P (type))
        *punsignedp = POINTERS_EXTEND_UNSIGNED;
       return Pmode;
     }
index 44ba5f7..a3bab33 100644 (file)
@@ -4983,13 +4983,13 @@ init_cumulative_args (struct sparc_args *cum, tree fntype,
 /* Handle promotion of pointer and integer arguments.  */
 
 static enum machine_mode
-sparc_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
+sparc_promote_function_mode (const_tree type,
                              enum machine_mode mode,
-                             int *punsignedp ATTRIBUTE_UNUSED,
+                             int *punsignedp,
                              const_tree fntype ATTRIBUTE_UNUSED,
                              int for_return ATTRIBUTE_UNUSED)
 {
-  if (POINTER_TYPE_P (type))
+  if (type != NULL_TREE && POINTER_TYPE_P (type))
     {
       *punsignedp = POINTERS_EXTEND_UNSIGNED;
       return Pmode;
index 7351e83..874a223 100644 (file)
@@ -962,6 +962,8 @@ 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.
 
+@var{type} can be NULL when promoting function arguments of libcalls.
+
 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}.
index 45d5982..be84e4e 100644 (file)
@@ -952,6 +952,8 @@ 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.
 
+@var{type} can be NULL when promoting function arguments of libcalls.
+
 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}.
index a0a160d..da04505 100644 (file)
@@ -771,6 +771,17 @@ enum machine_mode
 promote_function_mode (const_tree type, enum machine_mode mode, int *punsignedp,
                       const_tree funtype, int for_return)
 {
+  /* Called without a type node for a libcall.  */
+  if (type == NULL_TREE)
+    {
+      if (INTEGRAL_MODE_P (mode))
+       return targetm.calls.promote_function_mode (NULL_TREE, mode,
+                                                   punsignedp, funtype,
+                                                   for_return);
+      else
+       return mode;
+    }
+
   switch (TREE_CODE (type))
     {
     case INTEGER_TYPE:   case ENUMERAL_TYPE:   case BOOLEAN_TYPE:
@@ -791,6 +802,12 @@ enum machine_mode
 promote_mode (const_tree type ATTRIBUTE_UNUSED, enum machine_mode mode,
              int *punsignedp ATTRIBUTE_UNUSED)
 {
+  /* For libcalls this is invoked without TYPE from the backends
+     TARGET_PROMOTE_FUNCTION_MODE hooks.  Don't do anything in that
+     case.  */
+  if (type == NULL_TREE)
+    return mode;
+
   /* FIXME: this is the same logic that was there until GCC 4.4, but we
      probably want to test POINTERS_EXTEND_UNSIGNED even if PROMOTE_MODE
      is not defined.  The affected targets are M32C, S390, SPARC.  */
index 93a2c30..48d19a0 100644 (file)
@@ -124,7 +124,7 @@ default_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
                               const_tree funtype ATTRIBUTE_UNUSED,
                               int for_return ATTRIBUTE_UNUSED)
 {
-  if (for_return == 2)
+  if (type != NULL_TREE && for_return == 2)
     return promote_mode (type, mode, punsignedp);
   return mode;
 }