From 5e617be801a07a59e464005f9e1bac1959b6cf56 Mon Sep 17 00:00:00 2001 From: Andreas Krebbel Date: Wed, 4 May 2011 12:01:21 +0000 Subject: [PATCH] calls.c (emit_library_call_value_1): Invoke promote_function_mode hook on libcall arguments. 2011-05-04 Andreas Krebbel * 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. From-SVN: r173371 --- gcc/ChangeLog | 12 ++++++++++++ gcc/calls.c | 5 +++-- gcc/config/s390/s390.c | 2 +- gcc/config/sparc/sparc.c | 6 +++--- gcc/doc/tm.texi | 2 ++ gcc/doc/tm.texi.in | 2 ++ gcc/explow.c | 17 +++++++++++++++++ gcc/targhooks.c | 2 +- 8 files changed, 41 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c77c1396a25..1f6d535c81e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2011-05-04 Andreas Krebbel + + * 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 * config/bfin/bfin.c (bfin_cpus): Update silicon revisions. diff --git a/gcc/calls.c b/gcc/calls.c index 98f3009905a..44a16ff63ff 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -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); diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index e0f98e686e3..932ad31cfb7 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -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; } diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 44ba5f77002..a3bab331910 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -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; diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 7351e8338b8..874a2237829 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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}. diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 45d5982eb7b..be84e4e84fa 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -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}. diff --git a/gcc/explow.c b/gcc/explow.c index a0a160dd2bd..da04505a7e8 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -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. */ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 93a2c305c8b..48d19a05416 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -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; } -- 2.30.2