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: [patch] h8300.h: Simplify sacro definitions.


Hi Richard,

> No.  Use trunc_int_for_mode (x, SImode).

I see.  What about the following?  Later I may move the constant
initializations elsewhere for speed if that matters, but I hope at
least the logic is all right.

Thanks,

Kazu Hirata

Index: h8300-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300-protos.h,v
retrieving revision 1.30
diff -c -r1.30 h8300-protos.h
*** h8300-protos.h	1 Jun 2002 10:38:58 -0000	1.30
--- h8300-protos.h	26 Oct 2002 19:17:28 -0000
***************
*** 60,65 ****
--- 60,68 ----
  extern int bit_operator PARAMS ((rtx, enum machine_mode));
  extern int nshift_operator PARAMS ((rtx, enum machine_mode));
  
+ extern int h8300_eightbit_constant_address_p PARAMS ((rtx));
+ extern int h8300_tiny_constant_address_p PARAMS ((rtx));
+ 
  /* Used in builtins.c */
  extern rtx h8300_return_addr_rtx PARAMS ((int, rtx));
  #endif /* RTX_CODE */
Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.151
diff -c -r1.151 h8300.c
*** h8300.c	24 Oct 2002 21:58:21 -0000	1.151
--- h8300.c	26 Oct 2002 19:17:31 -0000
***************
*** 3856,3858 ****
--- 3856,3911 ----
    fprintf (asm_out_file, "\t.section %s\n", name);
  }
  #endif /* ! OBJECT_FORMAT_ELF */
+ 
+ int
+ h8300_eightbit_constant_address_p (x)
+      rtx x;
+ {
+   /* The ranges the 8-bit area. */
+   const unsigned HOST_WIDE_INT n1 = trunc_int_for_mode (0x0000ff00, SImode);
+   const unsigned HOST_WIDE_INT n2 = trunc_int_for_mode (0x0000ffff, SImode);
+   const unsigned HOST_WIDE_INT h1 = trunc_int_for_mode (0x00ffff00, SImode);
+   const unsigned HOST_WIDE_INT h2 = trunc_int_for_mode (0x00ffffff, SImode);
+   const unsigned HOST_WIDE_INT s1 = trunc_int_for_mode (0xffffff00, SImode);
+   const unsigned HOST_WIDE_INT s2 = trunc_int_for_mode (0xffffffff, SImode);
+ 
+   unsigned HOST_WIDE_INT addr;
+ 
+   if (GET_CODE (x) != CONST_INT)
+     return 0;
+ 
+   addr = INTVAL (x);
+ 
+   return (0
+ 	  || (TARGET_H8300  && IN_RANGE (addr, n1, n2))
+ 	  || (TARGET_H8300H && IN_RANGE (addr, h1, h2))
+ 	  || (TARGET_H8300S && IN_RANGE (addr, s1, s2)));
+ }
+ 
+ int
+ h8300_tiny_constant_address_p (x)
+      rtx x;
+ {
+   /* The ranges for the 16-bit area.  */
+   const unsigned HOST_WIDE_INT h1 = trunc_int_for_mode (0x00000000, SImode);
+   const unsigned HOST_WIDE_INT h2 = trunc_int_for_mode (0x00007fff, SImode);
+   const unsigned HOST_WIDE_INT h3 = trunc_int_for_mode (0x00ff8000, SImode);
+   const unsigned HOST_WIDE_INT h4 = trunc_int_for_mode (0x00ffffff, SImode);
+   const unsigned HOST_WIDE_INT s1 = trunc_int_for_mode (0x00000000, SImode);
+   const unsigned HOST_WIDE_INT s2 = trunc_int_for_mode (0x00007fff, SImode);
+   const unsigned HOST_WIDE_INT s3 = trunc_int_for_mode (0xffff8000, SImode);
+   const unsigned HOST_WIDE_INT s4 = trunc_int_for_mode (0xffffffff, SImode);
+ 
+   unsigned HOST_WIDE_INT addr;
+ 
+   if (GET_CODE (x) != CONST_INT)
+     return 0;
+ 
+   addr = INTVAL (x);
+ 
+   return (0
+ 	  || (TARGET_H8300H
+ 	      && IN_RANGE (addr, h1, h2) || IN_RANGE (addr, h3, h4))
+ 	  || (TARGET_H8300S
+ 	      && IN_RANGE (addr, s1, s2) || IN_RANGE (addr, s3, s4)));
+ }
Index: h8300.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.h,v
retrieving revision 1.107
diff -c -r1.107 h8300.h
*** h8300.h	24 Oct 2002 10:45:19 -0000	1.107
--- h8300.h	26 Oct 2002 19:17:32 -0000
***************
*** 825,851 ****
  /* Nonzero if X is a constant address suitable as an 8-bit absolute,
     which is a special case of the 'R' operand.  */
  
! #define EIGHTBIT_CONSTANT_ADDRESS_P(X)					\
!   ((GET_CODE (X) == CONST_INT)						\
!    && ((TARGET_H8300 && IN_RANGE (INTVAL (X) & 0xffff, 0xff00, 0xffff))	\
!        || (TARGET_H8300H && IN_RANGE (INTVAL (X) & 0xffffffff,		\
! 				      0xffff00, 0xffffff))		\
!        || (TARGET_H8300S && IN_RANGE (INTVAL (X) & 0xffffffff,		\
! 				      0xffffff00, 0xffffffff))))
  
  /* Nonzero if X is a constant address suitable as an 16-bit absolute
     on H8/300H and H8S.  */
  
! #define TINY_CONSTANT_ADDRESS_P(X)					\
!   ((GET_CODE (X) == CONST_INT)						\
!    && ((TARGET_H8300H							\
! 	&& (IN_RANGE (INTVAL (X) & 0xffffffff, 0x000000, 0x007fff)	\
! 	    || IN_RANGE (INTVAL (X) & 0xffffffff, 0xff8000, 0xffffff)))	\
!        || (TARGET_H8300S						\
! 	   && (IN_RANGE (INTVAL (X) & 0xffffffff,			\
! 			 0x00000000, 0x00007fff)			\
! 	       || IN_RANGE (INTVAL (X) & 0xffffffff,			\
! 			    0xffff8000, 0xffffffff)))))
  
  /* 'U' if valid for a bset destination;
     i.e. a register, register indirect, or the eightbit memory region
--- 825,838 ----
  /* Nonzero if X is a constant address suitable as an 8-bit absolute,
     which is a special case of the 'R' operand.  */
  
! #define EIGHTBIT_CONSTANT_ADDRESS_P(X)		\
!   h8300_eightbit_constant_address_p (X)
  
  /* Nonzero if X is a constant address suitable as an 16-bit absolute
     on H8/300H and H8S.  */
  
! #define TINY_CONSTANT_ADDRESS_P(X)		\
!   h8300_tiny_constant_address_p (X)
  
  /* 'U' if valid for a bset destination;
     i.e. a register, register indirect, or the eightbit memory region


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