This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
v850: Add clobber of r11 in prologue when using long calls
- From: Nick Clifton <nickc at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 04 Apr 2003 11:28:43 +0100
- Subject: v850: Add clobber of r11 in prologue when using long calls
Hi Guys,
I am applying the patch below to fix the following problem:
Register r11 is used during function prologue generation by the long
call code in the v850 port, but unfortunately this fact was not
being reflected in the RTL that was generated. The patch below
fixes this problem and also makes sure that the correct prologue
pattern is selected when long calls are in use.
Cheers
Nick
2003-04-04 Nick Clifton <nickc at redhat dot com>
* config/v850/v850.c (expand_prologue): Only use register save
helper functions if long calls are not being used.
Add a clobber of r11 id using long calls.
(pattern_is_ok_for_prologue): Account for the extra clobber.
(construct_save_jarl): Likewise.
* config/v850/v850.md (prolog pattern): Do not use this pattern
for v850e's.
Index: gcc/config/v850/v850.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/v850/v850.c,v
retrieving revision 1.72
diff -c -3 -p -w -r1.72 v850.c
*** gcc/config/v850/v850.c 28 Mar 2003 08:07:03 -0000 1.72
--- gcc/config/v850/v850.c 4 Apr 2003 10:19:45 -0000
*************** expand_prologue ()
*** 1713,1725 ****
/* Save arg registers to the stack if necessary. */
else if (current_function_args_info.anonymous_args)
{
! if (TARGET_PROLOG_FUNCTION)
! {
! if (TARGET_V850E && ! TARGET_DISABLE_CALLT)
emit_insn (gen_save_r6_r9_v850e ());
! else
emit_insn (gen_save_r6_r9 ());
- }
else
{
offset = 0;
--- 1713,1722 ----
/* Save arg registers to the stack if necessary. */
else if (current_function_args_info.anonymous_args)
{
! if (TARGET_PROLOG_FUNCTION && TARGET_V850E && !TARGET_DISABLE_CALLT)
emit_insn (gen_save_r6_r9_v850e ());
! else if (TARGET_PROLOG_FUNCTION && ! TARGET_LONG_CALLS)
emit_insn (gen_save_r6_r9 ());
else
{
offset = 0;
*************** expand_prologue ()
*** 1779,1797 ****
{
save_all = gen_rtx_PARALLEL
(VOIDmode,
! rtvec_alloc (num_save + (TARGET_V850 ? 2 : 1)));
XVECEXP (save_all, 0, 0)
= gen_rtx_SET (VOIDmode,
stack_pointer_rtx,
plus_constant (stack_pointer_rtx, -alloc_stack));
- if (TARGET_V850)
- {
- XVECEXP (save_all, 0, num_save+1)
- = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, 10));
- }
-
offset = - default_stack;
for (i = 0; i < num_save; i++)
{
--- 1776,1789 ----
{
save_all = gen_rtx_PARALLEL
(VOIDmode,
! rtvec_alloc (num_save + 1
! + (TARGET_V850 ? (TARGET_LONG_CALLS ? 2 : 1) : 0)));
XVECEXP (save_all, 0, 0)
= gen_rtx_SET (VOIDmode,
stack_pointer_rtx,
plus_constant (stack_pointer_rtx, -alloc_stack));
offset = - default_stack;
for (i = 0; i < num_save; i++)
{
*************** expand_prologue ()
*** 1804,1809 ****
--- 1796,1811 ----
offset -= 4;
}
+ if (TARGET_V850)
+ {
+ XVECEXP (save_all, 0, num_save + 1)
+ = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, 10));
+
+ if (TARGET_LONG_CALLS)
+ XVECEXP (save_all, 0, num_save + 2)
+ = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, 11));
+ }
+
code = recog (save_all, NULL_RTX, NULL);
if (code >= 0)
{
*************** pattern_is_ok_for_prologue (op, mode)
*** 2631,2637 ****
*/
! for (i = 2; i < count - 1; i++)
{
rtx dest;
rtx src;
--- 2633,2639 ----
*/
! for (i = 2; i < count - (TARGET_LONG_CALLS ? 2: 1); i++)
{
rtx dest;
rtx src;
*************** pattern_is_ok_for_prologue (op, mode)
*** 2671,2683 ****
}
}
! /* Make sure that the last entry in the vector is a clobber. */
vector_element = XVECEXP (op, 0, i);
if (GET_CODE (vector_element) != CLOBBER
|| GET_CODE (XEXP (vector_element, 0)) != REG
! || REGNO (XEXP (vector_element, 0)) != 10)
return 0;
return 1;
}
--- 2673,2689 ----
}
}
! /* Make sure that the last entries in the vector are clobbers. */
! for (; i < count; i++)
! {
vector_element = XVECEXP (op, 0, i);
if (GET_CODE (vector_element) != CLOBBER
|| GET_CODE (XEXP (vector_element, 0)) != REG
! || !(REGNO (XEXP (vector_element, 0)) == 10
! || (TARGET_LONG_CALLS ? (REGNO (XEXP (vector_element, 0)) == 11) : 0 )))
return 0;
+ }
return 1;
}
*************** construct_save_jarl (op)
*** 2720,2726 ****
stack_bytes = INTVAL (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 1));
/* Each push will put 4 bytes from the stack... */
! stack_bytes += (count - 2) * 4;
/* Make sure that the amount we are popping either 0 or 16 bytes. */
if (stack_bytes != 0 && stack_bytes != -16)
--- 2726,2732 ----
stack_bytes = INTVAL (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 1));
/* Each push will put 4 bytes from the stack... */
! stack_bytes += (count - (TARGET_LONG_CALLS ? 3 : 2)) * 4;
/* Make sure that the amount we are popping either 0 or 16 bytes. */
if (stack_bytes != 0 && stack_bytes != -16)
*************** construct_save_jarl (op)
*** 2731,2737 ****
/* Now compute the bit mask of registers to push. */
mask = 0;
! for (i = 1; i < count - 1; i++)
{
rtx vector_element = XVECEXP (op, 0, i);
--- 2737,2743 ----
/* Now compute the bit mask of registers to push. */
mask = 0;
! for (i = 1; i < count - (TARGET_LONG_CALLS ? 2 : 1); i++)
{
rtx vector_element = XVECEXP (op, 0, i);
Index: gcc/config/v850/v850.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/v850/v850.md,v
retrieving revision 1.22
diff -c -3 -p -w -r1.22 v850.md
*** gcc/config/v850/v850.md 13 Mar 2003 03:30:00 -0000 1.22
--- gcc/config/v850/v850.md 4 Apr 2003 10:19:46 -0000
***************
*** 1663,1669 ****
(set (mem:SI (plus:SI (reg:SI 3)
(match_operand:SI 2 "immediate_operand" "i")))
(match_operand:SI 3 "register_is_ok_for_epilogue" "r"))])]
! "TARGET_PROLOG_FUNCTION"
"* return construct_save_jarl (operands[0]);
"
[(set (attr "length") (if_then_else (eq_attr "long_calls" "yes")
--- 1663,1669 ----
(set (mem:SI (plus:SI (reg:SI 3)
(match_operand:SI 2 "immediate_operand" "i")))
(match_operand:SI 3 "register_is_ok_for_epilogue" "r"))])]
! "TARGET_PROLOG_FUNCTION && TARGET_V850"
"* return construct_save_jarl (operands[0]);
"
[(set (attr "length") (if_then_else (eq_attr "long_calls" "yes")