This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: AVR peephole2 fixes
- To: Marek Michalkiewicz <marekm at linux dot org dot pl>
- Subject: Re: AVR peephole2 fixes
- From: Denis Chertykov <denisc at overta dot ru>
- Date: 03 Jan 2001 23:59:59 +0300
- Cc: denisc at overta dot ru, gcc-patches at gcc dot gnu dot org
- References: <200101011729.SAA04243@marekm.home>
Marek Michalkiewicz <marekm@linux.org.pl> writes:
> OK to commit?
>
> 2001-01-01 Marek Michalkiewicz <marekm@linux.org.pl>
> Denis Chertykov <denisc@overta.ru>
>
> * config/avr/avr-protos.h (avr_peep2_scratch_safe): Prototype.
> * config/avr/avr.c (avr_peep2_scratch_safe): New function.
> * config/avr/avr.md (all peepholes that request a scratch register):
> Call it, FAIL the peephole if not safe (in interrupt functions).
>
> Index: config/avr/avr-protos.h
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/config/avr/avr-protos.h,v
> retrieving revision 1.10
> diff -c -3 -p -r1.10 avr-protos.h
> *** avr-protos.h 2000/11/19 07:10:54 1.10
> --- avr-protos.h 2001/01/01 17:25:53
> *************** extern const char * lshrsi3_out PARAMS (
> *** 111,116 ****
> --- 111,117 ----
>
> extern void avr_output_bld PARAMS ((rtx operands[], int bit_nr));
> extern void avr_output_addr_vec_elt PARAMS ((FILE *stream, int value));
> + extern int avr_peep2_scratch_safe PARAMS ((rtx scratch));
>
> extern enum reg_class preferred_reload_class PARAMS ((rtx x,
> enum reg_class class));
> Index: config/avr/avr.c
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/config/avr/avr.c,v
> retrieving revision 1.35
> diff -c -3 -p -r1.35 avr.c
> *** avr.c 2000/12/23 19:58:17 1.35
> --- avr.c 2001/01/01 17:26:06
> *************** avr_output_addr_vec_elt (stream, value)
> *** 5374,5376 ****
> --- 5374,5397 ----
> jump_tables_size++;
> }
>
> + int
> + avr_peep2_scratch_safe (scratch)
> + rtx scratch;
> + {
> + if ((interrupt_function_p (current_function_decl)
> + || signal_function_p (current_function_decl))
> + && leaf_function_p ())
> + {
> + int first_reg = true_regnum (scratch);
> + int last_reg = first_reg + GET_MODE_SIZE (GET_MODE (scratch)) - 1;
> + int reg;
> +
> + for (reg = first_reg; reg <= last_reg; reg++)
> + {
> + if (!regs_ever_live[reg])
> + return 0;
> + }
> + }
> + return 1;
> + }
I have used following variant:
(What you think about it?)
int
avr_peep2_scratch_safe (reg_rtx)
rtx reg_rtx;
{
if (interrupt_function_p (current_function_decl) ||
signal_function_p (current_function_decl))
{
int regno = true_regnum (reg_rtx);
int endregno = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg_rtx));
int reg;
for (reg = regno; reg < endregno; ++reg)
{
if (regs_ever_live[reg]
|| (!leaf_function_p () && call_used_regs[reg]))
continue;
return 0;
}
}
return 1;
}