aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBernd Schmidt <bernds@codesourcery.com>2014-11-05 12:14:36 +0000
committerBernd Schmidt <bernds@gcc.gnu.org>2014-11-05 12:14:36 +0000
commite0d14c396aaa626e054284cf96a250c7aaf907e4 (patch)
tree6ae355ca6def23b0f0cf6593b092c139fcd2f95a /gcc
parenta50fa76a9d8e3690ea563ff75d8d9cebb07208f7 (diff)
downloadgcc-e0d14c396aaa626e054284cf96a250c7aaf907e4.zip
gcc-e0d14c396aaa626e054284cf96a250c7aaf907e4.tar.gz
gcc-e0d14c396aaa626e054284cf96a250c7aaf907e4.tar.bz2
Allow a target to skip an unnecssary register return value for a struct return.
* target.def (omit_struct_return_reg): New data hook. * doc/tm.texi.in: Add @hook TARGET_OMIT_STRUCT_RETURN_REG. * doc/tm.texi: Regenerate. * function.c (expand_function_end): Use it. From-SVN: r217123
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/doc/tm.texi8
-rw-r--r--gcc/doc/tm.texi.in2
-rw-r--r--gcc/function.c4
-rw-r--r--gcc/target.def10
5 files changed, 27 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ff9ead6..74e0b0f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2014-11-05 Bernd Schmidt <bernds@codesourcery.com>
+ * target.def (omit_struct_return_reg): New data hook.
+ * doc/tm.texi.in: Add @hook TARGET_OMIT_STRUCT_RETURN_REG.
+ * doc/tm.texi: Regenerate.
+ * function.c (expand_function_end): Use it.
+
* target.def (no_register_allocation): New data hook.
* doc/tm.texi.in: Add @hook TARGET_NO_REGISTER_ALLOCATION.
* doc/tm.texi: Regenerate.
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index dbca62d..88631a1 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4371,6 +4371,14 @@ need more space than is implied by @code{FUNCTION_VALUE_REGNO_P} for
saving and restoring an arbitrary return value.
@end defmac
+@deftypevr {Target Hook} bool TARGET_OMIT_STRUCT_RETURN_REG
+Normally, when a function returns a structure by memory, the address
+is passed as an invisible pointer argument, but the compiler also
+arranges to return the address from the function like it would a normal
+pointer return value. Define this to true if that behaviour is
+undesirable on your target.
+@end deftypevr
+
@deftypefn {Target Hook} bool TARGET_RETURN_IN_MSB (const_tree @var{type})
This hook should return true if values of type @var{type} are returned
at the most significant end of a register (in other words, if they are
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index b732f1f..856e4dc 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3567,6 +3567,8 @@ need more space than is implied by @code{FUNCTION_VALUE_REGNO_P} for
saving and restoring an arbitrary return value.
@end defmac
+@hook TARGET_OMIT_STRUCT_RETURN_REG
+
@hook TARGET_RETURN_IN_MSB
@node Aggregate Return
diff --git a/gcc/function.c b/gcc/function.c
index 6d09982..91e3b2c 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5177,8 +5177,8 @@ expand_function_end (void)
If returning a structure PCC style,
the caller also depends on this value.
And cfun->returns_pcc_struct is not necessarily set. */
- if (cfun->returns_struct
- || cfun->returns_pcc_struct)
+ if ((cfun->returns_struct || cfun->returns_pcc_struct)
+ && !targetm.calls.omit_struct_return_reg)
{
rtx value_address = DECL_RTL (DECL_RESULT (current_function_decl));
tree type = TREE_TYPE (DECL_RESULT (current_function_decl));
diff --git a/gcc/target.def b/gcc/target.def
index de203c3..112f78e 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -3731,6 +3731,16 @@ structure value address at the beginning of a function. If you need\n\
to emit adjusting code, you should do it at this point.",
rtx, (tree fndecl, int incoming),
hook_rtx_tree_int_null)
+
+DEFHOOKPOD
+(omit_struct_return_reg,
+ "Normally, when a function returns a structure by memory, the address\n\
+is passed as an invisible pointer argument, but the compiler also\n\
+arranges to return the address from the function like it would a normal\n\
+pointer return value. Define this to true if that behaviour is\n\
+undesirable on your target.",
+ bool, false)
+
DEFHOOK
(return_in_memory,
"This target hook should return a nonzero value to say to return the\n\