This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
An update on reg-stack.c patch
- To: egcs-patches at cygnus dot com
- Subject: An update on reg-stack.c patch
- From: hjl at lucon dot org (H.J. Lu)
- Date: Wed, 8 Jul 1998 08:04:15 -0700 (PDT)
Hi,
Here is an updated version of my reg-stack.c patch. We don't have
to do anything of regstack->top <= 0. But we still need to deal
with the virtual register stack.
--
H.J. Lu (hjl@gnu.org)
---
Tue Jul 7 21:08:22 1998 H.J. Lu (hjl@gnu.org)
* reg-stack.c (straighten_stack): Handle the virtual register
stack.
--- ../../../import/egcs/gcc/reg-stack.c Mon Apr 20 08:23:00 1998
+++ ./reg-stack.c Tue Jul 7 21:05:56 1998
@@ -297,7 +297,7 @@ mark_regs_pat (pat, set)
SET_HARD_REG_BIT (*set, regno);
}
-/* Reorganise the stack into ascending numbers,
+/* Reorganise the virtual register stack into ascending numbers,
after this insn. */
static void
@@ -305,15 +305,27 @@ straighten_stack (insn, regstack)
rtx insn;
stack regstack;
{
- struct stack_def temp_stack;
- int top;
+ if (regstack->top > 0)
+ {
+ struct stack_def temp_stack;
+ int top;
+ int first_start_reg;
+
+#if defined(__GNUC__) && __GNUC__ >= 2 && defined (__OPTIMIZE__)
+ first_start_reg = ffs (regstack->reg_set) - 1;
+#else
+ first_start_reg = 0;
+ for (top = regstack->reg_set; (top & 1) == 0; top >>= 1)
+ first_start_reg++;
+#endif
- temp_stack.reg_set = regstack->reg_set;
+ temp_stack.reg_set = regstack->reg_set;
- for (top = temp_stack.top = regstack->top; top >= 0; top--)
- temp_stack.reg[top] = FIRST_STACK_REG + temp_stack.top - top;
+ for (top = temp_stack.top = regstack->top; top >= 0; top--)
+ temp_stack.reg[top] = first_start_reg + temp_stack.top - top;
- change_stack (insn, regstack, &temp_stack, emit_insn_after);
+ change_stack (insn, regstack, &temp_stack, emit_insn_after);
+ }
}
/* Return non-zero if any stack register is mentioned somewhere within PAT. */
@@ -2407,11 +2419,9 @@ subst_stack_regs_pat (insn, regstack, pa