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] h8300 port: Further clean up of bit operations.


Hi,

Attached is a patch to do further clean up of bit operations.

Tested on h8300 port.  Comitted.

Kazu Hirata

2002-05-29  Kazu Hirata  <kazu@cs.umass.edu>

	* config/h8300/h8300-protos.h: Remove prototypes for
	ok_for_bclr and small_power_of_two.
	* config/h8300/h8300.c (small_power_of_two): Remove.
	(ok_for_blcr): Likewise.
	(fix_bit_operand): Make WHAT deal with an integer instead of a
	constraint character.
	* config/h8300/h8300.h (CONST_OK_FOR_O): Remove.
	(CONST_OK_FOR_P): Likewise.
	(CONST_OK_FOR_LETTER_P): Do not call CONST_OK_FOR_O or
	CONST_OK_FOR_P any more.
	* config/h8300/h8300.md (andqi3): Adjust to the new prototype
	of fix_bit_operand.
	(iorqi3): Likewise.
	(xorqi3): Likewise.

Index: h8300-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300-protos.h,v
retrieving revision 1.28
diff -c -r1.28 h8300-protos.h
*** h8300-protos.h	29 May 2002 14:20:38 -0000	1.28
--- h8300-protos.h	29 May 2002 14:29:57 -0000
***************
*** 74,81 ****
  extern void h8300_init_once PARAMS ((void));
  extern void asm_file_start PARAMS ((FILE *));
  extern void asm_file_end PARAMS ((FILE *));
- extern int ok_for_bclr PARAMS ((HOST_WIDE_INT));
- extern int small_power_of_two PARAMS ((HOST_WIDE_INT));
  extern int initial_offset PARAMS ((int, int));
  
  #ifdef GCC_C_PRAGMA_H
--- 74,79 ----
Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.132
diff -c -r1.132 h8300.c
*** h8300.c	29 May 2002 14:20:39 -0000	1.132
--- h8300.c	29 May 2002 14:30:00 -0000
***************
*** 521,548 ****
    fprintf (file, "\t.end\n");
  }
  
- /* Return true if VALUE is a valid constant for constraint 'P'.
-    IE: VALUE is a power of two <= 2**15.  */
- 
- int
- small_power_of_two (value)
-      HOST_WIDE_INT value;
- {
-   int power = exact_log2 (value);
-   return power >= 0 && power <= 15;
- }
- 
- /* Return true if VALUE is a valid constant for constraint 'O', which
-    means that the constant would be ok to use as a bit for a bclr
-    instruction.  */
- 
- int
- ok_for_bclr (value)
-      HOST_WIDE_INT value;
- {
-   return small_power_of_two ((~value) & 0xff);
- }
- 
  /* Return true if OP is a valid source operand for an integer move
     instruction.  */
  
--- 521,526 ----
***************
*** 3245,3276 ****
       only 'U' memory afterwards, so if this is a MEM operand, we must force
       it to be valid for 'U' by reloading the address.  */
  
!   if (GET_CODE (operands[2]) == CONST_INT)
      {
!       if (CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), what))
! 	{
! 	  /* Ok to have a memory dest.  */
! 	  if (GET_CODE (operands[0]) == MEM
! 	      && !EXTRA_CONSTRAINT (operands[0], 'U'))
! 	    {
! 	      rtx mem = gen_rtx_MEM (GET_MODE (operands[0]),
! 				     copy_to_mode_reg (Pmode,
! 						       XEXP (operands[0], 0)));
! 	      MEM_COPY_ATTRIBUTES (mem, operands[0]);
! 	      operands[0] = mem;
! 	    }
! 
! 	  if (GET_CODE (operands[1]) == MEM
! 	      && !EXTRA_CONSTRAINT (operands[1], 'U'))
! 	    {
! 	      rtx mem = gen_rtx_MEM (GET_MODE (operands[1]),
! 				     copy_to_mode_reg (Pmode,
! 						       XEXP (operands[1], 0)));
! 	      MEM_COPY_ATTRIBUTES (mem, operands[0]);
! 	      operands[1] = mem;
! 	    }
! 	  return 0;
  	}
      }
  
    /* Dest and src op must be register.  */
--- 3223,3252 ----
       only 'U' memory afterwards, so if this is a MEM operand, we must force
       it to be valid for 'U' by reloading the address.  */
  
!   if ((what == 0 && single_zero_operand (operands[2], QImode))
!       || (what == 1 && single_one_operand (operands[2], QImode)))
      {
!       /* OK to have a memory dest.  */
!       if (GET_CODE (operands[0]) == MEM
! 	  && !EXTRA_CONSTRAINT (operands[0], 'U'))
! 	{
! 	  rtx mem = gen_rtx_MEM (GET_MODE (operands[0]),
! 				 copy_to_mode_reg (Pmode,
! 						   XEXP (operands[0], 0)));
! 	  MEM_COPY_ATTRIBUTES (mem, operands[0]);
! 	  operands[0] = mem;
! 	}
! 
!       if (GET_CODE (operands[1]) == MEM
! 	  && !EXTRA_CONSTRAINT (operands[1], 'U'))
! 	{
! 	  rtx mem = gen_rtx_MEM (GET_MODE (operands[1]),
! 				 copy_to_mode_reg (Pmode,
! 						   XEXP (operands[1], 0)));
! 	  MEM_COPY_ATTRIBUTES (mem, operands[0]);
! 	  operands[1] = mem;
  	}
+       return 0;
      }
  
    /* Dest and src op must be register.  */
Index: h8300.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.h,v
retrieving revision 1.91
diff -c -r1.91 h8300.h
*** h8300.h	19 May 2002 08:31:50 -0000	1.91
--- h8300.h	29 May 2002 14:30:01 -0000
***************
*** 429,436 ****
    (TARGET_H8300H || TARGET_H8300S			\
     ? (VALUE) == -1 || (VALUE) == -2 || (VALUE) == -4	\
     : (VALUE) == -1 || (VALUE) == -2)
- #define CONST_OK_FOR_O(VALUE) (ok_for_bclr (VALUE))
- #define CONST_OK_FOR_P(VALUE) (small_power_of_two (VALUE))
  
  #define CONST_OK_FOR_LETTER_P(VALUE, C)		\
    ((C) == 'I' ? CONST_OK_FOR_I (VALUE) :	\
--- 429,434 ----
***************
*** 439,446 ****
     (C) == 'L' ? CONST_OK_FOR_L (VALUE) :	\
     (C) == 'M' ? CONST_OK_FOR_M (VALUE) :	\
     (C) == 'N' ? CONST_OK_FOR_N (VALUE) :	\
-    (C) == 'O' ? CONST_OK_FOR_O (VALUE) :	\
-    (C) == 'P' ? CONST_OK_FOR_P (VALUE) :	\
     0)
  
  /* Similar, but for floating constants, and defining letters G and H.
--- 437,442 ----
Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.86
diff -c -r1.86 h8300.md
*** h8300.md	29 May 2002 14:20:40 -0000	1.86
--- h8300.md	29 May 2002 14:30:02 -0000
***************
*** 1023,1029 ****
    ""
    "
  {
!   if (fix_bit_operand (operands, 'O', AND))
      DONE;
  }")
  
--- 1023,1029 ----
    ""
    "
  {
!   if (fix_bit_operand (operands, 0, AND))
      DONE;
  }")
  
***************
*** 1094,1100 ****
    ""
    "
  {
!   if (fix_bit_operand (operands, 'P', IOR))
      DONE;
  }")
  
--- 1094,1100 ----
    ""
    "
  {
!   if (fix_bit_operand (operands, 1, IOR))
      DONE;
  }")
  
***************
*** 1136,1142 ****
    ""
    "
  {
!   if (fix_bit_operand (operands, 'O', XOR))
      DONE;
  }")
  
--- 1136,1142 ----
    ""
    "
  {
!   if (fix_bit_operand (operands, 1, XOR))
      DONE;
  }")
  


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