#include "cselib.h"
#include "df.h"
-extern char *reg_known_equiv_p;
-extern rtx *reg_known_value;
static regset_head reg_pending_sets_head;
static regset_head reg_pending_clobbers_head;
{
rtx addr = XEXP (mem, 0);
- if (REG_P (addr)
- && REGNO (addr) >= FIRST_PSEUDO_REGISTER
- && reg_known_value[REGNO (addr)])
- addr = reg_known_value[REGNO (addr)];
+ if (REG_P (addr) && REGNO (addr) >= FIRST_PSEUDO_REGISTER)
+ {
+ rtx t = get_reg_known_value (REGNO (addr));
+ if (t)
+ addr = t;
+ }
return rtx_addr_can_trap_p (addr);
}
\f
return 0;
if (GET_CODE (pat) == COND_EXEC)
return COND_EXEC_TEST (pat);
- if (GET_CODE (insn) != JUMP_INSN)
+ if (!JUMP_P (insn))
return 0;
if (GET_CODE (pat) != SET || SET_SRC (pat) != pc_rtx)
return 0;
static int
conditions_mutex_p (rtx cond1, rtx cond2)
{
- if (GET_RTX_CLASS (GET_CODE (cond1)) == '<'
- && GET_RTX_CLASS (GET_CODE (cond2)) == '<'
+ if (COMPARISON_P (cond1)
+ && COMPARISON_P (cond2)
&& GET_CODE (cond1) == reverse_condition (GET_CODE (cond2))
&& XEXP (cond1, 0) == XEXP (cond2, 0)
&& XEXP (cond1, 1) == XEXP (cond2, 1))
/* We can get a dependency on deleted insns due to optimizations in
the register allocation and reloading or due to splitting. Any
such dependency is useless and can be ignored. */
- if (GET_CODE (elem) == NOTE)
+ if (NOTE_P (elem))
return 0;
/* flow.c doesn't handle conditional lifetimes entirely correctly;
/* ??? add_dependence is the wrong place to be eliding dependencies,
as that forgets that the condition expressions themselves may
be dependent. */
- if (GET_CODE (insn) != CALL_INSN && GET_CODE (elem) != CALL_INSN)
+ if (!CALL_P (insn) && !CALL_P (elem))
{
cond1 = get_condition (insn);
cond2 = get_condition (elem);
No need for interblock dependences with calls, since
calls are not moved between blocks. Note: the edge where
elem is a CALL is still required. */
- if (GET_CODE (insn) == CALL_INSN
+ if (CALL_P (insn)
&& (INSN_BB (elem) != INSN_BB (insn)))
return 0;
#endif
dest = XEXP (dest, 0);
}
- if (GET_CODE (dest) == REG)
+ if (REG_P (dest))
{
regno = REGNO (dest);
/* Pseudos that are REG_EQUIV to something may be replaced
by that during reloading. We need only add dependencies for
the address in the REG_EQUIV note. */
- if (!reload_completed
- && reg_known_equiv_p[regno]
- && GET_CODE (reg_known_value[regno]) == MEM)
- sched_analyze_2 (deps, XEXP (reg_known_value[regno], 0), insn);
+ if (!reload_completed && get_reg_known_equiv_p (regno))
+ {
+ rtx t = get_reg_known_value (regno);
+ if (MEM_P (t))
+ sched_analyze_2 (deps, XEXP (t, 0), insn);
+ }
/* Don't let it cross a call after scheduling if it doesn't
already cross one. */
add_dependence_list (insn, deps->last_function_call, REG_DEP_ANTI);
}
}
- else if (GET_CODE (dest) == MEM)
+ else if (MEM_P (dest))
{
/* Writing memory. */
rtx t = dest;
/* Pseudos that are REG_EQUIV to something may be replaced
by that during reloading. We need only add dependencies for
the address in the REG_EQUIV note. */
- if (!reload_completed
- && reg_known_equiv_p[regno]
- && GET_CODE (reg_known_value[regno]) == MEM)
- sched_analyze_2 (deps, XEXP (reg_known_value[regno], 0), insn);
+ if (!reload_completed && get_reg_known_equiv_p (regno))
+ {
+ rtx t = get_reg_known_value (regno);
+ if (MEM_P (t))
+ sched_analyze_2 (deps, XEXP (t, 0), insn);
+ }
/* If the register does not already cross any calls, then add this
insn to the sched_before_next_call list so that it will still
}
for (u = deps->last_pending_memory_flush; u; u = XEXP (u, 1))
- if (GET_CODE (XEXP (u, 0)) != JUMP_INSN
+ if (!JUMP_P (XEXP (u, 0))
|| deps_may_trap_p (x))
add_dependence (insn, XEXP (u, 0), REG_DEP_ANTI);
sched_analyze_2 (deps, x, insn);
/* Mark registers CLOBBERED or used by called function. */
- if (GET_CODE (insn) == CALL_INSN)
+ if (CALL_P (insn))
{
for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
{
reg_pending_barrier = MOVE_BARRIER;
}
- if (GET_CODE (insn) == JUMP_INSN)
+ if (JUMP_P (insn))
{
rtx next;
next = next_nonnote_insn (insn);
- if (next && GET_CODE (next) == BARRIER)
+ if (next && BARRIER_P (next))
reg_pending_barrier = TRUE_BARRIER;
else
{
tmp = SET_DEST (set);
if (GET_CODE (tmp) == SUBREG)
tmp = SUBREG_REG (tmp);
- if (GET_CODE (tmp) == REG)
+ if (REG_P (tmp))
dest_regno = REGNO (tmp);
else
goto end_call_group;
tmp = SET_SRC (set);
if (GET_CODE (tmp) == SUBREG)
tmp = SUBREG_REG (tmp);
- if (GET_CODE (tmp) == REG)
+ if ((GET_CODE (tmp) == PLUS
+ || GET_CODE (tmp) == MINUS)
+ && REG_P (XEXP (tmp, 0))
+ && REGNO (XEXP (tmp, 0)) == STACK_POINTER_REGNUM
+ && dest_regno == STACK_POINTER_REGNUM)
+ src_regno = STACK_POINTER_REGNUM;
+ else if (REG_P (tmp))
src_regno = REGNO (tmp);
else
goto end_call_group;
if (src_regno < FIRST_PSEUDO_REGISTER
|| dest_regno < FIRST_PSEUDO_REGISTER)
{
- set_sched_group_p (insn);
+ /* If we are inside a post-call group right at the start of the
+ scheduling region, we must not add a dependency. */
+ if (deps->in_post_call_group_p == post_call_initial)
+ {
+ SCHED_GROUP_P (insn) = 1;
+ deps->in_post_call_group_p = post_call;
+ }
+ else
+ set_sched_group_p (insn);
CANT_MOVE (insn) = 1;
}
else
{
end_call_group:
- deps->in_post_call_group_p = false;
+ deps->in_post_call_group_p = not_post_call;
}
}
}
rtx loop_notes = 0;
if (current_sched_info->use_cselib)
- cselib_init ();
+ cselib_init (true);
+ /* Before reload, if the previous block ended in a call, show that
+ we are inside a post-call group, so as to keep the lifetimes of
+ hard registers correct. */
+ if (! reload_completed && !LABEL_P (head))
+ {
+ insn = prev_nonnote_insn (head);
+ if (insn && CALL_P (insn))
+ deps->in_post_call_group_p = post_call_initial;
+ }
for (insn = head;; insn = NEXT_INSN (insn))
{
rtx link, end_seq, r0, set;
- if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN)
+ if (NONJUMP_INSN_P (insn) || JUMP_P (insn))
{
/* Clear out the stale LOG_LINKS from flow. */
free_INSN_LIST_list (&LOG_LINKS (insn));
/* Make each JUMP_INSN a scheduling barrier for memory
references. */
- if (GET_CODE (insn) == JUMP_INSN)
+ if (JUMP_P (insn))
{
/* Keep the list a reasonable size. */
if (deps->pending_flush_length++ > MAX_PENDING_LIST_LENGTH)
sched_analyze_insn (deps, PATTERN (insn), insn, loop_notes);
loop_notes = 0;
}
- else if (GET_CODE (insn) == CALL_INSN)
+ else if (CALL_P (insn))
{
int i;
/* Before reload, begin a post-call group, so as to keep the
lifetimes of hard registers correct. */
if (! reload_completed)
- deps->in_post_call_group_p = true;
+ deps->in_post_call_group_p = post_call;
}
/* See comments on reemit_notes as to why we do this.
??? Actually, the reemit_notes just say what is done, not why. */
- if (GET_CODE (insn) == NOTE
+ if (NOTE_P (insn)
&& (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG
|| NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END
|| NOTE_LINE_NUMBER (insn) == NOTE_INSN_EH_REGION_BEG
|| NOTE_LINE_NUMBER (insn) == NOTE_INSN_EH_REGION_END)
rtx_region = GEN_INT (NOTE_EH_HANDLER (insn));
else
- rtx_region = GEN_INT (0);
+ rtx_region = const0_rtx;
loop_notes = alloc_EXPR_LIST (REG_SAVE_NOTE,
rtx_region,
the outermost libcall sequence. */
&& deps->libcall_block_tail_insn == 0
/* The sequence must start with a clobber of a register. */
- && GET_CODE (insn) == INSN
+ && NONJUMP_INSN_P (insn)
&& GET_CODE (PATTERN (insn)) == CLOBBER
- && (r0 = XEXP (PATTERN (insn), 0), GET_CODE (r0) == REG)
- && GET_CODE (XEXP (PATTERN (insn), 0)) == REG
+ && (r0 = XEXP (PATTERN (insn), 0), REG_P (r0))
+ && REG_P (XEXP (PATTERN (insn), 0))
/* The CLOBBER must also have a REG_LIBCALL note attached. */
&& (link = find_reg_note (insn, REG_LIBCALL, NULL_RTX)) != 0
&& (end_seq = XEXP (link, 0)) != 0
However, if we have enabled checking we might as well go
ahead and verify that add_dependence worked properly. */
- if (GET_CODE (from) == NOTE
+ if (NOTE_P (from)
|| INSN_DELETED_P (from)
|| (forward_dependency_cache != NULL
&& bitmap_bit_p (&forward_dependency_cache[INSN_LUID (from)],
deps->last_pending_memory_flush = 0;
deps->last_function_call = 0;
deps->sched_before_next_call = 0;
- deps->in_post_call_group_p = false;
+ deps->in_post_call_group_p = not_post_call;
deps->libcall_block_tail_insn = 0;
}