From: denisc Date: Fri, 5 Jan 2001 19:08:46 +0000 (+0000) Subject: * config/avr/avr-protos.h (avr_peep2_scratch_safe): Prototype. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=51fe737950ad9c2f0197b25ea2f73c8f2be2fc4d;p=thirdparty%2Fgcc.git * 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). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38718 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3a5979d10739..e72e4e8181fe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2001-01-05 Marek Michalkiewicz + Denis Chertykov + + * 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 * 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 4fa887a5fd46..5ebea175c3e6 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 669c163f1a4a..9e396df89cc0 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 c3a5e3717f72..b822445fd954 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")