This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Use ColdFire V4 MVS/MVZ instructions to create constants
- From: Peter Barada <peter at the-baradas dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: peter at the-baradas dot com
- Date: Wed, 5 May 2004 10:05:44 -0400 (EDT)
- Subject: [PATCH] Use ColdFire V4 MVS/MVZ instructions to create constants
ColdFire V4 adds the instructions MVZ and MVS to load a 16 bit value
and either zero or sign extend it to 32 bits. It can take a 16 bit
value as an operand to produce 32 bit constants in the range
-32767 to 65535.
2004-05-05 Peter Barada <peter@the-baradas.com>
* gcc/config/m68k/m68k.c(CONST_METHOD): Add MVZ, MVS.
* gcc/config/m68k/m68k.c(const_method): Likewise.
* gcc/config/m68k/m68k.c(const_int_cost): Likewise.
* gcc/config/m68k/m68k.c(const_int_cost): Likewise.
* gcc/config/m68k/m68k.c(output_move_const_into_data_reg): Likewise.
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 14:01:06 -0000
*************** legitimize_pic_address (rtx orig, enum m
*** 1470,1476 ****
}
! typedef enum { MOVL, SWAP, NEGW, NOTW, NOTB, MOVQ } CONST_METHOD;
static CONST_METHOD const_method (rtx);
--- 1470,1476 ----
}
! typedef enum { MOVL, SWAP, NEGW, NOTW, NOTB, MOVQ, MVS, MVZ } CONST_METHOD;
static CONST_METHOD const_method (rtx);
*************** const_method (rtx constant)
*** 1505,1510 ****
--- 1505,1520 ----
if (USE_MOVQ ((u >> 16) | (u << 16)))
return SWAP;
}
+
+ if (TARGET_CFV4)
+ {
+ /* Try using MVZ/MVS with an immedaite value to load constants. */
+ if (i >= 0 && i <= 65535)
+ return MVZ;
+ if (i >= -32768 && i <= 32767)
+ return MVS;
+ }
+
/* Otherwise, use move.l */
return MOVL;
}
*************** const_int_cost (rtx constant)
*** 1517,1522 ****
--- 1527,1534 ----
case MOVQ :
/* Constants between -128 and 127 are cheap due to moveq */
return 0;
+ case MVZ:
+ case MVS:
case NOTB :
case NOTW :
case NEGW :
*************** output_move_const_into_data_reg (rtx *op
*** 1661,1666 ****
--- 1673,1682 ----
i = INTVAL (operands[1]);
switch (const_method (operands[1]))
{
+ case MVZ:
+ return "mvsw %1,%0";
+ case MVS:
+ return "mvzw %1,%0";
case MOVQ :
return "moveq %1,%0";
case NOTB :