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]

Re: [m68k] gcc-3.4.0 fails for ColdFire(does not satisfy constraints)


On Mon, May 31, 2004 at 01:57:33PM -0700, Richard Henderson wrote:
>On Sun, May 30, 2004 at 06:13:23AM +0200, Bernardo Innocenti wrote:
>> >	* config/m68k/m68k.h: disallow bytes in address registers.
>> >	* config/m68k/m68k.c: Likewise.
>
>This seems reasonable.   I doubt you get much benefit from holding
>bytes in address registers to begin with.
>
>> > add peephole2
>> >          to use a data register to hold the constant for the add if
>> >          one is available. 
>
>First, this is an unrelated change, so it should have been
>submitted separately.  Second, don't you want to *only* perform
>this peephole for immediates outside -8 ... 8, i.e. those that
>can be handled by addq.l directly?

With prodding from Bernine, I've gone back and updated this patch for
mainline.  I've also removed the peephole so this bite-sized pieces
can get approved first.  I'll come back with other patches to add in
the peephole as well as to fix pointer increments/decrements that are
in memory for ColdFire.  The description is from the original patch
submission email:

I'm trying to use gcc-3.4.0 --target=m68k-uclinux, and it fails while
building printf.c from uClibc:

m68k-uclinux-gcc  -Wall -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing  -Os  -Wa,--bitwise-or
-I/home/peter/work/src/ucLinux/ucTools/linux-2.4.x/include -m5200
-msoft-float -fno-builtin -nostdinc -D_LIBC -I../../include
-I.
-I/home/mylocal/uclinux/tools-3.4.0/lib/gcc/m68k-uclinux/3.4.0/include
-DNDEBUG -DL__fpmaxtostr printf.c -c -o _fpmaxtostr.o
printf.c: In function `_fpmaxtostr':
printf.c:2454: error: insn does not satisfy its constraints:
(insn 1376 536 537 38 (set (reg:QI 8 %a0)
        (mem:QI (plus:SI (reg/f:SI 14 %a6)
                (const_int -209 [0xffffff2f])) [0 mode+0 S1 A8])) 33
{*m68k.md:826} (nil)
    (nil))
printf.c:2454: internal compiler error: in
reload_cse_simplify_operands, at postreload.c:378
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[2]: *** [_fpmaxtostr.o] Error 1
make[2]: Leaving directory
`/home/peter/work/src/ucLinux/ucTools/uClibc-0.9.26/libc/stdio'

This has been reported before in PR #16719, PR #17114, PR #18421 and
probably others.

To fix this I:

1) Modified m68k.h/m68k.c to disallow bytes in address registers
2) Changed addsi3_5200 to add 'i' constraint

Previously built and tested uClinux on ColdFire platform; currently
built uberbaum; produces correct code for PR #18421 and PR #16719.

--
Peter Barada
peter@the-baradas.com


gcc/
2004-12-06  Peter Barada  <peter@the-baradas.com>
	    * config/m68k/m68k.h: (HARD_REGNO_MODE_OK): disallow bytes
	      in address registers. 
	    * config/m68k/m68k.c: (hard_regno_mode_ok): Likewise.
	    * config/m68k/m68k.md: Replace 's' with 'i' in 4th
	      alternative of addsi3_5200

Index: gcc/config/m68k/m68k-protos.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k-protos.h,v
retrieving revision 1.17
diff -c -3 -p -r1.17 m68k-protos.h
*** gcc/config/m68k/m68k-protos.h	22 Oct 2004 12:47:24 -0000	1.17
--- gcc/config/m68k/m68k-protos.h	6 Dec 2004 15:54:05 -0000
*************** extern rtx legitimize_pic_address (rtx, 
*** 53,58 ****
--- 53,59 ----
  
  #endif /* RTX_CODE */
  
+ extern int m68k_regno_mode_ok(int, enum machine_mode);
  extern int flags_in_68881 (void);
  extern bool use_return_insn (void);
  extern void override_options (void);
Index: gcc/config/m68k/m68k.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.c,v
retrieving revision 1.143
diff -c -3 -p -r1.143 m68k.c
*** gcc/config/m68k/m68k.c	9 Nov 2004 10:13:09 -0000	1.143
--- gcc/config/m68k/m68k.c	6 Dec 2004 15:54:06 -0000
*************** m68k_hard_regno_rename_ok (unsigned int 
*** 3445,3447 ****
--- 3445,3479 ----
  
    return 1;
  }
+ 
+ /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
+    On the 68000, the cpu registers can hold any mode except bytes in
+    address registers, but the 68881 registers
+    can hold only SFmode or DFmode.  */
+ int
+ m68k_regno_mode_ok(int regno, enum machine_mode mode)
+ {
+   if (regno < 8)
+     {
+       /* Data Registers */
+       return 1;
+     }
+   else if (regno < 16)
+     {
+       /* Address Registers, can't hold bytes, can hold aggregate if
+ 	 fits in */
+       if (GET_MODE_SIZE (mode) == 1)
+ 	return 0;
+       if (!((regno) < 8 && (regno) + GET_MODE_SIZE (mode) / 4 > 8))
+ 	return 1;
+     }
+   else if (regno < 24)
+     {
+       /* FPU registers, hold float or complex float of long double or smaller */
+       if ((GET_MODE_CLASS (mode) == MODE_FLOAT
+ 	   || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
+ 	  && GET_MODE_UNIT_SIZE (mode) <= 12)
+ 	return 1;
+     }
+   return 0;
+ }
Index: gcc/config/m68k/m68k.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.h,v
retrieving revision 1.122
diff -c -3 -p -r1.122 m68k.h
*** gcc/config/m68k/m68k.h	9 Nov 2004 10:13:09 -0000	1.122
--- gcc/config/m68k/m68k.h	6 Dec 2004 15:54:06 -0000
*************** extern int target_flags;
*** 486,500 ****
  #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
    m68k_hard_regno_rename_ok (OLD_REG, NEW_REG)
  
! /* On the m68k, the cpu registers can hold any mode but the 68881 registers
!    can hold only SFmode or DFmode.  */
  #define HARD_REGNO_MODE_OK(REGNO, MODE) \
!   (((REGNO) < 16					\
!     && !((REGNO) < 8 && (REGNO) + GET_MODE_SIZE (MODE) / 4 > 8))	\
!    || ((REGNO) >= 16 && (REGNO) < 24				        \
!        && (GET_MODE_CLASS (MODE) == MODE_FLOAT		\
! 	   || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)		\
!        && GET_MODE_UNIT_SIZE (MODE) <= 12))
  
  #define MODES_TIEABLE_P(MODE1, MODE2)			\
    (! TARGET_68881					\
--- 486,497 ----
  #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
    m68k_hard_regno_rename_ok (OLD_REG, NEW_REG)
  
! /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
!    On the 68000, the cpu registers can hold any mode except bytes in
!    address registers, the 68881 registers can hold only SFmode or DFmode.  */
! 
  #define HARD_REGNO_MODE_OK(REGNO, MODE) \
!   m68k_regno_mode_ok ((REGNO), (MODE))
  
  #define MODES_TIEABLE_P(MODE1, MODE2)			\
    (! TARGET_68881					\
Index: gcc/config/m68k/m68k.md
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.md,v
retrieving revision 1.80
diff -c -3 -p -r1.80 m68k.md
*** gcc/config/m68k/m68k.md	6 Aug 2004 07:14:56 -0000	1.80
--- gcc/config/m68k/m68k.md	6 Dec 2004 15:54:07 -0000
***************
*** 1850,1856 ****
  (define_insn "*addsi3_5200"
    [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
  	(plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
! 		 (match_operand:SI 2 "general_src_operand" "d,rJK,a,mrIKLs")))]
    "TARGET_COLDFIRE"
    "* return output_addsi3 (operands);")
  
--- 1850,1856 ----
  (define_insn "*addsi3_5200"
    [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
  	(plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
! 		 (match_operand:SI 2 "general_src_operand" "d,rJK,a,mrIKLi")))]
    "TARGET_COLDFIRE"
    "* return output_addsi3 (operands);")
  


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