Commit f8305d18 by Richard Sandiford Committed by Richard Sandiford

combine-stack-adj.c: Include rtl-iter.h.

gcc/
	* combine-stack-adj.c: Include rtl-iter.h.
	(record_stack_refs_data): Delete.
	(record_stack_refs): Turn from being a for_each_rtx callback
	to being a function that examines each subrtx itself.
	Take a pointer to the reflist.  Invert sense of return value
	so that true means success and false means failure.  Don't
	handle null rtxes.
	(combine_stack_adjustments_for_block): Update accordingly.

From-SVN: r214625
parent 46bbda03
2014-08-28 Richard Sandiford <rdsandiford@googlemail.com> 2014-08-28 Richard Sandiford <rdsandiford@googlemail.com>
* combine-stack-adj.c: Include rtl-iter.h.
(record_stack_refs_data): Delete.
(record_stack_refs): Turn from being a for_each_rtx callback
to being a function that examines each subrtx itself.
Take a pointer to the reflist. Invert sense of return value
so that true means success and false means failure. Don't
handle null rtxes.
(combine_stack_adjustments_for_block): Update accordingly.
2014-08-28 Richard Sandiford <rdsandiford@googlemail.com>
* combine.c (record_truncated_value): Turn from being a for_each_rtx * combine.c (record_truncated_value): Turn from being a for_each_rtx
callback to a function that takes an rtx and returns a bool callback to a function that takes an rtx and returns a bool
(record_truncated_values): Use FOR_EACH_SUBRTX_VAR instead of (record_truncated_values): Use FOR_EACH_SUBRTX_VAR instead of
......
...@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see
#include "except.h" #include "except.h"
#include "reload.h" #include "reload.h"
#include "tree-pass.h" #include "tree-pass.h"
#include "rtl-iter.h"
/* Turn STACK_GROWS_DOWNWARD into a boolean. */ /* Turn STACK_GROWS_DOWNWARD into a boolean. */
...@@ -86,7 +87,6 @@ static struct csa_reflist *record_one_stack_ref (rtx_insn *, rtx *, ...@@ -86,7 +87,6 @@ static struct csa_reflist *record_one_stack_ref (rtx_insn *, rtx *,
static int try_apply_stack_adjustment (rtx_insn *, struct csa_reflist *, static int try_apply_stack_adjustment (rtx_insn *, struct csa_reflist *,
HOST_WIDE_INT, HOST_WIDE_INT); HOST_WIDE_INT, HOST_WIDE_INT);
static void combine_stack_adjustments_for_block (basic_block); static void combine_stack_adjustments_for_block (basic_block);
static int record_stack_refs (rtx *, void *);
/* Main entry point for stack adjustment combination. */ /* Main entry point for stack adjustment combination. */
...@@ -237,36 +237,37 @@ try_apply_stack_adjustment (rtx_insn *insn, struct csa_reflist *reflist, ...@@ -237,36 +237,37 @@ try_apply_stack_adjustment (rtx_insn *insn, struct csa_reflist *reflist,
return 0; return 0;
} }
/* Called via for_each_rtx and used to record all stack memory and other /* For non-debug insns, record all stack memory references in INSN
references in the insn and discard all other stack pointer references. */ and return true if there were no other (unrecorded) references to the
struct record_stack_refs_data stack pointer. For debug insns, record all stack references regardless
{ of context and unconditionally return true. */
rtx_insn *insn;
struct csa_reflist *reflist;
};
static int static bool
record_stack_refs (rtx *xp, void *data) record_stack_refs (rtx_insn *insn, struct csa_reflist **reflist)
{ {
rtx x = *xp; subrtx_ptr_iterator::array_type array;
struct record_stack_refs_data *d = FOR_EACH_SUBRTX_PTR (iter, array, &PATTERN (insn), NONCONST)
(struct record_stack_refs_data *) data; {
if (!x) rtx *loc = *iter;
return 0; rtx x = *loc;
switch (GET_CODE (x)) switch (GET_CODE (x))
{ {
case MEM: case MEM:
if (!reg_mentioned_p (stack_pointer_rtx, x)) if (!reg_mentioned_p (stack_pointer_rtx, x))
return -1; iter.skip_subrtxes ();
/* We are not able to handle correctly all possible memrefs containing /* We are not able to handle correctly all possible memrefs
stack pointer, so this check is necessary. */ containing stack pointer, so this check is necessary. */
if (stack_memref_p (x)) else if (stack_memref_p (x))
{ {
d->reflist = record_one_stack_ref (d->insn, xp, d->reflist); *reflist = record_one_stack_ref (insn, loc, *reflist);
return -1; iter.skip_subrtxes ();
} }
/* Try harder for DEBUG_INSNs, handle e.g. (mem (mem (sp + 16) + 4). */ /* Try harder for DEBUG_INSNs, handle e.g.
return !DEBUG_INSN_P (d->insn); (mem (mem (sp + 16) + 4). */
else if (!DEBUG_INSN_P (insn))
return false;
break;
case REG: case REG:
/* ??? We want be able to handle non-memory stack pointer /* ??? We want be able to handle non-memory stack pointer
references later. For now just discard all insns referring to references later. For now just discard all insns referring to
...@@ -282,16 +283,17 @@ record_stack_refs (rtx *xp, void *data) ...@@ -282,16 +283,17 @@ record_stack_refs (rtx *xp, void *data)
they will cause -fcompare-debug failures. */ they will cause -fcompare-debug failures. */
if (REGNO (x) == STACK_POINTER_REGNUM) if (REGNO (x) == STACK_POINTER_REGNUM)
{ {
if (!DEBUG_INSN_P (d->insn)) if (!DEBUG_INSN_P (insn))
return 1; return false;
d->reflist = record_one_stack_ref (d->insn, xp, d->reflist); *reflist = record_one_stack_ref (insn, loc, *reflist);
return -1;
} }
break; break;
default: default:
break; break;
} }
return 0; }
return true;
} }
/* If INSN has a REG_ARGS_SIZE note, move it to LAST. /* If INSN has a REG_ARGS_SIZE note, move it to LAST.
...@@ -432,7 +434,6 @@ combine_stack_adjustments_for_block (basic_block bb) ...@@ -432,7 +434,6 @@ combine_stack_adjustments_for_block (basic_block bb)
struct csa_reflist *reflist = NULL; struct csa_reflist *reflist = NULL;
rtx_insn *insn, *next; rtx_insn *insn, *next;
rtx set; rtx set;
struct record_stack_refs_data data;
bool end_of_block = false; bool end_of_block = false;
for (insn = BB_HEAD (bb); !end_of_block ; insn = next) for (insn = BB_HEAD (bb); !end_of_block ; insn = next)
...@@ -583,15 +584,9 @@ combine_stack_adjustments_for_block (basic_block bb) ...@@ -583,15 +584,9 @@ combine_stack_adjustments_for_block (basic_block bb)
} }
} }
data.insn = insn;
data.reflist = reflist;
if (!CALL_P (insn) && last_sp_set if (!CALL_P (insn) && last_sp_set
&& !for_each_rtx (&PATTERN (insn), record_stack_refs, &data)) && record_stack_refs (insn, &reflist))
{
reflist = data.reflist;
continue; continue;
}
reflist = data.reflist;
/* Otherwise, we were not able to process the instruction. /* Otherwise, we were not able to process the instruction.
Do not continue collecting data across such a one. */ Do not continue collecting data across such a one. */
......
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