This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use ColdFire V4 mov3q instruction to store constants to memory


ColdFire V4 adds the MOV3Q instruction which allows for storing a SImode
constant in the range of (-1, 1 .. 7) to memory.

2004-05-05  Peter Barada  <peter@the-baradas.com>
	* gcc/config/m68k/m68k-protos.h: Add prototype for valid_mov3q_const.
	* gcc/config/m68k/m68k.h(EXTRA_CONSTRAINTS): Add 'R' for mov3q.
	* gcc/config/m68k/m68k.c(output_move_simode_const): Use mov3q
          if possile.
	* gcc/config/m68k/m68k.md(pushexthsi_const): Likewise
	* gcc/config/m68k/m68k.md: Split off ColdFire movsi insn and
          add 'R' constraint for mov3q.


Index: m68k-protos.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k-protos.h,v
retrieving revision 1.14
diff -c -3 -p -r1.14 m68k-protos.h
*** m68k-protos.h	11 Oct 2003 06:35:53 -0000	1.14
--- m68k-protos.h	5 May 2004 15:46:13 -0000
***************
*** 1,5 ****
  /* Definitions of target machine for GNU compiler.  Sun 68000/68020 version.
!    Copyright (C) 2000, 2002 Free Software Foundation, Inc.
  
  This file is part of GCC.
  
--- 1,5 ----
  /* Definitions of target machine for GNU compiler.  Sun 68000/68020 version.
!    Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
  
  This file is part of GCC.
  
*************** Boston, MA 02111-1307, USA.  */
*** 23,28 ****
--- 23,29 ----
  #ifdef RTX_CODE
  extern HOST_WIDE_INT m68k_initial_elimination_offset (int from, int to);
  extern const char *output_move_const_into_data_reg (rtx *);
+ extern int valid_move3q_const (rtx);
  extern const char *output_move_simode_const (rtx *);
  extern const char *output_move_simode (rtx *);
  extern const char *output_move_himode (rtx *);
Index: m68k.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.h,v
retrieving revision 1.110
diff -c -3 -p -r1.110 m68k.h
*** m68k.h	10 Mar 2004 05:07:45 -0000	1.110
--- m68k.h	5 May 2004 15:46:13 -0000
*************** extern enum reg_class regno_reg_class[];
*** 734,743 ****
--- 734,749 ----
     second operand.
  
     `Q' means address register indirect addressing mode.
+    `R' means for ColdFire a valid constant usable by mov3q.
     `S' is for operands that satisfy 'm' when -mpcrel is in effect.
     `T' is for operands that satisfy 's' when -mpcrel is not in effect.  */
  
  #define EXTRA_CONSTRAINT(OP,CODE)			\
+   ((((CODE) == 'R') && TARGET_CFV4)			\
+    ? (GET_CODE (OP) == CONST_INT			\
+       && (INTVAL (OP) == -1				\
+           || (INTVAL (OP) >= 1 && INTVAL (OP) <= 7)))	\
+    :							\
    (((CODE) == 'S')					\
     ? (TARGET_PCREL					\
        && GET_CODE (OP) == MEM				\
*************** extern enum reg_class regno_reg_class[];
*** 755,761 ****
     ? (GET_CODE (OP) == MEM 				\
        && GET_CODE (XEXP (OP, 0)) == REG)		\
     :							\
!    0)))
  
  /* Given an rtx X being reloaded into a reg required to be
     in class CLASS, return the class of reg to actually use.
--- 761,767 ----
     ? (GET_CODE (OP) == MEM 				\
        && GET_CODE (XEXP (OP, 0)) == REG)		\
     :							\
!    0))))
  
  /* Given an rtx X being reloaded into a reg required to be
     in class CLASS, return the class of reg to actually use.
Index: m68k.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.c,v
retrieving revision 1.129
diff -c -3 -p -r1.129 m68k.c
*** m68k.c	10 Mar 2004 05:07:45 -0000	1.129
--- m68k.c	5 May 2004 15:46:14 -0000
*************** output_move_const_into_data_reg (rtx *op
*** 1688,1693 ****
--- 1688,1706 ----
      }
  }
  
+ int
+ valid_mov3q_const(rtx constant)
+ {
+   int i;
+ 
+   if (GET_CODE (constant) == CONST_INT) {
+     i = INTVAL (constant);
+     if ((i == -1) || (i >= 1 && i <= 7))
+       return 1;
+   }
+   return 0;
+ }
+ 
  const char *
  output_move_simode_const (rtx *operands)
  {
*************** output_move_simode_const (rtx *operands)
*** 1705,1710 ****
--- 1718,1726 ----
      return "sub%.l %0,%0";
    else if (DATA_REG_P (operands[0]))
      return output_move_const_into_data_reg (operands);
+   else if (TARGET_CFV4 && (GET_MODE (operands[0]) == SImode)
+ 	   && valid_mov3q_const (operands[1]))
+     return "move3q%.l %1,%0";
    else if (ADDRESS_REG_P (operands[0])
  	   && INTVAL (operands[1]) < 0x8000
  	   && INTVAL (operands[1]) >= -0x8000)
Index: m68k.md
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.md,v
retrieving revision 1.75
diff -c -3 -p -r1.75 m68k.md
*** m68k.md	16 Mar 2004 03:54:33 -0000	1.75
--- m68k.md	5 May 2004 15:46:15 -0000
***************
*** 587,592 ****
--- 587,594 ----
  {
    if (operands[1] == const0_rtx)
      return "clr%.l %0";
+   if (valid_movq3_const (operands[1])
+     return "mov3q%.l %1,%-";
    return "pea %a1";
  })
  
***************
*** 678,684 ****
  (define_insn ""
    [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g")
  	(match_operand:SI 1 "general_operand" "g,r<Q>"))]
!   "TARGET_COLDFIRE"
    "* return output_move_simode (operands);")
  
  ;; Special case of fullword move, where we need to get a non-GOT PIC
--- 680,692 ----
  (define_insn ""
    [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g")
  	(match_operand:SI 1 "general_operand" "g,r<Q>"))]
!   "TARGET_COLDFIRE && !TARGET_CFV4"
!   "* return output_move_simode (operands);")
! 
! (define_insn ""
!   [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g")
! 	(match_operand:SI 1 "general_operand" "g,Rr<Q>"))]
!   "TARGET_CFV4"
    "* return output_move_simode (operands);")
  
  ;; Special case of fullword move, where we need to get a non-GOT PIC


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]