This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ARM] hard VFP calling convention support [1/3]
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 08 Dec 2008 17:00:27 +0000
- Subject: Re: [ARM] hard VFP calling convention support [1/3]
- References: <1228755497.17641.20.camel@pc960.cambridge.arm.com>
This is the part of the patch that needs approval from another
maintainer.
* target-def.h (TARGET_LIBCALL_VALUE): New hook.
* target.h (gcc_target): Add libcall_value to table of call hooks.
* targhooks.h (default_libcall_value): Default implementation.
* targhooks.c (default_libcall_value): Likewise.
* doc/tm.texi (TARGET_LIBCALL_VALUE): Document it.
* optabs.c (expand_unop): Use it.
* expr.h (hard_libcall_value): Pass the function RTX through.
* calls.c (emit_library_call_value_1): Update call to
hard_libcall_value.
* explow.c (hard_libcall_value): Use new target hook.
Index: doc/tm.texi
===================================================================
--- doc/tm.texi (revision 142389)
+++ doc/tm.texi (working copy)
@@ -4313,6 +4313,17 @@ The definition of @code{LIBRARY_VALUE} n
data types, because none of the library functions returns such types.
@end defmac
+@deftypefn {Target Hook} rtx TARGET_LIBCALL_VALUE (enum machine_mode
+@var{mode}, rtx @var{fun})
+Define this hook if the back-end needs to know the name of the libcall
+function in order to determine where the result should be returned.
+
+The mode of the result is given by @var{mode} and the name of the called
+library function is given by @var{fun}. The hook should return an RTX
+representing the place where the library function result will be returned.
+
+If this hook is not defined, then LIBCALL_VALUE will be used.
+
@defmac FUNCTION_VALUE_REGNO_P (@var{regno})
A C expression that is nonzero if @var{regno} is the number of a hard
register in which the values of called function may come back.
Index: targhooks.c
===================================================================
--- targhooks.c (revision 142389)
+++ targhooks.c (working copy)
@@ -561,6 +561,12 @@ default_function_value (const_tree ret_t
}
rtx
+default_libcall_value (enum machine_mode mode, rtx fun ATTRIBUTE_UNUSED)
+{
+ return LIBCALL_VALUE (mode);
+}
+
+rtx
default_internal_arg_pointer (void)
{
/* If the reg that the virtual arg pointer will be translated into is
Index: targhooks.h
===================================================================
--- targhooks.h (revision 142389)
+++ targhooks.h (working copy)
@@ -87,6 +87,7 @@ extern const char *hook_invalid_arg_for_
(const_tree, const_tree, const_tree);
extern bool hook_bool_const_rtx_commutative_p (const_rtx, int);
extern rtx default_function_value (const_tree, const_tree, bool);
+extern rtx default_libcall_value (enum machine_mode, rtx);
extern rtx default_internal_arg_pointer (void);
#ifdef IRA_COVER_CLASSES
extern const enum reg_class *default_ira_cover_classes (void);
Index: optabs.c
===================================================================
--- optabs.c (revision 142389)
+++ optabs.c (working copy)
@@ -3300,7 +3300,8 @@ expand_unop (enum machine_mode mode, opt
if (unoptab == ffs_optab || unoptab == clz_optab || unoptab == ctz_optab
|| unoptab == popcount_optab || unoptab == parity_optab)
outmode
- = GET_MODE (hard_libcall_value (TYPE_MODE (integer_type_node)));
+ = GET_MODE (hard_libcall_value (TYPE_MODE (integer_type_node),
+ optab_libfunc (unoptab, mode)));
start_sequence ();
Index: target.h
===================================================================
--- target.h (revision 142389)
+++ target.h (working copy)
@@ -870,6 +870,10 @@ struct gcc_target
rtx (*function_value) (const_tree ret_type, const_tree fn_decl_or_type,
bool outgoing);
+ /* Return the rtx for the result of a libcall of mode MODE,
+ calling the function FN_NAME. */
+ rtx (*libcall_value) (enum machine_mode, rtx);
+
/* Return an rtx for the argument pointer incoming to the
current function. */
rtx (*internal_arg_pointer) (void);
Index: expr.h
===================================================================
--- expr.h (revision 142389)
+++ expr.h (working copy)
@@ -751,7 +751,7 @@ extern void probe_stack_range (HOST_WIDE
/* Return an rtx that refers to the value returned by a library call
in its original home. This becomes invalid if any more code is emitted. */
-extern rtx hard_libcall_value (enum machine_mode);
+extern rtx hard_libcall_value (enum machine_mode, rtx);
/* Return the mode desired by operand N of a particular bitfield
insert/extract insn, or MAX_MACHINE_MODE if no such insn is
Index: calls.c
===================================================================
--- calls.c (revision 142389)
+++ calls.c (working copy)
@@ -3758,7 +3758,7 @@ emit_library_call_value_1 (int retval, r
cse'ing of library calls could delete a call and leave the pop. */
NO_DEFER_POP;
valreg = (mem_value == 0 && outmode != VOIDmode
- ? hard_libcall_value (outmode) : NULL_RTX);
+ ? hard_libcall_value (outmode, orgfun) : NULL_RTX);
/* Stack must be properly aligned now. */
gcc_assert (!(stack_pointer_delta
Index: explow.c
===================================================================
--- explow.c (revision 142389)
+++ explow.c (working copy)
@@ -1491,9 +1491,9 @@ hard_function_value (const_tree valtype,
in which a scalar value of mode MODE was returned by a library call. */
rtx
-hard_libcall_value (enum machine_mode mode)
+hard_libcall_value (enum machine_mode mode, rtx fun)
{
- return LIBCALL_VALUE (mode);
+ return targetm.calls.libcall_value (mode, fun);
}
/* Look up the tree code for a given rtx code
Index: target-def.h
===================================================================
--- target-def.h (revision 142389)
+++ target-def.h (working copy)
@@ -590,6 +590,7 @@
#define TARGET_ARG_PARTIAL_BYTES hook_int_CUMULATIVE_ARGS_mode_tree_bool_0
#define TARGET_FUNCTION_VALUE default_function_value
+#define TARGET_LIBCALL_VALUE default_libcall_value
#define TARGET_INTERNAL_ARG_POINTER default_internal_arg_pointer
#define TARGET_UPDATE_STACK_BOUNDARY NULL
#define TARGET_GET_DRAP_RTX NULL
@@ -613,6 +614,7 @@
TARGET_ARG_PARTIAL_BYTES, \
TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN, \
TARGET_FUNCTION_VALUE, \
+ TARGET_LIBCALL_VALUE, \
TARGET_INTERNAL_ARG_POINTER, \
TARGET_UPDATE_STACK_BOUNDARY, \
TARGET_GET_DRAP_RTX, \