re PR target/36424 (avr-gcc use don't saved registers in ISR with -O3 ('-frename...
authorAnatoly Sokolov <aesok@post.ru>
Sun, 8 Jun 2008 16:08:08 +0000 (20:08 +0400)
committerAnatoly Sokolov <aesok@gcc.gnu.org>
Sun, 8 Jun 2008 16:08:08 +0000 (20:08 +0400)
PR target/36424
* config/avr/avr.h (HARD_REGNO_RENAME_OK): Define.
* config/avr/avr.c (avr_hard_regno_rename_ok): New function.
* config/avr/avr-protos.h (avr_hard_regno_rename_ok): New prototype.

From-SVN: r136562

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

index a64dc10..216f818 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-08  Anatoly Sokolov  <aesok@post.ru>
+
+       PR target/36424
+       * config/avr/avr.h (HARD_REGNO_RENAME_OK): Define.
+       * config/avr/avr.c (avr_hard_regno_rename_ok): New function. 
+       * config/avr/avr-protos.h (avr_hard_regno_rename_ok): New prototype. 
+
 2008-06-07  Danny Smith  <dannysmith@users.sourceforge.net>
 
        * config/i386/cygming.h (MAYBE_UWIN_CPP_BUILTINS): Remove.
index 3fa3ea8..73e70c6 100644 (file)
@@ -37,6 +37,7 @@ extern int initial_elimination_offset (int from, int to);
 extern int avr_simple_epilogue (void);
 extern void gas_output_limited_string (FILE *file, const char *str);
 extern void gas_output_ascii (FILE *file, const char *str, size_t length);
+extern int avr_hard_regno_rename_ok (unsigned int, unsigned int);
 
 #ifdef TREE_CODE
 extern void asm_output_external (FILE *file, tree decl, char *name);
index 405f42f..e4820e6 100644 (file)
@@ -5916,6 +5916,23 @@ avr_peep2_scratch_safe (rtx scratch)
   return 1;
 }
 
+/* Return nonzero if register OLD_REG can be renamed to register NEW_REG.  */
+
+int
+avr_hard_regno_rename_ok (unsigned int old_reg ATTRIBUTE_UNUSED,
+                         unsigned int new_reg)
+{
+  /* Interrupt functions can only use registers that have already been
+     saved by the prologue, even if they would normally be
+     call-clobbered.  */
+
+  if ((cfun->machine->is_interrupt || cfun->machine->is_signal)
+      && !df_regs_ever_live_p (new_reg))
+    return 0;
+
+  return 1;
+}
+
 /* Output a branch that tests a single bit of a register (QI, HI or SImode)
    or memory location in the I/O space (QImode only).
 
index 6ae1c63..90e62a3 100644 (file)
@@ -1026,6 +1026,9 @@ mmcu=*:-mmcu=%*}"
 
 #define OBJECT_FORMAT_ELF
 
+#define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
+  avr_hard_regno_rename_ok (OLD_REG, NEW_REG)
+
 /* A C structure for machine-specific, per-function data.
    This is added to the cfun structure.  */
 struct machine_function GTY(())