Commit b1eb8119 by DJ Delorie Committed by DJ Delorie

mn10300.c (TARGET_DEFAULT_TARGET_FLAGS): Add MASK_PTR_A0D0.

* 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.

From-SVN: r104508
parent d06e6434
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> 2005-09-21 Uros Bizjak <uros@kss-loka.si>
PR target/22585 PR target/22585
......
...@@ -49,6 +49,7 @@ extern bool mn10300_wide_const_load_uses_clr (rtx operands[2]); ...@@ -49,6 +49,7 @@ extern bool mn10300_wide_const_load_uses_clr (rtx operands[2]);
#ifdef TREE_CODE #ifdef TREE_CODE
extern struct rtx_def *function_arg (CUMULATIVE_ARGS *, extern struct rtx_def *function_arg (CUMULATIVE_ARGS *,
enum machine_mode, tree, int); enum machine_mode, tree, int);
extern rtx mn10300_function_value (tree, tree, int);
#endif /* TREE_CODE */ #endif /* TREE_CODE */
extern void expand_prologue (void); extern void expand_prologue (void);
......
...@@ -95,7 +95,7 @@ static int mn10300_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode, ...@@ -95,7 +95,7 @@ static int mn10300_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
#undef TARGET_DEFAULT_TARGET_FLAGS #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 #undef TARGET_HANDLE_OPTION
#define TARGET_HANDLE_OPTION mn10300_handle_option #define TARGET_HANDLE_OPTION mn10300_handle_option
...@@ -1449,7 +1449,9 @@ static bool ...@@ -1449,7 +1449,9 @@ static bool
mn10300_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED) mn10300_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
{ {
/* Return values > 8 bytes in length in memory. */ /* 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; /* Flush the argument registers to the stack for a stdarg function;
...@@ -1505,7 +1507,7 @@ mn10300_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED, ...@@ -1505,7 +1507,7 @@ mn10300_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
else else
size = GET_MODE_SIZE (mode); 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 an RTX to represent where a value with mode MODE will be returned
...@@ -1598,6 +1600,37 @@ mn10300_arg_partial_bytes (CUMULATIVE_ARGS *cum, enum machine_mode mode, ...@@ -1598,6 +1600,37 @@ mn10300_arg_partial_bytes (CUMULATIVE_ARGS *cum, enum machine_mode mode,
return nregs * UNITS_PER_WORD - cum->nbytes; 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. */ /* Output a tst insn. */
const char * const char *
output_tst (rtx operand, rtx insn) output_tst (rtx operand, rtx insn)
......
...@@ -594,8 +594,9 @@ struct cum_arg {int nbytes; }; ...@@ -594,8 +594,9 @@ struct cum_arg {int nbytes; };
otherwise, FUNC is 0. */ otherwise, FUNC is 0. */
#define FUNCTION_VALUE(VALTYPE, FUNC) \ #define FUNCTION_VALUE(VALTYPE, FUNC) \
gen_rtx_REG (TYPE_MODE (VALTYPE), POINTER_TYPE_P (VALTYPE) \ mn10300_function_value (VALTYPE, FUNC, 0)
? FIRST_ADDRESS_REGNUM : FIRST_DATA_REGNUM) #define FUNCTION_OUTGOING_VALUE(VALTYPE, FUNC) \
mn10300_function_value (VALTYPE, FUNC, 1)
/* Define how to find the value returned by a library function /* Define how to find the value returned by a library function
assuming the value has mode MODE. */ assuming the value has mode MODE. */
......
...@@ -35,3 +35,7 @@ Work around hardware multiply bug ...@@ -35,3 +35,7 @@ Work around hardware multiply bug
mrelax mrelax
Target RejectNegative Target RejectNegative
Enable linker relaxations Enable linker relaxations
mreturn-pointer-on-d0
Target Report Mask(PTR_A0D0)
Return pointers in both a0 and d0
...@@ -609,6 +609,7 @@ Objective-C and Objective-C++ Dialects}. ...@@ -609,6 +609,7 @@ Objective-C and Objective-C++ Dialects}.
@gccoptlist{-mmult-bug -mno-mult-bug @gol @gccoptlist{-mmult-bug -mno-mult-bug @gol
-mam33 -mno-am33 @gol -mam33 -mno-am33 @gol
-mam33-2 -mno-am33-2 @gol -mam33-2 -mno-am33-2 @gol
-mreturn-pointer-on-d0 @gol
-mno-crt0 -mrelax} -mno-crt0 -mrelax}
@emph{MS1 Options} @emph{MS1 Options}
...@@ -10584,6 +10585,14 @@ Generate code which uses features specific to the AM33 processor. ...@@ -10584,6 +10585,14 @@ Generate code which uses features specific to the AM33 processor.
Do not generate code which uses features specific to the AM33 processor. This Do not generate code which uses features specific to the AM33 processor. This
is the default. 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 @item -mno-crt0
@opindex mno-crt0 @opindex mno-crt0
Do not link in the C run-time initialization object file. Do not link in the C run-time initialization object file.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment