summaryrefslogtreecommitdiffstats
path: root/gcc/regmove.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2000-04-28 23:27:40 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2000-04-28 23:27:40 +0000
commit4c0bc702381d4a5249612ea29de42066be5000cb (patch)
treeca0ace4f28ac0a11daeb30daf851ad58902ce4af /gcc/regmove.c
parent6471239df6b0a9f1e5bb62fedf5b60e47961cf06 (diff)
downloadppe42-gcc-4c0bc702381d4a5249612ea29de42066be5000cb.tar.gz
ppe42-gcc-4c0bc702381d4a5249612ea29de42066be5000cb.zip
* regmove.c (struct record_stack_memrefs_data): New.
(record_stack_memrefs): New function. (combine_stack_adjustments_for_block): Use it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33529 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/regmove.c')
-rw-r--r--gcc/regmove.c76
1 files changed, 58 insertions, 18 deletions
diff --git a/gcc/regmove.c b/gcc/regmove.c
index 3b4a7e660e0..5b244a028f5 100644
--- a/gcc/regmove.c
+++ b/gcc/regmove.c
@@ -2100,6 +2100,7 @@ static struct csa_memlist *record_one_stack_memref
static int try_apply_stack_adjustment
PARAMS ((rtx, struct csa_memlist *, HOST_WIDE_INT, HOST_WIDE_INT));
static void combine_stack_adjustments_for_block PARAMS ((basic_block));
+static int record_stack_memrefs PARAMS ((rtx *, void *));
/* Main entry point for stack adjustment combination. */
@@ -2258,6 +2259,51 @@ try_apply_stack_adjustment (insn, memlist, new_adjust, delta)
return 0;
}
+/* Called via for_each_rtx and used to record all stack memory references in
+ the insn and discard all other stack pointer references. */
+struct record_stack_memrefs_data
+{
+ rtx insn;
+ struct csa_memlist *memlist;
+};
+
+static int
+record_stack_memrefs (xp, data)
+ rtx *xp;
+ void *data;
+{
+ rtx x = *xp;
+ struct record_stack_memrefs_data *d =
+ (struct record_stack_memrefs_data *) data;
+ if (!x)
+ return 0;
+ switch (GET_CODE (x))
+ {
+ case MEM:
+ if (!reg_mentioned_p (stack_pointer_rtx, x))
+ return -1;
+ /* We are not able to handle correctly all possible memrefs containing
+ stack pointer, so this check is neccesary. */
+ if (stack_memref_p (x))
+ {
+ d->memlist = record_one_stack_memref (d->insn, xp, d->memlist);
+ return -1;
+ }
+ return 1;
+ case REG:
+ /* ??? We want be able to handle non-memory stack pointer references
+ later. For now just discard all insns refering to stack pointer
+ outside mem expressions. We would probably want to teach
+ validate_replace to simplify expressions first. */
+ if (x == stack_pointer_rtx)
+ return 1;
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
/* Subroutine of combine_stack_adjustments, called for each basic block. */
static void
@@ -2269,6 +2315,7 @@ combine_stack_adjustments_for_block (bb)
struct csa_memlist *memlist = NULL;
rtx pending_delete;
rtx insn, next;
+ struct record_stack_memrefs_data data;
for (insn = bb->head; ; insn = next)
{
@@ -2277,7 +2324,7 @@ combine_stack_adjustments_for_block (bb)
pending_delete = NULL_RTX;
next = NEXT_INSN (insn);
- if (GET_RTX_CLASS (GET_CODE (insn)) != 'i')
+ if (! INSN_P (insn))
goto processed;
set = single_set_for_csa (insn);
@@ -2337,23 +2384,6 @@ combine_stack_adjustments_for_block (bb)
goto processed;
}
- /* Find loads from stack memory and record them. */
- if (last_sp_set && stack_memref_p (src)
- && ! reg_mentioned_p (stack_pointer_rtx, dest))
- {
- memlist = record_one_stack_memref (insn, &SET_SRC (set), memlist);
- goto processed;
- }
-
- /* Find stores to stack memory and record them. */
- if (last_sp_set && stack_memref_p (dest)
- && ! reg_mentioned_p (stack_pointer_rtx, src))
- {
- memlist = record_one_stack_memref (insn, &SET_DEST (set),
- memlist);
- goto processed;
- }
-
/* Find a predecrement of exactly the previous adjustment and
turn it into a direct store. Obviously we can't do this if
there were any intervening uses of the stack pointer. */
@@ -2380,6 +2410,16 @@ combine_stack_adjustments_for_block (bb)
}
}
+ data.insn = insn;
+ data.memlist = memlist;
+ if (GET_CODE (insn) != CALL_INSN && last_sp_set
+ && !for_each_rtx (&PATTERN (insn), record_stack_memrefs, &data))
+ {
+ memlist = data.memlist;
+ goto processed;
+ }
+ memlist = data.memlist;
+
/* Otherwise, we were not able to process the instruction.
Do not continue collecting data across such a one. */
if (last_sp_set
OpenPOWER on IntegriCloud