Commit 614d5bd8 by Alan Modra Committed by Alan Modra

function.h (struct emit_status): Delete x_first_insn, x_last_insn and sequence_stack.

	* function.h (struct emit_status): Delete x_first_insn, x_last_insn
	and sequence_stack.  Add seq.
	(seq_stack): Delete.
	* function.c (prepare_function_start): Don't access x_last_insn.
	* emit-rtl.h (get_current_sequence, get_topmost_sequence): New.
	(get_insns, set_first_insn, get_last_insn, set_last_insn): Use them.
	* emit_rtl.c (start_sequence, push_topmost_sequence,
	pop_topmost_sequence, end_sequence, in_sequence_p, init_emit): Use
	sequence accessors.
	(get_last_insn_anywhere, add_insn_after_nobb, add_insn_before_nobb,
	remove_insn): Likewise.  Simplify.
	* config/m32c/m32c.c (m32c_leaf_function_p): Use push_topmost_sequence
	and pop_topmost_sequence.
	(m32c_function_needs_enter): Use get_topmost_sequence.  Ignore
	debug insns.
	* config/rs6000/rs6000.c (rs6000_call_aix): Use get_current_sequence.

From-SVN: r222112
parent 241cbc7a
2015-04-15 Alan Modra <amodra@gmail.com>
* function.h (struct emit_status): Delete x_first_insn, x_last_insn
and sequence_stack. Add seq.
(seq_stack): Delete.
* function.c (prepare_function_start): Don't access x_last_insn.
* emit-rtl.h (get_current_sequence, get_topmost_sequence): New.
(get_insns, set_first_insn, get_last_insn, set_last_insn): Use them.
* emit_rtl.c (start_sequence, push_topmost_sequence,
pop_topmost_sequence, end_sequence, in_sequence_p, init_emit): Use
sequence accessors.
(get_last_insn_anywhere, add_insn_after_nobb, add_insn_before_nobb,
remove_insn): Likewise. Simplify.
* config/m32c/m32c.c (m32c_leaf_function_p): Use push_topmost_sequence
and pop_topmost_sequence.
(m32c_function_needs_enter): Use get_topmost_sequence. Ignore
debug insns.
* config/rs6000/rs6000.c (rs6000_call_aix): Use get_current_sequence.
2015-04-14 Yvan Roux <yvan.roux@linaro.org> 2015-04-14 Yvan Roux <yvan.roux@linaro.org>
PR target/65729 PR target/65729
......
...@@ -4056,24 +4056,11 @@ m32c_encode_section_info (tree decl, rtx rtl, int first) ...@@ -4056,24 +4056,11 @@ m32c_encode_section_info (tree decl, rtx rtl, int first)
static int static int
m32c_leaf_function_p (void) m32c_leaf_function_p (void)
{ {
rtx_insn *saved_first, *saved_last;
struct sequence_stack *seq;
int rv; int rv;
saved_first = crtl->emit.x_first_insn; push_topmost_sequence ();
saved_last = crtl->emit.x_last_insn;
for (seq = crtl->emit.sequence_stack; seq && seq->next; seq = seq->next)
;
if (seq)
{
crtl->emit.x_first_insn = seq->first;
crtl->emit.x_last_insn = seq->last;
}
rv = leaf_function_p (); rv = leaf_function_p ();
pop_topmost_sequence ();
crtl->emit.x_first_insn = saved_first;
crtl->emit.x_last_insn = saved_last;
return rv; return rv;
} }
...@@ -4084,23 +4071,17 @@ static bool ...@@ -4084,23 +4071,17 @@ static bool
m32c_function_needs_enter (void) m32c_function_needs_enter (void)
{ {
rtx_insn *insn; rtx_insn *insn;
struct sequence_stack *seq;
rtx sp = gen_rtx_REG (Pmode, SP_REGNO); rtx sp = gen_rtx_REG (Pmode, SP_REGNO);
rtx fb = gen_rtx_REG (Pmode, FB_REGNO); rtx fb = gen_rtx_REG (Pmode, FB_REGNO);
insn = get_insns (); for (insn = get_topmost_sequence ()->first; insn; insn = NEXT_INSN (insn))
for (seq = crtl->emit.sequence_stack; if (NONDEBUG_INSN_P (insn))
seq; {
insn = seq->first, seq = seq->next); if (reg_mentioned_p (sp, insn))
return true;
while (insn) if (reg_mentioned_p (fb, insn))
{ return true;
if (reg_mentioned_p (sp, insn)) }
return true;
if (reg_mentioned_p (fb, insn))
return true;
insn = NEXT_INSN (insn);
}
return false; return false;
} }
......
...@@ -33096,7 +33096,7 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx flag, rtx cookie) ...@@ -33096,7 +33096,7 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx flag, rtx cookie)
override a static chain value. */ override a static chain value. */
if (!direct_call_p if (!direct_call_p
&& TARGET_POINTERS_TO_NESTED_FUNCTIONS && TARGET_POINTERS_TO_NESTED_FUNCTIONS
&& !chain_already_loaded (crtl->emit.sequence_stack->last)) && !chain_already_loaded (get_current_sequence ()->next->last))
{ {
rtx sc_reg = gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM); rtx sc_reg = gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
rtx func_sc_offset = GEN_INT (2 * GET_MODE_SIZE (Pmode)); rtx func_sc_offset = GEN_INT (2 * GET_MODE_SIZE (Pmode));
...@@ -3175,12 +3175,10 @@ make_safe_from (rtx x, rtx other) ...@@ -3175,12 +3175,10 @@ make_safe_from (rtx x, rtx other)
rtx_insn * rtx_insn *
get_last_insn_anywhere (void) get_last_insn_anywhere (void)
{ {
struct sequence_stack *stack; struct sequence_stack *seq;
if (get_last_insn ()) for (seq = get_current_sequence (); seq; seq = seq->next)
return get_last_insn (); if (seq->last != 0)
for (stack = seq_stack; stack; stack = stack->next) return seq->last;
if (stack->last != 0)
return stack->last;
return 0; return 0;
} }
...@@ -4014,19 +4012,14 @@ add_insn_after_nobb (rtx_insn *insn, rtx_insn *after) ...@@ -4014,19 +4012,14 @@ add_insn_after_nobb (rtx_insn *insn, rtx_insn *after)
if (next == NULL) if (next == NULL)
{ {
if (get_last_insn () == after) struct sequence_stack *seq;
set_last_insn (insn);
else for (seq = get_current_sequence (); seq; seq = seq->next)
{ if (after == seq->last)
struct sequence_stack *stack = seq_stack; {
/* Scan all pending sequences too. */ seq->last = insn;
for (; stack; stack = stack->next) break;
if (after == stack->last) }
{
stack->last = insn;
break;
}
}
} }
} }
...@@ -4043,21 +4036,16 @@ add_insn_before_nobb (rtx_insn *insn, rtx_insn *before) ...@@ -4043,21 +4036,16 @@ add_insn_before_nobb (rtx_insn *insn, rtx_insn *before)
if (prev == NULL) if (prev == NULL)
{ {
if (get_insns () == before) struct sequence_stack *seq;
set_first_insn (insn);
else
{
struct sequence_stack *stack = seq_stack;
/* Scan all pending sequences too. */
for (; stack; stack = stack->next)
if (before == stack->first)
{
stack->first = insn;
break;
}
gcc_assert (stack); for (seq = get_current_sequence (); seq; seq = seq->next)
} if (before == seq->first)
{
seq->first = insn;
break;
}
gcc_assert (seq);
} }
} }
...@@ -4168,24 +4156,18 @@ remove_insn (rtx uncast_insn) ...@@ -4168,24 +4156,18 @@ remove_insn (rtx uncast_insn)
SET_NEXT_INSN (sequence->insn (sequence->len () - 1)) = next; SET_NEXT_INSN (sequence->insn (sequence->len () - 1)) = next;
} }
} }
else if (get_insns () == insn)
{
if (next)
SET_PREV_INSN (next) = NULL;
set_first_insn (next);
}
else else
{ {
struct sequence_stack *stack = seq_stack; struct sequence_stack *seq;
/* Scan all pending sequences too. */
for (; stack; stack = stack->next) for (seq = get_current_sequence (); seq; seq = seq->next)
if (insn == stack->first) if (insn == seq->first)
{ {
stack->first = next; seq->first = next;
break; break;
} }
gcc_assert (stack); gcc_assert (seq);
} }
if (next) if (next)
...@@ -4197,20 +4179,18 @@ remove_insn (rtx uncast_insn) ...@@ -4197,20 +4179,18 @@ remove_insn (rtx uncast_insn)
SET_PREV_INSN (sequence->insn (0)) = prev; SET_PREV_INSN (sequence->insn (0)) = prev;
} }
} }
else if (get_last_insn () == insn)
set_last_insn (prev);
else else
{ {
struct sequence_stack *stack = seq_stack; struct sequence_stack *seq;
/* Scan all pending sequences too. */
for (; stack; stack = stack->next) for (seq = get_current_sequence (); seq; seq = seq->next)
if (insn == stack->last) if (insn == seq->last)
{ {
stack->last = prev; seq->last = prev;
break; break;
} }
gcc_assert (stack); gcc_assert (seq);
} }
/* Fix up basic block boundaries, if necessary. */ /* Fix up basic block boundaries, if necessary. */
...@@ -5399,11 +5379,10 @@ start_sequence (void) ...@@ -5399,11 +5379,10 @@ start_sequence (void)
else else
tem = ggc_alloc<sequence_stack> (); tem = ggc_alloc<sequence_stack> ();
tem->next = seq_stack; tem->next = get_current_sequence ()->next;
tem->first = get_insns (); tem->first = get_insns ();
tem->last = get_last_insn (); tem->last = get_last_insn ();
get_current_sequence ()->next = tem;
seq_stack = tem;
set_first_insn (0); set_first_insn (0);
set_last_insn (0); set_last_insn (0);
...@@ -5445,13 +5424,11 @@ push_to_sequence2 (rtx_insn *first, rtx_insn *last) ...@@ -5445,13 +5424,11 @@ push_to_sequence2 (rtx_insn *first, rtx_insn *last)
void void
push_topmost_sequence (void) push_topmost_sequence (void)
{ {
struct sequence_stack *stack, *top = NULL; struct sequence_stack *top;
start_sequence (); start_sequence ();
for (stack = seq_stack; stack; stack = stack->next) top = get_topmost_sequence ();
top = stack;
set_first_insn (top->first); set_first_insn (top->first);
set_last_insn (top->last); set_last_insn (top->last);
} }
...@@ -5462,11 +5439,9 @@ push_topmost_sequence (void) ...@@ -5462,11 +5439,9 @@ push_topmost_sequence (void)
void void
pop_topmost_sequence (void) pop_topmost_sequence (void)
{ {
struct sequence_stack *stack, *top = NULL; struct sequence_stack *top;
for (stack = seq_stack; stack; stack = stack->next)
top = stack;
top = get_topmost_sequence ();
top->first = get_insns (); top->first = get_insns ();
top->last = get_last_insn (); top->last = get_last_insn ();
...@@ -5489,11 +5464,11 @@ pop_topmost_sequence (void) ...@@ -5489,11 +5464,11 @@ pop_topmost_sequence (void)
void void
end_sequence (void) end_sequence (void)
{ {
struct sequence_stack *tem = seq_stack; struct sequence_stack *tem = get_current_sequence ()->next;
set_first_insn (tem->first); set_first_insn (tem->first);
set_last_insn (tem->last); set_last_insn (tem->last);
seq_stack = tem->next; get_current_sequence ()->next = tem->next;
memset (tem, 0, sizeof (*tem)); memset (tem, 0, sizeof (*tem));
tem->next = free_sequence_stack; tem->next = free_sequence_stack;
...@@ -5505,7 +5480,7 @@ end_sequence (void) ...@@ -5505,7 +5480,7 @@ end_sequence (void)
int int
in_sequence_p (void) in_sequence_p (void)
{ {
return seq_stack != 0; return get_current_sequence ()->next != 0;
} }
/* Put the various virtual registers into REGNO_REG_RTX. */ /* Put the various virtual registers into REGNO_REG_RTX. */
...@@ -5721,7 +5696,7 @@ init_emit (void) ...@@ -5721,7 +5696,7 @@ init_emit (void)
cur_debug_insn_uid = 1; cur_debug_insn_uid = 1;
reg_rtx_no = LAST_VIRTUAL_REGISTER + 1; reg_rtx_no = LAST_VIRTUAL_REGISTER + 1;
first_label_num = label_num; first_label_num = label_num;
seq_stack = NULL; get_current_sequence ()->next = NULL;
/* Init the tables that describe all the pseudo regs. */ /* Init the tables that describe all the pseudo regs. */
......
...@@ -75,12 +75,36 @@ extern int mem_expr_equal_p (const_tree, const_tree); ...@@ -75,12 +75,36 @@ extern int mem_expr_equal_p (const_tree, const_tree);
extern bool need_atomic_barrier_p (enum memmodel, bool); extern bool need_atomic_barrier_p (enum memmodel, bool);
/* Return the current sequence. */
static inline struct sequence_stack *
get_current_sequence (void)
{
return &crtl->emit.seq;
}
/* Return the outermost sequence. */
static inline struct sequence_stack *
get_topmost_sequence (void)
{
struct sequence_stack *seq, *top;
seq = get_current_sequence ();
do
{
top = seq;
seq = seq->next;
} while (seq);
return top;
}
/* Return the first insn of the current sequence or current function. */ /* Return the first insn of the current sequence or current function. */
static inline rtx_insn * static inline rtx_insn *
get_insns (void) get_insns (void)
{ {
return crtl->emit.x_first_insn; return get_current_sequence ()->first;
} }
/* Specify a new insn as the first in the chain. */ /* Specify a new insn as the first in the chain. */
...@@ -89,7 +113,7 @@ static inline void ...@@ -89,7 +113,7 @@ static inline void
set_first_insn (rtx_insn *insn) set_first_insn (rtx_insn *insn)
{ {
gcc_checking_assert (!insn || !PREV_INSN (insn)); gcc_checking_assert (!insn || !PREV_INSN (insn));
crtl->emit.x_first_insn = insn; get_current_sequence ()->first = insn;
} }
/* Return the last insn emitted in current sequence or current function. */ /* Return the last insn emitted in current sequence or current function. */
...@@ -97,7 +121,7 @@ set_first_insn (rtx_insn *insn) ...@@ -97,7 +121,7 @@ set_first_insn (rtx_insn *insn)
static inline rtx_insn * static inline rtx_insn *
get_last_insn (void) get_last_insn (void)
{ {
return crtl->emit.x_last_insn; return get_current_sequence ()->last;
} }
/* Specify a new insn as the last in the chain. */ /* Specify a new insn as the last in the chain. */
...@@ -106,7 +130,7 @@ static inline void ...@@ -106,7 +130,7 @@ static inline void
set_last_insn (rtx_insn *insn) set_last_insn (rtx_insn *insn)
{ {
gcc_checking_assert (!insn || !NEXT_INSN (insn)); gcc_checking_assert (!insn || !NEXT_INSN (insn));
crtl->emit.x_last_insn = insn; get_current_sequence ()->last = insn;
} }
/* Return a number larger than any instruction's uid in this function. */ /* Return a number larger than any instruction's uid in this function. */
......
...@@ -4831,7 +4831,7 @@ push_struct_function (tree fndecl) ...@@ -4831,7 +4831,7 @@ push_struct_function (tree fndecl)
static void static void
prepare_function_start (void) prepare_function_start (void)
{ {
gcc_assert (!crtl->emit.x_last_insn); gcc_assert (!get_last_insn ());
init_temp_slots (); init_temp_slots ();
init_emit (); init_emit ();
init_varasm_status (); init_varasm_status ();
......
...@@ -41,19 +41,17 @@ struct GTY(()) emit_status { ...@@ -41,19 +41,17 @@ struct GTY(()) emit_status {
/* Lowest label number in current function. */ /* Lowest label number in current function. */
int x_first_label_num; int x_first_label_num;
/* The ends of the doubly-linked chain of rtl for the current function. /* seq.first and seq.last are the ends of the doubly-linked chain of
Both are reset to null at the start of rtl generation for the function. rtl for the current function. Both are reset to null at the
start of rtl generation for the function.
start_sequence saves both of these on `sequence_stack' and then starts start_sequence saves both of these on seq.next and then starts
a new, nested sequence of insns. */ a new, nested sequence of insns.
rtx_insn *x_first_insn;
rtx_insn *x_last_insn;
/* Stack of pending (incomplete) sequences saved by `start_sequence'. seq.next is a stack of pending (incomplete) sequences saved by
Each element describes one pending sequence. start_sequence. Each element describes one pending sequence.
The main insn-chain is saved in the last element of the chain, The main insn-chain is the last element of the chain. */
unless the chain is empty. */ struct sequence_stack seq;
struct sequence_stack *sequence_stack;
/* INSN_UID for next insn emitted. /* INSN_UID for next insn emitted.
Reset to 1 for each function compiled. */ Reset to 1 for each function compiled. */
...@@ -88,7 +86,6 @@ extern GTY ((length ("crtl->emit.x_reg_rtx_no"))) rtx * regno_reg_rtx; ...@@ -88,7 +86,6 @@ extern GTY ((length ("crtl->emit.x_reg_rtx_no"))) rtx * regno_reg_rtx;
/* For backward compatibility... eventually these should all go away. */ /* For backward compatibility... eventually these should all go away. */
#define reg_rtx_no (crtl->emit.x_reg_rtx_no) #define reg_rtx_no (crtl->emit.x_reg_rtx_no)
#define seq_stack (crtl->emit.sequence_stack)
#define REGNO_POINTER_ALIGN(REGNO) (crtl->emit.regno_pointer_align[REGNO]) #define REGNO_POINTER_ALIGN(REGNO) (crtl->emit.regno_pointer_align[REGNO])
......
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