nvptx_init_machine_status (void)
{
struct machine_function *p = ggc_cleared_alloc<machine_function> ();
- p->ret_reg_mode = VOIDmode;
+ p->return_mode = VOIDmode;
return p;
}
static rtx
nvptx_libcall_value (machine_mode mode, const_rtx)
{
- if (cfun->machine->start_call == NULL_RTX)
+ if (!cfun->machine->doing_call)
/* Pretend to return in a hard reg for early uses before pseudos can be
generated. */
return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM);
if (outgoing)
{
- cfun->machine->ret_reg_mode = mode;
+ cfun->machine->return_mode = mode;
return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM);
}
optimization-level specific, so no caller can make use of
this data, but more importantly for us, we must ensure it
doesn't change the PTX prototype. */
- mode = (machine_mode) cfun->machine->ret_reg_mode;
+ mode = (machine_mode) cfun->machine->return_mode;
if (mode == VOIDmode)
return return_in_mem;
- /* Clear ret_reg_mode to inhibit copy of retval to non-existent
+ /* Clear return_mode to inhibit copy of retval to non-existent
retval parameter. */
- cfun->machine->ret_reg_mode = VOIDmode;
+ cfun->machine->return_mode = VOIDmode;
}
else
mode = promote_return (mode);
fprintf (file, "%s", s.str().c_str());
- if (regno_reg_rtx[OUTGOING_STATIC_CHAIN_REGNUM] != const0_rtx)
+ /* Declare a local var for outgoing varargs. */
+ if (cfun->machine->has_varadic)
+ init_frame (file, STACK_POINTER_REGNUM,
+ UNITS_PER_WORD, crtl->outgoing_args_size);
+
+ /* Declare a local variable for the frame. */
+ HOST_WIDE_INT sz = get_frame_size ();
+ if (sz || cfun->machine->has_chain)
+ init_frame (file, FRAME_POINTER_REGNUM,
+ crtl->stack_alignment_needed / BITS_PER_UNIT, sz);
+
+ if (cfun->machine->has_chain)
fprintf (file, "\t.reg.u%d %s;\n", GET_MODE_BITSIZE (Pmode),
reg_names[OUTGOING_STATIC_CHAIN_REGNUM]);
}
}
- /* Declare a local var for outgoing varargs. */
- if (cfun->machine->has_call_with_varargs)
- init_frame (file, STACK_POINTER_REGNUM,
- UNITS_PER_WORD, crtl->outgoing_args_size);
-
- /* Declare a local variable for the frame. */
- HOST_WIDE_INT sz = get_frame_size ();
- if (sz || cfun->machine->has_call_with_sc)
- init_frame (file, FRAME_POINTER_REGNUM,
- crtl->stack_alignment_needed / BITS_PER_UNIT, sz);
-
/* Emit axis predicates. */
if (cfun->machine->axis_predicate[0])
nvptx_init_axis_predicate (file,
const char *
nvptx_output_return (void)
{
- machine_mode mode = (machine_mode)cfun->machine->ret_reg_mode;
+ machine_mode mode = (machine_mode)cfun->machine->return_mode;
if (mode != VOIDmode)
fprintf (asm_out_file, "\tst.param%s\t[%s_out], %s;\n",
argument to the next call. */
static void
-nvptx_call_args (rtx arg, tree funtype)
+nvptx_call_args (rtx arg, tree fntype)
{
- if (cfun->machine->start_call == NULL_RTX)
+ if (!cfun->machine->doing_call)
{
- cfun->machine->call_args = NULL;
- cfun->machine->funtype = funtype;
- cfun->machine->start_call = const0_rtx;
+ cfun->machine->doing_call = true;
+ cfun->machine->is_varadic = false;
+ cfun->machine->num_args = 0;
+
+ if (fntype && stdarg_p (fntype))
+ {
+ cfun->machine->is_varadic = true;
+ cfun->machine->has_varadic = true;
+ cfun->machine->num_args++;
+ }
}
- if (arg == pc_rtx)
- return;
- rtx_expr_list *args_so_far = cfun->machine->call_args;
- if (REG_P (arg))
- cfun->machine->call_args = alloc_EXPR_LIST (VOIDmode, arg, args_so_far);
+ if (REG_P (arg) && arg != pc_rtx)
+ {
+ cfun->machine->num_args++;
+ cfun->machine->call_args = alloc_EXPR_LIST (VOIDmode, arg,
+ cfun->machine->call_args);
+ }
}
/* Implement the corresponding END_CALL_ARGS hook. Clear and free the
static void
nvptx_end_call_args (void)
{
- cfun->machine->start_call = NULL_RTX;
+ cfun->machine->doing_call = false;
free_EXPR_LIST_list (&cfun->machine->call_args);
}
void
nvptx_expand_call (rtx retval, rtx address)
{
- int nargs = 0;
rtx callee = XEXP (address, 0);
- rtx pat, t;
- rtvec vec;
rtx varargs = NULL_RTX;
unsigned parallel = 0;
- for (t = cfun->machine->call_args; t; t = XEXP (t, 1))
- nargs++;
-
if (!call_insn_operand (callee, Pmode))
{
callee = force_reg (Pmode, callee);
if (decl != NULL_TREE)
{
if (DECL_STATIC_CHAIN (decl))
- cfun->machine->has_call_with_sc = true;
+ cfun->machine->has_chain = true;
tree attr = get_oacc_fn_attrib (decl);
if (attr)
}
}
- if (cfun->machine->funtype
- && stdarg_p (cfun->machine->funtype))
+ unsigned nargs = cfun->machine->num_args;
+ if (cfun->machine->is_varadic)
{
varargs = gen_reg_rtx (Pmode);
emit_move_insn (varargs, stack_pointer_rtx);
- cfun->machine->has_call_with_varargs = true;
}
- vec = rtvec_alloc (nargs + 1 + (varargs ? 1 : 0));
- pat = gen_rtx_PARALLEL (VOIDmode, vec);
+ rtvec vec = rtvec_alloc (nargs + 1);
+ rtx pat = gen_rtx_PARALLEL (VOIDmode, vec);
int vec_pos = 0;
-
+
+ rtx call = gen_rtx_CALL (VOIDmode, address, const0_rtx);
rtx tmp_retval = retval;
- t = gen_rtx_CALL (VOIDmode, address, const0_rtx);
- if (retval != NULL_RTX)
+ if (retval)
{
if (!nvptx_register_operand (retval, GET_MODE (retval)))
tmp_retval = gen_reg_rtx (GET_MODE (retval));
- t = gen_rtx_SET (tmp_retval, t);
+ call = gen_rtx_SET (tmp_retval, call);
}
- XVECEXP (pat, 0, vec_pos++) = t;
+ XVECEXP (pat, 0, vec_pos++) = call;
/* Construct the call insn, including a USE for each argument pseudo
register. These will be used when printing the insn. */
for (rtx arg = cfun->machine->call_args; arg; arg = XEXP (arg, 1))
- {
- rtx this_arg = XEXP (arg, 0);
- XVECEXP (pat, 0, vec_pos++) = gen_rtx_USE (VOIDmode, this_arg);
- }
+ XVECEXP (pat, 0, vec_pos++) = gen_rtx_USE (VOIDmode, XEXP (arg, 0));
if (varargs)
XVECEXP (pat, 0, vec_pos++) = gen_rtx_USE (VOIDmode, varargs);
return false;
}
}
-
-/* Implement HARD_REGNO_MODE_OK. We barely use hard regs, but we want
- to ensure that the return register's mode isn't changed. */
-
-bool
-nvptx_hard_regno_mode_ok (int regno, machine_mode mode)
-{
- if (regno != NVPTX_RETURN_REGNUM
- || cfun == NULL || cfun->machine->ret_reg_mode == VOIDmode)
- return true;
- return mode == cfun->machine->ret_reg_mode;
-}
\f
/* Machinery to output constant initializers. When beginning an
initializer, we decide on a fragment size (which is visible in ptx
/* Mark unused regs as unused. */
int max_regs = max_reg_num ();
- for (int i = 0; i < max_regs; i++)
+ for (int i = LAST_VIRTUAL_REGISTER + 1; i < max_regs; i++)
if (REG_N_SETS (i) == 0 && REG_N_REFS (i) == 0)
regno_reg_rtx[i] = const0_rtx;