From faf8dab54b28ab718ed5b14a711b8889a83ac381 Mon Sep 17 00:00:00 2001
From: ciceron <ciceron@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 28 Jun 2002 21:16:58 +0000
Subject: [PATCH] 	* config/m68hc11/m68hc11.md ("*addsi3"): Use 'o'
 constraint to 	avoid the auto increment addressing modes. 	("*subsi3"):
 Likewise. 	(split for add/sub on address): For 68HC12 push the value on 
 the stack and do the operation with a pop.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@55083 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                 |  8 +++++
 gcc/config/m68hc11/m68hc11.md | 55 +++++++++++++++++++++++++++++------
 2 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1f8fbd58ec75..033fc4baea3e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2002-06-28  Stephane Carrez  <stcarrez@nerim.fr>
+
+	* config/m68hc11/m68hc11.md ("*addsi3"): Use 'o' constraint to
+	avoid the auto increment addressing modes.
+	("*subsi3"): Likewise.
+	(split for add/sub on address): For 68HC12 push the value on 
+	the stack and do the operation with a pop.
+
 2002-06-28  Neil Booth  <neil@daikokuya.co.uk>
 
 	* cpplib.c (_cpp_handle_directive): Move #define-specific
diff --git a/gcc/config/m68hc11/m68hc11.md b/gcc/config/m68hc11/m68hc11.md
index 6cad95162a91..ce32b53a50a6 100644
--- a/gcc/config/m68hc11/m68hc11.md
+++ b/gcc/config/m68hc11/m68hc11.md
@@ -1,6 +1,6 @@
 ;;- Machine description file for Motorola 68HC11 and 68HC12.
 ;;- Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
-;;- Contributed by Stephane Carrez (stcarrez@worldnet.fr)
+;;- Contributed by Stephane Carrez (stcarrez@nerim.fr)
 
 ;; This file is part of GNU CC.
 
@@ -1900,9 +1900,9 @@
 }")
 
 (define_insn "*addsi3"
-  [(set (match_operand:SI 0 "non_push_operand" "=m,D,!u,?D,D")
+  [(set (match_operand:SI 0 "non_push_operand" "=o,D,!u,?D,D")
 	(plus:SI (match_operand:SI 1 "non_push_operand" "%0,0,0,0,0")
-		 (match_operand:SI 2 "general_operand" "ML,i,ML,?D,?miu")))
+		 (match_operand:SI 2 "general_operand" "ML,i,ML,?D,?oiu")))
    (clobber (match_scratch:HI 3 "=d,X,d,X,X"))]
   ""
   "*
@@ -2500,8 +2500,8 @@
 
 (define_insn "*subsi3"
   [(set (match_operand:SI 0 "register_operand" "=D,D,D,D,!u")
-	(minus:SI (match_operand:SI 1 "general_operand" "0,mi,0,!u,0")
-		  (match_operand:SI 2 "general_operand" "mi,D,!u,D,!mui")))
+	(minus:SI (match_operand:SI 1 "general_operand" "0,oi,0,!u,0")
+		  (match_operand:SI 2 "general_operand" "oi,D,!u,D,!oui")))
    (clobber (match_scratch:HI 3 "=X,X,X,X,d"))]
   ""
   "#")
@@ -3932,19 +3932,55 @@
             || (GET_CODE (operands[2]) == CONST_INT
 	        && INTVAL (operands[2]) >= -4
 	        && INTVAL (operands[2]) <= 4)))"
-  [(set (match_dup 4) (match_dup 5))
+  [(set (match_dup 9) (match_dup 0))
+   (set (match_dup 4) (match_dup 5))
    (set (match_dup 8) (match_dup 7))
+   (set (match_dup 0) (match_dup 1))
    (parallel [(set (reg:HI D_REGNUM) (match_dup 0))
               (set (match_dup 0) (reg:HI D_REGNUM))])
    (set (reg:HI D_REGNUM) (match_op_dup 3 [(reg:HI D_REGNUM) (match_dup 6)]))
    (parallel [(set (reg:HI D_REGNUM) (match_dup 0))
               (set (match_dup 0) (reg:HI D_REGNUM))])]
   "
+   operands[9] = operands[0];
+   /* For 68HC12, push the value on the stack and do the operation
+      with a pop.  */
+   if (TARGET_M6812
+       && m68hc11_non_shift_operator (operands[3], HImode)
+       && (H_REG_P (operands[2])
+	   || (m68hc11_small_indexed_indirect_p (operands[2], HImode)
+	       && reg_mentioned_p (operands[0], operands[2]))))
+     {
+       operands[4] = gen_rtx (MEM, HImode,
+			      gen_rtx (PRE_DEC, HImode,
+				       gen_rtx (REG, HImode, HARD_SP_REGNUM)));
+       operands[6] = gen_rtx (MEM, HImode,
+			      gen_rtx (POST_INC, HImode,
+				       gen_rtx (REG, HImode, HARD_SP_REGNUM)));
+       operands[5] = operands[2];
+       operands[8] = operands[7] = operands[0];
+     }
    /* Save the operand2 in a temporary location and use it.  */
-   if ((H_REG_P (operands[2])
-        || reg_mentioned_p  (operands[0], operands[2]))
-       && !(SP_REG_P (operands[2]) && GET_CODE (operands[3]) == PLUS))
+   else if ((H_REG_P (operands[2])
+             || reg_mentioned_p  (operands[0], operands[2]))
+            && !(SP_REG_P (operands[2]) && GET_CODE (operands[3]) == PLUS))
      {
+       if (GET_CODE (operands[3]) == MINUS
+	   && reg_mentioned_p (operands[0], operands[2]))
+	 {
+	   operands[9] = gen_rtx (MEM, HImode,
+			      gen_rtx (PRE_DEC, HImode,
+				       gen_rtx (REG, HImode, HARD_SP_REGNUM)));
+	   operands[1] = gen_rtx (MEM, HImode,
+			      gen_rtx (POST_INC, HImode,
+				       gen_rtx (REG, HImode, HARD_SP_REGNUM)));
+	   operands[8] = gen_rtx (REG, HImode, SOFT_TMP_REGNUM);
+	   operands[4] = operands[7] = operands[0];
+	   operands[6] = operands[8];
+	   operands[5] = operands[2];
+	 }
+       else 
+	 {
        operands[4] = gen_rtx (REG, HImode, SOFT_TMP_REGNUM);
        operands[6] = operands[4];
        if (!H_REG_P (operands[2]))
@@ -3958,6 +3994,7 @@
            operands[5] = operands[2];
 	   operands[8] = operands[7] = operands[0];
 	 }
+	 }
      }
    else
      {
-- 
GitLab