aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2015-10-08 17:31:36 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2015-10-08 17:31:36 +0000
commit25662751d1b0c026bfd9790deb5c1c7cd1d2c8f9 (patch)
treeef8e9eefd18dcc6ef65b3540cfc1c2fcfbaa94aa /gcc
parent4835c97845294868e600ab765385b5c0b95157f5 (diff)
downloadgcc-25662751d1b0c026bfd9790deb5c1c7cd1d2c8f9.zip
gcc-25662751d1b0c026bfd9790deb5c1c7cd1d2c8f9.tar.gz
gcc-25662751d1b0c026bfd9790deb5c1c7cd1d2c8f9.tar.bz2
nvptx.h (struct machine_function): Add comment.
* config/nvptx/nvptx.h (struct machine_function): Add comment. * config/nvptx/nvptx.c (nvptx_declare_function_name): Functions may return pointer as well as in memory. (nvptx_output_return): Likewise. From-SVN: r228618
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/nvptx/nvptx.c33
-rw-r--r--gcc/config/nvptx/nvptx.h2
3 files changed, 22 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b22f928..b2e4f6a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-08 Nathan Sidwell <nathan@acm.org>
+
+ * config/nvptx/nvptx.h (struct machine_function): Add comment.
+ * config/nvptx/nvptx.c (nvptx_declare_function_name): Functions
+ may return pointer as well as in memory.
+ (nvptx_output_return): Likewise.
+
2015-10-08 Richard Sandiford <richard.sandiford@arm.com>
* builtins.c (fold_builtin_sqrt, fold_builtin_cbrt): Delete.
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index e9177dc..57830c3 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -531,13 +531,8 @@ nvptx_declare_function_name (FILE *file, const char *name, const_tree decl)
nvptx_write_function_decl (s, name, decl);
fprintf (file, "%s", s.str().c_str());
- bool return_in_mem = false;
- if (TYPE_MODE (result_type) != VOIDmode)
- {
- machine_mode mode = TYPE_MODE (result_type);
- if (!RETURN_IN_REG_P (mode))
- return_in_mem = true;
- }
+ bool return_in_mem = (TYPE_MODE (result_type) != VOIDmode
+ && !RETURN_IN_REG_P (TYPE_MODE (result_type)));
fprintf (file, "\n{\n");
@@ -547,9 +542,13 @@ nvptx_declare_function_name (FILE *file, const char *name, const_tree decl)
false, return_in_mem);
if (return_in_mem)
fprintf (file, "\t.reg.u%d %%ar1;\n", GET_MODE_BITSIZE (Pmode));
- else if (TYPE_MODE (result_type) != VOIDmode)
+
+ /* C++11 ABI causes us to return a reference to the passed in
+ pointer for return_in_mem. */
+ if (cfun->machine->ret_reg_mode != VOIDmode)
{
- machine_mode mode = arg_promotion (TYPE_MODE (result_type));
+ machine_mode mode = arg_promotion
+ ((machine_mode)cfun->machine->ret_reg_mode);
fprintf (file, "\t.reg%s %%retval;\n",
nvptx_ptx_type_from_mode (mode, false));
}
@@ -635,17 +634,13 @@ nvptx_declare_function_name (FILE *file, const char *name, const_tree decl)
const char *
nvptx_output_return (void)
{
- tree fntype = TREE_TYPE (current_function_decl);
- tree result_type = TREE_TYPE (fntype);
- if (TYPE_MODE (result_type) != VOIDmode)
+ machine_mode mode = (machine_mode)cfun->machine->ret_reg_mode;
+
+ if (mode != VOIDmode)
{
- machine_mode mode = TYPE_MODE (result_type);
- if (RETURN_IN_REG_P (mode))
- {
- mode = arg_promotion (mode);
- fprintf (asm_out_file, "\tst.param%s\t[%%out_retval], %%retval;\n",
- nvptx_ptx_type_from_mode (mode, false));
- }
+ mode = arg_promotion (mode);
+ fprintf (asm_out_file, "\tst.param%s\t[%%out_retval], %%retval;\n",
+ nvptx_ptx_type_from_mode (mode, false));
}
return "ret;";
diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index 60a922a..7ba3914 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -228,7 +228,7 @@ struct GTY(()) machine_function
bool has_call_with_varargs;
bool has_call_with_sc;
HOST_WIDE_INT outgoing_stdarg_size;
- int ret_reg_mode;
+ int ret_reg_mode; /* machine_mode not defined yet. */
int punning_buffer_size;
};
#endif