diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-16 20:02:02 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-16 20:02:02 +0000 |
commit | 7bb66bb92f3df9a8d407e0ff8ef0e44e9c96f769 (patch) | |
tree | 1916f8f611073ba7c7aef78a028a77abab1de808 /gcc/config/nvptx/nvptx.c | |
parent | 4ac6fcc2e42683e8ad80430c8ca9d7fd945103ea (diff) | |
download | gcc-7bb66bb92f3df9a8d407e0ff8ef0e44e9c96f769.tar.gz |
* config/nvptx/nvptx.h (OUTGOING_STATIC_CHAIN_REGNUM): Remove.
(REGISTER_NAMES): Adjust.
* config/nvptx/nvptx.c (nvptx_pass_by_reference): Avoid long line.
(nvptx_static_hain): Delete.
(write_arg_mode): Don't emit initializer if argno < 0.
(write_arg_type): Fix whitespace.
(init_frame): Initialize reg to zero if frame is zero-sized.
(nvptx_declare_function_name): Use write_arg_type to emit chain
decl.
(nvptx_output_call_insn): Adjust static chain emission.
(nvptx_goacc_reduction): Make static.
(TARGET_STATIC_CHAIN): Don't override.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231718 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/nvptx/nvptx.c')
-rw-r--r-- | gcc/config/nvptx/nvptx.c | 72 |
1 files changed, 31 insertions, 41 deletions
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 131a45ed4e3..39999f250a5 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -525,8 +525,9 @@ nvptx_function_value_regno_p (const unsigned int regno) reference in memory. */ static bool -nvptx_pass_by_reference (cumulative_args_t ARG_UNUSED (cum), machine_mode mode, - const_tree type, bool ARG_UNUSED (named)) +nvptx_pass_by_reference (cumulative_args_t ARG_UNUSED (cum), + machine_mode mode, const_tree type, + bool ARG_UNUSED (named)) { return pass_in_memory (mode, type, false); } @@ -549,18 +550,6 @@ nvptx_promote_function_mode (const_tree type, machine_mode mode, return promote_arg (mode, for_return || !type || TYPE_ARG_TYPES (funtype)); } -/* Implement TARGET_STATIC_CHAIN. */ - -static rtx -nvptx_static_chain (const_tree fndecl, bool incoming_p) -{ - if (!DECL_STATIC_CHAIN (fndecl)) - return NULL; - - return gen_rtx_REG (Pmode, (incoming_p ? STATIC_CHAIN_REGNUM - : OUTGOING_STATIC_CHAIN_REGNUM)); -} - /* Helper for write_arg. Emit a single PTX argument of MODE, either in a prototype, or as copy in a function prologue. ARGNO is the index of this argument in the PTX function. FOR_REG is negative, @@ -588,12 +577,15 @@ write_arg_mode (std::stringstream &s, int for_reg, int argno, else s << "%ar" << argno; s << ";\n"; - s << "\tld.param" << ptx_type << " "; - if (for_reg) - s << reg_names[for_reg]; - else - s << "%ar" << argno; - s << ", [%in_ar" << argno << "];\n"; + if (argno >= 0) + { + s << "\tld.param" << ptx_type << " "; + if (for_reg) + s << reg_names[for_reg]; + else + s << "%ar" << argno; + s << ", [%in_ar" << argno << "];\n"; + } } return argno + 1; } @@ -625,7 +617,7 @@ write_arg_type (std::stringstream &s, int for_reg, int argno, { /* Complex types are sent as two separate args. */ type = TREE_TYPE (type); - mode = TYPE_MODE (type); + mode = TYPE_MODE (type); prototyped = true; } @@ -917,16 +909,20 @@ nvptx_maybe_record_fnsym (rtx sym) } /* Emit a local array to hold some part of a conventional stack frame - and initialize REGNO to point to it. */ + and initialize REGNO to point to it. If the size is zero, it'll + never be valid to dereference, so we can simply initialize to + zero. */ static void init_frame (FILE *file, int regno, unsigned align, unsigned size) { - fprintf (file, "\t.reg.u%d %s;\n" - "\t.local.align %d .b8 %s_ar[%u];\n" - "\tcvta.local.u%d %s, %s_ar;\n", - POINTER_SIZE, reg_names[regno], - align, reg_names[regno], size ? size : 1, + if (size) + fprintf (file, "\t.local .align %d .b8 %s_ar[%u];\n", + align, reg_names[regno], size); + fprintf (file, "\t.reg.u%d %s;\n", + POINTER_SIZE, reg_names[regno]); + fprintf (file, (size ? "\tcvta.local.u%d %s, %s_ar;\n" + : "\tmov.u%d %s, 0;\n"), POINTER_SIZE, reg_names[regno], reg_names[regno]); } @@ -981,12 +977,14 @@ nvptx_declare_function_name (FILE *file, const char *name, const_tree decl) } if (stdarg_p (fntype)) - argno = write_arg_type (s, ARG_POINTER_REGNUM, argno, ptr_type_node, true); - - if (DECL_STATIC_CHAIN (decl)) - argno = write_arg_type (s, STATIC_CHAIN_REGNUM, argno, ptr_type_node, + argno = write_arg_type (s, ARG_POINTER_REGNUM, argno, ptr_type_node, true); + if (DECL_STATIC_CHAIN (decl) || cfun->machine->has_chain) + write_arg_type (s, STATIC_CHAIN_REGNUM, + DECL_STATIC_CHAIN (decl) ? argno : -1, ptr_type_node, + true); + fprintf (file, "%s", s.str().c_str()); /* Declare a local var for outgoing varargs. */ @@ -1000,10 +998,6 @@ nvptx_declare_function_name (FILE *file, const char *name, const_tree decl) 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 the pseudos we have as ptx registers. */ int maxregs = max_reg_num (); for (int i = LAST_VIRTUAL_REGISTER + 1; i < maxregs; i++) @@ -1864,8 +1858,7 @@ nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee) } if (decl && DECL_STATIC_CHAIN (decl)) { - fprintf (asm_out_file, ", %s%s", open, - reg_names [OUTGOING_STATIC_CHAIN_REGNUM]); + fprintf (asm_out_file, ", %s%s", open, reg_names [STATIC_CHAIN_REGNUM]); open = ""; } if (!open[0]) @@ -4779,7 +4772,7 @@ nvptx_goacc_reduction_teardown (gcall *call) /* NVPTX reduction expander. */ -void +static void nvptx_goacc_reduction (gcall *call) { unsigned code = (unsigned)TREE_INT_CST_LOW (gimple_call_arg (call, 0)); @@ -4845,9 +4838,6 @@ nvptx_goacc_reduction (gcall *call) #define TARGET_OMIT_STRUCT_RETURN_REG true #undef TARGET_STRICT_ARGUMENT_NAMING #define TARGET_STRICT_ARGUMENT_NAMING nvptx_strict_argument_naming -#undef TARGET_STATIC_CHAIN -#define TARGET_STATIC_CHAIN nvptx_static_chain - #undef TARGET_CALL_ARGS #define TARGET_CALL_ARGS nvptx_call_args #undef TARGET_END_CALL_ARGS |