aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Michalkiewicz <marekm@linux.org.pl>2001-01-05 20:08:46 +0100
committerDenis Chertykov <denisc@gcc.gnu.org>2001-01-05 22:08:46 +0300
commitdcfb1a361ba787b4cf2b7488c6ee822bd7058bc6 (patch)
treee4d648976e35b05228dc75752f5f77e100691232 /gcc
parentcef3d50c9f37af32c3298a6f6bac0e1c90dd16d7 (diff)
downloadgcc-dcfb1a361ba787b4cf2b7488c6ee822bd7058bc6.zip
gcc-dcfb1a361ba787b4cf2b7488c6ee822bd7058bc6.tar.gz
gcc-dcfb1a361ba787b4cf2b7488c6ee822bd7058bc6.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/avr/avr-protos.h3
-rw-r--r--gcc/config/avr/avr.c25
-rw-r--r--gcc/config/avr/avr.md29
4 files changed, 53 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3a5979d..e72e4e8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+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.
diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h
index 4fa887a..5ebea17 100644
--- a/gcc/config/avr/avr-protos.h
+++ b/gcc/config/avr/avr-protos.h
@@ -1,6 +1,6 @@
/* 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
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index 669c163..9e396df 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -1,5 +1,5 @@
/* 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;
+}
diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md
index c3a5e37..b822445 100644
--- a/gcc/config/avr/avr.md
+++ b/gcc/config/avr/avr.md
@@ -1,7 +1,7 @@
;; -*- 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")