+2015-12-11 Nathan Sidwell <nathan@acm.org>
+
+ * config/nvptx/nvptx.h (RETURN_ADDR_REGNO): Delete.
+ (OUTGOING_ARG_POINTER_REGNUM): Delete.
+ (ASM_OUTPUT_COMMON, ASM_OUTPUT_LOCAL): Delete.
+ (REGISTER_NAMES): Name static chain regs.
+ * config/nvptx/nvptx.c (nvptx_function_arg): Add ARG_UNUSED, merge
+ ifs.
+ (nvptx_incoming_arg): Merge ifs.
+ (nvptx_function_arg_boundary): Reimplement to avoid mixing units.
+ (nvptx_function_value): Tail call nvptx_libcall_value.
+ (nvptx_pass_by_reference): Add ARG_UNUSED.
+ (nvptx_static_chain): Use conditional op.
+ (nvptx_handle_kernel_attribute): Use VOID_TYPE_P.
+
2015-12-11 Jan-Benedict Glaw <jbglaw@lug-owl.de>
Dominique d'Humieres <dominiq@lps.ens.fr>
/* Implement TARGET_FUNCTION_ARG. */
static rtx
-nvptx_function_arg (cumulative_args_t, machine_mode mode,
+nvptx_function_arg (cumulative_args_t ARG_UNUSED (cum_v), machine_mode mode,
const_tree, bool named)
{
- if (mode == VOIDmode)
+ if (mode == VOIDmode || !named)
return NULL_RTX;
- if (named)
- return gen_reg_rtx (mode);
- return NULL_RTX;
+ return gen_reg_rtx (mode);
}
/* Implement TARGET_FUNCTION_INCOMING_ARG. */
const_tree, bool named)
{
CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
- if (mode == VOIDmode)
- return NULL_RTX;
- if (!named)
+ if (mode == VOIDmode || !named)
return NULL_RTX;
/* No need to deal with split modes here, the only case that can
bool ARG_UNUSED (named))
{
CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
+
cum->count++;
}
nvptx_strict_argument_naming (cumulative_args_t cum_v)
{
CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
+
return cum->fntype == NULL_TREE || stdarg_p (cum->fntype);
}
{
unsigned int boundary = type ? TYPE_ALIGN (type) : GET_MODE_BITSIZE (mode);
- if (boundary > BITS_PER_WORD)
- return 2 * BITS_PER_WORD;
-
- if (mode == BLKmode)
+ if (boundary > UNITS_PER_WORD * BITS_PER_UNIT)
+ boundary = UNITS_PER_WORD * BITS_PER_UNIT;
+ else if (mode == BLKmode)
{
HOST_WIDE_INT size = int_size_in_bytes (type);
- if (size > 4)
- return 2 * BITS_PER_WORD;
- if (boundary < BITS_PER_WORD)
- {
- if (size >= 3)
- return BITS_PER_WORD;
- if (size >= 2)
- return 2 * BITS_PER_UNIT;
- }
+
+ if (size > UNITS_PER_WORD)
+ boundary = UNITS_PER_WORD;
+ else
+ {
+ /* Keep rounding up until only 1 bit set. */
+ unsigned lsb = (unsigned) size;
+
+ boundary = 0;
+ do
+ {
+ boundary += lsb;
+ lsb = boundary & -boundary;
+ }
+ while (boundary != lsb);
+ }
+ boundary *= BITS_PER_UNIT;
}
+
return boundary;
}
/* Pretend to return in a hard reg for early uses before pseudos can be
generated. */
return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM);
+
return gen_reg_rtx (mode);
}
&unsignedp, NULL_TREE, 1);
if (outgoing)
return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM);
- if (cfun->machine->start_call == NULL_RTX)
- /* Pretend to return in a hard reg for early uses before pseudos can be
- generated. */
- return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM);
- return gen_reg_rtx (mode);
+
+ return nvptx_libcall_value (mode, NULL_RTX);
}
/* Implement TARGET_FUNCTION_VALUE_REGNO_P. */
reference in memory. */
static bool
-nvptx_pass_by_reference (cumulative_args_t, machine_mode mode,
- const_tree type, bool)
+nvptx_pass_by_reference (cumulative_args_t ARG_UNUSED (cum), machine_mode mode,
+ const_tree type, bool ARG_UNUSED (named))
{
return !PASS_IN_REG_P (mode, type);
}
if (!DECL_STATIC_CHAIN (fndecl))
return NULL;
- if (incoming_p)
- return gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
- else
- return gen_rtx_REG (Pmode, OUTGOING_STATIC_CHAIN_REGNUM);
+
+ 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
error ("%qE attribute only applies to functions", name);
*no_add_attrs = true;
}
-
- else if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
+ else if (!VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
{
error ("%qE attribute requires a void return type", name);
*no_add_attrs = true;
#define NVPTX_RETURN_REGNUM 4
#define FRAME_POINTER_REGNUM 15
#define ARG_POINTER_REGNUM 14
-#define RETURN_ADDR_REGNO 13
#define STATIC_CHAIN_REGNUM 12
-#define OUTGOING_ARG_POINTER_REGNUM 11
#define OUTGOING_STATIC_CHAIN_REGNUM 10
#define FIRST_PARM_OFFSET(FNDECL) ((void)(FNDECL), 0)
#undef ASM_APP_OFF
#define ASM_APP_OFF "\t// #NO_APP \n"
-#define ASM_OUTPUT_COMMON(stream, name, size, rounded)
-#define ASM_OUTPUT_LOCAL(stream, name, size, rounded)
-
#define REGISTER_NAMES \
{ \
- "%hr0", "%outargs", "%hfp", "%hr3", "%retval", "%retval_in", "%hr6", "%hr7", \
- "%hr8", "%hr9", "%hr10", "%hr11", "%hr12", "%hr13", "%argp", "%frame" \
+ "%hr0", "%outargs", "%hfp", "%hr3", "%retval", "%hr5", "%hr6", "%hr7", \
+ "%hr8", "%hr9", "%chain_out", "%hr11", "%chain_in", "%hr13", "%argp", "%frame" \
}
#define DBX_REGISTER_NUMBER(N) N