* [m68k] ColdFire V4 patch
@ 2004-06-15 0:27 Peter Barada
2004-06-15 10:53 ` Andreas Schwab
2004-07-26 23:06 ` Roman Zippel
0 siblings, 2 replies; 10+ messages in thread
From: Peter Barada @ 2004-06-15 0:27 UTC (permalink / raw)
To: gcc-patches; +Cc: peter
This patch adds mov3q, mvs/mvz support for ColdFire V4 cores, updates
MUL costs for V3/V4, uses bitfiled instructions where possible for ColdFire.
Built uberbaum tree with it.
gcc/
2004-06-14 Peter Barada <peter@the-baradas.com>
* config/m68k/m68k.md: (movsi_cfv4): New pattern to allow mov3q.
(movsi_cf): make named, don't match TARGET_CFV4.
(pushexthisi_const): Use mov3q if possible.
(extendhisi2, cvf4_extendhisi2): Split extendhisi2 pattern
to special case mvz.w for ColdFire V4.
(extendqisi2, cvf4_extendqisi2): Split extendhisi2 pattern
to special case mvz.b for ColdFire V4.
(udivmodhi4, divmodhi4): Use mvz to zero extend arg for
divide.
(iorsi3, xorsi3, andsi3): Use bitfiled instructiosn if possible.
* config/m68k/m68k.c(valid_mov3q_const): New function.
(const_method): SWAP is valid for ColdFire.
(MULL_COST, MULW_COST): Fix costs for ColdFire V3/V4.
* config/m68k/m68k-protos.h: Prototype here.
Index: gcc/config/m68k/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
*** gcc/config/m68k/m68k-protos.h 11 Oct 2003 06:35:53 -0000 1.14
--- gcc/config/m68k/m68k-protos.h 14 Jun 2004 23:20:06 -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_mov3q_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: gcc/config/m68k/m68k.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.c,v
retrieving revision 1.133
diff -c -3 -p -r1.133 m68k.c
*** gcc/config/m68k/m68k.c 1 Jun 2004 13:22:04 -0000 1.133
--- gcc/config/m68k/m68k.c 14 Jun 2004 23:20:06 -0000
*************** const_method (rtx constant)
*** 1447,1458 ****
/* This is the only value where neg.w is useful */
if (i == -65408)
return NEGW;
- /* Try also with swap */
- u = i;
- if (USE_MOVQ ((u >> 16) | (u << 16)))
- return SWAP;
}
if (TARGET_CFV4)
{
/* Try using MVZ/MVS with an immediate value to load constants. */
--- 1447,1459 ----
/* This is the only value where neg.w is useful */
if (i == -65408)
return NEGW;
}
+ /* Try also with swap */
+ u = i;
+ if (USE_MOVQ ((u >> 16) | (u << 16)))
+ return SWAP;
+
if (TARGET_CFV4)
{
/* Try using MVZ/MVS with an immediate value to load constants. */
*************** m68k_rtx_costs (rtx x, int code, int out
*** 1524,1532 ****
for add and the time for shift, taking away a little more because
sometimes move insns are needed. */
/* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
! #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : TARGET_CFV3 ? 3 : TARGET_COLDFIRE ? 10 : 13)
#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
! TARGET_CFV3 ? 2 : 5)
#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
case PLUS:
--- 1525,1533 ----
for add and the time for shift, taking away a little more because
sometimes move insns are needed. */
/* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
! #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : (TARGET_COLDFIRE && !TARGET_5200) ? 3 : TARGET_COLDFIRE ? 10 : 13)
#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
! (TARGET_COLDFIRE && !TARGET_5200) ? 2 : 5)
#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
case PLUS:
*************** output_move_const_into_data_reg (rtx *op
*** 1651,1656 ****
--- 1652,1674 ----
}
}
+ /* Return 1 if 'constant' can be represented by
+ mov3q on a ColdFire V4 core */
+ int
+ valid_mov3q_const(constant)
+ rtx constant;
+ {
+ int i;
+
+ if (TARGET_CFV4 && 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)
*** 1663,1668 ****
--- 1681,1689 ----
|| !(GET_CODE (operands[0]) == MEM
&& MEM_VOLATILE_P (operands[0]))))
return "clr%.l %0";
+ else if ((GET_MODE(operands[0]) == SImode)
+ && valid_mov3q_const(operands[1]))
+ return "mov3q%.l %1,%0";
else if (operands[1] == const0_rtx
&& ADDRESS_REG_P (operands[0]))
return "sub%.l %0,%0";
*************** output_move_simode_const (rtx *operands)
*** 1671,1683 ****
else if (ADDRESS_REG_P (operands[0])
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! return "move%.w %1,%0";
else if (GET_CODE (operands[0]) == MEM
&& GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
&& REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! return "pea %a1";
return "move%.l %1,%0";
}
--- 1692,1712 ----
else if (ADDRESS_REG_P (operands[0])
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! {
! if (valid_mov3q_const (operands[1]))
! return "mov3q%.l %1,%0";
! return "move%.w %1,%0";
! }
else if (GET_CODE (operands[0]) == MEM
&& GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
&& REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! {
! if (valid_mov3q_const (operands[1]))
! return "mov3q%.l %1,%-";
! return "pea %a1";
! }
return "move%.l %1,%0";
}
Index: gcc/config/m68k/m68k.md
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.md,v
retrieving revision 1.76
diff -c -3 -p -r1.76 m68k.md
*** gcc/config/m68k/m68k.md 29 May 2004 15:10:41 -0000 1.76
--- gcc/config/m68k/m68k.md 14 Jun 2004 23:20:07 -0000
***************
*** 587,592 ****
--- 587,594 ----
{
if (operands[1] == const0_rtx)
return "clr%.l %0";
+ if (valid_mov3q_const(operands[1]))
+ return "mov3q%.l %1,%-";
return "pea %a1";
})
***************
*** 675,684 ****
return output_move_simode (operands);
})
! (define_insn ""
[(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
(match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
! "TARGET_COLDFIRE"
"* return output_move_simode (operands);")
;; Special case of fullword move, where we need to get a non-GOT PIC
--- 677,692 ----
return output_move_simode (operands);
})
! (define_insn "movsi_cf"
[(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
(match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
! "TARGET_COLDFIRE && !TARGET_CFV4"
! "* return output_move_simode (operands);")
!
! (define_insn "movsi_cfv4"
! [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
! (match_operand:SI 1 "general_operand" "Rg,Rr<Q>,U"))]
! "TARGET_CFV4"
"* return output_move_simode (operands);")
;; Special case of fullword move, where we need to get a non-GOT PIC
***************
*** 1250,1255 ****
--- 1258,1265 ----
{
if (DATA_REG_P (operands[0]))
{
+ if (TARGET_CFV4)
+ return "mvz%.w %1,%0";
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
return "and%.l #0xFFFF,%0";
***************
*** 1280,1289 ****
{
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
! return (!TARGET_COLDFIRE ? "and%.w #0xFF,%0" : "and%.l #0xFF,%0");
if (reg_mentioned_p (operands[0], operands[1]))
! return (!TARGET_COLDFIRE ? "move%.b %1,%0\;and%.w #0xFF,%0"
! : "move%.b %1,%0\;and%.l #0xFF,%0");
return "clr%.w %0\;move%.b %1,%0";
}
else if (GET_CODE (operands[0]) == MEM
--- 1290,1307 ----
{
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
! {
! if (TARGET_CFV4)
! return "mvz%.b %0,%0";
! return (!TARGET_COLDFIRE ? "and%.w #0xFF,%0" : "and%.l #0xFF,%0");
! }
if (reg_mentioned_p (operands[0], operands[1]))
! {
! if (TARGET_CFV4)
! return "mvz%.b %1,%0";
! return (!TARGET_COLDFIRE ? "move%.b %1,%0\;and%.w #0xFF,%0"
! : "move%.b %1,%0\;and%.l #0xFF,%0");
! }
return "clr%.w %0\;move%.b %1,%0";
}
else if (GET_CODE (operands[0]) == MEM
***************
*** 1318,1323 ****
--- 1336,1343 ----
{
if (DATA_REG_P (operands[0]))
{
+ if (TARGET_CFV4)
+ return "mvz%.b %1,%0";
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
return "and%.l #0xFF,%0";
***************
*** 1358,1363 ****
--- 1378,1385 ----
{
CC_STATUS_INIT;
operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
+ if (TARGET_CFV4)
+ return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
if (TARGET_68020 || TARGET_COLDFIRE)
return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
else
***************
*** 1372,1377 ****
--- 1394,1401 ----
{
CC_STATUS_INIT;
operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
+ if (TARGET_CFV4)
+ return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
if (TARGET_68020 || TARGET_COLDFIRE)
return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
else
***************
*** 1423,1433 ****
return "smi %0\;ext%.w %0\;ext%.l %0";
})
! (define_insn "extendhisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
(sign_extend:SI
(match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
! ""
{
if (ADDRESS_REG_P (operands[0]))
return "move%.w %1,%0";
--- 1447,1471 ----
return "smi %0\;ext%.w %0\;ext%.l %0";
})
! (define_expand "extendhisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "")
! (sign_extend:SI
! (match_operand:HI 1 "nonimmediate_src_operand" "")))]
! ""
! "")
!
! (define_insn "cfv4_extendhisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
! (sign_extend:SI
! (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
! "TARGET_CFV4"
! "mvs%.w %1,%0")
!
! (define_insn "68k_extendhisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
(sign_extend:SI
(match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
! "!TARGET_CFV4"
{
if (ADDRESS_REG_P (operands[0]))
return "move%.w %1,%0";
***************
*** 1440,1449 ****
""
"ext%.w %0")
! (define_insn "extendqisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
! "TARGET_68020 || TARGET_COLDFIRE"
"extb%.l %0")
\f
;; Conversions between float and double.
--- 1478,1499 ----
""
"ext%.w %0")
! (define_expand "extendqisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "")
! (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
! "TARGET_68020 || TARGET_COLDFIRE"
! "")
!
! (define_insn "cfv4_extendqisi2"
! [(set (match_operand:SI 0 "general_operand" "=d")
! (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
! "TARGET_CFV4"
! "mvs%.b %1,%0")
!
! (define_insn "m68k_extendqisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
! "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_CFV4)"
"extb%.l %0")
\f
;; Conversions between float and double.
***************
*** 2985,2994 ****
(umod:HI (match_dup 1) (match_dup 2)))]
"!TARGET_COLDFIRE || TARGET_CF_HWDIV"
{
! output_asm_insn (MOTOROLA ?
! "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
! "and%.l #0xFFFF,%0\;divu %2,%0",
! operands);
if (!find_reg_note(insn, REG_UNUSED, operands[3]))
{
CC_STATUS_INIT;
--- 3035,3051 ----
(umod:HI (match_dup 1) (match_dup 2)))]
"!TARGET_COLDFIRE || TARGET_CF_HWDIV"
{
! if (TARGET_CFV4)
! output_asm_insn (MOTOROLA ?
! "mvz%.w %0,%0\;divu%.w %2,%0" :
! "mvz%.w %0,%0\;divu %2,%0",
! operands);
! else
! output_asm_insn (MOTOROLA ?
! "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
! "and%.l #0xFFFF,%0\;divu %2,%0",
! operands);
!
if (!find_reg_note(insn, REG_UNUSED, operands[3]))
{
CC_STATUS_INIT;
***************
*** 3091,3097 ****
(and:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! "and%.l %2,%0")
(define_insn "andhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
--- 3148,3164 ----
(and:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! {
! if (TARGET_CFV4 && DATA_REG_P (operands[0])
! && GET_CODE (operands[2]) == CONST_INT)
! {
! if (INTVAL (operands[2]) == 0x000000ff)
! return \"mvz%.b %0,%0\";
! else if (INTVAL (operands[2]) == 0x0000ffff)
! return \"mvz%.w %0,%0\";
! }
! return output_andsi3 (operands);
! })
(define_insn "andhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
***************
*** 3253,3259 ****
(ior:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! "or%.l %2,%0")
(define_insn "iorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
--- 3320,3328 ----
(ior:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! {
! return output_iorsi3 (operands);
! })
(define_insn "iorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
***************
*** 3432,3438 ****
(xor:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_operand" "d,Ks")))]
"TARGET_COLDFIRE"
! "eor%.l %2,%0")
(define_insn "xorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
--- 3501,3509 ----
(xor:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_operand" "d,Ks")))]
"TARGET_COLDFIRE"
! {
! return output_xorsi3 (operands);
! })
(define_insn "xorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [m68k] ColdFire V4 patch
2004-06-15 0:27 [m68k] ColdFire V4 patch Peter Barada
@ 2004-06-15 10:53 ` Andreas Schwab
2004-06-15 15:13 ` Peter Barada
2004-06-15 15:15 ` Peter Barada
2004-07-26 23:06 ` Roman Zippel
1 sibling, 2 replies; 10+ messages in thread
From: Andreas Schwab @ 2004-06-15 10:53 UTC (permalink / raw)
To: Peter Barada; +Cc: gcc-patches
Peter Barada <peter@the-baradas.com> writes:
> *************** output_move_const_into_data_reg (rtx *op
> *** 1651,1656 ****
> --- 1652,1674 ----
> }
> }
>
> + /* Return 1 if 'constant' can be represented by
> + mov3q on a ColdFire V4 core */
> + int
> + valid_mov3q_const(constant)
> + rtx constant;
> + {
> + int i;
> +
> + if (TARGET_CFV4 && GET_CODE(constant) == CONST_INT) {
> + i = INTVAL(constant);
> + if ((i == -1) || (i >= 1 && i <= 7))
> + return 1;
> + }
> + return 0;
> + }
Style: Space before open paren in function calls, brace on own line, no
old-style decls any more, comments should end with a period.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [m68k] ColdFire V4 patch
2004-06-15 10:53 ` Andreas Schwab
@ 2004-06-15 15:13 ` Peter Barada
2004-06-15 15:15 ` Peter Barada
1 sibling, 0 replies; 10+ messages in thread
From: Peter Barada @ 2004-06-15 15:13 UTC (permalink / raw)
To: schwab; +Cc: gcc-patches
>Style: Space before open paren in function calls, brace on own line, no
>old-style decls any more, comments should end with a period.
Here it is again, cleaned up:
This patch adds mov3q, mvs/mvz support for ColdFire V4 cores, updates
MUL costs for V3/V4, uses bitfiled instructions where possible for ColdFire.
Built uberbaum tree with it.
gcc/
2004-06-15 Peter Barada <peter@the-baradas.com>
* config/m68k/m68k.md: (movsi_cfv4): New pattern to allow mov3q.
(movsi_cf): make named, don't match TARGET_CFV4.
(pushexthisi_const): Use mov3q if possible.
(extendhisi2, cvf4_extendhisi2): Split extendhisi2 pattern
to special case mvz.w for ColdFire V4.
(extendqisi2, cvf4_extendqisi2): Split extendhisi2 pattern
to special case mvz.b for ColdFire V4.
(udivmodhi4, divmodhi4): Use mvz to zero extend arg for
divide.
(iorsi3, xorsi3, andsi3): Use bitfiled instructiosn if possible.
* config/m68k/m68k.c(valid_mov3q_const): New function.
(const_method): SWAP is valid for ColdFire.
(MULL_COST, MULW_COST): Fix costs for ColdFire V3/V4.
* config/m68k/m68k-protos.h: Prototype here.
Index: gcc/config/m68k/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
*** gcc/config/m68k/m68k-protos.h 11 Oct 2003 06:35:53 -0000 1.14
--- gcc/config/m68k/m68k-protos.h 15 Jun 2004 14:19:28 -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_mov3q_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: gcc/config/m68k/m68k.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.c,v
retrieving revision 1.133
diff -c -3 -p -r1.133 m68k.c
*** gcc/config/m68k/m68k.c 1 Jun 2004 13:22:04 -0000 1.133
--- gcc/config/m68k/m68k.c 15 Jun 2004 14:19:28 -0000
*************** const_method (rtx constant)
*** 1441,1458 ****
N^ff will be, so use moveq #N^ff, dreg; not.b dreg. */
if (USE_MOVQ (i ^ 0xff))
return NOTB;
! /* Likewise, try with not.w */
if (USE_MOVQ (i ^ 0xffff))
return NOTW;
! /* This is the only value where neg.w is useful */
if (i == -65408)
return NEGW;
- /* Try also with swap */
- u = i;
- if (USE_MOVQ ((u >> 16) | (u << 16)))
- return SWAP;
}
if (TARGET_CFV4)
{
/* Try using MVZ/MVS with an immediate value to load constants. */
--- 1441,1459 ----
N^ff will be, so use moveq #N^ff, dreg; not.b dreg. */
if (USE_MOVQ (i ^ 0xff))
return NOTB;
! /* Likewise, try with not.w. */
if (USE_MOVQ (i ^ 0xffff))
return NOTW;
! /* This is the only value where neg.w is useful. */
if (i == -65408)
return NEGW;
}
+ /* Try also with swap. */
+ u = i;
+ if (USE_MOVQ ((u >> 16) | (u << 16)))
+ return SWAP;
+
if (TARGET_CFV4)
{
/* Try using MVZ/MVS with an immediate value to load constants. */
*************** const_method (rtx constant)
*** 1462,1468 ****
return MVS;
}
! /* Otherwise, use move.l */
return MOVL;
}
--- 1463,1469 ----
return MVS;
}
! /* Otherwise, use move.l. */
return MOVL;
}
*************** const_int_cost (rtx constant)
*** 1472,1478 ****
switch (const_method (constant))
{
case MOVQ :
! /* Constants between -128 and 127 are cheap due to moveq */
return 0;
case MVZ:
case MVS:
--- 1473,1479 ----
switch (const_method (constant))
{
case MOVQ :
! /* Constants between -128 and 127 are cheap due to moveq. */
return 0;
case MVZ:
case MVS:
*************** const_int_cost (rtx constant)
*** 1480,1486 ****
case NOTW :
case NEGW :
case SWAP :
! /* Constants easily generated by moveq + not.b/not.w/neg.w/swap */
return 1;
case MOVL :
return 2;
--- 1481,1487 ----
case NOTW :
case NEGW :
case SWAP :
! /* Constants easily generated by moveq + not.b/not.w/neg.w/swap. */
return 1;
case MOVL :
return 2;
*************** m68k_rtx_costs (rtx x, int code, int out
*** 1524,1532 ****
for add and the time for shift, taking away a little more because
sometimes move insns are needed. */
/* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
! #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : TARGET_CFV3 ? 3 : TARGET_COLDFIRE ? 10 : 13)
#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
! TARGET_CFV3 ? 2 : 5)
#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
case PLUS:
--- 1525,1533 ----
for add and the time for shift, taking away a little more because
sometimes move insns are needed. */
/* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
! #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : (TARGET_COLDFIRE && !TARGET_5200) ? 3 : TARGET_COLDFIRE ? 10 : 13)
#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
! (TARGET_COLDFIRE && !TARGET_5200) ? 2 : 5)
#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
case PLUS:
*************** output_move_const_into_data_reg (rtx *op
*** 1651,1656 ****
--- 1652,1674 ----
}
}
+ /* Return 1 if 'constant' can be represented by
+ mov3q on a ColdFire V4 core. */
+ int
+ valid_mov3q_const (rtx constant)
+ {
+ int i;
+
+ if (TARGET_CFV4 && 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)
*** 1663,1668 ****
--- 1681,1689 ----
|| !(GET_CODE (operands[0]) == MEM
&& MEM_VOLATILE_P (operands[0]))))
return "clr%.l %0";
+ else if ((GET_MODE (operands[0]) == SImode)
+ && valid_mov3q_const (operands[1]))
+ return "mov3q%.l %1,%0";
else if (operands[1] == const0_rtx
&& ADDRESS_REG_P (operands[0]))
return "sub%.l %0,%0";
*************** output_move_simode_const (rtx *operands)
*** 1671,1683 ****
else if (ADDRESS_REG_P (operands[0])
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! return "move%.w %1,%0";
else if (GET_CODE (operands[0]) == MEM
&& GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
&& REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! return "pea %a1";
return "move%.l %1,%0";
}
--- 1692,1712 ----
else if (ADDRESS_REG_P (operands[0])
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! {
! if (valid_mov3q_const (operands[1]))
! return "mov3q%.l %1,%0";
! return "move%.w %1,%0";
! }
else if (GET_CODE (operands[0]) == MEM
&& GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
&& REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! {
! if (valid_mov3q_const (operands[1]))
! return "mov3q%.l %1,%-";
! return "pea %a1";
! }
return "move%.l %1,%0";
}
Index: gcc/config/m68k/m68k.md
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.md,v
retrieving revision 1.76
diff -c -3 -p -r1.76 m68k.md
*** gcc/config/m68k/m68k.md 29 May 2004 15:10:41 -0000 1.76
--- gcc/config/m68k/m68k.md 15 Jun 2004 14:19:29 -0000
***************
*** 587,592 ****
--- 587,594 ----
{
if (operands[1] == const0_rtx)
return "clr%.l %0";
+ if (valid_mov3q_const(operands[1]))
+ return "mov3q%.l %1,%-";
return "pea %a1";
})
***************
*** 675,684 ****
return output_move_simode (operands);
})
! (define_insn ""
[(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
(match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
! "TARGET_COLDFIRE"
"* return output_move_simode (operands);")
;; Special case of fullword move, where we need to get a non-GOT PIC
--- 677,692 ----
return output_move_simode (operands);
})
! (define_insn "movsi_cf"
[(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
(match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
! "TARGET_COLDFIRE && !TARGET_CFV4"
! "* return output_move_simode (operands);")
!
! (define_insn "movsi_cfv4"
! [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
! (match_operand:SI 1 "general_operand" "Rg,Rr<Q>,U"))]
! "TARGET_CFV4"
"* return output_move_simode (operands);")
;; Special case of fullword move, where we need to get a non-GOT PIC
***************
*** 1250,1255 ****
--- 1258,1265 ----
{
if (DATA_REG_P (operands[0]))
{
+ if (TARGET_CFV4)
+ return "mvz%.w %1,%0";
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
return "and%.l #0xFFFF,%0";
***************
*** 1280,1289 ****
{
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
! return (!TARGET_COLDFIRE ? "and%.w #0xFF,%0" : "and%.l #0xFF,%0");
if (reg_mentioned_p (operands[0], operands[1]))
! return (!TARGET_COLDFIRE ? "move%.b %1,%0\;and%.w #0xFF,%0"
! : "move%.b %1,%0\;and%.l #0xFF,%0");
return "clr%.w %0\;move%.b %1,%0";
}
else if (GET_CODE (operands[0]) == MEM
--- 1290,1307 ----
{
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
! {
! if (TARGET_CFV4)
! return "mvz%.b %0,%0";
! return (!TARGET_COLDFIRE ? "and%.w #0xFF,%0" : "and%.l #0xFF,%0");
! }
if (reg_mentioned_p (operands[0], operands[1]))
! {
! if (TARGET_CFV4)
! return "mvz%.b %1,%0";
! return (!TARGET_COLDFIRE ? "move%.b %1,%0\;and%.w #0xFF,%0"
! : "move%.b %1,%0\;and%.l #0xFF,%0");
! }
return "clr%.w %0\;move%.b %1,%0";
}
else if (GET_CODE (operands[0]) == MEM
***************
*** 1318,1323 ****
--- 1336,1343 ----
{
if (DATA_REG_P (operands[0]))
{
+ if (TARGET_CFV4)
+ return "mvz%.b %1,%0";
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
return "and%.l #0xFF,%0";
***************
*** 1358,1363 ****
--- 1378,1385 ----
{
CC_STATUS_INIT;
operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
+ if (TARGET_CFV4)
+ return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
if (TARGET_68020 || TARGET_COLDFIRE)
return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
else
***************
*** 1372,1377 ****
--- 1394,1401 ----
{
CC_STATUS_INIT;
operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
+ if (TARGET_CFV4)
+ return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
if (TARGET_68020 || TARGET_COLDFIRE)
return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
else
***************
*** 1423,1433 ****
return "smi %0\;ext%.w %0\;ext%.l %0";
})
! (define_insn "extendhisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
(sign_extend:SI
(match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
! ""
{
if (ADDRESS_REG_P (operands[0]))
return "move%.w %1,%0";
--- 1447,1471 ----
return "smi %0\;ext%.w %0\;ext%.l %0";
})
! (define_expand "extendhisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "")
! (sign_extend:SI
! (match_operand:HI 1 "nonimmediate_src_operand" "")))]
! ""
! "")
!
! (define_insn "cfv4_extendhisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
! (sign_extend:SI
! (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
! "TARGET_CFV4"
! "mvs%.w %1,%0")
!
! (define_insn "68k_extendhisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
(sign_extend:SI
(match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
! "!TARGET_CFV4"
{
if (ADDRESS_REG_P (operands[0]))
return "move%.w %1,%0";
***************
*** 1440,1449 ****
""
"ext%.w %0")
! (define_insn "extendqisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
! "TARGET_68020 || TARGET_COLDFIRE"
"extb%.l %0")
\f
;; Conversions between float and double.
--- 1478,1499 ----
""
"ext%.w %0")
! (define_expand "extendqisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "")
! (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
! "TARGET_68020 || TARGET_COLDFIRE"
! "")
!
! (define_insn "cfv4_extendqisi2"
! [(set (match_operand:SI 0 "general_operand" "=d")
! (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
! "TARGET_CFV4"
! "mvs%.b %1,%0")
!
! (define_insn "m68k_extendqisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
! "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_CFV4)"
"extb%.l %0")
\f
;; Conversions between float and double.
***************
*** 2985,2994 ****
(umod:HI (match_dup 1) (match_dup 2)))]
"!TARGET_COLDFIRE || TARGET_CF_HWDIV"
{
! output_asm_insn (MOTOROLA ?
! "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
! "and%.l #0xFFFF,%0\;divu %2,%0",
! operands);
if (!find_reg_note(insn, REG_UNUSED, operands[3]))
{
CC_STATUS_INIT;
--- 3035,3051 ----
(umod:HI (match_dup 1) (match_dup 2)))]
"!TARGET_COLDFIRE || TARGET_CF_HWDIV"
{
! if (TARGET_CFV4)
! output_asm_insn (MOTOROLA ?
! "mvz%.w %0,%0\;divu%.w %2,%0" :
! "mvz%.w %0,%0\;divu %2,%0",
! operands);
! else
! output_asm_insn (MOTOROLA ?
! "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
! "and%.l #0xFFFF,%0\;divu %2,%0",
! operands);
!
if (!find_reg_note(insn, REG_UNUSED, operands[3]))
{
CC_STATUS_INIT;
***************
*** 3091,3097 ****
(and:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! "and%.l %2,%0")
(define_insn "andhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
--- 3148,3164 ----
(and:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! {
! if (TARGET_CFV4 && DATA_REG_P (operands[0])
! && GET_CODE (operands[2]) == CONST_INT)
! {
! if (INTVAL (operands[2]) == 0x000000ff)
! return \"mvz%.b %0,%0\";
! else if (INTVAL (operands[2]) == 0x0000ffff)
! return \"mvz%.w %0,%0\";
! }
! return output_andsi3 (operands);
! })
(define_insn "andhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
***************
*** 3253,3259 ****
(ior:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! "or%.l %2,%0")
(define_insn "iorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
--- 3320,3328 ----
(ior:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! {
! return output_iorsi3 (operands);
! })
(define_insn "iorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
***************
*** 3432,3438 ****
(xor:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_operand" "d,Ks")))]
"TARGET_COLDFIRE"
! "eor%.l %2,%0")
(define_insn "xorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
--- 3501,3509 ----
(xor:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_operand" "d,Ks")))]
"TARGET_COLDFIRE"
! {
! return output_xorsi3 (operands);
! })
(define_insn "xorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [m68k] ColdFire V4 patch
2004-06-15 10:53 ` Andreas Schwab
2004-06-15 15:13 ` Peter Barada
@ 2004-06-15 15:15 ` Peter Barada
2004-06-15 21:11 ` Richard Henderson
1 sibling, 1 reply; 10+ messages in thread
From: Peter Barada @ 2004-06-15 15:15 UTC (permalink / raw)
To: schwab; +Cc: gcc-patches, peter
>Style: Space before open paren in function calls, brace on own line, no
>old-style decls any more, comments should end with a period.
Here it is again, cleaned up:
This patch adds mov3q, mvs/mvz support for ColdFire V4 cores, updates
MUL costs for V3/V4, uses bitfiled instructions where possible for ColdFire.
Built uberbaum tree with it.
gcc/
2004-06-15 Peter Barada <peter@the-baradas.com>
* config/m68k/m68k.md: (movsi_cfv4): New pattern to allow mov3q.
(movsi_cf): make named, don't match TARGET_CFV4.
(pushexthisi_const): Use mov3q if possible.
(extendhisi2, cvf4_extendhisi2): Split extendhisi2 pattern
to special case mvz.w for ColdFire V4.
(extendqisi2, cvf4_extendqisi2): Split extendhisi2 pattern
to special case mvz.b for ColdFire V4.
(udivmodhi4, divmodhi4): Use mvz to zero extend arg for
divide.
(iorsi3, xorsi3, andsi3): Use bitfiled instructiosn if possible.
* config/m68k/m68k.c(valid_mov3q_const): New function.
(const_method): SWAP is valid for ColdFire.
(MULL_COST, MULW_COST): Fix costs for ColdFire V3/V4.
* config/m68k/m68k-protos.h: Prototype here.
Index: gcc/config/m68k/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
*** gcc/config/m68k/m68k-protos.h 11 Oct 2003 06:35:53 -0000 1.14
--- gcc/config/m68k/m68k-protos.h 15 Jun 2004 14:25:26 -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_mov3q_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: gcc/config/m68k/m68k.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.c,v
retrieving revision 1.133
diff -c -3 -p -r1.133 m68k.c
*** gcc/config/m68k/m68k.c 1 Jun 2004 13:22:04 -0000 1.133
--- gcc/config/m68k/m68k.c 15 Jun 2004 14:25:27 -0000
*************** const_method (rtx constant)
*** 1447,1458 ****
/* This is the only value where neg.w is useful */
if (i == -65408)
return NEGW;
- /* Try also with swap */
- u = i;
- if (USE_MOVQ ((u >> 16) | (u << 16)))
- return SWAP;
}
if (TARGET_CFV4)
{
/* Try using MVZ/MVS with an immediate value to load constants. */
--- 1447,1459 ----
/* This is the only value where neg.w is useful */
if (i == -65408)
return NEGW;
}
+ /* Try also with swap. */
+ u = i;
+ if (USE_MOVQ ((u >> 16) | (u << 16)))
+ return SWAP;
+
if (TARGET_CFV4)
{
/* Try using MVZ/MVS with an immediate value to load constants. */
*************** m68k_rtx_costs (rtx x, int code, int out
*** 1524,1532 ****
for add and the time for shift, taking away a little more because
sometimes move insns are needed. */
/* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
! #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : TARGET_CFV3 ? 3 : TARGET_COLDFIRE ? 10 : 13)
#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
! TARGET_CFV3 ? 2 : 5)
#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
case PLUS:
--- 1525,1533 ----
for add and the time for shift, taking away a little more because
sometimes move insns are needed. */
/* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
! #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : (TARGET_COLDFIRE && !TARGET_5200) ? 3 : TARGET_COLDFIRE ? 10 : 13)
#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
! (TARGET_COLDFIRE && !TARGET_5200) ? 2 : 5)
#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
case PLUS:
*************** output_move_const_into_data_reg (rtx *op
*** 1651,1656 ****
--- 1652,1674 ----
}
}
+ /* Return 1 if 'constant' can be represented by
+ mov3q on a ColdFire V4 core. */
+ int
+ valid_mov3q_const (rtx constant)
+ {
+ int i;
+
+ if (TARGET_CFV4 && 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)
*** 1663,1668 ****
--- 1681,1689 ----
|| !(GET_CODE (operands[0]) == MEM
&& MEM_VOLATILE_P (operands[0]))))
return "clr%.l %0";
+ else if ((GET_MODE (operands[0]) == SImode)
+ && valid_mov3q_const (operands[1]))
+ return "mov3q%.l %1,%0";
else if (operands[1] == const0_rtx
&& ADDRESS_REG_P (operands[0]))
return "sub%.l %0,%0";
*************** output_move_simode_const (rtx *operands)
*** 1671,1683 ****
else if (ADDRESS_REG_P (operands[0])
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! return "move%.w %1,%0";
else if (GET_CODE (operands[0]) == MEM
&& GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
&& REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! return "pea %a1";
return "move%.l %1,%0";
}
--- 1692,1712 ----
else if (ADDRESS_REG_P (operands[0])
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! {
! if (valid_mov3q_const (operands[1]))
! return "mov3q%.l %1,%0";
! return "move%.w %1,%0";
! }
else if (GET_CODE (operands[0]) == MEM
&& GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
&& REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! {
! if (valid_mov3q_const (operands[1]))
! return "mov3q%.l %1,%-";
! return "pea %a1";
! }
return "move%.l %1,%0";
}
Index: gcc/config/m68k/m68k.md
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.md,v
retrieving revision 1.76
diff -c -3 -p -r1.76 m68k.md
*** gcc/config/m68k/m68k.md 29 May 2004 15:10:41 -0000 1.76
--- gcc/config/m68k/m68k.md 15 Jun 2004 14:25:27 -0000
***************
*** 587,592 ****
--- 587,594 ----
{
if (operands[1] == const0_rtx)
return "clr%.l %0";
+ if (valid_mov3q_const(operands[1]))
+ return "mov3q%.l %1,%-";
return "pea %a1";
})
***************
*** 675,684 ****
return output_move_simode (operands);
})
! (define_insn ""
[(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
(match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
! "TARGET_COLDFIRE"
"* return output_move_simode (operands);")
;; Special case of fullword move, where we need to get a non-GOT PIC
--- 677,692 ----
return output_move_simode (operands);
})
! (define_insn "movsi_cf"
[(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
(match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
! "TARGET_COLDFIRE && !TARGET_CFV4"
! "* return output_move_simode (operands);")
!
! (define_insn "movsi_cfv4"
! [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
! (match_operand:SI 1 "general_operand" "Rg,Rr<Q>,U"))]
! "TARGET_CFV4"
"* return output_move_simode (operands);")
;; Special case of fullword move, where we need to get a non-GOT PIC
***************
*** 1250,1255 ****
--- 1258,1265 ----
{
if (DATA_REG_P (operands[0]))
{
+ if (TARGET_CFV4)
+ return "mvz%.w %1,%0";
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
return "and%.l #0xFFFF,%0";
***************
*** 1280,1289 ****
{
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
! return (!TARGET_COLDFIRE ? "and%.w #0xFF,%0" : "and%.l #0xFF,%0");
if (reg_mentioned_p (operands[0], operands[1]))
! return (!TARGET_COLDFIRE ? "move%.b %1,%0\;and%.w #0xFF,%0"
! : "move%.b %1,%0\;and%.l #0xFF,%0");
return "clr%.w %0\;move%.b %1,%0";
}
else if (GET_CODE (operands[0]) == MEM
--- 1290,1307 ----
{
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
! {
! if (TARGET_CFV4)
! return "mvz%.b %0,%0";
! return (!TARGET_COLDFIRE ? "and%.w #0xFF,%0" : "and%.l #0xFF,%0");
! }
if (reg_mentioned_p (operands[0], operands[1]))
! {
! if (TARGET_CFV4)
! return "mvz%.b %1,%0";
! return (!TARGET_COLDFIRE ? "move%.b %1,%0\;and%.w #0xFF,%0"
! : "move%.b %1,%0\;and%.l #0xFF,%0");
! }
return "clr%.w %0\;move%.b %1,%0";
}
else if (GET_CODE (operands[0]) == MEM
***************
*** 1318,1323 ****
--- 1336,1343 ----
{
if (DATA_REG_P (operands[0]))
{
+ if (TARGET_CFV4)
+ return "mvz%.b %1,%0";
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
return "and%.l #0xFF,%0";
***************
*** 1358,1363 ****
--- 1378,1385 ----
{
CC_STATUS_INIT;
operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
+ if (TARGET_CFV4)
+ return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
if (TARGET_68020 || TARGET_COLDFIRE)
return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
else
***************
*** 1372,1377 ****
--- 1394,1401 ----
{
CC_STATUS_INIT;
operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
+ if (TARGET_CFV4)
+ return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
if (TARGET_68020 || TARGET_COLDFIRE)
return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
else
***************
*** 1423,1433 ****
return "smi %0\;ext%.w %0\;ext%.l %0";
})
! (define_insn "extendhisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
(sign_extend:SI
(match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
! ""
{
if (ADDRESS_REG_P (operands[0]))
return "move%.w %1,%0";
--- 1447,1471 ----
return "smi %0\;ext%.w %0\;ext%.l %0";
})
! (define_expand "extendhisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "")
! (sign_extend:SI
! (match_operand:HI 1 "nonimmediate_src_operand" "")))]
! ""
! "")
!
! (define_insn "cfv4_extendhisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
! (sign_extend:SI
! (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
! "TARGET_CFV4"
! "mvs%.w %1,%0")
!
! (define_insn "68k_extendhisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
(sign_extend:SI
(match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
! "!TARGET_CFV4"
{
if (ADDRESS_REG_P (operands[0]))
return "move%.w %1,%0";
***************
*** 1440,1449 ****
""
"ext%.w %0")
! (define_insn "extendqisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
! "TARGET_68020 || TARGET_COLDFIRE"
"extb%.l %0")
\f
;; Conversions between float and double.
--- 1478,1499 ----
""
"ext%.w %0")
! (define_expand "extendqisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "")
! (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
! "TARGET_68020 || TARGET_COLDFIRE"
! "")
!
! (define_insn "cfv4_extendqisi2"
! [(set (match_operand:SI 0 "general_operand" "=d")
! (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
! "TARGET_CFV4"
! "mvs%.b %1,%0")
!
! (define_insn "m68k_extendqisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
! "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_CFV4)"
"extb%.l %0")
\f
;; Conversions between float and double.
***************
*** 2985,2994 ****
(umod:HI (match_dup 1) (match_dup 2)))]
"!TARGET_COLDFIRE || TARGET_CF_HWDIV"
{
! output_asm_insn (MOTOROLA ?
! "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
! "and%.l #0xFFFF,%0\;divu %2,%0",
! operands);
if (!find_reg_note(insn, REG_UNUSED, operands[3]))
{
CC_STATUS_INIT;
--- 3035,3051 ----
(umod:HI (match_dup 1) (match_dup 2)))]
"!TARGET_COLDFIRE || TARGET_CF_HWDIV"
{
! if (TARGET_CFV4)
! output_asm_insn (MOTOROLA ?
! "mvz%.w %0,%0\;divu%.w %2,%0" :
! "mvz%.w %0,%0\;divu %2,%0",
! operands);
! else
! output_asm_insn (MOTOROLA ?
! "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
! "and%.l #0xFFFF,%0\;divu %2,%0",
! operands);
!
if (!find_reg_note(insn, REG_UNUSED, operands[3]))
{
CC_STATUS_INIT;
***************
*** 3091,3097 ****
(and:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! "and%.l %2,%0")
(define_insn "andhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
--- 3148,3164 ----
(and:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! {
! if (TARGET_CFV4 && DATA_REG_P (operands[0])
! && GET_CODE (operands[2]) == CONST_INT)
! {
! if (INTVAL (operands[2]) == 0x000000ff)
! return \"mvz%.b %0,%0\";
! else if (INTVAL (operands[2]) == 0x0000ffff)
! return \"mvz%.w %0,%0\";
! }
! return output_andsi3 (operands);
! })
(define_insn "andhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
***************
*** 3253,3259 ****
(ior:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! "or%.l %2,%0")
(define_insn "iorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
--- 3320,3328 ----
(ior:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! {
! return output_iorsi3 (operands);
! })
(define_insn "iorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
***************
*** 3432,3438 ****
(xor:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_operand" "d,Ks")))]
"TARGET_COLDFIRE"
! "eor%.l %2,%0")
(define_insn "xorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
--- 3501,3509 ----
(xor:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_operand" "d,Ks")))]
"TARGET_COLDFIRE"
! {
! return output_xorsi3 (operands);
! })
(define_insn "xorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [m68k] ColdFire V4 patch
2004-06-15 15:15 ` Peter Barada
@ 2004-06-15 21:11 ` Richard Henderson
2004-06-15 21:24 ` Peter Barada
0 siblings, 1 reply; 10+ messages in thread
From: Richard Henderson @ 2004-06-15 21:11 UTC (permalink / raw)
To: Peter Barada; +Cc: schwab, gcc-patches
On Tue, Jun 15, 2004 at 10:25:59AM -0400, Peter Barada wrote:
> ! (define_insn "movsi_cf"
> ! (define_insn "movsi_cfv4"
> ! (define_insn "cfv4_extendhisi2"
> ! (define_insn "68k_extendhisi2"
> ! (define_insn "cfv4_extendqisi2"
> ! (define_insn "m68k_extendqisi2"
You don't use these symbols, which means that you should be
prefixing them with '*'.
Otherwise ok.
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [m68k] ColdFire V4 patch
2004-06-15 21:11 ` Richard Henderson
@ 2004-06-15 21:24 ` Peter Barada
2004-06-15 21:30 ` Richard Henderson
0 siblings, 1 reply; 10+ messages in thread
From: Peter Barada @ 2004-06-15 21:24 UTC (permalink / raw)
To: rth; +Cc: schwab, gcc-patches, peter
>On Tue, Jun 15, 2004 at 10:25:59AM -0400, Peter Barada wrote:
>> ! (define_insn "movsi_cf"
>> ! (define_insn "movsi_cfv4"
>> ! (define_insn "cfv4_extendhisi2"
>> ! (define_insn "68k_extendhisi2"
>> ! (define_insn "cfv4_extendqisi2"
>> ! (define_insn "m68k_extendqisi2"
>
>You don't use these symbols, which means that you should be
>prefixing them with '*'.
Ok. Here it is again with that fixed:
This patch adds mov3q, mvs/mvz support for ColdFire V4 cores, updates
MUL costs for V3/V4, uses bitfiled instructions where possible for ColdFire.
Built uberbaum tree with it.
gcc/
2004-06-15 Peter Barada <peter@the-baradas.com>
* config/m68k/m68k.md: (movsi_cfv4): New pattern to allow mov3q.
(movsi_cf): make named, don't match TARGET_CFV4.
(pushexthisi_const): Use mov3q if possible.
(extendhisi2, cvf4_extendhisi2): Split extendhisi2 pattern
to special case mvz.w for ColdFire V4.
(extendqisi2, cvf4_extendqisi2): Split extendhisi2 pattern
to special case mvz.b for ColdFire V4.
(udivmodhi4, divmodhi4): Use mvz to zero extend arg for
divide.
(iorsi3, xorsi3, andsi3): Use bitfiled instructiosn if possible.
* config/m68k/m68k.c(valid_mov3q_const): New function.
(const_method): SWAP is valid for ColdFire.
(MULL_COST, MULW_COST): Fix costs for ColdFire V3/V4.
* config/m68k/m68k-protos.h: Prototype here.
Index: gcc/config/m68k/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
*** gcc/config/m68k/m68k-protos.h 11 Oct 2003 06:35:53 -0000 1.14
--- gcc/config/m68k/m68k-protos.h 15 Jun 2004 19:31:40 -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_mov3q_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: gcc/config/m68k/m68k.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.c,v
retrieving revision 1.133
diff -c -3 -p -r1.133 m68k.c
*** gcc/config/m68k/m68k.c 1 Jun 2004 13:22:04 -0000 1.133
--- gcc/config/m68k/m68k.c 15 Jun 2004 19:31:41 -0000
*************** const_method (rtx constant)
*** 1447,1458 ****
/* This is the only value where neg.w is useful */
if (i == -65408)
return NEGW;
- /* Try also with swap */
- u = i;
- if (USE_MOVQ ((u >> 16) | (u << 16)))
- return SWAP;
}
if (TARGET_CFV4)
{
/* Try using MVZ/MVS with an immediate value to load constants. */
--- 1447,1459 ----
/* This is the only value where neg.w is useful */
if (i == -65408)
return NEGW;
}
+ /* Try also with swap. */
+ u = i;
+ if (USE_MOVQ ((u >> 16) | (u << 16)))
+ return SWAP;
+
if (TARGET_CFV4)
{
/* Try using MVZ/MVS with an immediate value to load constants. */
*************** m68k_rtx_costs (rtx x, int code, int out
*** 1524,1532 ****
for add and the time for shift, taking away a little more because
sometimes move insns are needed. */
/* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
! #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : TARGET_CFV3 ? 3 : TARGET_COLDFIRE ? 10 : 13)
#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
! TARGET_CFV3 ? 2 : 5)
#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
case PLUS:
--- 1525,1533 ----
for add and the time for shift, taking away a little more because
sometimes move insns are needed. */
/* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
! #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : (TARGET_COLDFIRE && !TARGET_5200) ? 3 : TARGET_COLDFIRE ? 10 : 13)
#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
! (TARGET_COLDFIRE && !TARGET_5200) ? 2 : 5)
#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
case PLUS:
*************** output_move_const_into_data_reg (rtx *op
*** 1651,1656 ****
--- 1652,1674 ----
}
}
+ /* Return 1 if 'constant' can be represented by
+ mov3q on a ColdFire V4 core. */
+ int
+ valid_mov3q_const (rtx constant)
+ {
+ int i;
+
+ if (TARGET_CFV4 && 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)
*** 1663,1668 ****
--- 1681,1689 ----
|| !(GET_CODE (operands[0]) == MEM
&& MEM_VOLATILE_P (operands[0]))))
return "clr%.l %0";
+ else if ((GET_MODE (operands[0]) == SImode)
+ && valid_mov3q_const (operands[1]))
+ return "mov3q%.l %1,%0";
else if (operands[1] == const0_rtx
&& ADDRESS_REG_P (operands[0]))
return "sub%.l %0,%0";
*************** output_move_simode_const (rtx *operands)
*** 1671,1683 ****
else if (ADDRESS_REG_P (operands[0])
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! return "move%.w %1,%0";
else if (GET_CODE (operands[0]) == MEM
&& GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
&& REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! return "pea %a1";
return "move%.l %1,%0";
}
--- 1692,1712 ----
else if (ADDRESS_REG_P (operands[0])
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! {
! if (valid_mov3q_const (operands[1]))
! return "mov3q%.l %1,%0";
! return "move%.w %1,%0";
! }
else if (GET_CODE (operands[0]) == MEM
&& GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
&& REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
&& INTVAL (operands[1]) < 0x8000
&& INTVAL (operands[1]) >= -0x8000)
! {
! if (valid_mov3q_const (operands[1]))
! return "mov3q%.l %1,%-";
! return "pea %a1";
! }
return "move%.l %1,%0";
}
Index: gcc/config/m68k/m68k.md
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.md,v
retrieving revision 1.76
diff -c -3 -p -r1.76 m68k.md
*** gcc/config/m68k/m68k.md 29 May 2004 15:10:41 -0000 1.76
--- gcc/config/m68k/m68k.md 15 Jun 2004 19:31:41 -0000
***************
*** 587,592 ****
--- 587,594 ----
{
if (operands[1] == const0_rtx)
return "clr%.l %0";
+ if (valid_mov3q_const(operands[1]))
+ return "mov3q%.l %1,%-";
return "pea %a1";
})
***************
*** 675,684 ****
return output_move_simode (operands);
})
! (define_insn ""
[(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
(match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
! "TARGET_COLDFIRE"
"* return output_move_simode (operands);")
;; Special case of fullword move, where we need to get a non-GOT PIC
--- 677,692 ----
return output_move_simode (operands);
})
! (define_insn "*movsi_cf"
[(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
(match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
! "TARGET_COLDFIRE && !TARGET_CFV4"
! "* return output_move_simode (operands);")
!
! (define_insn "*movsi_cfv4"
! [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
! (match_operand:SI 1 "general_operand" "Rg,Rr<Q>,U"))]
! "TARGET_CFV4"
"* return output_move_simode (operands);")
;; Special case of fullword move, where we need to get a non-GOT PIC
***************
*** 1250,1255 ****
--- 1258,1265 ----
{
if (DATA_REG_P (operands[0]))
{
+ if (TARGET_CFV4)
+ return "mvz%.w %1,%0";
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
return "and%.l #0xFFFF,%0";
***************
*** 1280,1289 ****
{
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
! return (!TARGET_COLDFIRE ? "and%.w #0xFF,%0" : "and%.l #0xFF,%0");
if (reg_mentioned_p (operands[0], operands[1]))
! return (!TARGET_COLDFIRE ? "move%.b %1,%0\;and%.w #0xFF,%0"
! : "move%.b %1,%0\;and%.l #0xFF,%0");
return "clr%.w %0\;move%.b %1,%0";
}
else if (GET_CODE (operands[0]) == MEM
--- 1290,1307 ----
{
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
! {
! if (TARGET_CFV4)
! return "mvz%.b %0,%0";
! return (!TARGET_COLDFIRE ? "and%.w #0xFF,%0" : "and%.l #0xFF,%0");
! }
if (reg_mentioned_p (operands[0], operands[1]))
! {
! if (TARGET_CFV4)
! return "mvz%.b %1,%0";
! return (!TARGET_COLDFIRE ? "move%.b %1,%0\;and%.w #0xFF,%0"
! : "move%.b %1,%0\;and%.l #0xFF,%0");
! }
return "clr%.w %0\;move%.b %1,%0";
}
else if (GET_CODE (operands[0]) == MEM
***************
*** 1318,1323 ****
--- 1336,1343 ----
{
if (DATA_REG_P (operands[0]))
{
+ if (TARGET_CFV4)
+ return "mvz%.b %1,%0";
if (GET_CODE (operands[1]) == REG
&& REGNO (operands[0]) == REGNO (operands[1]))
return "and%.l #0xFF,%0";
***************
*** 1358,1363 ****
--- 1378,1385 ----
{
CC_STATUS_INIT;
operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
+ if (TARGET_CFV4)
+ return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
if (TARGET_68020 || TARGET_COLDFIRE)
return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
else
***************
*** 1372,1377 ****
--- 1394,1401 ----
{
CC_STATUS_INIT;
operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
+ if (TARGET_CFV4)
+ return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
if (TARGET_68020 || TARGET_COLDFIRE)
return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
else
***************
*** 1423,1433 ****
return "smi %0\;ext%.w %0\;ext%.l %0";
})
! (define_insn "extendhisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
(sign_extend:SI
(match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
! ""
{
if (ADDRESS_REG_P (operands[0]))
return "move%.w %1,%0";
--- 1447,1471 ----
return "smi %0\;ext%.w %0\;ext%.l %0";
})
! (define_expand "extendhisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "")
! (sign_extend:SI
! (match_operand:HI 1 "nonimmediate_src_operand" "")))]
! ""
! "")
!
! (define_insn "*cfv4_extendhisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
! (sign_extend:SI
! (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
! "TARGET_CFV4"
! "mvs%.w %1,%0")
!
! (define_insn "*68k_extendhisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
(sign_extend:SI
(match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
! "!TARGET_CFV4"
{
if (ADDRESS_REG_P (operands[0]))
return "move%.w %1,%0";
***************
*** 1440,1449 ****
""
"ext%.w %0")
! (define_insn "extendqisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
! "TARGET_68020 || TARGET_COLDFIRE"
"extb%.l %0")
\f
;; Conversions between float and double.
--- 1478,1499 ----
""
"ext%.w %0")
! (define_expand "extendqisi2"
! [(set (match_operand:SI 0 "nonimmediate_operand" "")
! (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
! "TARGET_68020 || TARGET_COLDFIRE"
! "")
!
! (define_insn "*cfv4_extendqisi2"
! [(set (match_operand:SI 0 "general_operand" "=d")
! (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
! "TARGET_CFV4"
! "mvs%.b %1,%0")
!
! (define_insn "*68k_extendqisi2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
! "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_CFV4)"
"extb%.l %0")
\f
;; Conversions between float and double.
***************
*** 2985,2994 ****
(umod:HI (match_dup 1) (match_dup 2)))]
"!TARGET_COLDFIRE || TARGET_CF_HWDIV"
{
! output_asm_insn (MOTOROLA ?
! "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
! "and%.l #0xFFFF,%0\;divu %2,%0",
! operands);
if (!find_reg_note(insn, REG_UNUSED, operands[3]))
{
CC_STATUS_INIT;
--- 3035,3051 ----
(umod:HI (match_dup 1) (match_dup 2)))]
"!TARGET_COLDFIRE || TARGET_CF_HWDIV"
{
! if (TARGET_CFV4)
! output_asm_insn (MOTOROLA ?
! "mvz%.w %0,%0\;divu%.w %2,%0" :
! "mvz%.w %0,%0\;divu %2,%0",
! operands);
! else
! output_asm_insn (MOTOROLA ?
! "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
! "and%.l #0xFFFF,%0\;divu %2,%0",
! operands);
!
if (!find_reg_note(insn, REG_UNUSED, operands[3]))
{
CC_STATUS_INIT;
***************
*** 3091,3097 ****
(and:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! "and%.l %2,%0")
(define_insn "andhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
--- 3148,3164 ----
(and:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! {
! if (TARGET_CFV4 && DATA_REG_P (operands[0])
! && GET_CODE (operands[2]) == CONST_INT)
! {
! if (INTVAL (operands[2]) == 0x000000ff)
! return \"mvz%.b %0,%0\";
! else if (INTVAL (operands[2]) == 0x0000ffff)
! return \"mvz%.w %0,%0\";
! }
! return output_andsi3 (operands);
! })
(define_insn "andhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
***************
*** 3253,3259 ****
(ior:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! "or%.l %2,%0")
(define_insn "iorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
--- 3320,3328 ----
(ior:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_src_operand" "d,dmsK")))]
"TARGET_COLDFIRE"
! {
! return output_iorsi3 (operands);
! })
(define_insn "iorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
***************
*** 3432,3438 ****
(xor:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_operand" "d,Ks")))]
"TARGET_COLDFIRE"
! "eor%.l %2,%0")
(define_insn "xorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
--- 3501,3509 ----
(xor:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_operand" "d,Ks")))]
"TARGET_COLDFIRE"
! {
! return output_xorsi3 (operands);
! })
(define_insn "xorhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [m68k] ColdFire V4 patch
2004-06-15 21:24 ` Peter Barada
@ 2004-06-15 21:30 ` Richard Henderson
2004-06-15 21:36 ` Peter Barada
0 siblings, 1 reply; 10+ messages in thread
From: Richard Henderson @ 2004-06-15 21:30 UTC (permalink / raw)
To: Peter Barada; +Cc: schwab, gcc-patches
On Tue, Jun 15, 2004 at 03:33:11PM -0400, Peter Barada wrote:
> Ok. Here it is again with that fixed:
I did say "ok with that fixed", so given that you've fixed it,
please check it in.
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [m68k] ColdFire V4 patch
2004-06-15 21:30 ` Richard Henderson
@ 2004-06-15 21:36 ` Peter Barada
2004-06-17 1:27 ` Bernardo Innocenti
0 siblings, 1 reply; 10+ messages in thread
From: Peter Barada @ 2004-06-15 21:36 UTC (permalink / raw)
To: rth; +Cc: schwab, gcc-patches, peter
>> Ok. Here it is again with that fixed:
>
>I did say "ok with that fixed", so given that you've fixed it,
>please check it in.
I don't have write access so someone will have to do it for me :)
--
Peter Barada
peter@the-baradas.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [m68k] ColdFire V4 patch
2004-06-15 21:36 ` Peter Barada
@ 2004-06-17 1:27 ` Bernardo Innocenti
0 siblings, 0 replies; 10+ messages in thread
From: Bernardo Innocenti @ 2004-06-17 1:27 UTC (permalink / raw)
To: Peter Barada; +Cc: rth, schwab, gcc-patches
Peter Barada wrote:
>>>Ok. Here it is again with that fixed:
>>
>>I did say "ok with that fixed", so given that you've fixed it,
>>please check it in.
>
>
> I don't have write access so someone will have to do it for me :)
I'm checking it in right now, thank you!
--
// Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/ http://www.develer.com/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [m68k] ColdFire V4 patch
2004-06-15 0:27 [m68k] ColdFire V4 patch Peter Barada
2004-06-15 10:53 ` Andreas Schwab
@ 2004-07-26 23:06 ` Roman Zippel
1 sibling, 0 replies; 10+ messages in thread
From: Roman Zippel @ 2004-07-26 23:06 UTC (permalink / raw)
To: Peter Barada; +Cc: gcc-patches
Hi,
On Mon, 14 Jun 2004, Peter Barada wrote:
> ! (define_insn "movsi_cfv4"
> ! [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
> ! (match_operand:SI 1 "general_operand" "Rg,Rr<Q>,U"))]
> ! "TARGET_CFV4"
> "* return output_move_simode (operands);")
Is it possible you forgot something here? I don't see where 'R' is defined
as constraint.
bye, Roman
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2004-07-26 18:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-15 0:27 [m68k] ColdFire V4 patch Peter Barada
2004-06-15 10:53 ` Andreas Schwab
2004-06-15 15:13 ` Peter Barada
2004-06-15 15:15 ` Peter Barada
2004-06-15 21:11 ` Richard Henderson
2004-06-15 21:24 ` Peter Barada
2004-06-15 21:30 ` Richard Henderson
2004-06-15 21:36 ` Peter Barada
2004-06-17 1:27 ` Bernardo Innocenti
2004-07-26 23:06 ` Roman Zippel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).