]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* config/avr/avr-protos.h (avr_peep2_scratch_safe): Prototype.
authordenisc <denisc@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Jan 2001 19:08:46 +0000 (19:08 +0000)
committerdenisc <denisc@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Jan 2001 19:08:46 +0000 (19:08 +0000)
* 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).

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38718 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/avr/avr-protos.h
gcc/config/avr/avr.c
gcc/config/avr/avr.md

index 3a5979d1073999e6408027091c3125a3fa4bc33c..e72e4e8181fec1872085d27d1bcef5c82e9df6fd 100644 (file)
@@ -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.
index 4fa887a5fd46f4c0699eba79b078c0b93cba0a9b..5ebea175c3e68a995a9f85ee52c240c714923a1d 100644 (file)
@@ -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
index 669c163f1a4acc1a10c24d5c1b39578ff0516b05..9e396df89cc06286ce52ec4ea2b563f2195d1860 100644 (file)
@@ -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;
+}
index c3a5e3717f720ccc9d1a524e7f73dd5203782951..b822445fd9544550a12c602b309bfcfed82420c1 100644 (file)
@@ -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.
     && 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)
     && 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"
     && 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"
   ""
   [(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")
   ""
   [(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")
   ""
   [(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")
   ""
   [(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")
   ""
   [(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")
   ""
   [(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")