Commit dcfb1a36 by Marek Michalkiewicz Committed by Denis Chertykov

avr-protos.h (avr_peep2_scratch_safe): Prototype.

	* 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).

Co-Authored-By: Denis Chertykov <denisc@overta.ru>

From-SVN: r38718
parent cef3d50c
2001-01-05 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).
2001-01-05 Mark Mitchell <mark@codesourcery.com>
* ggc-page.c (NUM_EXTRA_ORDERS): Hardwire to zero for now.
......
/* Prototypes for exported functions defined in avr.c
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Contributed by Denis Chertykov (denisc@overta.ru)
This file is part of GNU CC.
......@@ -156,6 +156,7 @@ extern void out_shift_with_cnt PARAMS ((const char *template, rtx insn,
rtx operands[], int *len,
int t_len));
extern int const_int_pow2_p PARAMS ((rtx x));
extern int avr_peep2_scratch_safe PARAMS ((rtx reg_rtx));
#endif /* RTX_CODE */
#ifdef HAVE_MACHINE_MODES
......
/* Subroutines for insn-output.c for ATMEL AVR micro controllers
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Denis Chertykov (denisc@overta.ru)
This file is part of GNU CC.
......@@ -5374,3 +5374,26 @@ avr_output_addr_vec_elt (stream, value)
jump_tables_size++;
}
/* Returns 1 if SCRATCH are safe to be allocated as a scratch
registers (for a define_peephole2) in the current function. */
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;
}
;; -*- Mode: Scheme -*-
;; Machine description for GNU compiler,
;; for ATMEL AVR micro controllers.
;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
;; Contributed by Denis Chertykov (denisc@overta.ru)
;; This file is part of GNU CC.
......@@ -200,7 +200,8 @@
&& test_hard_reg_class (NO_LD_REGS, operands[0]))"
[(parallel [(set (match_dup 0) (match_dup 1))
(clobber (match_dup 2))])]
"")
"if (!avr_peep2_scratch_safe (operands[2]))
FAIL;")
;;============================================================================
;; move word (16 bit)
......@@ -228,7 +229,8 @@
&& test_hard_reg_class (NO_LD_REGS, operands[0]))"
[(parallel [(set (match_dup 0) (match_dup 1))
(clobber (match_dup 2))])]
"")
"if (!avr_peep2_scratch_safe (operands[2]))
FAIL;")
;; '*' because it is not used in rtl generation, only in above peephole
(define_insn "*reload_inhi"
......@@ -276,7 +278,8 @@
&& test_hard_reg_class (NO_LD_REGS, operands[0]))"
[(parallel [(set (match_dup 0) (match_dup 1))
(clobber (match_dup 2))])]
"")
"if (!avr_peep2_scratch_safe (operands[2]))
FAIL;")
;; '*' because it is not used in rtl generation.
(define_insn "*reload_insi"
......@@ -929,7 +932,8 @@
""
[(parallel [(set (match_dup 0) (ashift:HI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
"if (!avr_peep2_scratch_safe (operands[3]))
FAIL;")
(define_insn "*ashlhi3_const"
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
......@@ -949,7 +953,8 @@
""
[(parallel [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
"if (!avr_peep2_scratch_safe (operands[3]))
FAIL;")
(define_insn "*ashlsi3_const"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
......@@ -1001,7 +1006,8 @@
""
[(parallel [(set (match_dup 0) (ashiftrt:HI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
"if (!avr_peep2_scratch_safe (operands[3]))
FAIL;")
(define_insn "*ashrhi3_const"
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
......@@ -1021,7 +1027,8 @@
""
[(parallel [(set (match_dup 0) (ashiftrt:SI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
"if (!avr_peep2_scratch_safe (operands[3]))
FAIL;")
(define_insn "*ashrsi3_const"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
......@@ -1073,7 +1080,8 @@
""
[(parallel [(set (match_dup 0) (lshiftrt:HI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
"if (!avr_peep2_scratch_safe (operands[3]))
FAIL;")
(define_insn "*lshrhi3_const"
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
......@@ -1093,7 +1101,8 @@
""
[(parallel [(set (match_dup 0) (lshiftrt:SI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
"if (!avr_peep2_scratch_safe (operands[3]))
FAIL;")
(define_insn "*lshrsi3_const"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
......
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