From 44c068aecb0ba30a25e3086e1c2dad7f6a3f8303 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 16 Dec 2015 13:51:36 +0000 Subject: [PATCH] nvptx-protos.h (nvptx_hard_regno_mode_ok): Delete. * config/nvptx/nvptx-protos.h (nvptx_hard_regno_mode_ok): Delete. * config/nvptx/nvptx.h (struct machine_function): Reimplement. Adjust all users. * config/nvptx/nvptx.c (nvptx_declare_function_name): Move stack and frame array generation earlier. (nvptx_call_args): Reimplement. (nvptx_expand_call): Adjust. (nvptx_hard_reno_mode_ok): Delete. (nvptx_reorg): Revert scan of hard regs. From-SVN: r231691 --- gcc/ChangeLog | 19 +++++- gcc/config/nvptx/nvptx-protos.h | 1 - gcc/config/nvptx/nvptx.c | 116 ++++++++++++++------------------ gcc/config/nvptx/nvptx.h | 17 ++--- 4 files changed, 76 insertions(+), 77 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0f75f85b74e..c04c01f86ea 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,11 +1,24 @@ +2015-12-16 Nathan Sidwell + + * config/nvptx/nvptx-protos.h (nvptx_hard_regno_mode_ok): Delete. + * config/nvptx/nvptx.h (struct machine_function): + Reimplement. Adjust all users. + * config/nvptx/nvptx.c (nvptx_declare_function_name): Move stack + and frame array generation earlier. + (nvptx_call_args): Reimplement. + (nvptx_expand_call): Adjust. + (nvptx_hard_reno_mode_ok): Delete. + (nvptx_reorg): Revert scan of hard regs. + 2015-12-16 Tom de Vries - * opts.c (default_options_optimization): Set fipa-pta on by default for - fopenacc. + * opts.c (default_options_optimization): Set fipa-pta on by + default for fopenacc. * passes.def: Move kernels pass group to pass_ipa_oacc. * tree-pass.h (make_pass_oacc_kernels2): Remove. (make_pass_ipa_oacc, make_pass_ipa_oacc_kernels): Declare. - * tree-ssa-loop.c (pass_oacc_kernels2, make_pass_oacc_kernels2): Remove. + * tree-ssa-loop.c (pass_oacc_kernels2, make_pass_oacc_kernels2): + Remove. (pass_ipa_oacc, pass_ipa_oacc_kernels): New pass. (make_pass_ipa_oacc, make_pass_ipa_oacc_kernels): New function. * tree-ssa-structalias.c (pass_ipa_pta::clone): New function. diff --git a/gcc/config/nvptx/nvptx-protos.h b/gcc/config/nvptx/nvptx-protos.h index 7e0c296e3f0..084ff8e9ade 100644 --- a/gcc/config/nvptx/nvptx-protos.h +++ b/gcc/config/nvptx/nvptx-protos.h @@ -41,7 +41,6 @@ extern const char *nvptx_ptx_type_from_mode (machine_mode, bool); extern const char *nvptx_output_mov_insn (rtx, rtx); extern const char *nvptx_output_call_insn (rtx_insn *, rtx, rtx); extern const char *nvptx_output_return (void); -extern bool nvptx_hard_regno_mode_ok (int, machine_mode); extern rtx nvptx_maybe_convert_symbolic_operand (rtx); #endif #endif diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 0700937c815..131a45ed4e3 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -147,7 +147,7 @@ static struct machine_function * nvptx_init_machine_status (void) { struct machine_function *p = ggc_cleared_alloc (); - p->ret_reg_mode = VOIDmode; + p->return_mode = VOIDmode; return p; } @@ -487,7 +487,7 @@ nvptx_strict_argument_naming (cumulative_args_t cum_v) 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); @@ -506,7 +506,7 @@ nvptx_function_value (const_tree type, const_tree ARG_UNUSED (func), if (outgoing) { - cfun->machine->ret_reg_mode = mode; + cfun->machine->return_mode = mode; return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM); } @@ -678,14 +678,14 @@ write_return_type (std::stringstream &s, bool for_proto, tree type) 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); @@ -989,7 +989,18 @@ nvptx_declare_function_name (FILE *file, const char *name, const_tree decl) 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]); @@ -1010,17 +1021,6 @@ nvptx_declare_function_name (FILE *file, const char *name, const_tree decl) } } - /* 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, @@ -1036,7 +1036,7 @@ nvptx_declare_function_name (FILE *file, const char *name, const_tree decl) 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", @@ -1076,20 +1076,28 @@ nvptx_get_drap_rtx (void) 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; - } - if (arg == pc_rtx) - return; + cfun->machine->doing_call = true; + cfun->machine->is_varadic = false; + cfun->machine->num_args = 0; - 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 (fntype && stdarg_p (fntype)) + { + cfun->machine->is_varadic = true; + cfun->machine->has_varadic = true; + cfun->machine->num_args++; + } + } + + 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 @@ -1098,7 +1106,7 @@ nvptx_call_args (rtx arg, tree funtype) 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); } @@ -1111,16 +1119,10 @@ nvptx_end_call_args (void) 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); @@ -1133,7 +1135,7 @@ nvptx_expand_call (rtx retval, rtx address) 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) @@ -1154,35 +1156,31 @@ nvptx_expand_call (rtx retval, rtx address) } } - 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); @@ -1477,18 +1475,6 @@ nvptx_legitimate_address_p (machine_mode, rtx x, bool) 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; -} /* Machinery to output constant initializers. When beginning an initializer, we decide on a fragment size (which is visible in ptx @@ -3773,7 +3759,7 @@ nvptx_reorg (void) /* 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; diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h index b5e2b0172ab..f7230b70b7c 100644 --- a/gcc/config/nvptx/nvptx.h +++ b/gcc/config/nvptx/nvptx.h @@ -220,14 +220,15 @@ struct nvptx_args { #if defined HOST_WIDE_INT struct GTY(()) machine_function { - rtx_expr_list *call_args; - rtx start_call; - tree funtype; - bool has_call_with_varargs; - bool has_call_with_sc; - HOST_WIDE_INT outgoing_stdarg_size; - int ret_reg_mode; /* machine_mode not defined yet. */ - rtx axis_predicate[2]; + rtx_expr_list *call_args; /* Arg list for the current call. */ + bool doing_call; /* Within a CALL_ARGS ... CALL_ARGS_END sequence. */ + bool is_varadic; /* This call is varadic */ + bool has_varadic; /* Current function has a varadic call. */ + bool has_chain; /* Current function has outgoing static chain. */ + int num_args; /* Number of args of current call. */ + int return_mode; /* Return mode of current fn. + (machine_mode not defined yet.) */ + rtx axis_predicate[2]; /* Neutering predicates. */ }; #endif