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: Simplify code around EIGHTBIT_CONSTANT_ADDRESS_P.


Hi,

Attached is a patch to simplify code around EIGHTBIT_CONSTANT_ADDRESS_P.

Without the patch, EIGHTBIT_CONSTANT_ADDRESS_P checks if the given
address is of the form (mem (const_int ?)) that is in the eight bit
area.

The patch extends EIGHTBIT_CONSTANT_ADDRESS_P by also checking if the
given address is the address of a variable declared with __attribute__
((eightbit)) since every use of EIGHTBIT_CONSTANT_ADDRESS_P does this.

Tested on h8300 port.  Committed.

Kazu Hirata

2002-11-19  Kazu Hirata  <kazu@cs.umass.edu>

	* config/h8300/h8300.c (print_operand): Update the use of
	EIGHTBIT_CONSTANT_ADDRESS_P.
	(h8300_adjust_insn_length): Likewise.
	(h8300_eightbit_constant_address_p): Check if the given rtx is
	a variable with __attribute__((eightbit_data)).
	* config/h8300/h8300.h (OK_FOR_U): Update the use of
	EIGHTBIT_CONSTANT_ADDRESS_P.

Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.156
diff -u -r1.156 h8300.c
--- h8300.c	12 Nov 2002 18:53:39 -0000	1.156
+++ h8300.c	19 Nov 2002 14:44:53 -0000
@@ -1434,9 +1434,7 @@
 	case MEM:
 	  {
 	    rtx addr = XEXP (x, 0);
-	    int eightbit_ok = ((GET_CODE (addr) == SYMBOL_REF
-				&& SYMBOL_REF_FLAG (addr))
-			       || EIGHTBIT_CONSTANT_ADDRESS_P (addr));
+	    int eightbit_ok = EIGHTBIT_CONSTANT_ADDRESS_P (addr);
 	    int tiny_ok = ((GET_CODE (addr) == SYMBOL_REF
 			    && TINY_DATA_NAME_P (XSTR (addr, 0)))
 			   || TINY_CONSTANT_ADDRESS_P (addr));
@@ -3721,8 +3719,7 @@
 
 	  /* @aa:8 is 2 bytes shorter than the longest.  */
 	  if (GET_MODE (SET_SRC (pat)) == QImode
-	      && ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_FLAG (addr))
-		  || EIGHTBIT_CONSTANT_ADDRESS_P (addr)))
+	      && EIGHTBIT_CONSTANT_ADDRESS_P (addr))
 	    return -2;
 	}
       else
@@ -3874,6 +3871,10 @@
   const unsigned HOST_WIDE_INT s2 = trunc_int_for_mode (0xffffffff, SImode);
 
   unsigned HOST_WIDE_INT addr;
+
+  /* We accept symbols declared with eightbit_data.  */
+  if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FLAG (x))
+    return 1;
 
   if (GET_CODE (x) != CONST_INT)
     return 0;
Index: h8300.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.h,v
retrieving revision 1.114
diff -u -r1.114 h8300.h
--- h8300.h	2 Nov 2002 12:51:05 -0000	1.114
+++ h8300.h	19 Nov 2002 14:44:54 -0000
@@ -863,7 +863,7 @@
    || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG		\
        && REG_OK_FOR_BASE_P (XEXP (OP, 0)))				\
    || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == SYMBOL_REF	\
-       && (TARGET_H8300S || SYMBOL_REF_FLAG (XEXP (OP, 0))))		\
+       && TARGET_H8300S)						\
    || ((GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == CONST	\
         && GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS			\
         && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == SYMBOL_REF	\


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