diff options
author | Kazu Hirata <kazu@cs.umass.edu> | 2003-01-02 14:59:30 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2003-01-02 14:59:30 +0000 |
commit | 8ccf5d5fe8ab1facea7ad7563d11edf5fb56411c (patch) | |
tree | 8a1b93b9f6e96d2bd8d4393dc4f17d6fe3738736 | |
parent | 43c6a96ab2d2ad55a19deb77ad8e33517ee8d568 (diff) | |
download | gcc-8ccf5d5fe8ab1facea7ad7563d11edf5fb56411c.zip gcc-8ccf5d5fe8ab1facea7ad7563d11edf5fb56411c.tar.gz gcc-8ccf5d5fe8ab1facea7ad7563d11edf5fb56411c.tar.bz2 |
h8300.c (stack_pointer_operand): New.
* config/h8300/h8300.c (stack_pointer_operand): New.
(const_int_gt_2_operand): Likewise.
(const_int_ge_8_operand): Likewise.
* config/h8300/h8300.md (a splitter): Likewise.
(a peephole2): Likewise.
* config/h8300/h8300-protos.h: Add prototypes for the new
functions above.
From-SVN: r60784
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/config/h8300/h8300-protos.h | 5 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.c | 34 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.md | 31 |
4 files changed, 78 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e762668..99cb082 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2003-01-02 Kazu Hirata <kazu@cs.umass.edu> + + * config/h8300/h8300.c (stack_pointer_operand): New. + (const_int_gt_2_operand): Likewise. + (const_int_ge_8_operand): Likewise. + * config/h8300/h8300.md (a splitter): Likewise. + (a peephole2): Likewise. + * config/h8300/h8300-protos.h: Add prototypes for the new + functions above. + 2003-01-02 Steven Bosscher <s.bosscher@student.tudelft.nl> * objc/Make-lang.in, objc/config-lang.in, objc/lang-specs.h, diff --git a/gcc/config/h8300/h8300-protos.h b/gcc/config/h8300/h8300-protos.h index f324237..0aa2315 100644 --- a/gcc/config/h8300/h8300-protos.h +++ b/gcc/config/h8300/h8300-protos.h @@ -1,6 +1,6 @@ /* Definitions of target machine for GNU compiler. Hitachi H8/300 version generating coff - Copyright (C) 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. Contributed by Steve Chamberlain (sac@cygnus.com), Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com). @@ -62,8 +62,11 @@ extern int small_call_insn_operand PARAMS ((rtx, enum machine_mode)); extern int jump_address_operand PARAMS ((rtx, enum machine_mode)); extern int bit_operand PARAMS ((rtx, enum machine_mode)); extern int bit_memory_operand PARAMS ((rtx, enum machine_mode)); +extern int stack_pointer_operand PARAMS ((rtx, enum machine_mode)); extern int const_int_le_2_operand PARAMS ((rtx, enum machine_mode)); extern int const_int_le_6_operand PARAMS ((rtx, enum machine_mode)); +extern int const_int_gt_2_operand PARAMS ((rtx, enum machine_mode)); +extern int const_int_ge_8_operand PARAMS ((rtx, enum machine_mode)); extern int const_int_qi_operand PARAMS ((rtx, enum machine_mode)); extern int const_int_hi_operand PARAMS ((rtx, enum machine_mode)); extern int incdec_operand PARAMS ((rtx, enum machine_mode)); diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index 4313143..7da1780 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -1827,6 +1827,16 @@ notice_update_cc (body, insn) } } +/* Return nonzero if X is a stack pointer. */ + +int +stack_pointer_operand (x, mode) + rtx x; + enum machine_mode mode ATTRIBUTE_UNUSED; +{ + return x == stack_pointer_rtx; +} + /* Return nonzero if X is a constant whose absolute value is no greater than 2. */ @@ -1851,6 +1861,30 @@ const_int_le_6_operand (x, mode) && abs (INTVAL (x)) <= 6); } +/* Return nonzero if X is a constant whose absolute value is greater + than 2. */ + +int +const_int_gt_2_operand (x, mode) + rtx x; + enum machine_mode mode ATTRIBUTE_UNUSED; +{ + return (GET_CODE (x) == CONST_INT + && abs (INTVAL (x)) > 2); +} + +/* Return nonzero if X is a constant whose absolute value is no + smaller than 8. */ + +int +const_int_ge_8_operand (x, mode) + rtx x; + enum machine_mode mode ATTRIBUTE_UNUSED; +{ + return (GET_CODE (x) == CONST_INT + && abs (INTVAL (x)) >= 8); +} + /* Return nonzero if X is a constant expressible in QImode. */ int diff --git a/gcc/config/h8300/h8300.md b/gcc/config/h8300/h8300.md index cce5181..70b9858 100644 --- a/gcc/config/h8300/h8300.md +++ b/gcc/config/h8300/h8300.md @@ -1,6 +1,6 @@ ;; GCC machine description for Hitachi H8/300 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -;; 2001, 2002 Free Software Foundation, Inc. +;; 2001, 2002, 2003 Free Software Foundation, Inc. ;; Contributed by Steve Chamberlain (sac@cygnus.com), ;; Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com). @@ -783,6 +783,35 @@ [(set_attr "length" "2,2,2,4,2") (set_attr "cc" "none_0hit,none_0hit,clobber,clobber,set_zn")]) +;; This splitter is very important to make the stack adjustment +;; interrupt-safe. The combination of add.b and addx is unsafe! +;; +;; We apply this split after the peephole2 pass so that we won't end +;; up creating too many adds/subs when a scratch register is +;; available, which is actually a common case because stack unrolling +;; tends to happen immediately after a function call. + +(define_split + [(set (match_operand:HI 0 "stack_pointer_operand" "") + (plus:HI (match_dup 0) + (match_operand 1 "const_int_gt_2_operand" "")))] + "TARGET_H8300 && flow2_completed" + [(const_int 0)] + "split_adds_subs (HImode, operands, 0); DONE;") + +(define_peephole2 + [(match_scratch:HI 2 "r") + (set (match_operand:HI 0 "stack_pointer_operand" "") + (plus:HI (match_dup 0) + (match_operand:HI 1 "const_int_ge_8_operand" "")))] + "TARGET_H8300" + [(set (match_dup 2) + (match_dup 1)) + (set (match_dup 0) + (plus:HI (match_dup 0) + (match_dup 2)))] + "") + (define_insn "*addhi3_h8300hs" [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r") (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0") |