===================================================================
@@ -8687,17 +8687,23 @@ s390_promote_function_mode (const_tree t
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)
-{
- if (type)
- {
- int unsignedp = TYPE_UNSIGNED (type);
- mode = promote_function_mode (type, TYPE_MODE (type), &unsignedp, fn, 1);
+static rtx
+s390_function_and_libcall_value (enum machine_mode mode,
+ const_tree ret_type,
+ const_tree fntype_or_decl,
+ bool outgoing ATTRIBUTE_UNUSED)
+{
+ /* For normal functions perform the promotion as
+ promote_function_mode would do. */
+ if (ret_type)
+ {
+ 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, co
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, co
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 nunrol
#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
===================================================================
@@ -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)
===================================================================
@@ -111,9 +111,3 @@ extern int s390_branch_condition_mask (r
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 */