/* Combine stack adjustments.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
- 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
- Free Software Foundation, Inc.
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+ 2010 Free Software Foundation, Inc.
This file is part of GCC.
#include "basic-block.h"
#include "df.h"
#include "except.h"
-#include "toplev.h"
#include "reload.h"
#include "timevar.h"
#include "tree-pass.h"
return 0;
}
-/* Adjust or create REG_FRAME_RELATED_EXPR note when merging a stack
- adjustment into a frame related insn. */
+/* If INSN has a REG_ARGS_SIZE note, move it to LAST.
+ AFTER is true iff LAST follows INSN in the instruction stream. */
static void
-adjust_frame_related_expr (rtx last_sp_set, rtx insn,
- HOST_WIDE_INT this_adjust)
+maybe_move_args_size_note (rtx last, rtx insn, bool after)
{
- rtx note = find_reg_note (last_sp_set, REG_FRAME_RELATED_EXPR, NULL_RTX);
- rtx new_expr = NULL_RTX;
+ rtx note, last_note;
- if (note == NULL_RTX && RTX_FRAME_RELATED_P (insn))
+ note = find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX);
+ if (note == NULL)
return;
- if (note
- && GET_CODE (XEXP (note, 0)) == SEQUENCE
- && XVECLEN (XEXP (note, 0), 0) >= 2)
+ last_note = find_reg_note (last, REG_ARGS_SIZE, NULL_RTX);
+ if (last_note)
{
- rtx expr = XEXP (note, 0);
- rtx last = XVECEXP (expr, 0, XVECLEN (expr, 0) - 1);
- int i;
-
- if (GET_CODE (last) == SET
- && RTX_FRAME_RELATED_P (last) == RTX_FRAME_RELATED_P (insn)
- && SET_DEST (last) == stack_pointer_rtx
- && GET_CODE (SET_SRC (last)) == PLUS
- && XEXP (SET_SRC (last), 0) == stack_pointer_rtx
- && CONST_INT_P (XEXP (SET_SRC (last), 1)))
- {
- XEXP (SET_SRC (last), 1)
- = GEN_INT (INTVAL (XEXP (SET_SRC (last), 1)) + this_adjust);
- return;
- }
-
- new_expr = gen_rtx_SEQUENCE (VOIDmode,
- rtvec_alloc (XVECLEN (expr, 0) + 1));
- for (i = 0; i < XVECLEN (expr, 0); i++)
- XVECEXP (new_expr, 0, i) = XVECEXP (expr, 0, i);
+ /* The ARGS_SIZE notes are *not* cumulative. They represent an
+ absolute value, and the "most recent" note wins. */
+ if (!after)
+ XEXP (last_note, 0) = XEXP (note, 0);
}
else
- {
- new_expr = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (2));
- if (note)
- XVECEXP (new_expr, 0, 0) = XEXP (note, 0);
- else
- {
- rtx expr = copy_rtx (single_set_for_csa (last_sp_set));
-
- XEXP (SET_SRC (expr), 1)
- = GEN_INT (INTVAL (XEXP (SET_SRC (expr), 1)) - this_adjust);
- RTX_FRAME_RELATED_P (expr) = 1;
- XVECEXP (new_expr, 0, 0) = expr;
- }
- }
-
- XVECEXP (new_expr, 0, XVECLEN (new_expr, 0) - 1)
- = copy_rtx (single_set_for_csa (insn));
- RTX_FRAME_RELATED_P (XVECEXP (new_expr, 0, XVECLEN (new_expr, 0) - 1))
- = RTX_FRAME_RELATED_P (insn);
- if (note)
- XEXP (note, 0) = new_expr;
- else
- add_reg_note (last_sp_set, REG_FRAME_RELATED_EXPR, new_expr);
+ add_reg_note (last, REG_ARGS_SIZE, XEXP (note, 0));
}
/* Subroutine of combine_stack_adjustments, called for each basic block. */
last_sp_adjust + this_adjust,
this_adjust))
{
- if (RTX_FRAME_RELATED_P (last_sp_set))
- adjust_frame_related_expr (last_sp_set, insn,
- this_adjust);
+ maybe_move_args_size_note (last_sp_set, insn, false);
+
/* It worked! */
delete_insn (insn);
last_sp_adjust += this_adjust;
last_sp_adjust + this_adjust,
-last_sp_adjust))
{
+ maybe_move_args_size_note (insn, last_sp_set, true);
+
/* It worked! */
delete_insn (last_sp_set);
last_sp_set = insn;
static bool
gate_handle_stack_adjustments (void)
{
- return (optimize > 0);
+ return flag_combine_stack_adjustments;
}
static unsigned int
0, /* properties_destroyed */
0, /* todo_flags_start */
TODO_df_finish | TODO_verify_rtl_sharing |
- TODO_dump_func |
TODO_ggc_collect, /* todo_flags_finish */
}
};