From b46616fda7124e8a4b3b976255cbca66258cd152 Mon Sep 17 00:00:00 2001 From: Andreas Krebbel Date: Thu, 3 Mar 2011 12:08:21 +0000 Subject: [PATCH] s390.c (s390_function_value): Rename to ... 2011-03-03 Andreas Krebbel * config/s390/s390.c (s390_function_value): Rename to ... (s390_function_and_libcall_value): ... this. (s390_function_value): New function. (s390_libcall_value): New function. (TARGET_FUNCTION_VALUE, TARGET_LIBCALL_VALUE): Define target hooks. * config/s390/s390.h (FUNCTION_VALUE, LIBCALL_VALUE): Remove target macro definitions. * config/s390/s390-protos.h (s390_function_value): Remove prototype. From-SVN: r170649 --- gcc/ChangeLog | 12 +++++++++ gcc/config/s390/s390-protos.h | 6 ----- gcc/config/s390/s390.c | 48 ++++++++++++++++++++++++++++++----- gcc/config/s390/s390.h | 8 ------ 4 files changed, 53 insertions(+), 21 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0c8c51f033a..ede6eea09d0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2011-03-03 Andreas Krebbel + + * config/s390/s390.c (s390_function_value): Rename to ... + (s390_function_and_libcall_value): ... this. + (s390_function_value): New function. + (s390_libcall_value): New function. + (TARGET_FUNCTION_VALUE, TARGET_LIBCALL_VALUE): Define target + hooks. + * config/s390/s390.h (FUNCTION_VALUE, LIBCALL_VALUE): Remove + target macro definitions. + * config/s390/s390-protos.h (s390_function_value): Remove prototype. + 2011-03-02 Joseph Myers * config/i386/freebsd64.h (CC1_SPEC): Define. diff --git a/gcc/config/s390/s390-protos.h b/gcc/config/s390/s390-protos.h index 619d0e51dd7..94648792b31 100644 --- a/gcc/config/s390/s390-protos.h +++ b/gcc/config/s390/s390-protos.h @@ -111,9 +111,3 @@ extern int s390_branch_condition_mask (rtx); extern int s390_compare_and_branch_condition_mask (rtx); #endif /* RTX_CODE */ - -#ifdef TREE_CODE -#ifdef RTX_CODE -extern rtx s390_function_value (const_tree, const_tree, enum machine_mode); -#endif /* RTX_CODE */ -#endif /* TREE_CODE */ diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index a8c8bd94362..f43b3765032 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -8687,17 +8687,23 @@ s390_promote_function_mode (const_tree type, enum machine_mode mode, return mode; } -/* Define where to return a (scalar) value of type TYPE. - If TYPE is null, define where to return a (scalar) +/* Define where to return a (scalar) value of type RET_TYPE. + If RET_TYPE is null, define where to return a (scalar) value of mode MODE from a libcall. */ -rtx -s390_function_value (const_tree type, const_tree fn, enum machine_mode mode) +static rtx +s390_function_and_libcall_value (enum machine_mode mode, + const_tree ret_type, + const_tree fntype_or_decl, + bool outgoing ATTRIBUTE_UNUSED) { - if (type) + /* For normal functions perform the promotion as + promote_function_mode would do. */ + if (ret_type) { - int unsignedp = TYPE_UNSIGNED (type); - mode = promote_function_mode (type, TYPE_MODE (type), &unsignedp, fn, 1); + int unsignedp = TYPE_UNSIGNED (ret_type); + mode = promote_function_mode (ret_type, mode, &unsignedp, + fntype_or_decl, 1); } gcc_assert (GET_MODE_CLASS (mode) == MODE_INT || SCALAR_FLOAT_MODE_P (mode)); @@ -8710,6 +8716,10 @@ s390_function_value (const_tree type, const_tree fn, enum machine_mode mode) return gen_rtx_REG (mode, 2); else if (GET_MODE_SIZE (mode) == 2 * UNITS_PER_LONG) { + /* This case is triggered when returning a 64 bit value with + -m31 -mzarch. Although the value would fit into a single + register it has to be forced into a 32 bit register pair in + order to match the ABI. */ rtvec p = rtvec_alloc (2); RTVEC_ELT (p, 0) @@ -8723,6 +8733,26 @@ s390_function_value (const_tree type, const_tree fn, enum machine_mode mode) gcc_unreachable (); } +/* Define where to return a scalar return value of type RET_TYPE. */ + +static rtx +s390_function_value (const_tree ret_type, const_tree fn_decl_or_type, + bool outgoing) +{ + return s390_function_and_libcall_value (TYPE_MODE (ret_type), ret_type, + fn_decl_or_type, outgoing); +} + +/* Define where to return a scalar libcall return value of mode + MODE. */ + +static rtx +s390_libcall_value (enum machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED) +{ + return s390_function_and_libcall_value (mode, NULL_TREE, + NULL_TREE, true); +} + /* Create and return the va_list datatype. @@ -10694,6 +10724,10 @@ s390_loop_unroll_adjust (unsigned nunroll, struct loop *loop) #define TARGET_FUNCTION_ARG s390_function_arg #undef TARGET_FUNCTION_ARG_ADVANCE #define TARGET_FUNCTION_ARG_ADVANCE s390_function_arg_advance +#undef TARGET_FUNCTION_VALUE +#define TARGET_FUNCTION_VALUE s390_function_value +#undef TARGET_LIBCALL_VALUE +#define TARGET_LIBCALL_VALUE s390_libcall_value #undef TARGET_FIXED_CONDITION_CODE_REGS #define TARGET_FIXED_CONDITION_CODE_REGS s390_fixed_condition_code_regs diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h index abf4efcce27..105f5aa0c51 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -688,14 +688,6 @@ CUMULATIVE_ARGS; (N) == 16 || (N) == 17 || (TARGET_64BIT && ((N) == 18 || (N) == 19))) -/* Scalar return values. */ - -#define FUNCTION_VALUE(VALTYPE, FUNC) \ - s390_function_value ((VALTYPE), (FUNC), VOIDmode) - -#define LIBCALL_VALUE(MODE) \ - s390_function_value (NULL, NULL, (MODE)) - /* Only gpr 2 and fpr 0 are ever used as return registers. */ #define FUNCTION_VALUE_REGNO_P(N) ((N) == 2 || (N) == 16) -- 2.30.2