* 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
+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,
/* 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).
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));
}
}
+/* 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. */
&& 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
;; 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).
[(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")