+2005-09-21 DJ Delorie <dj@redhat.com>
+
+ * config/mn10300/mn10300.c (TARGET_DEFAULT_TARGET_FLAGS): Add
+ MASK_PTR_A0D0.
+ (mn10300_return_in_memory): Support variable size types also.
+ (mn10300_pass_by_reference): Likewise.
+ (mn10300_function_value): New.
+ * config/mn10300/mn10300.h (FUNCTION_VALUE): Call the above.
+ (FUNCTION_OUTGOING_VALUE): Likewise.
+ * config/mn10300/mn10300.opt: Add -mreturn-pointer-on-d0.
+ * doc/invoke.texi: Document it.
+
2005-09-21 Uros Bizjak <uros@kss-loka.si>
PR target/22585
#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
#undef TARGET_DEFAULT_TARGET_FLAGS
-#define TARGET_DEFAULT_TARGET_FLAGS MASK_MULT_BUG
+#define TARGET_DEFAULT_TARGET_FLAGS MASK_MULT_BUG | MASK_PTR_A0D0
#undef TARGET_HANDLE_OPTION
#define TARGET_HANDLE_OPTION mn10300_handle_option
mn10300_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
{
/* Return values > 8 bytes in length in memory. */
- return int_size_in_bytes (type) > 8 || TYPE_MODE (type) == BLKmode;
+ return (int_size_in_bytes (type) > 8
+ || int_size_in_bytes (type) == 0
+ || TYPE_MODE (type) == BLKmode);
}
/* Flush the argument registers to the stack for a stdarg function;
else
size = GET_MODE_SIZE (mode);
- return size > 8;
+ return (size > 8 || size == 0);
}
/* Return an RTX to represent where a value with mode MODE will be returned
return nregs * UNITS_PER_WORD - cum->nbytes;
}
+/* Return the location of the function's value. This will be either
+ $d0 for integer functions, $a0 for pointers, or a PARALLEL of both
+ $d0 and $a0 if the -mreturn-pointer-on-do flag is set. Note that
+ we only return the PARALLEL for outgoing values; we do not want
+ callers relying on this extra copy. */
+
+rtx
+mn10300_function_value (tree valtype, tree func, int outgoing)
+{
+ rtx rv;
+ enum machine_mode mode = TYPE_MODE (valtype);
+
+ if (! POINTER_TYPE_P (valtype))
+ return gen_rtx_REG (mode, FIRST_DATA_REGNUM);
+ else if (! TARGET_PTR_A0D0 || ! outgoing
+ || current_function_returns_struct)
+ return gen_rtx_REG (mode, FIRST_ADDRESS_REGNUM);
+
+ rv = gen_rtx_PARALLEL (mode, rtvec_alloc (2));
+ XVECEXP (rv, 0, 0)
+ = gen_rtx_EXPR_LIST (VOIDmode,
+ gen_rtx_REG (mode, FIRST_ADDRESS_REGNUM),
+ GEN_INT (0));
+
+ XVECEXP (rv, 0, 1)
+ = gen_rtx_EXPR_LIST (VOIDmode,
+ gen_rtx_REG (mode, FIRST_DATA_REGNUM),
+ GEN_INT (0));
+ return rv;
+}
+
/* Output a tst insn. */
const char *
output_tst (rtx operand, rtx insn)
otherwise, FUNC is 0. */
#define FUNCTION_VALUE(VALTYPE, FUNC) \
- gen_rtx_REG (TYPE_MODE (VALTYPE), POINTER_TYPE_P (VALTYPE) \
- ? FIRST_ADDRESS_REGNUM : FIRST_DATA_REGNUM)
+ mn10300_function_value (VALTYPE, FUNC, 0)
+#define FUNCTION_OUTGOING_VALUE(VALTYPE, FUNC) \
+ mn10300_function_value (VALTYPE, FUNC, 1)
/* Define how to find the value returned by a library function
assuming the value has mode MODE. */
@gccoptlist{-mmult-bug -mno-mult-bug @gol
-mam33 -mno-am33 @gol
-mam33-2 -mno-am33-2 @gol
+-mreturn-pointer-on-d0 @gol
-mno-crt0 -mrelax}
@emph{MS1 Options}
Do not generate code which uses features specific to the AM33 processor. This
is the default.
+@item -mreturn-pointer-on-d0
+@opindex mreturn-pointer-on-d0
+When generating a function which returns a pointer, return the pointer
+in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
+only in a0, and attempts to call such functions without a prototype
+would result in errors. Note that this option is on by default; use
+@option{-mno-return-pointer-on-d0} to disable it.
+
@item -mno-crt0
@opindex mno-crt0
Do not link in the C run-time initialization object file.