Commit 863af9a4 by Nathan Sidwell Committed by Nathan Sidwell

nvptx.c (write_func_decl_from_insn): Replace callee arg with name.

	* config/nvptx/nvptx.c (write_func_decl_from_insn): Replace callee
	arg with name.  Don't deal with split regs.  Tweak formatting.
	(nvptx_expand_call): Adjust write_func_decl_from_insn call.
	(nvptx_output_call_insn): Don't deal with split regs here.

	testsuite/
	* gcc.target/nvptx/proto-1.c: Adjust expected asm.

From-SVN: r230965
parent 5977cb07
2015-11-26 Nathan Sidwell <nathan@acm.org>
* config/nvptx/nvptx.c (write_func_decl_from_insn): Replace callee
arg with name. Don't deal with split regs. Tweak formatting.
(nvptx_expand_call): Adjust write_func_decl_from_insn call.
(nvptx_output_call_insn): Don't deal with split regs here.
2015-11-26 Matthew Wahab <matthew.wahab@arm.com> 2015-11-26 Matthew Wahab <matthew.wahab@arm.com>
* config/aarch64/aarch64-simd-builtins.def * config/aarch64/aarch64-simd-builtins.def
...@@ -719,69 +719,46 @@ nvptx_output_return (void) ...@@ -719,69 +719,46 @@ nvptx_output_return (void)
generated by emit_library_call for which no decl exists. */ generated by emit_library_call for which no decl exists. */
static void static void
write_func_decl_from_insn (std::stringstream &s, rtx result, rtx pat, write_func_decl_from_insn (std::stringstream &s, const char *name,
rtx callee) rtx result, rtx pat)
{ {
bool callprototype = register_operand (callee, Pmode); if (!name)
const char *name = "_"; {
if (!callprototype) s << "\t.callprototype ";
name = "_";
}
else
{ {
name = XSTR (callee, 0);
name = nvptx_name_replacement (name);
s << "\n// BEGIN GLOBAL FUNCTION DECL: " << name << "\n"; s << "\n// BEGIN GLOBAL FUNCTION DECL: " << name << "\n";
s << "\t.extern .func ";
} }
s << (callprototype ? "\t.callprototype\t" : "\t.extern .func ");
if (result != NULL_RTX) if (result != NULL_RTX)
{ s << "(.param"
s << "(.param"; << nvptx_ptx_type_from_mode (arg_promotion (GET_MODE (result)), false)
s << nvptx_ptx_type_from_mode (arg_promotion (GET_MODE (result)), << " %rval) ";
false);
s << " ";
if (callprototype)
s << "_";
else
s << "%out_retval";
s << ")";
}
s << name; s << name;
const char *sep = " (";
int arg_end = XVECLEN (pat, 0); int arg_end = XVECLEN (pat, 0);
for (int i = 1; i < arg_end; i++)
if (1 < arg_end)
{ {
const char *comma = ""; /* We don't have to deal with mode splitting here, as that was
s << " ("; already done when generating the call sequence. */
for (int i = 1; i < arg_end; i++) machine_mode mode = GET_MODE (XEXP (XVECEXP (pat, 0, i), 0));
{
rtx t = XEXP (XVECEXP (pat, 0, i), 0); s << sep
machine_mode mode = GET_MODE (t); << ".param"
machine_mode split = maybe_split_mode (mode); << nvptx_ptx_type_from_mode (mode, false)
int count = 1; << " %arg"
<< i;
if (split != VOIDmode) if (mode == QImode || mode == HImode)
{ s << "[1]";
mode = split; sep = ", ";
count = 2;
}
while (count--)
{
s << comma << ".param";
s << nvptx_ptx_type_from_mode (mode, false);
s << " ";
if (callprototype)
s << "_";
else
s << "%arg" << i - 1;
if (mode == QImode || mode == HImode)
s << "[1]";
comma = ", ";
}
}
s << ")";
} }
if (arg_end != 1)
s << ")";
s << ";\n"; s << ";\n";
} }
...@@ -905,10 +882,7 @@ nvptx_expand_call (rtx retval, rtx address) ...@@ -905,10 +882,7 @@ nvptx_expand_call (rtx retval, rtx address)
&& stdarg_p (cfun->machine->funtype)) && stdarg_p (cfun->machine->funtype))
{ {
varargs = gen_reg_rtx (Pmode); varargs = gen_reg_rtx (Pmode);
if (Pmode == DImode) emit_move_insn (varargs, stack_pointer_rtx);
emit_move_insn (varargs, stack_pointer_rtx);
else
emit_move_insn (varargs, stack_pointer_rtx);
cfun->machine->has_call_with_varargs = true; cfun->machine->has_call_with_varargs = true;
} }
vec = rtvec_alloc (nargs + 1 + (varargs ? 1 : 0)); vec = rtvec_alloc (nargs + 1 + (varargs ? 1 : 0));
...@@ -951,7 +925,11 @@ nvptx_expand_call (rtx retval, rtx address) ...@@ -951,7 +925,11 @@ nvptx_expand_call (rtx retval, rtx address)
if (*slot == NULL) if (*slot == NULL)
{ {
*slot = callee; *slot = callee;
write_func_decl_from_insn (func_decls, retval, pat, callee);
const char *name = XSTR (callee, 0);
if (decl_type)
name = nvptx_name_replacement (name);
write_func_decl_from_insn (func_decls, name, retval, pat);
} }
} }
...@@ -1798,7 +1776,7 @@ nvptx_assemble_undefined_decl (FILE *file, const char *name, const_tree decl) ...@@ -1798,7 +1776,7 @@ nvptx_assemble_undefined_decl (FILE *file, const char *name, const_tree decl)
const char * const char *
nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee) nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee)
{ {
char buf[256]; char buf[16];
static int labelno; static int labelno;
bool needs_tgt = register_operand (callee, Pmode); bool needs_tgt = register_operand (callee, Pmode);
rtx pat = PATTERN (insn); rtx pat = PATTERN (insn);
...@@ -1825,36 +1803,22 @@ nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee) ...@@ -1825,36 +1803,22 @@ nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee)
labelno++; labelno++;
ASM_OUTPUT_LABEL (asm_out_file, buf); ASM_OUTPUT_LABEL (asm_out_file, buf);
std::stringstream s; std::stringstream s;
write_func_decl_from_insn (s, result, pat, callee); write_func_decl_from_insn (s, NULL, result, pat);
fputs (s.str().c_str(), asm_out_file); fputs (s.str().c_str(), asm_out_file);
} }
for (int i = 1, argno = 0; i < arg_end; i++) for (int argno = 1; argno < arg_end; argno++)
{ {
rtx t = XEXP (XVECEXP (pat, 0, i), 0); rtx t = XEXP (XVECEXP (pat, 0, argno), 0);
machine_mode mode = GET_MODE (t); machine_mode mode = GET_MODE (t);
machine_mode split = maybe_split_mode (mode);
int count = 1;
if (split != VOIDmode)
{
mode = split;
count = 2;
}
for (int n = 0; n != count; n++) /* Mode splitting has already been done. */
{ fprintf (asm_out_file, "\t\t.param%s %%out_arg%d%s;\n",
fprintf (asm_out_file, "\t\t.param%s %%out_arg%d%s;\n", nvptx_ptx_type_from_mode (mode, false), argno,
nvptx_ptx_type_from_mode (mode, false), argno, mode == QImode || mode == HImode ? "[1]" : "");
mode == QImode || mode == HImode ? "[1]" : ""); fprintf (asm_out_file, "\t\tst.param%s [%%out_arg%d], %%r%d;\n",
fprintf (asm_out_file, "\t\tst.param%s [%%out_arg%d], %%r%d", nvptx_ptx_type_from_mode (mode, false), argno,
nvptx_ptx_type_from_mode (mode, false), argno, REGNO (t));
REGNO (t));
if (split != VOIDmode)
fprintf (asm_out_file, "$%d", n);
fprintf (asm_out_file, ";\n");
argno++;
}
} }
fprintf (asm_out_file, "\t\tcall "); fprintf (asm_out_file, "\t\tcall ");
...@@ -1870,31 +1834,20 @@ nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee) ...@@ -1870,31 +1834,20 @@ nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee)
else else
output_address (VOIDmode, callee); output_address (VOIDmode, callee);
if (arg_end > 1 || (decl && DECL_STATIC_CHAIN (decl))) const char *open = "(";
for (int argno = 1; argno < arg_end; argno++)
{ {
const char *comma = ""; fprintf (asm_out_file, ", %s%%out_arg%d", open, argno);
open = "";
fprintf (asm_out_file, ", (");
for (int i = 1, argno = 0; i < arg_end; i++)
{
rtx t = XEXP (XVECEXP (pat, 0, i), 0);
machine_mode mode = GET_MODE (t);
machine_mode split = maybe_split_mode (mode);
if (split != VOIDmode)
{
fprintf (asm_out_file, "%s%%out_arg%d", comma, argno++);
comma = ", ";
}
fprintf (asm_out_file, "%s%%out_arg%d", comma, argno++);
comma = ", ";
}
if (decl && DECL_STATIC_CHAIN (decl))
fprintf (asm_out_file, "%s%s", comma,
reg_names [OUTGOING_STATIC_CHAIN_REGNUM]);
fprintf (asm_out_file, ")");
} }
if (decl && DECL_STATIC_CHAIN (decl))
{
fprintf (asm_out_file, ", %s%s", open,
reg_names [OUTGOING_STATIC_CHAIN_REGNUM]);
open = "";
}
if (!open[0])
fprintf (asm_out_file, ")");
if (needs_tgt) if (needs_tgt)
{ {
...@@ -1902,10 +1855,8 @@ nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee) ...@@ -1902,10 +1855,8 @@ nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee)
assemble_name (asm_out_file, buf); assemble_name (asm_out_file, buf);
} }
fprintf (asm_out_file, ";\n"); fprintf (asm_out_file, ";\n");
if (result != NULL_RTX)
return "\tld.param%t0\t%0, [%%retval_in];\n\t}";
return "}"; return result != NULL_RTX ? "\tld.param%t0\t%0, [%%retval_in];\n\t}" : "}";
} }
/* Implement TARGET_PRINT_OPERAND_PUNCT_VALID_P. */ /* Implement TARGET_PRINT_OPERAND_PUNCT_VALID_P. */
......
2015-11-26 Nathan Sidwell <nathan@acm.org>
* gcc.target/nvptx/proto-1.c: Adjust expected asm.
2015-11-26 Richard Biener <rguenther@suse.de> 2015-11-26 Richard Biener <rguenther@suse.de>
PR testsuite/68555 PR testsuite/68555
......
...@@ -6,8 +6,8 @@ int f(void) ...@@ -6,8 +6,8 @@ int f(void)
/* Check that without an explicit prototype, we deduce from call site the /* Check that without an explicit prototype, we deduce from call site the
signature for the (mandatory in PTX) prototype. */ signature for the (mandatory in PTX) prototype. */
/* extern int acc_on_device_(int *); */ /* extern int foo (int *); */
/* { dg-final { scan-assembler-not "\\\.callprototype" } } */ /* { dg-final { scan-assembler-not "\\\.callprototype" } } */
/* { dg-final { scan-assembler "\\\.extern \\\.func \\\(\[^,\n\r\]+\\\)acc_on_device_ \\\(\[^,\n\r\]+\\\);" } } */ /* { dg-final { scan-assembler "\\\.extern \\\.func \\\(\[^,\n\r\]+\\\) foo \\\(\[^,\n\r\]+\\\);" } } */
return !acc_on_device_(&dev); return !foo(&dev);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment